Esempio n. 1
0
        // PUT api/paymentvoucher/5
        public int Put(int id, PaymentVoucherModel m)
        {
            m.paymentVoucherId = id;
            int i = PaymentVoucherProvider.insertPaymentVoucher(m);

            return(i);
        }
        public static int insertPaymentVoucher(PaymentVoucherModel s)
        {
            try
            {
                SqlHandler sql = new SqlHandler();
                List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >();

                parameter.Add(new KeyValuePair <string, object>("@PaymentVoucherId", s.paymentVoucherId));

                parameter.Add(new KeyValuePair <string, object>("@Amount", s.Amount));
                parameter.Add(new KeyValuePair <string, object>("@DrAccountId", s.AccountId));

                parameter.Add(new KeyValuePair <string, object>("@PaymentType", s.PaymentType));
                parameter.Add(new KeyValuePair <string, object>("@narration", s.Narration));
                parameter.Add(new KeyValuePair <string, object>("@CrAccount", s.CrAccount));
                parameter.Add(new KeyValuePair <string, object>("@DueGold", s.OpeningGold));
                parameter.Add(new KeyValuePair <string, object>("@FinancialYearId", s.financialYearID));
                parameter.Add(new KeyValuePair <string, object>("@CompanyId", s.CompanyId));
                parameter.Add(new KeyValuePair <string, object>("@insertDate", s.InseertDate));

                parameter.Add(new KeyValuePair <string, object>("@InsertBy", s.InsertBy));



                int i = sql.ExecuteNonQueryI("Usp_PaymentVoucher", parameter);
                return(i);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public List <PaymentVoucherModel> GetPaymentbyId(long id)
        {
            List <PaymentVoucherModel> lstPayment = new List <PaymentVoucherModel>();
            PaymentVoucherModel        objPayment;
            StringBuilder SbQuery = new StringBuilder();

            SbQuery.AppendLine("SELECT p.*,m.ACC_Name FROM Payment_Voucher_Master as p");
            SbQuery.AppendLine("left join accountmaster as m on p.PaymentModeId=m.Ac_Id");
            SbQuery.AppendLine("WHERE `Payment_Id`=" + id);
            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(SbQuery.ToString(), _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objPayment = new PaymentVoucherModel();

                objPayment.Pay_Id         = DataFormat.GetInteger(dr["Payment_ID"]);
                objPayment.Voucher_Series = dr["Series"].ToString();
                objPayment.Pay_Date       = DataFormat.GetDateTime(dr["Pay_Date"]);
                objPayment.Voucher_Number = DataFormat.GetInteger(dr["VoucherNo"]);
                objPayment.Type           = dr["Type"].ToString();
                objPayment.PaymentModeId  = Convert.ToInt64(dr["PaymentModeId"].ToString());
                objPayment.PaymentMode    = dr["ACC_Name"].ToString();
                objPayment.PDCDate        = Convert.ToDateTime(dr["PDC_Date"]);
                objPayment.LongNarration  = dr["LongNarration"].ToString();
                objPayment.TotalDebitAmt  = Convert.ToDecimal(dr["TotalDebitAmt"]);
                objPayment.TotalCreditAmt = Convert.ToDecimal(dr["TotalCreditAmt"]);


                //SELECT Payment Voucher Details

                string itemQuery = "SELECT * FROM `Payment_Voucher_Details` WHERE `Payment_Id`=" + objPayment.Pay_Id;
                System.Data.IDataReader drAcc = _dbHelper.ExecuteDataReader(itemQuery, _dbHelper.GetConnObject());

                objPayment.PaymentAccountModel = new List <AccountModel>();
                AccountModel objAcc;

                while (drAcc.Read())
                {
                    objAcc = new AccountModel();

                    objAcc.AC_Id     = DataFormat.GetInteger(drAcc["AC_Id"]);
                    objAcc.ParentId  = DataFormat.GetInteger(drAcc["Payment_Id"]);
                    objAcc.DC        = drAcc["DC"].ToString();
                    objAcc.Account   = drAcc["Account"].ToString();
                    objAcc.LedgerId  = Convert.ToInt64(drAcc["LegderId"].ToString());
                    objAcc.Debit     = Convert.ToDecimal(drAcc["Debit"]);
                    objAcc.Credit    = Convert.ToDecimal(drAcc["Credit"]);
                    objAcc.Amount    = Convert.ToDecimal(drAcc["Debit"]);
                    objAcc.Narration = drAcc["Narration"].ToString();

                    objPayment.PaymentAccountModel.Add(objAcc);
                }

                lstPayment.Add(objPayment);
            }
            return(lstPayment);
        }
Esempio n. 4
0
        public List <PaymentVoucherModel> GetPaymentbyId(int id)
        {
            List <PaymentVoucherModel> lstPayment = new List <PaymentVoucherModel>();
            PaymentVoucherModel        objPayment;

            string Query = "SELECT * FROM Payment_Voucher WHERE Payment_Id=" + id;

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objPayment = new PaymentVoucherModel();

                objPayment.Pay_Id         = DataFormat.GetInteger(dr["Payment_ID"]);
                objPayment.Voucher_Series = dr["Series"].ToString();
                objPayment.Pay_Date       = DataFormat.GetDateTime(dr["Pay_Date"]);
                objPayment.Voucher_Number = DataFormat.GetInteger(dr["VoucherNo"]);
                objPayment.Type           = dr["Type"].ToString();
                if (dr["PDC_Date"].ToString() != "")
                {
                    objPayment.PDCDate = Convert.ToDateTime(dr["PDC_Date"]);
                }

                //SELECT Payment Voucher Accounts

                string itemQuery = "SELECT * FROM Payment_Voucher_Accounts WHERE Payment_Id=" + objPayment.Pay_Id;
                System.Data.IDataReader drAcc = _dbHelper.ExecuteDataReader(itemQuery, _dbHelper.GetConnObject());

                objPayment.PaymentAccountModel = new List <AccountModel>();
                AccountModel objAcc;

                while (drAcc.Read())
                {
                    objAcc = new AccountModel();

                    objAcc.AC_Id     = DataFormat.GetInteger(drAcc["AC_Id"]);
                    objAcc.ParentId  = DataFormat.GetInteger(drAcc["Payment_Id"]);
                    objAcc.DC        = drAcc["DC"].ToString();
                    objAcc.Account   = drAcc["Account"].ToString();
                    objAcc.Debit     = Convert.ToDecimal(drAcc["Debit"]);
                    objAcc.Credit    = Convert.ToDecimal(drAcc["Credit"]);
                    objAcc.Narration = drAcc["Narration"].ToString();

                    objPayment.PaymentAccountModel.Add(objAcc);
                }

                lstPayment.Add(objPayment);
            }
            return(lstPayment);
        }
Esempio n. 5
0
        public bool SavePaymentVoucher(PaymentVoucherModel objpaymod)
        {
            string Query = string.Empty;
            //int payid = 0;
            bool isSaved = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();


                paramCollection.Add(new DBParameter("@VoucherNumber", objpaymod.Voucher_Number));
                paramCollection.Add(new DBParameter("@Series", objpaymod.Voucher_Series));
                paramCollection.Add(new DBParameter("@PayDate", objpaymod.Pay_Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Type", objpaymod.Type));
                paramCollection.Add(new DBParameter("@PaymentModeId", objpaymod.PaymentModeId));
                paramCollection.Add(new DBParameter("@PDCDate", objpaymod.PDCDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@LongNarration", objpaymod.LongNarration));
                paramCollection.Add(new DBParameter("@TotalCreditAmount", objpaymod.TotalCreditAmt, DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalDebitAmount", objpaymod.TotalDebitAmt, DbType.Decimal));
                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, DbType.DateTime));
                paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, DbType.DateTime));

                System.Data.IDataReader dr =
                    _dbHelper.ExecuteDataReader("spInsertPaymentMaster", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                int id = 0;
                dr.Read();
                id = Convert.ToInt32(dr[0]);
                SavePaymentAccounts(objpaymod.PaymentAccountModel, id);
                objLPBL.LedgerPostingAddByList(objpaymod.PaymentLPDebit);
                objLPBL.LedgerPostingAddByList(objpaymod.PaymentLPCredit);
            }
            catch (Exception ex)
            {
                isSaved = false;
                throw ex;
            }

            return(isSaved);
        }
Esempio n. 6
0
        public int SavePaymentVoucher(PaymentVoucherModel obpaybl)
        {
            string Query = string.Empty;
            int    payid = 0;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();


                paramCollection.Add(new DBParameter("@Series", obpaybl.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", obpaybl.Pay_Date));
                paramCollection.Add(new DBParameter("@Voucher_Number", obpaybl.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", obpaybl.Type));
                paramCollection.Add(new DBParameter("@PDDate", obpaybl.PDCDate));
                //paramCollection.Add(new DBParameter("@Long", obpaybl.LongNarration));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));


                Query = "INSERT INTO Payment_Voucher([Series],[Pay_Date],[VoucherNo],[Type],[PDC_Date]," +
                        "[CreatedBy],[CreatedDate]) VALUES " +
                        "(@Series,@Date,@Voucher_Number,@Type,@PDDate, " +
                        " @CreatedBy,@CreatedDate)";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    SavePaymentAccounts(obpaybl.PaymentAccountModel);
                    payid = GetPaymentId();
                }
            }
            catch (Exception ex)
            {
                payid = 0;
                throw ex;
            }

            return(payid);
        }
Esempio n. 7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            PaymentVoucherModel objPayment = new PaymentVoucherModel();

            if (tbxVchNumber.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }
            objPayment.Voucher_Series = tbxVoucherSeries.Text.Trim();
            objPayment.Voucher_Number = Convert.ToInt32(tbxVchNumber.Text.Trim());
            objPayment.Pay_Date       = Convert.ToDateTime(dtDate.Text);
            objPayment.Type           = tbxType.Text.Trim() == null ? string.Empty : tbxType.Text.Trim();
            objPayment.PDCDate        = Convert.ToDateTime(dtPDCDate.Text);
            objPayment.PaymentModeId  = objAccBL.GetLedgerIdByAccountName(cbxPayMode.Text.Trim() == null?string.Empty:cbxPayMode.Text.Trim());
            objPayment.LongNarration  = tbxLongNarration.Text.Trim() == null ? string.Empty : tbxLongNarration.Text.Trim();
            if (objPayment.PaymentModeId == 0)
            {
                objPayment.TotalDebitAmt  = Convert.ToDecimal(colDebit.SummaryItem.SummaryValue);
                objPayment.TotalCreditAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }
            else
            {
                objPayment.TotalCreditAmt = Convert.ToDecimal(colAmount.SummaryItem.SummaryValue);
            }
            //Payment details
            AccountModel        objacc;
            List <AccountModel> lstAccounts = new List <AccountModel>();

            for (int i = 0; i < gdvPayment.DataRowCount; i++)
            {
                DataRow row = gdvPayment.GetDataRow(i);

                objacc          = new AccountModel();
                objacc.DC       = row["DC"].ToString();
                objacc.Account  = row["Account"].ToString();
                objacc.LedgerId = objAccBL.GetLedgerIdByAccountName(row["Account"].ToString());
                if (objPayment.PaymentModeId == 0)
                {
                    objacc.Debit  = Convert.ToDecimal(row["Debit"].ToString() == string.Empty ? "0.00" : row["Debit"].ToString());
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"].ToString());
                }
                else
                {
                    objacc.Debit = Convert.ToDecimal(row["Amount"].ToString() == string.Empty ? "0.00" : row["Amount"].ToString());
                }
                objacc.Narration = row["Narration"].ToString() == null ? string.Empty : row["Narration"].ToString();
                objacc.ParentId  = Convert.ToInt32(row["ParentId"].ToString() == string.Empty ? "0" : row["ParentId"]);
                objacc.AC_Id     = Convert.ToInt32(row["Ac_Id"].ToString() == string.Empty ? "0" : row["Ac_Id"]);
                lstAccounts.Add(objacc);
            }

            objPayment.PaymentAccountModel = lstAccounts;
            objPayment.Pay_Id = Payid;

            bool isSuccess = objpaybl.UpdatePaymentVoucher(objPayment);

            if (isSuccess)
            {
                MessageBox.Show("Update Successfully!");
                Payid = 0;
                ClearFormValues();
                Transaction.List.PaymentVouchersList frmList = new Transaction.List.PaymentVouchersList();
                frmList.StartPosition = FormStartPosition.CenterScreen;
                frmList.ShowDialog();

                FillPaymentVoucher();
            }
        }
Esempio n. 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            PaymentVoucherModel objPayment = new PaymentVoucherModel();

            if (tbxVchNumber.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }
            objPayment.Voucher_Series = tbxVoucherSeries.Text.Trim();
            objPayment.Voucher_Number = Convert.ToInt32(tbxVchNumber.Text.Trim());
            objPayment.Pay_Date       = Convert.ToDateTime(dtDate.Text);
            objPayment.Type           = tbxType.Text.Trim() == null ? string.Empty : tbxType.Text.Trim();
            objPayment.PDCDate        = Convert.ToDateTime(dtPDCDate.Text);
            objPayment.LongNarration  = tbxLongNarration.Text.Trim() == null?string.Empty:tbxLongNarration.Text.Trim();
            objPayment.PaymentModeId  = objAccBL.GetLedgerIdByAccountName(cbxPayMode.Text.Trim() == null ? string.Empty : cbxPayMode.Text.Trim());
            if (objPayment.PaymentModeId == 0)
            {
                objPayment.TotalDebitAmt  = Convert.ToDecimal(colDebit.SummaryItem.SummaryValue);
                objPayment.TotalCreditAmt = Convert.ToDecimal(colCredit.SummaryItem.SummaryValue);
            }
            else
            {
                objPayment.TotalCreditAmt = Convert.ToDecimal(colAmount.SummaryItem.SummaryValue);
            }

            //Payment details
            AccountModel        objacc;
            List <AccountModel> lstAccounts = new List <AccountModel>();

            for (int i = 0; i < gdvPayment.DataRowCount; i++)
            {
                DataRow row = gdvPayment.GetDataRow(i);

                objacc          = new AccountModel();
                objacc.DC       = row["DC"].ToString();
                objacc.Account  = row["Account"].ToString();
                objacc.LedgerId = objAccBL.GetLedgerIdByAccountName(row["Account"].ToString());
                if (objPayment.PaymentModeId == 0)
                {
                    objacc.Debit  = Convert.ToDecimal(row["Debit"].ToString() == string.Empty ? "0.00" : row["Debit"].ToString());
                    objacc.Credit = Convert.ToDecimal(row["Credit"].ToString() == string.Empty ? "0.00" : row["Credit"].ToString());
                }
                else
                {
                    objacc.Debit = Convert.ToDecimal(row["Amount"].ToString() == string.Empty ? "0.00" : row["Amount"].ToString());
                }
                objacc.Narration = row["Narration"].ToString() == null?string.Empty: row["Narration"].ToString();
                lstAccounts.Add(objacc);
            }
            objPayment.PaymentAccountModel = lstAccounts;
            //Ledger Posting
            if (objPayment.PaymentModeId != 0)
            {
                //Single Entery Ledger Debit Posting
                LedgerPostingModel        objLedger;
                List <LedgerPostingModel> lstLedgerDebit = new List <LedgerPostingModel>();

                for (int i = 0; i < gdvPayment.DataRowCount; i++)
                {
                    DataRow row = gdvPayment.GetDataRow(i);

                    objLedger               = new LedgerPostingModel();
                    objLedger.LedgerId      = objAccBL.GetLedgerIdByAccountName(row["Account"].ToString());
                    objLedger.Date          = Convert.ToDateTime(dtDate.Text.Trim());
                    objLedger.Debit         = Convert.ToDecimal(row["Amount"].ToString() == string.Empty ? "0.00" : row["Amount"].ToString());
                    objLedger.Credit        = 0;
                    objLedger.VoucherNo     = tbxVchNumber.Text.Trim();
                    objLedger.VoucherTypeId = 1;
                    objLedger.ChequeNo      = string.Empty;
                    objLedger.ChequeDate    = DateTime.Now;
                    objLedger.Extra1        = string.Empty;
                    objLedger.Extra2        = string.Empty;
                    objLedger.DetailsId     = 0;
                    objLedger.YearId        = 1;
                    lstLedgerDebit.Add(objLedger);
                }
                objPayment.PaymentLPDebit = lstLedgerDebit;
                //Single Entery Ledger Credit Posting
                LedgerPostingModel        objLedgerCredit;
                List <LedgerPostingModel> lstLedgerCredit = new List <LedgerPostingModel>();

                for (int i = 0; i < gdvPayment.DataRowCount; i++)
                {
                    DataRow row = gdvPayment.GetDataRow(i);

                    objLedgerCredit               = new LedgerPostingModel();
                    objLedgerCredit.LedgerId      = objPayment.PaymentModeId;
                    objLedgerCredit.Date          = Convert.ToDateTime(dtDate.Text.Trim());
                    objLedgerCredit.Credit        = Convert.ToDecimal(row["Amount"].ToString() == string.Empty ? "0.00" : row["Amount"].ToString());
                    objLedgerCredit.Debit         = 0;
                    objLedgerCredit.VoucherNo     = tbxVchNumber.Text.Trim();
                    objLedgerCredit.VoucherTypeId = 1;
                    objLedgerCredit.ChequeNo      = string.Empty;
                    objLedgerCredit.ChequeDate    = DateTime.Now;
                    objLedgerCredit.Extra1        = string.Empty;
                    objLedgerCredit.Extra2        = string.Empty;
                    objLedgerCredit.DetailsId     = 0;
                    objLedgerCredit.DetailsId     = 1;
                    lstLedgerCredit.Add(objLedgerCredit);
                }
                objPayment.PaymentLPCredit = lstLedgerCredit;
            }
            else
            {
            }



            bool isSuccess = objpaybl.SavePaymentVoucher(objPayment);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
                Payid = 0;
                //ClearFormValues();
            }
        }
Esempio n. 9
0
        //Update Payment Voucher
        public bool UpdatePaymentVoucher(PaymentVoucherModel objPay)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                //UPDATE CREDIT NOTE TABLE - PARENT TABLE

                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objPay.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", objPay.Pay_Date));
                paramCollection.Add(new DBParameter("@Voucher_Number", objPay.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", objPay.Type));
                paramCollection.Add(new DBParameter("@PDDate", objPay.PDCDate));
                //paramCollection.Add(new DBParameter("@TotalCreditAmt", "0"));
                //paramCollection.Add(new DBParameter("@TotalDebitAmt", "0"));

                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now));
                paramCollection.Add(new DBParameter("@id", objPay.Pay_Id));

                Query = "UPDATE Payment_Voucher SET [Series]=@Series,[Pay_Date]=@Date,[VoucherNo]=@Voucher_Number," +
                        "[Type]=@Type,[PDC_Date]=@PDDate,[ModifiedBy]=@ModifiedBy," +
                        "[ModifiedDate]=@ModifiedDate " +
                        "WHERE Payment_Id=@id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    List <AccountModel> lstAcct = new List <AccountModel>();

                    //UPDATE CREDIT NOTE ACCOUNT -CHILD TABLE UPDATES
                    foreach (AccountModel act in objPay.PaymentAccountModel)
                    {
                        if (act.AC_Id > 0)
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now));
                            paramCollection.Add(new DBParameter("@ACT_ID", act.AC_Id));

                            Query = "UPDATE Payment_Voucher_Accounts SET [DC]=@DC," +
                                    "[Account]=@Account,[Debit]=@Debit,[Credit]=@Credit,[Narration]=@Narration,[ModifiedBy]=@ModifiedBy,[ModifiedDate]=@ModifiedDate " +
                                    "WHERE [AC_Id]=@ACT_ID";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                        else
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DN_ID", (act.ParentId)));
                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));


                            Query = "INSERT INTO Payment_Voucher_Accounts([Payment_Id],[DC],[Account],[Debit]," +
                                    "[Credit],[Narration],[CreatedBy],[CreatedDate]) VALUES " +
                                    "(@Pay_ID,@DC,@Account,@Debit,@Credit,@Narration,@CreatedBy,@CreatedDate)";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }
