Exemple #1
0
        /// <summary>
        /// Function to Update values in PaymentMaster Table
        /// </summary>
        /// <param name="paymentmasterinfo"></param>
        /// <returns></returns>
        public decimal PaymentMasterEdit(PaymentMasterInfo paymentmasterinfo)
        {
            decimal decPaymentMasterId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PaymentMasterEdit", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam          = sccmd.Parameters.Add("@paymentMasterId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.PaymentMasterId;
                sprmparam          = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value    = paymentmasterinfo.VoucherNo;
                sprmparam          = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value    = paymentmasterinfo.InvoiceNo;
                sprmparam          = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.SuffixPrefixId;
                sprmparam          = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value    = paymentmasterinfo.Date;
                sprmparam          = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.LedgerId;
                sprmparam          = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.TotalAmount;
                sprmparam          = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value    = paymentmasterinfo.Narration;
                sprmparam          = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.VoucherTypeId;
                sprmparam          = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.UserId;
                sprmparam          = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value    = paymentmasterinfo.FinancialYearId;
                sprmparam          = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value    = paymentmasterinfo.Extra1;
                sprmparam          = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value    = paymentmasterinfo.Extra2;
                decPaymentMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decPaymentMasterId);
        }
 /// <summary>
 /// Function to Update values in PaymentMaster Table
 /// </summary>
 /// <param name="paymentmasterinfo"></param>
 /// <returns></returns>
 public decimal PaymentMasterEdit(PaymentMasterInfo paymentmasterinfo)
 {
     decimal decPaymentMasterId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PaymentMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@paymentMasterId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.PaymentMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = paymentmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = paymentmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = paymentmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = paymentmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = paymentmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = paymentmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = paymentmasterinfo.Extra2;
         decPaymentMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decPaymentMasterId;
 }
Exemple #3
0
        /// <summary>
        /// Function to get particular values from PaymentMaster table based on the parameter
        /// </summary>
        /// <param name="paymentMastertId"></param>
        /// <returns></returns>
        public PaymentMasterInfo PaymentMasterView(decimal paymentMastertId)
        {
            PaymentMasterInfo paymentmasterinfo = new PaymentMasterInfo();
            SqlDataReader     sdrreader         = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PaymentMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@paymentMasterId", SqlDbType.Decimal);
                sprmparam.Value = paymentMastertId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    paymentmasterinfo.PaymentMasterId = decimal.Parse(sdrreader[0].ToString());
                    paymentmasterinfo.VoucherNo       = sdrreader[1].ToString();
                    paymentmasterinfo.InvoiceNo       = sdrreader[2].ToString();
                    paymentmasterinfo.SuffixPrefixId  = decimal.Parse(sdrreader[3].ToString());
                    paymentmasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    paymentmasterinfo.LedgerId        = decimal.Parse(sdrreader[5].ToString());
                    paymentmasterinfo.TotalAmount     = decimal.Parse(sdrreader[6].ToString());
                    paymentmasterinfo.Narration       = sdrreader[7].ToString();
                    paymentmasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[8].ToString());
                    paymentmasterinfo.UserId          = decimal.Parse(sdrreader[10].ToString());
                    paymentmasterinfo.FinancialYearId = decimal.Parse(sdrreader[11].ToString());
                    paymentmasterinfo.ExtraDate       = DateTime.Parse(sdrreader[12].ToString());
                    paymentmasterinfo.Extra1          = sdrreader[13].ToString();
                    paymentmasterinfo.Extra2          = sdrreader[14].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(paymentmasterinfo);
        }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void gridfill()
 {
     try
     {
         PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll();
         PaymentMasterInfo infoPaymentMaster = new PaymentMasterInfo();
         List <DataTable>  listObj           = new List <DataTable>();
         if (cmbAccountLedger.Items.Count > 0)
         {
             if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView")
             {
                 if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty)
                 {
                     listObj = BllPaymentVoucher.PaymentMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text);
                     dgvPaymentRegister.DataSource = listObj[0];
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PREG4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #5
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void gridfill()
 {
     try
     {
         PaymentMasterSP   SpPaymentMaster   = new PaymentMasterSP();
         PaymentMasterInfo infoPaymentMaster = new PaymentMasterInfo();
         DataTable         dtbl = new DataTable();
         if (cmbAccountLedger.Items.Count > 0)
         {
             if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView")
             {
                 if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty)
                 {
                     dtbl = SpPaymentMaster.PaymentMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text);
                     dgvPaymentRegister.DataSource = dtbl;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PREG4:" + ex.Message;
     }
 }
        /// <summary>
        /// Edit Function
        /// </summary>
        /// <param name="decMasterId"></param>
        public void Edit(decimal decMasterId)
        {
            try
            {
                int inRowCount = dgvPaymentVoucher.RowCount;
                int inTableRowCount = dtblPartyBalance.Rows.Count;
                int inB = 0;
                PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo();
                PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo();
                PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP();
                LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
                LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                BankReconciliationSP SpBankReconcilation = new BankReconciliationSP();
                InfoPaymentMaster.Date = dtpDate.Value;
                InfoPaymentMaster.PaymentMasterId = decMasterId;
                InfoPaymentMaster.Extra1 = string.Empty;
                InfoPaymentMaster.Extra2 = string.Empty;
                InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString());
                InfoPaymentMaster.Narration = txtNarration.Text.Trim();
                InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId;
                decimal decTotalAmount = TotalAmountCalculation();
                InfoPaymentMaster.TotalAmount = decTotalAmount;
                InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId;

                InfoPaymentMaster.VoucherNo = strVoucherNo;

                InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId;
                decimal decPaymentMasterId = SpPaymentMaster.PaymentMasterEdit(InfoPaymentMaster);
                if (decPaymentmasterId != 0)
                {
                    MasterLedgerPostingEdit();
                }
                foreach (object obj in arrlstOfRemove)
                {
                    string str = Convert.ToString(obj);
                    SpPaymentDetails.PaymentDetailsDelete(Convert.ToDecimal(str));
                    SpLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decPaymentVoucherTypeId);
                }
                SpLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPaymentVoucherTypeId, 12);
                decimal decPaymentDetailsId1 = 0;
                for (int inI = 0; inI < inRowCount - 1; inI++)
                {
                    InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                    InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                    InfoPaymentDetails.Extra1 = string.Empty;
                    InfoPaymentDetails.Extra2 = string.Empty;
                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {
                        InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                    }
                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                        if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                        }
                        else
                        {
                            InfoPaymentDetails.ChequeDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        InfoPaymentDetails.ChequeNo = string.Empty;
                        InfoPaymentDetails.ChequeDate = DateTime.Now;
                    }
                    InfoPaymentDetails.PaymentMasterId = decPaymentMasterId;
                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].FormattedValue.ToString() == "0")//if new rows are added
                    {
                        if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows added which are completed
                        {
                            decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsAdd(InfoPaymentDetails);//to add new rows in payment details
                            if (decPaymentDetailsId != 0)
                            {
                                for (int inJ = 0; inJ < inTableRowCount; inJ++)
                                {
                                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString())
                                    {
                                        PartyBalanceAddOrEdit(inJ);
                                    }
                                }
                                inB++;
                                DetailsLedgerPosting(inI, decPaymentDetailsId);//to add new ledger posting
                            }
                        }
                    }
                    else
                    {
                        if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows updated which are completed
                        {
                            InfoPaymentDetails.PaymentDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString());
                            decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsEdit(InfoPaymentDetails);//to edit rows
                            if (decPaymentDetailsId != 0)
                            {
                                for (int inJ = 0; inJ < inTableRowCount; inJ++)
                                {
                                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString())
                                    {
                                        PartyBalanceAddOrEdit(inJ);
                                    }
                                }
                                inB++;
                                decPaymentDetailsId1 = InfoPaymentDetails.PaymentDetailsId;
                                decimal decLedgerPostId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                                DetailsLedgerPostingEdit(inI, decLedgerPostId, decPaymentDetailsId1);
                            }
                        }
                        else
                        {
                            decimal decDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString());
                            SpPaymentDetails.PaymentDetailsDelete(decDetailsId);
                            SpLedgerPosting.LedgerPostDeleteByDetailsId(decDetailsId, strVoucherNo, decPaymentVoucherTypeId);
                            for (int inJ = 0; inJ < dtblPartyBalance.Rows.Count; inJ++)
                            {
                                if (dtblPartyBalance.Rows.Count == inJ)
                                {
                                    break;
                                }
                                if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                                {
                                    if (dtblPartyBalance.Rows[inJ]["LedgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString())
                                    {
                                        if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                        {
                                            arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
                DeletePartyBalanceOfRemovedRow();
                isUpdated = true;
                Messages.UpdatedMessage();
                if (cbxPrintafterSave.Checked)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decPaymentmasterId);
                    }
                    else
                    {
                        Print(decPaymentMasterId);
                    }
                }
                if (frmPaymentRegisterObj != null)
                {
                    this.Close();
                    frmPaymentRegisterObj.CallFromPaymentVoucher(this);
                }
                if (frmPaymentReportObj != null)
                {
                    this.Close();
                    frmPaymentReportObj.CallFromPaymentVoucher(this);
                }
                if (frmDayBookObj != null)
                {
                    this.Close();
                }
                if (frmBillallocationObj != null)
                {
                    this.Close();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Save Function
        /// </summary>
        public void Save()
        {
            try
            {
                int inGridRowCount = dgvPaymentVoucher.RowCount;
                int inTableRowCount = dtblPartyBalance.Rows.Count;
                int inB = 0;
                PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo();
                PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo();
                PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                DateValidation objVal = new DateValidation();
                TextBox txtDate1 = new TextBox();
                InfoPaymentMaster.Date = dtpDate.Value;
                InfoPaymentMaster.Extra1 = string.Empty;
                InfoPaymentMaster.Extra2 = string.Empty;
                InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim(); ;
                InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString());
                InfoPaymentMaster.Narration = txtNarration.Text.Trim();
                InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId;
                decimal decTotalAmount = TotalAmountCalculation();
                InfoPaymentMaster.TotalAmount = decTotalAmount;
                InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId;
                InfoPaymentMaster.VoucherNo = strVoucherNo;
                InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId;
                decimal decPaymentMasterId = SpPaymentMaster.PaymentMasterAdd(InfoPaymentMaster);
                if (decPaymentMasterId != 0)
                {
                    MasterLedgerPosting();
                }
                for (int inI = 0; inI < inGridRowCount - 1; inI++)
                {
                    if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")
                    {
                        InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        InfoPaymentDetails.Extra1 = string.Empty;
                        InfoPaymentDetails.Extra2 = string.Empty;
                        InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        InfoPaymentDetails.PaymentMasterId = decPaymentMasterId;
                        if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        }
                        if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();

                            if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                InfoPaymentDetails.ChequeDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            InfoPaymentDetails.ChequeNo = string.Empty;
                            InfoPaymentDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsAdd(InfoPaymentDetails);
                        if (decPaymentDetailsId != 0)
                        {
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString())
                                {
                                    PartyBalanceAddOrEdit(inJ);
                                }
                            }
                            inB++;
                            DetailsLedgerPosting(inI, decPaymentDetailsId);
                        }
                    }
                }
                Messages.SavedMessage();
                if (cbxPrintafterSave.Checked)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decPaymentmasterId);
                    }
                    else
                    {
                        Print(decPaymentMasterId);
                    }
                }
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Grid Fill function while coming from other form to update or delete
        /// </summary>
        public void FillFunction()
        {
            try
            {
                PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo();
                PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
                VoucherTypeSP SpVoucherType = new VoucherTypeSP();
                AccountGroupSP spAccountGroup = new AccountGroupSP();
                AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
                InfoPaymentMaster = SpPaymentMaster.PaymentMasterViewByMasterId(decPaymentmasterId);//view master details                    
                isAutomatic = SpVoucherType.CheckMethodOfVoucherNumbering(InfoPaymentMaster.VoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                    txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo;
                    txtDate.Focus();
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                    txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo;
                    txtVoucherNo.Focus();
                }
                dtpDate.Text = InfoPaymentMaster.Date.ToString();
                cmbBankorCash.SelectedValue = InfoPaymentMaster.LedgerId;
                txtNarration.Text = InfoPaymentMaster.Narration;
                txtTotal.Text = InfoPaymentMaster.TotalAmount.ToString();
                decDailySuffixPrefixId = InfoPaymentMaster.SuffixPrefixId;
                decPaymentVoucherTypeId = InfoPaymentMaster.VoucherTypeId;
                strVoucherNo = InfoPaymentMaster.VoucherNo;
                strInvoiceNo = InfoPaymentMaster.InvoiceNo;
                DataTable dtbl = new DataTable();
                dtbl = SpPaymentDetails.PaymentDetailsViewByMasterId(decPaymentmasterId);//view details details
                for (int inI = 0; inI < dtbl.Rows.Count; inI++)
                {
                    dgvPaymentVoucher.Rows.Add();
                    dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString());
                    dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentMasterId"].Value = dtbl.Rows[inI]["paymentMasterId"].ToString();
                    dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value = dtbl.Rows[inI]["paymentDetailsId"].ToString();
                    dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = dtbl.Rows[inI]["amount"].ToString();
                    dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString());
                    decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["paymentDetailsId"].ToString());
                    decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decPaymentVoucherTypeId);
                    dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                    decimal decLedgerId = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString());
                    bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId);
                    decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()));
                    if (decI > 0)//to make amount and currency read only when party is choosen as ledger
                    {
                        dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true;
                        dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true;
                    }
                    else
                    {
                        dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false;
                        dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false;
                    }
                    dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["ChequeNo"].ToString();
                    if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(dtbl.Rows[inI]["ChequeDate"].ToString()).ToString("dd-MMM-yyyy");
                    }
                }
                DataTable dtbl1 = new DataTable();
                dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPaymentVoucherTypeId, strVoucherNo, InfoPaymentMaster.Date);

                dtblPartyBalance = dtbl1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to get particular values from PaymentMaster table based on the parameter
 /// </summary>
 /// <param name="paymentMastertId"></param>
 /// <returns></returns>
 public PaymentMasterInfo PaymentMasterViewByMasterId(decimal paymentMastertId)
 {
     PaymentMasterInfo paymentmasterinfo = new PaymentMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PaymentMasterViewByMasterId", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@paymentMasterId", SqlDbType.Decimal);
         sprmparam.Value = paymentMastertId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             
             paymentmasterinfo.VoucherNo = sdrreader["voucherNo"].ToString();
             paymentmasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString();
             paymentmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader["suffixprefixId"].ToString());
             paymentmasterinfo.Date = DateTime.Parse(sdrreader["date"].ToString());
             paymentmasterinfo.LedgerId = decimal.Parse(sdrreader["ledgerId"].ToString());
             paymentmasterinfo.TotalAmount = decimal.Parse(sdrreader["totalAmount"].ToString());
             paymentmasterinfo.Narration = sdrreader["narration"].ToString();
             paymentmasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
             paymentmasterinfo.UserId = decimal.Parse(sdrreader["userId"].ToString());
             paymentmasterinfo.FinancialYearId = decimal.Parse(sdrreader["financialYearId"].ToString());
             
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return paymentmasterinfo;
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void gridfill()
 {
     try
     {
         PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
         PaymentMasterInfo infoPaymentMaster = new PaymentMasterInfo();
         DataTable dtbl = new DataTable();
         if (cmbAccountLedger.Items.Count > 0)
         {
             if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView")
             {
                 if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty)
                 {
                     dtbl = SpPaymentMaster.PaymentMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text);
                     dgvPaymentRegister.DataSource = dtbl;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PREG4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }