Friday, 11 November 2016

Auto Service Example

Auto Service Example :

 aspx:

<%@ Page Language="C#" MasterPageFile="~/MasterForms/MainMaster.Master" AutoEventWireup="true"
    CodeBehind="MemberWithdrawal.aspx.cs" Inherits="SPANDANA.MemberWithdrawal" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <style>
        input[type=text], input[type=submit], input[type=checkbox], textarea, select, button
        {
            -webkit-transition: all 0.30s ease-in-out;
            -moz-transition: all 0.30s ease-in-out;
            -ms-transition: all 0.30s ease-in-out;
            -o-transition: all 0.30s ease-in-out;
            outline: none;
            padding: 3px 0px 3px 3px;
            margin: 5px 1px 3px 0px;
            border: 1px solid #DDDDDD;
        }
        input[type=text]:focus, input[type=submit]:focus, input[type=checkbox]:focus, textarea:focus, select:focus, button:focus
        {
            box-shadow: 0 0 5px rgba(81, 203, 238, 1);
            padding: 3px 0px 3px 3px;
            margin: 5px 1px 3px 0px;
            border: 1px solid rgba(81, 203, 238, 1);
        }
        button
        {
            display: block;
            border: 1px solid;
            border-color: #aaa #000 #000 #aaa;
            width: 4em;
            background: #fc0;
        }
        button:hover
        {
            position: relative;
            top: 1px;
            left: 1px;
            border-color: #000 #aaa #aaa #000;
        }
        .ui-jqgrid tr.jqgrow td
        {
            word-wrap: break-word; /* IE 5.5+ and CSS3 */
            white-space: pre-wrap; /* CSS3 */
            white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
            white-space: -pre-wrap; /* Opera 4-6 */
            white-space: -o-pre-wrap; /* Opera 7 */
            overflow: hidden;
            height: auto;
            vertical-align: middle;
            padding-top: 3px;
            padding-bottom: 3px;
        }
        .ui-jqgrid .ui-jqgrid-htable th div, .ui-jqgrid-sortable
        {
            height: auto;
            overflow: hidden;
            white-space: normal !important;
        }
        .ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column
        {
            overflow: hidden;
            white-space: nowrap;
            text-align: center;
            border-top: 0px none;
            border-bottom: 0px none;
            text-align: center !important;
        }
        .style1
        {
            width: 190px;
        }
        #txtCode
        {
            width: 160px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function() {

            //Auto service for Branch
            $("#<%=txtBranch.ClientID %>").autocomplete({
                source: function(request, response) {
                    // $("#txtCentername").val('');
                    var field1 = JSON.stringify({ prefixText: request.term, UserID: $('#<%=HUID.ClientID %>').val() });
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: '<%=ResolveUrl("~/WebServices/MIS/MemberSaving.asmx/getBranch") %>',
                        data: field1,
                        dataType: "json",
                        success: function(data) {
                            if (data.d.length == 0) {
                                $("#<%=txtBranch.ClientID %>").val('');
                                $("#txtsearch").val('');
                                $("#ddlOptions").val('S');
                                $("#<%=txtBranch.ClientID %>").focus();
                            }
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.split('$')[0],
                                    branch: item.split('|')[0],
                                    id: item.split('|')[1]
                                }
                            }));
                        },
                        error: function(result) {
                            alert(result.responseText);
                        }
                    });
                },
                select: function(dat, ui) {
                    $('#<%=bid.ClientID %>').val(ui.item.id)
                }
            });




            //Auto service for Village
            $("#<%=txtVillage.ClientID %>").autocomplete({
                source: function(request, response) {
                    var field1 = JSON.stringify({ prefixText: request.term, UserID: $('#<%=HUID.ClientID %>').val(), BID: $('#<%=bid.ClientID %>').val() });
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: '<%=ResolveUrl("~/WebServices/MIS/MemberSaving.asmx/getVillage") %>',
                        data: field1,
                        dataType: "json",
                        success: function(data) {
                            if (data.d.length == 0) {
                                $("#<%=txtVillage.ClientID %>").val('');
                                $("#txtsearch").val('');
                                $("#ddlOptions").val('S');
                                $("#<%=txtBranch.ClientID %>").focus();
                            }
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.split('$')[0],
                                    branch: item.split('|')[0],
                                    id: item.split('|')[1]
                                }
                            }));
                        },
                        error: function(result) {
                            alert(result.responseText);
                        }
                    });
                },
                select: function(dat, ui) {
                    $('#<%=vid.ClientID %>').val(ui.item.id);
                }
            });

            //Auto service for Center

            $("#<%=txtCentername.ClientID %>").autocomplete({
                source: function(request, response) {
                    var field1 = JSON.stringify({ prefixText: request.term, UserID: $('#<%=HUID.ClientID %>').val(), BID: $('#<%=bid.ClientID %>').val(), VID: $('#<%=vid.ClientID%>').val() });
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: '<%=ResolveUrl("~/WebServices/MIS/MemberSaving.asmx/getCenter") %>',
                        data: field1,
                        dataType: "json",
                        success: function(data) {
                            if (data.d.length == 0) {
                                $("#<%=txtCentername.ClientID %>").val('');
                                $("#txtsearch").val('');
                                $("#ddlOptions").val('S');
                                $("#<%=txtBranch.ClientID %>").focus();
                            }
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.split('$')[0],
                                    branch: item.split('|')[0],
                                    id: item.split('|')[1]
                                }
                            }));
                        },
                        error: function(result) {
                            alert(result.responseText);
                        }
                    });
                },
                select: function(dat, ui) {
                    $('#<%=cid.ClientID %>').val(ui.item.id);
                }
            });

            //Auto service for Group

            $("#<%=txtgroup.ClientID %>").autocomplete({
                source: function(request, response) {
                    var field1 = JSON.stringify({ prefixText: request.term, UserID: $('#<%=HUID.ClientID %>').val(), BID: $('#<%=bid.ClientID %>').val(), VID: $('#<%=vid.ClientID%>').val(),
                        CID: $('#<%=cid.ClientID%>').val()
                    });
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: '<%=ResolveUrl("~/WebServices/MIS/MemberSaving.asmx/getGroup") %>',
                        data: field1,
                        dataType: "json",
                        success: function(data) {
                            if (data.d.length == 0) {
                                $("#<%=txtCentername.ClientID %>").val('');
                                $("#txtsearch").val('');
                                $("#ddlOptions").val('S');
                                $("#<%=txtBranch.ClientID %>").focus();
                            }
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.split('$')[0],
                                    branch: item.split('|')[0],
                                    id: item.split('|')[1]
                                }
                            }));
                        },
                        error: function(result) {
                            alert(result.responseText);
                        }
                    });
                },
                select: function(dat, ui) {
                    $('#<%=gid.ClientID %>').val(ui.item.id);
                    Grid();
                }
            });


            //Auto service for Member

            $("#<%=txtmember.ClientID %>").autocomplete({
                source: function(request, response) {
                    var field1 = JSON.stringify({ prefixText: request.term, UserID: $('#<%=HUID.ClientID %>').val(), BID: $('#<%=bid.ClientID %>').val(), VID: $('#<%=vid.ClientID%>').val(),
                        CID: $('#<%=cid.ClientID%>').val(), GID: $('#<%=gid.ClientID%>').val()
                    });
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: '<%=ResolveUrl("~/WebServices/MIS/MemberSaving.asmx/getMember") %>',
                        data: field1,
                        dataType: "json",
                        success: function(data) {
                            if (data.d.length == 0) {
                                $("#<%=txtCentername.ClientID %>").val('');
                                $("#txtsearch").val('');
                                $("#ddlOptions").val('S');
                                $("#<%=txtBranch.ClientID %>").focus();
                            }
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.split('$')[0],
                                    branch: item.split('|')[0],
                                    id: item.split('|')[1]
                                }
                            }));
                        },
                        error: function(result) {
                            alert(result.responseText);

                        }
                    });
                },
                select: function(dat, ui) {
                    $('#<%=Mid.ClientID %>').val(ui.item.id);
                    Grid();
                }
            });


        });  //Page Load



        var rowsToColor = [];
        function Grid() {
            jQuery("#tblMemberSaving").GridUnload();
            jQuery("#tblMemberSaving").jqGrid({
                url: '<%= ResolveUrl("~/WebServices/MIS/MemberWithdrawal.asmx/showGrid") %>',
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                height: '100%',
                postData: {
                    GGID: $('#<%=gid.ClientID %>').val(),
                    Mem: $("#<%=Mid.ClientID %>").val()
                },
                rowNum: 10,
                width: "798",
                cmTemplate: { sortable: false },
                rowList: [100, 200, 300],
                theme: 'energyred',
                colNames: ['Click', 'MId', 'Member Name', 'MemberCode', 'SavingBalance', 'Withdrawal Amt', 'Interest', 'Interest Withdraw', 'Cash(or)Bank', 'ChequeNo', 'ReceiptNo'
                 ],
                colModel: [
                                { name: 'Act', width: 40, index: 'Act', align: 'center', title: false },
                                { name: 'MMI_ID', index: 'MMI_ID', width: 20, sorttype: "string" },
                                { name: 'MMI_Name', index: 'MGI_Name', width: 80, sorttype: "string" },
                                { name: 'MMI_Code', index: 'MGI_Code', width: 50, sorttype: "string" },
                                { name: 'MMI_SavingBal', index: 'MMI_SavingBal', width: 50, sorttype: "string", formatter: MemberSavingBalance },
                                { name: 'MMI_WithdrawAmt', index: 'MMI_WithdrawAmt', width: 50, sorttype: "string", formatter: WithdrawAmt },
                                 { name: 'MMI_Interest', index: 'MMI_Interest', width: 50, sorttype: "string", formatter: Interest },
                                 { name: 'MMI_IntWithdraw', index: 'MMI_IntWithdraw', width: 50, sorttype: "string", formatter: IntWithdraw },
                                { name: 'CashBank', index: 'CashBank', width: 50, sorttype: "string", formatter: CashOrBank },
                                { name: 'ChequeNo', index: 'ChequeNO', width: 50, sorttype: "string", formatter: Cheque },
                                { name: 'ReceiptNo', index: 'ReceiptNo', width: 50, sorttype: "string", formatter: ReceiptNo },


                ],
                pager: "#pager",
                multiselect: true,
                viewrecords: true,
                altRows: true,
                caption: "Member",
                jsonReader: {
                    root: function(obj) { return obj.rows },
                    page: function(obj) { return obj.page },
                    total: function(obj) { return obj.total },
                    records: function(obj) { return obj.records },
                    id: "0",
                    cell: "",
                    repeatitems: false
                },
                gridComplete: function(rowID) {

                    var ids = jQuery("#tblMemberSaving").jqGrid('getDataIDs');
                    if (ids.length == 0) {

                    }
                    else {
                        for (var i = 0; i < ids.length; i++) {
                            var cl = ids[i];
                            se = "<span tittle='Edit'  style='display:inline-block'  class='ui-icon ui-icon-pencil' onclick='EditRecords(" + cl + ")'></span> ";
                            ce = "<span tittle='Delete'  style='display:inline-block'  class='ui-icon ui-icon-trash' onclick='DeleteRecords(" + cl + ")'></span>";
                            jQuery("#tblGroup").jqGrid('setRowData', ids[i], { Act: se + ce });
                        }

                        document.getElementById('NoDetails').innerHTML = '';
                    }
                }
            });

            return false;
        }
      
        function MemberSavingBalance(cellvalue, options, rowObject) {
            var MemberBal = 0;  //rowObject.MLDI_RepayStartDate;
            //            return '<label id="lblMemSavingBalance' + options.rowId + '" value="' + MemberBal + '"  style="width:70px; text-align:center;" type="text" ></label>'
            return '<input id="lblMemSavingBalance' + options.rowId + '"  value="' + MemberBal + '" style="width:70px; text-align:center;" type="text" ></input>'
        }

        function WithdrawAmt(cellvalue, options, rowObject) {
            return '<input id="MMI_WithdrawAmt' + options.rowId + '" style="width:70px; text-align:center;" type="text" ></input>'

        }
        function Interest(cellvalue, options, rowObject) {
            return '<input id="MMI_Interest' + options.rowId + '" style="width:70px; text-align:center;" type="text" ></input>'

        }
        function IntWithdraw(cellvalue, options, rowObject) {
            return '<input id="MMI_IntWithdraw' + options.rowId + '" style="width:70px; text-align:center;" type="text" ></input>'

        }

        function CashOrBank(cellvalue, options, rowObject) {
            return "<select  style='width:100%' id='ddlMemCB" + options.rowId + "' onchange='return cheq(" + options.rowId + ")'><option value='C'>Cash</option><option value='B'>Bank</option> </select>"
        }

        function Cheque(cellvalue, options, rowObject) {
            return '<input id="txtCheque' + options.rowId + '" style="width:50px;" type="text" disbaled="disabled" ></input>'
        }

        function ReceiptNo(cellvalue, options, rowObject) {
            return '<input id="txtReceiptNo' + options.rowId + '" style="width:50px;" type="text" disbaled="disabled" ></input>'
        }


        function cheq(rowID) {
            var rowData = jQuery("#tblMemberSaving").jqGrid('getRowData', rowID);
            var abc = $('#ddlMemCB' + rowID).val();
            if (abc == 'B') {
                $('#txtCheque' + rowID).attr('disabled', false);
                //$('#txtCheque' + rowID).show();
            }
            else {
                $('#txtCheque' + rowID).attr('disabled', true);
                // $('#txtCheque' + rowID).hide();
            }
            return false;
        }

        //savevalues
        function savevalues() {
            var obj = new Object();
            var MMI_IDs = "", MMI_Names = "", MMI_Codes = "", MMI_SavBals = "", MMI_WithdrawAmts = "";
            var MMI_Interests = "", MMI_IntWithdraws = "", ChequeNos = "", RecieptNOs = "", CashBanks = "";
            //obj.RecieptNO += $('#txtReceiptNo' + ids[k]).val()+'|';
            var ids = $("#tblMemberSaving").jqGrid('getGridParam', 'selarrrow');
            if (ids == undefined || ids == "" || ids.length == 0) {
                alert("Select Atleast One Check Box");
                return false;
            }
            if (ids.length) {
                for (k = 0; k < ids.length; k++) {
                    var rowData = $('#tblMemberSaving').jqGrid('getRowData', ids[k]);
                    MMI_IDs += rowData.MMI_ID + ',';
                    MMI_Names += rowData.MMI_Name + ',';
                    MMI_Codes += rowData.MMI_Code + ',';
                    MMI_SavBals += $('#lblMemSavingBalance' + ids[k]).val() + ',';
                    MMI_WithdrawAmts += $('#MMI_WithdrawAmt' + ids[k]).val() + ',';
                    MMI_Interests += $('#MMI_Interest' + ids[k]).val() + ',';
                    MMI_IntWithdraws += $('#MMI_IntWithdraw' + ids[k]).val() + ',';
                    ChequeNos += $('#txtCheque' + ids[k]).val() + ',';
                    RecieptNOs += $('#txtReceiptNo' + ids[k]).val() + ',';
                    CashBanks += $('#ddlMemCB' + ids[k]).val() + ',';
                }
            }

            obj.MMI_ID = MMI_IDs;
            obj.MMI_Name = MMI_Names;
            obj.MMI_Code = MMI_Codes;
            obj.MMI_SavBal = MMI_SavBals;
            obj.MMI_WithdrawAmt = MMI_WithdrawAmts;
            obj.MMI_Interest = MMI_Interests;
            obj.ChequeNo = ChequeNos;
            obj.RecieptNO = RecieptNOs;
            obj.CashBank = CashBanks;
            obj.MMI_IntWithdraw = MMI_IntWithdraws;
            PageMethods.savedata(obj, onSuccess, onFailure)
            function onSuccess(r) {
                alert(r);
                clearAll();
                return false;
            }
            function onFailure(r) {
                alert('Insert Failed');
                return false;
            }
            return false;
        }

        function clearAll() {
//            $("#<%=txtBranch.ClientID %>").val('');
//            $("#<%= txtVillage.ClientID %>").val('');
//            $("#<%= txtCentername.ClientID %>").val('');
//            $("#<%= txtgroup.ClientID %>").val('');
 //           $("#<%= txtmember.ClientID %>").val('');

            $("#tblGroup").GridUnload();
//            $('#lblMemSavingBalance').val("");
//            $('#MMI_WithdrawAmt').val("");
//            $('#MMI_Interest').val("");
//            $('#MMI_IntWithdraw').val("");
//            $('#txtCheque').val("");
//            $("#ddlMemCB").val("");
            Grid();
        }

        $(function() {
            $(":button").button();
            $("#accordian").accordion({
                heightStyle: "content",
                active: 0,
                collapsible: true
            });
        });
       
    </script>

    <table width="100%">
        <tr>
            <td class="tdheading">
                Member&nbsp; Withdrawal
            </td>
        </tr>
    </table>
    <table width="100%">
        <tr>
            <td>
                <div id="accordian">
                    <h3>
                        Member Withdrawal</h3>
                    <div>
                        <table>
                            <tr>
                                <td class="tdtext">
                                    Branch Name<span style="font-size: 11pt; color: #ff4500">*</span>
                                </td>
                                <td style="width: 219px">
                                    <input tabindex="1" type="text" id="txtBranch" runat="server" class="textbox_autocompltee" />
                                </td>
                                <td class="tdtext">
                                    Village/Locality<span style="font-size: 11pt; color: #ff4500">*</span>
                                </td>
                                <td>
                                    <input type="text" id="txtVillage" class="textbox_autocompltee" runat="server" tabindex="2" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tdtext" style="width: 114px">
                                    Center Number<span style="font-size: 11pt; color: #ff4500">*</span>
                                </td>
                                <td>
                                    <input type="text" id="txtCentername" runat="server" class="textbox_autocompltee"
                                        tabindex="3" />
                                </td>
                                <td class="tdtext">
                                    Group Name<span style="font-size: 11pt; color: #ff4500">*</span>
                                </td>
                                <td style="width: 99px">
                                    <input type="text" id="txtgroup" runat="server" class="textbox_autocompltee" tabindex="3" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tdtext">
                                    Member Name<span style="font-size: 11pt; color: #ff4500">*</span>
                                </td>
                                <td style="width: 99px">
                                    <input type="text" id="txtmember" runat="server" class="textbox_autocompltee" tabindex="3" />
                                </td>
                            </tr>
                        </table>
                        <table class="table">
                            <tr>
                                <td>
                                    <button id="btnSave" onclick="return savevalues();" title="Tip:Select the Save Button">
                                        Save</button>
                                    <button id="btnView" onclick="return ShowGrid();" title="Tip:Display the Data">
                                        View</button>
                                    <button id="btnClear" onclick="return ClearAll();" title="Tip: Clears Data">
                                        Clear</button>
                                    <em><span style="color: #ff4500; font-weight: bolder; font-size: 12px;" id="NoDetails">
                                    </span></em>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table id="tblMemberSaving">
                                    </table>
                                    <div id="pager">
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span style="font-size: 8pt; color: #ff4500">Note: (*) Marked Fields Are Mandatory.</span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <input type="hidden" id="Hidden1" runat="server" />
    <input type="hidden" id="hidvillage" runat="server" />
    <input type="hidden" id="HidUid" runat="server" />
    <input type="hidden" id="hidbranch" runat="server" />
    <input type="hidden" id="hidMCIID" runat="server" />
    <input type="hidden" id="HUID" runat="server" />
    <input type="hidden" id="bid" runat="server" />
    <input type="hidden" id="vid" runat="server" />
    <input type="hidden" id="cid" runat="server" />
    <input type="hidden" id="gid" runat="server" />
    <input type="hidden" id="Mid" runat="server" />
</asp:Content>

 



 .CS:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BOLayer;
using BALayer;
using DALayer;
using System.Web.Services;

namespace SPANDANA
{
    public partial class MemberWithdrawal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["UserId"] = 1;
            HUID.Value = Session["UserId"].ToString();
        }

        [WebMethod]
        public static string savedata(MemberWithdrawalBOL objMemberWithdrawalBOL)
        {
            MemberWithdrawalBAL objMemberWithdrawalBAL = new MemberWithdrawalBAL();
            return objMemberWithdrawalBAL.savedate(objMemberWithdrawalBOL);
        }
    }
}
 


BAL:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BOLayer;
using DALayer;
using System.Collections.Specialized;
namespace BALayer
{
    public class MemberWithdrawalBAL
    {
        MemberWithdrawalDAL objMemberWithdrawalDAL = new MemberWithdrawalDAL();
        public DataSet FillMemBAl(string MMID, string GGID)
        {
            DataSet FillDMemberWithdrawalBAl = objMemberWithdrawalDAL.ShowMemberWithdrawalDAL(MMID,GGID);
            return FillDMemberWithdrawalBAl;
        }
        public string savedate(MemberWithdrawalBOL objMemberWithdrawalBOL)
        {
            try
            {
                return objMemberWithdrawalDAL.savedata(objMemberWithdrawalBOL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
 



DAL:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;
using BOLayer;

namespace DALayer
{
    public class MemberWithdrawalDAL
    {
        string con = BaseConnection.GetConnectionStringMD();
        public DataTable GetBID(string FilterText, string UserID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];
                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;
                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "B";
                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetVid(string FilterText, string UserId, string BID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];
                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;
                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "V";
                sp[3] = new SqlParameter("@UserID", SqlDbType.Char, 5);
                sp[3].Value = UserId;
                sp[3] = new SqlParameter("@BID", SqlDbType.Char, 5);
                sp[3].Value = BID;
                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetCid(string FilterText, string UserId, string BID, string VID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];

                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;

                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "C";

                sp[4] = new SqlParameter("@BID", SqlDbType.Char, 5);
                sp[4].Value = BID;

                sp[5] = new SqlParameter("@VID", SqlDbType.Char, 5);
                sp[5].Value = VID;

                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetGid(string FilterText, string UserId, string BID, string VID, string CID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];

                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;

                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "G";

                sp[3] = new SqlParameter("@BID", SqlDbType.Char, 5);
                sp[3].Value = BID;

                sp[3] = new SqlParameter("@VID", SqlDbType.Char, 5);
                sp[3].Value = VID;

                sp[4] = new SqlParameter("@CID", SqlDbType.Char, 5);
                sp[4].Value = CID;


                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public DataTable GetMid(string FilterText, string UserId, string BID, string VID, string CID, string GID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];

                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;

                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "M";

                sp[4] = new SqlParameter("@BID", SqlDbType.Char, 5);
                sp[4].Value = BID;

                sp[5] = new SqlParameter("@VID", SqlDbType.Char, 5);
                sp[5].Value = VID;

                sp[6] = new SqlParameter("@CID", SqlDbType.Char, 5);
                sp[6].Value = CID;

                sp[6] = new SqlParameter("@GID", SqlDbType.Char, 5);
                sp[6].Value = GID;


                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetShowGrid(string FilterText, string UserId, string BID, string VID, string CID, string GID, string MMID)
        {
            DataSet ds = new DataSet();
            try
            {
                SqlParameter[] sp = new SqlParameter[10];

                sp[0] = new SqlParameter("@FlterText", SqlDbType.VarChar, -1);
                sp[0].Value = FilterText;

                sp[2] = new SqlParameter("@Flag", SqlDbType.Char, 1);
                sp[2].Value = "M";

                sp[4] = new SqlParameter("@BID", SqlDbType.Char, 5);
                sp[4].Value = BID;

                sp[5] = new SqlParameter("@VID", SqlDbType.Char, 5);
                sp[5].Value = VID;

                sp[6] = new SqlParameter("@CID", SqlDbType.Char, 5);
                sp[6].Value = CID;

                sp[6] = new SqlParameter("@GID", SqlDbType.Char, 5);
                sp[6].Value = GID;

                sp[7] = new SqlParameter("@MID", SqlDbType.Char, 5);
                sp[7].Value = MMID;


                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", sp).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public DataSet ShowMemberWithdrawalDAL(string MMID, string GGID)
        {
            try
            {
                SqlParameter[] p1 = new SqlParameter[3];

                p1[0] = new SqlParameter("@Flag", SqlDbType.VarChar, 100);
                p1[0].Value = "Gr";

                p1[1] = new SqlParameter("@MID", SqlDbType.VarChar, 3000);
                p1[1].Value = MMID;

                p1[2] = new SqlParameter("@GID", SqlDbType.VarChar, 3000);
                p1[2].Value = GGID;

                return SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "Usp_Member_saving", p1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string savedata(MemberWithdrawalBOL objMemberWithdrawalBOL)
        {
            try
            {
                string messsage = "";

             
                SqlParameter[] p1 = new SqlParameter[20];

                p1[0] = new SqlParameter("@Flag", SqlDbType.VarChar, 100);
                p1[0].Value = "WI";

                p1[1] = new SqlParameter("@MID", SqlDbType.VarChar, 3000);
                p1[1].Value = objMemberWithdrawalBOL.MMI_ID;

                p1[2] = new SqlParameter("@MMI_code", SqlDbType.VarChar, 3000);
                p1[2].Value = objMemberWithdrawalBOL.MMI_Code;

                p1[3] = new SqlParameter("@MMI_Name", SqlDbType.VarChar, 3000);
                p1[3].Value = objMemberWithdrawalBOL.MMI_Name;

                p1[4] = new SqlParameter("@MMI_SaveBal", SqlDbType.VarChar, 3000);
                p1[4].Value = objMemberWithdrawalBOL.MMI_SavBal;

                p1[5] = new SqlParameter("@MMI_SaveAmt", SqlDbType.VarChar, 3000);
                p1[5].Value = objMemberWithdrawalBOL.MMI_SavAmt;

                p1[6] = new SqlParameter("@ChequeNo", SqlDbType.VarChar, 3000);
                p1[6].Value = objMemberWithdrawalBOL.ChequeNo;

                p1[7] = new SqlParameter("@ReceiptNo", SqlDbType.VarChar, 3000);
                p1[7].Value = objMemberWithdrawalBOL.RecieptNO;

                p1[8] = new SqlParameter("@BankCash", SqlDbType.VarChar, 3000);
                p1[8].Value = objMemberWithdrawalBOL.CashBank;


                p1[9] = new SqlParameter("@MMI_WithdrawAmt", SqlDbType.VarChar, 3000);
                p1[9].Value = objMemberWithdrawalBOL.MMI_WithdrawAmt;

                p1[10] = new SqlParameter("@MMI_Interest", SqlDbType.VarChar, 3000);
                p1[10].Value = objMemberWithdrawalBOL.MMI_Interest;

                p1[11] = new SqlParameter("@MMI_IntWithdraw", SqlDbType.VarChar, 3000);
                p1[11].Value = objMemberWithdrawalBOL.MMI_IntWithdraw;

                p1[12] = new SqlParameter("@Msg", SqlDbType.VarChar, 1000);
                p1[12].Direction = ParameterDirection.Output;


                SqlHelper.ExecuteScalar(con, CommandType.StoredProcedure, "Usp_Member_saving", p1);
                messsage = Convert.ToString(p1[12].Value);
                return messsage;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
 



BOL:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BOLayer
{
    public class MemberWithdrawalBOL
    {
        public string MMI_ID { get; set; }
        public string MMI_Name { get; set; }
        public string MMI_Code { get; set; }
        public string MMI_SavBal { get; set; }
        public string MMI_SavAmt { get; set; }
        public string CashBank { get; set; }
        public string ChequeNo { get; set; }
        public string RecieptNO { get; set; }
        public string MMI_WithdrawAmt { get; set; }
        public string MMI_Interest { get; set; }
        public string MMI_IntWithdraw { get; set; }




    }
}
 



ASMX:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using DALayer;
using BALayer;
using BOLayer;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

namespace SPANDANA.WebServices.MIS
{
    /// <summary>
    /// Summary description for MemberWithdrawal
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class MemberWithdrawal : System.Web.Services.WebService
    {

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> getBranch(string prefixText, string UserID)
        {
            List<string> lstParties = new List<string>();
            MemberWithdrawalDAL lstBranchGp1DAL = new MemberWithdrawalDAL();
            DataTable dt = lstBranchGp1DAL.GetBID(prefixText, UserID);
            foreach (DataRow dr in dt.Rows)
            {
                lstParties.Add(string.Format("{0}", dr["Branch"]));
            }
            return lstParties;
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> getVillage(string prefixText, string UserID, string BID)
        {
            List<string> lstParties = new List<string>();
            MemberWithdrawalDAL lstBranchGp1DAL = new MemberWithdrawalDAL();
            DataTable dt = lstBranchGp1DAL.GetVid(prefixText, UserID, BID);
            foreach (DataRow dr in dt.Rows)
            {
                lstParties.Add(string.Format("{0}", dr["Village"]));
            }
            return lstParties;
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> getCenter(string prefixText, string UserID, string BID, string VID)
        {
            List<string> lstParties = new List<string>();
            MemberWithdrawalDAL lstBranchGp1DAL = new MemberWithdrawalDAL();
            DataTable dt = lstBranchGp1DAL.GetCid(prefixText, UserID, BID, VID);
            foreach (DataRow dr in dt.Rows)
            {
                lstParties.Add(string.Format("{0}", dr["Center"]));
            }
            return lstParties;
        }


        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> getGroup(string prefixText, string UserID, string BID, string VID, string CID)
        {
            List<string> lstParties = new List<string>();
            MemberWithdrawalDAL lstBranchGp1DAL = new MemberWithdrawalDAL();
            DataTable dt = lstBranchGp1DAL.GetGid(prefixText, UserID, BID, VID, CID);
            foreach (DataRow dr in dt.Rows)
            {
                lstParties.Add(string.Format("{0}", dr["Group"]));
            }
            return lstParties;
        }
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> getMember(string prefixText, string UserID, string BID, string VID, string CID, string GID)
        {
            List<string> lstParties = new List<string>();
            MemberWithdrawalDAL lstBranchGp1DAL = new MemberWithdrawalDAL();
            DataTable dt = lstBranchGp1DAL.GetMid(prefixText, UserID, BID, VID, CID, GID);
            foreach (DataRow dr in dt.Rows)
            {
                lstParties.Add(string.Format("{0}", dr["Member"]));
            }
            return lstParties;
        }

        [WebMethod]
        public void showGrid(string Mem,string GGID)
        {
            string msg = "";
            try
            {
                MemberWithdrawalBOL objMemberWithdrawalBOL = new MemberWithdrawalBOL();
                MemberWithdrawalBAL objMemberWithdrawalBAL = new MemberWithdrawalBAL();
                DataSet dtl = objMemberWithdrawalBAL.FillMemBAl(Mem,GGID);

                List<MemberWithdrawalBOL> obMemberWithdrawalBOL = new List<MemberWithdrawalBOL>();
                foreach (DataRow dr in dtl.Tables[0].Rows)
                {
                    MemberWithdrawalBOL objsMemberWithdrawalBOL = new MemberWithdrawalBOL();
                    objsMemberWithdrawalBOL.MMI_ID = Convert.ToString(dr["MMI_ID"]);
                    objsMemberWithdrawalBOL.MMI_Name = Convert.ToString(dr["MMI_NAME"]);
                    objsMemberWithdrawalBOL.MMI_Code = Convert.ToString(dr["MMI_Code"]);
                    obMemberWithdrawalBOL.Add(objsMemberWithdrawalBOL);
                }
                GridPaging gp = new GridPaging();
                Vals Val = gp.Parms(obMemberWithdrawalBOL);
                List<MemberWithdrawalBOL> final = new List<MemberWithdrawalBOL>(Val.rows);
                if (obMemberWithdrawalBOL.Count < Val.end)
                {
                    Val.end = obMemberWithdrawalBOL.Count;
                }
                for (int i = Val.start; i < Val.end; i++)
                {
                    final.Add(obMemberWithdrawalBOL[i]);
                }
                var griddata = new
                {
                    total = Math.Ceiling((Decimal)obMemberWithdrawalBOL.Count / Val.rows),
                    page = Val.page,
                    records = obMemberWithdrawalBOL.Count,
                    rows = final,
                };


                JavaScriptSerializer objJavaScriptSerializer = new JavaScriptSerializer();
                Context.Response.ContentType = "application/json";
                Context.Response.Flush();

                Context.Response.Write(objJavaScriptSerializer.Serialize(griddata));

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        }

    }
}
 


PROCEDURE:

 
--Usp_Member_saving @FlterText='%',@Flag='Gr',@BID='',@VID='',@CID='1',@GID='',@MID=1 
 
Create proc Usp_Member_saving 
@FlterText varchar(Max)=Null, 
@Flag char(2)=Null, 
@BID int=Null, 
@VID int=Null, 
@CID int=Null, 
@GID  int=Null, 
@MID varchar(max)=Null, 
@MMI_SaveBal varchar(max)=null, 
@MMI_SaveAmt money=null, 
@ChequeNo varchar(20)=null, 
@ReceiptNo varchar(20)=null, 
@BankCash varchar(10)=null, 
@MMI_code varchar(10)=null, 
@MMI_Name varchar(max)=Null ,
@MMI_WithdrawAmt varchar=Null,
@MMI_Interest varchar=Null,
@MMI_IntWithdraw varchar=null,
@msg varchar(max)=Null output
 
as 
Begin 
 
  If(@Flag='B')     
   Begin  
     select MBRI_Name+'|'+convert(varchar,br.MBRI_ID) Branch      
     from mast_branch_info br(nolock)     
     --inner join @Branch filbr on br.mbri_id=filbr.Bid     
     inner join DAY_CLOSE_DETAILS DY on DY.mbri_id=br.mbri_id and DCD_FLAG='B'             
     WHERE MBRI_Name like '%'+@FlterText+'%' or Mbri_code like '%'+@FlterText+'%' 
   End    
  If(@Flag='V')     
   Begin     
     select MVI_NAME+' | '+convert(varchar,isnull(vl.MVI_ID,''))+' | '+convert(varchar,br.MBRI_ID) Village      
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on br.MBRI_Id=vl.MBRI_Id 
     where  (MVI_Name like '%'+@FlterText+'%' or MVI_code like '%'+@FlterText+'%'  ) and  vl.MBRI_ID=@BID  
   End    
    
  If(@Flag='C')     
   Begin     
     select MCI_NAME+' | '+convert(varchar,isnull(cr.MCI_ID,''))+' | '+convert(varchar,isnull(vl.MVI_ID,''))+' | '+convert(varchar,br.MBRI_ID) Center      
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on br.MBRI_Id=vl.MBRI_Id 
     inner join MAst_center_info(Nolock) Cr on vl.MVI_ID=cr.MVI_ID 
     where  (MCI_Name like '%'+@FlterText+'%' or MCI_code like '%'+@FlterText+'%'  ) and cr.MVI_ID=@VID      
   End  
    
   If(@Flag='G')     
   Begin     
     select MGI_NAME+' | '+convert(varchar,isnull(Gr.MGI_ID,''))+' | '+convert(varchar,isnull(Cr.MCI_ID,''))+' | '+convert(varchar,isnull(vl.MVI_ID,''))+' | '+convert(varchar,br.MBRI_ID) [Group]      
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on br.MBRI_Id=vl.MBRI_Id 
     inner join MAst_center_info(Nolock) Cr on vl.MVI_ID=cr.MVI_ID 
     inner join MAst_Group_info(Nolock) Gr on Gr.MCI_ID=Cr.MCI_ID 
     where  (MGI_Name like '%'+@FlterText+'%' or MGI_code like '%'+@FlterText+'%'  ) and  cr.MCI_ID=@CID    
   End          
       
   If(@Flag='M')     
   Begin   
   
     select MMI_NAME+' | '+convert(varchar,isnull(MEm.MMI_ID,''))+' | '+convert(varchar,isnull(Gr.MGI_ID,''))+' | '+convert(varchar,isnull(Cr.MCI_ID,''))+' | '+convert(varchar,isnull(vl.MVI_ID,''))+' | '+convert(varchar,br.MBRI_ID) Member      
      
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on vl.MBRI_Id=br.MBRI_Id 
     inner join MAst_center_info(Nolock) Cr on Cr.MVI_ID=vl.MVI_ID 
     inner join MAst_Group_info(Nolock) Gr on Gr.MCI_ID=Cr.MCI_ID 
     inner join MAst_Member_info(Nolock) Mem on MeM.MGI_ID=Gr.MGI_ID           
     where (MMI_Name like '%'+@FlterText+'%' or MMI_code like '%'+@FlterText+'%') and  Mem.MGI_ID=@GID    
   End    
    
 If(@Flag='Gr')     
   Begin   
  if(@MID='' or @MID=Null) 
  begin 
  --declare @Gid int=1,@FlterText varchar(max)='%',@MID varchar(max)='0' 
     select MMI_ID,MMI_NAME,MMI_Code           
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on vl.MBRI_Id=br.MBRI_Id 
     inner join MAst_center_info(Nolock) Cr on Cr.MVI_ID=vl.MVI_ID 
     inner join MAst_Group_info(Nolock) Gr on Gr.MCI_ID=Cr.MCI_ID 
     inner join MAst_Member_info(Nolock) Mem on MeM.MGI_ID=Gr.MGI_ID           
     where   gr.MGI_ID=@GID
   End 
   else 
   begin 
     select MMI_ID,MMI_NAME,MMI_Code           
     from mast_branch_info (nolock) br 
     inner join Mast_Village_Info(Nolock) vl on vl.MBRI_Id=br.MBRI_Id 
     inner join MAst_center_info(Nolock) Cr on Cr.MVI_ID=vl.MVI_ID 
     inner join MAst_Group_info(Nolock) Gr on Gr.MCI_ID=Cr.MCI_ID 
     inner join MAst_Member_info(Nolock) Mem on MeM.MGI_ID=Gr.MGI_ID           
     where   MMI_ID=@MID 
   end 
  end 
  --if(@flag='SI') 
  --begin 
  --   insert into Mast_Member_savings_info values(@MID,@MMI_Name,@MMI_code,@MMI_SaveBal,@MMI_SaveAmt,@BankCash,@ChequeNo,@ReceiptNo) 
  --   set @msg='Insert Successfull'
  --   select @msg
  --end   
  -- if(@flag='WI') 
  --begin 
  --   insert into Mast_Member_Withdrawal_info values(@MID,@MMI_Name,@MMI_code,@MMI_SaveBal,@MMI_WithdrawAmt,@MMI_Interest,@MMI_IntWithdraw,@BankCash,@ChequeNo,@ReceiptNo)     
  --    set @msg='Insert Successfull'
  --   select @msg
  --end  
 
if(@flag='SI') 
  begin 
     insert into Mast_Member_savings_info(MMI_ID,MMI_NAME,MMI_COde,MMI_SavBal,MMI_SavAmt,CashBank,ChequeNo,RecieptNO) 
    
     --declare @MID varchar(max)='1,2,3',@MMI_Name varchar(max)='1,b,c',@MMI_code varchar(max)='1,20,30',@MMI_SaveBal varchar(max)='1,20,30',@MMI_SaveAmt varchar(max)='1,20,30',
     --@BankCash varchar(max)='1,20,30',@ChequeNo varchar(max)='1,20,30',@ReceiptNo varchar(max)='1,20,30'
     select
      A.Value,B.Value,C.Value,D.Value,E.Value,F.Value,g.Value ,h.Value
        from udf_split(@MID,',') A     
        Left join udf_split(@MMI_Name,',') B ON A.ID=B.Id     
        Left join udf_split(@MMI_code,',') C ON A.Id=C.Id     
        Left join udf_split(@MMI_SaveBal,',') D ON A.Id=D.Id     
        Left join udf_split(@MMI_SaveAmt,',') E ON A.Id=E.Id     
        Left join udf_split(@BankCash,',') f ON A.Id=f.Id 
         Left join udf_split(@ChequeNo,',') g ON A.Id=g.Id
          Left join udf_split(@ReceiptNo,',') h ON A.Id=h.Id         
    
    
     set @msg='Insert Successfull'
     select @msg
  end  
   if(@flag='WI') 
  begin 
     insert into Mast_Member_Withdrawal_info(MMI_ID,MMI_NAME,MMI_COde,MMI_SavBal,MMI_WithdrawAmt,MMI_Interest,MMI_IntWithdraw,CashBank,ChequeNo,RecieptNO)     
      select
      A.Value,B.Value,C.Value,D.Value,E.Value,F.Value,g.Value ,h.Value ,i.Value,j.Value
        from udf_split(@MID,',') A     
        Left join udf_split(@MMI_Name,',') B ON A.ID=B.Id     
        Left join udf_split(@MMI_code,',') C ON A.Id=C.Id     
        Left join udf_split(@MMI_SaveBal,',') D ON A.Id=D.Id     
        Left join udf_split(@MMI_WithdrawAmt,',') E ON A.Id=E.Id     
        Left join udf_split(@MMI_Interest,',') f ON A.Id=f.Id 
         Left join udf_split(@MMI_IntWithdraw,',') g ON A.Id=g.Id
          inner join udf_split(@BankCash,',') h ON A.Id=h.Id
          inner join udf_split(@ChequeNo,',') i ON A.Id=i.Id
           inner join udf_split(@ReceiptNo,',') j ON A.Id=j.Id         
         
      set @msg='Insert Successfull'
     select @msg
  end        
end   


 
 
 

 

No comments:

Post a Comment