Esempio n. 10
0
        // POST api/paymentvoucher
        public int Post(PaymentVoucherModel m)
        {
            int i = PaymentVoucherProvider.insertPaymentVoucher(m);

            return(i);
        }
Esempio n. 11
0
        //Update Payment Voucher
        public bool UpdatePaymentVoucher(PaymentVoucherModel objPay)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Series", objPay.Voucher_Series));
                paramCollection.Add(new DBParameter("@Date", objPay.Pay_Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Voucher_Number", objPay.Voucher_Number));
                paramCollection.Add(new DBParameter("@Type", objPay.Type));
                paramCollection.Add(new DBParameter("@PaymentModeId", objPay.PaymentModeId));
                paramCollection.Add(new DBParameter("@PDDate", objPay.PDCDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@LongNarration", objPay.LongNarration));
                paramCollection.Add(new DBParameter("@TotalCreditAmt", objPay.TotalCreditAmt, System.Data.DbType.Decimal));
                paramCollection.Add(new DBParameter("@TotalDebitAmt", objPay.TotalDebitAmt, System.Data.DbType.Decimal));

                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@id", objPay.Pay_Id));

                Query = "UPDATE Payment_Voucher_Master SET `Series`=@Series,`PaymentModeId`=PaymentModeId,`Pay_Date`=@Date,`VoucherNo`=@Voucher_Number," +
                        "`Type`=@Type,`PDC_Date`=@PDDate,`LongNarration`=@LongNarration,`TotalCreditAmt`=@TotalCreditAmt,`TotalDebitAmt`=@TotalDebitAmt,`ModifiedBy`=@ModifiedBy," +
                        "`ModifiedDate`=@ModifiedDate " +
                        "WHERE Payment_Id=@id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    List <AccountModel> lstAcct = new List <AccountModel>();

                    foreach (AccountModel act in objPay.PaymentAccountModel)
                    {
                        act.ParentId = objPay.Pay_Id;
                        if (act.AC_Id > 0)
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@LegderId", act.LedgerId));
                            paramCollection.Add(new DBParameter("@Debit", act.Debit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Credit", act.Credit, System.Data.DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, System.Data.DbType.DateTime));
                            paramCollection.Add(new DBParameter("@ACT_ID", act.AC_Id));
                            paramCollection.Add(new DBParameter("@ParentId", act.ParentId));

                            Query = "UPDATE Payment_Voucher_Details SET `DC`=@DC," +
                                    "`Account`=@Account,`Debit`=@Debit,`LegderId`=@LegderId,`Credit`=@Credit,`Narration`=@Narration,`ModifiedBy`=@ModifiedBy,`ModifiedDate`=@ModifiedDate " +
                                    "WHERE `AC_Id`=@ACT_ID AND Payment_Id=@ParentId";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                        else
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@PaymentId", (act.ParentId)));
                            paramCollection.Add(new DBParameter("@DC", (act.DC)));
                            paramCollection.Add(new DBParameter("@Account", act.Account));
                            paramCollection.Add(new DBParameter("@LegderId", act.LedgerId));
                            paramCollection.Add(new DBParameter("@DebitAmount", act.Debit, DbType.Decimal));
                            paramCollection.Add(new DBParameter("@CreditAmount", act.Credit, DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Amount", act.Amount, DbType.Decimal));
                            paramCollection.Add(new DBParameter("@Narration", act.Narration));

                            paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now, DbType.DateTime));
                            paramCollection.Add(new DBParameter("@ModifiedBy", ""));
                            paramCollection.Add(new DBParameter("@ModifiedDate", DateTime.Now, DbType.DateTime));

                            System.Data.IDataReader dr =
                                _dbHelper.ExecuteDataReader("spInsertPaymentDetails", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);
                            isUpdated = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }