public void ContraDetailsEdit(ContraDetailsInfo InfoContraDetails)
 {
     try
     {
         SpContraDetails.ContraDetailsEdit(InfoContraDetails);
     }
     catch (Exception)
     {
     }
 }
示例#2
0
        public void ContraDetailsEdit(ContraDetailsInfo contradetailsinfo)
        {
            try
            {
                ContraDetailsSP spContraDetails = new ContraDetailsSP();
                spContraDetails.ContraDetailsEdit(contradetailsinfo);
            }

            catch (Exception ex)
            {
                MessageBox.Show("CVBLL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public decimal ContraDetailsAddReturnWithhIdentity(ContraDetailsInfo contradetailsinfo)
        {
            decimal decId = 0;

            try
            {
                decId = SpContraDetails.ContraDetailsAddReturnWithhIdentity(InfoContraDetails);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decId);
        }
示例#4
0
        public decimal ContraDetailsAddReturnWithhIdentity(ContraDetailsInfo infoContraDetails)
        {
            decimal decIdentity = 0;

            try
            {
                ContraDetailsSP spContraDetails = new ContraDetailsSP();
                decIdentity = spContraDetails.ContraDetailsAddReturnWithhIdentity(infoContraDetails);
            }

            catch (Exception ex)
            {
                MessageBox.Show("CVBLL:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decIdentity);
        }
示例#5
0
        public ContraDetailsInfo ContraDetailsView(decimal contraDetailsId)
        {
            ContraDetailsInfo contradetailsinfo = new ContraDetailsInfo();
            SqlDataReader     sdrreader         = null;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ContraDetailsView", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam2 = new SqlParameter();
                sprmparam2       = sccmd.Parameters.Add("@contraDetailsId", SqlDbType.Decimal);
                sprmparam2.Value = contraDetailsId;
                sdrreader        = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    contradetailsinfo.ContraDetailsId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString());
                    contradetailsinfo.ContraMasterId  = decimal.Parse(((DbDataReader)sdrreader)[1].ToString());
                    contradetailsinfo.LedgerId        = decimal.Parse(((DbDataReader)sdrreader)[2].ToString());
                    contradetailsinfo.Amount          = decimal.Parse(((DbDataReader)sdrreader)[3].ToString());
                    contradetailsinfo.ChequeNo        = ((DbDataReader)sdrreader)[4].ToString();
                    contradetailsinfo.ChequeDate      = DateTime.Parse(((DbDataReader)sdrreader)[5].ToString());
                    contradetailsinfo.ExtraDate       = DateTime.Parse(((DbDataReader)sdrreader)[6].ToString());
                    contradetailsinfo.Extra1          = ((DbDataReader)sdrreader)[7].ToString();
                    contradetailsinfo.Extra2          = ((DbDataReader)sdrreader)[8].ToString();
                    contradetailsinfo.ExchangeRateId  = decimal.Parse(((DbDataReader)sdrreader)["Currency"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                base.sqlcon.Close();
            }
            return(contradetailsinfo);
        }
示例#6
0
        public decimal ContraDetailsAdd(ContraDetailsInfo contradetailsinfo)
        {
            decimal deceffect = 0m;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ContraDetailsAdd", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam10 = new SqlParameter();
                sprmparam10       = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
                sprmparam10.Value = contradetailsinfo.ContraMasterId;
                sprmparam10       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam10.Value = contradetailsinfo.LedgerId;
                sprmparam10       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
                sprmparam10.Value = contradetailsinfo.Amount;
                sprmparam10       = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
                sprmparam10.Value = contradetailsinfo.ChequeNo;
                sprmparam10       = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
                sprmparam10.Value = contradetailsinfo.ChequeDate;
                sprmparam10       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam10.Value = contradetailsinfo.ExchangeRateId;
                sprmparam10       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam10       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam10.Value = contradetailsinfo.Extra1;
                sprmparam10       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam10.Value = contradetailsinfo.Extra2;
                deceffect         = Convert.ToDecimal(sccmd.ExecuteNonQuery().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                base.sqlcon.Close();
            }
            return(deceffect);
        }
示例#7
0
 /// <summary>
 /// Function to Update values in ContraDetails Table
 /// </summary>
 /// <param name="contradetailsinfo"></param>
 public void ContraDetailsEdit(ContraDetailsInfo contradetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ContraDetailsEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@contraDetailsId", SqlDbType.Decimal);
         sprmparam.Value = contradetailsinfo.ContraDetailsId;
         sprmparam       = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
         sprmparam.Value = contradetailsinfo.ContraMasterId;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = contradetailsinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = contradetailsinfo.Amount;
         sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = contradetailsinfo.ExchangeRateId;
         sprmparam       = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
         sprmparam.Value = contradetailsinfo.ChequeNo;
         sprmparam       = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
         sprmparam.Value = contradetailsinfo.ChequeDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = contradetailsinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = contradetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
        /// <summary>
        /// Edit function Call the ledger posting Edit function also
        /// </summary>
        /// <param name="decMasterId"></param>
        public void EditFunction(decimal decMasterId)
        {
            try
            {
                //ContraMasterSP spContraMaster = new ContraMasterSP();
                ContraMasterInfo infoContraMaster = new ContraMasterInfo();
                //ContraDetailsSP spContraDetails = new ContraDetailsSP();
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                ContraDetailsInfo infoCOntraDetails = new ContraDetailsInfo();
                ExchangeRateBll BllExchangeRate = new ExchangeRateBll();

                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                decimal decContraDetailsId = 0;
                decimal decLedgerPostId = 0;
                infoContraMaster.ContraMasterId = decMasterId;
                infoContraMaster.LedgerId = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());
                if (isAutomatic)
                {
                    infoContraMaster.VoucherNo = strVoucherNo;
                }

                if (isAutomatic)
                {
                    infoContraMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoContraMaster.InvoiceNo = txtVoucherNo.Text;
                }
                infoContraMaster.Date = Convert.ToDateTime(dtpContraVoucherDate.Text.ToString());

                infoContraMaster.Narration = txtNarration.Text.Trim();
                infoContraMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
                if (rbtnDeposit.Checked)
                    infoContraMaster.Type = "Deposit";
                else
                    infoContraMaster.Type = "Withdraw";
                infoContraMaster.SuffixPrefixId = decContraSuffixPrefixId;
                infoContraMaster.VoucherTypeId = DecContraVoucherTypeId;
                infoContraMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoContraMaster.UserId = PublicVariables._decCurrentUserId;
                infoContraMaster.Extra1 = string.Empty;
                infoContraMaster.Extra2 = string.Empty;
                infoContraMaster.Date = Convert.ToDateTime(txtContraVoucherDate.Text);

                int inCount = dgvContraVoucher.RowCount;
                int inValue = 0;
                for (int i = 0; i < inCount - 1; i++)
                {

                    if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null &&
                        dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != null)
                    {
                        inValue++;
                    }
                }
                if (inValue > 0)
                {

                    if (Convert.ToDecimal(txtTotal.Text) != 0)
                    {
                        infoCOntraDetails.ContraMasterId = decMasterId;
                        infoCOntraDetails.Extra1 = string.Empty;
                        infoCOntraDetails.Extra2 = string.Empty;
                        //------------------deleting removed rows----------------------------------------//

                        foreach (var item in arrlstOfRemove)
                        {
                            decimal decId = Convert.ToDecimal(item);
                            bllContraVoucherDetails.ContraDetailsDelete(Convert.ToDecimal(decId));
                            BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(decId), strVoucherNo, DecContraVoucherTypeId);
                        }
                        //--------------------------End---------------------------------------------------//
                        int inRowCount = dgvContraVoucher.RowCount;

                        decimal decLedgerId = 0;
                        decimal decLedger1Id = 0;
                        decimal decDebit = 0;
                        decimal decCredit = 0;

                        decLedger1Id = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());

                        for (int i = 0; i < inRowCount; i++)
                        {
                            if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "")
                            {
                                decLedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                                infoCOntraDetails.LedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString() != "")
                            {
                                infoCOntraDetails.ChequeNo = dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString();
                            }
                            else
                            {
                                infoCOntraDetails.ChequeNo = string.Empty;
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString() != "")
                            {
                                infoCOntraDetails.ChequeDate = Convert.ToDateTime(dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString());
                            }
                            else
                            {
                                infoCOntraDetails.ChequeDate = Convert.ToDateTime("1/1/1753");
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != "")
                            {
                                infoCOntraDetails.Amount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                                if (dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString() != "")
                                {
                                    infoCOntraDetails.ContraDetailsId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString());
                                    decContraDetailsId = infoCOntraDetails.ContraDetailsId;
                                    decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString()));
                                    decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                                    decConvertRate = decAmount * decSelectedCurrencyRate;
                                    if (rbtnDeposit.Checked)
                                    {
                                        decCredit = decConvertRate;
                                        decDebit = 0;
                                    }
                                    else
                                    {
                                        decDebit = decConvertRate;
                                        decCredit = 0;
                                    }
                                    infoCOntraDetails.ContraMasterId = decMasterId;
                                    infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                                    bllContraVoucherDetails.ContraDetailsEdit(infoCOntraDetails);
                                    decLedgerPostId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                                    LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                                }
                                else
                                {
                                    infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                                    decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString()));
                                    decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                                    decConvertRate = decAmount * decSelectedCurrencyRate;
                                    if (rbtnDeposit.Checked)
                                    {
                                        decCredit = decConvertRate;
                                        decDebit = 0;
                                    }
                                    else
                                    {
                                        decDebit = decConvertRate;
                                        decCredit = 0;
                                    }
                                    decContraDetailsId = bllContraVoucherDetails.ContraDetailsAddReturnWithhIdentity(infoCOntraDetails);
                                    LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                                }
                            }
                        }
                        bllContraVoucherDetails.ContraMasterEdit(infoContraMaster);
                        decLedgerPostId = BllLedgerPosting.LedgerPostingIdForTotalAmount(strVoucherNo, DecContraVoucherTypeId);
                        decAmount = Convert.ToDecimal(txtTotal.Text);
                        decContraDetailsId = 0;
                        if (rbtnDeposit.Checked)
                        {
                            decDebit = decAmount;
                            decCredit = 0;
                            LedgerPostingEdit(decLedgerPostId, decLedger1Id, decCredit, decDebit, decContraDetailsId, -1);
                        }
                        else
                        {
                            decCredit = decAmount;
                            decDebit = 0;
                            LedgerPostingEdit(decLedgerPostId, decLedger1Id, decCredit, decDebit, decContraDetailsId, -1);
                        }
                        Messages.UpdatedMessage();
                        if (cbxPrintafterSave.Checked)
                        {
                            if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decMasterId);
                            }
                            else
                            {
                                Print(decMasterId);
                            }
                        }
                        this.Close();
                    }
                    else
                    {
                        Messages.InformationMessage("Cannot save total amount as 0");
                        dgvContraVoucher.Focus();
                    }
                }
                else
                {
                    Messages.InformationMessage("Cant update contra voucher without atleast one ledger with complete details");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Save function Call the ledger posting function also
        /// </summary>
        public void SaveFuction()
        {
            try
            {
                decimal decContraDetailsId = 0;
                //ContraMasterSP spContraMaster = new ContraMasterSP();
                ContraMasterInfo infoContraMaster = new ContraMasterInfo();
                //ContraDetailsSP spContraDetails = new ContraDetailsSP();
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                ContraDetailsInfo infoCOntraDetails = new ContraDetailsInfo();
                ExchangeRateBll BllExchangeRate = new ExchangeRateBll();
                decimal decIdentity = 0;
                decimal decLedgerId = 0;
                decimal decDebit = 0;
                decimal decCredit = 0;
                int inCount = dgvContraVoucher.RowCount;
                int inValue = 0;
                for (int i = 0; i < inCount - 1; i++)
                {
                    if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null &&
                        dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != null)
                    {
                        inValue++;
                    }
                }
                if (inValue > 0)
                {
                    if (Convert.ToDecimal(txtTotal.Text) != 0)
                    {
                        infoContraMaster.LedgerId = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());
                        if (isAutomatic)
                        {
                            infoContraMaster.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            decimal decVoucherNo = bllContraVoucherDetails.ContraVoucherMasterGetMaxPlusOne(DecContraVoucherTypeId) + 1;
                            infoContraMaster.VoucherNo = Convert.ToString(decVoucherNo);
                        }
                        infoContraMaster.Date = Convert.ToDateTime(dtpContraVoucherDate.Text.ToString());
                        infoContraMaster.Narration = txtNarration.Text.Trim();
                        infoContraMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
                        infoContraMaster.Extra1 = string.Empty;
                        infoContraMaster.Extra2 = string.Empty;

                        if (rbtnDeposit.Checked)
                        {
                            infoContraMaster.Type = "Deposit";
                        }
                        else
                        {
                            infoContraMaster.Type = "Withdraw";
                        }
                        infoContraMaster.SuffixPrefixId = decContraSuffixPrefixId;
                        infoContraMaster.VoucherTypeId = DecContraVoucherTypeId;
                        infoContraMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        infoContraMaster.UserId = PublicVariables._decCurrentUserId;
                        if (isAutomatic)
                        {
                            infoContraMaster.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoContraMaster.InvoiceNo = txtVoucherNo.Text;
                        }
                        decIdentity = bllContraVoucherDetails.ContraMasterAdd(infoContraMaster);
                        infoCOntraDetails.ContraMasterId = decIdentity;
                        infoCOntraDetails.Extra1 = string.Empty;
                        infoCOntraDetails.Extra2 = string.Empty;
                        int inRowCount = dgvContraVoucher.RowCount;

                        //-------------------------------Saving grid details--------------------------------------------------------------------
                        for (int i = 0; i < inRowCount - 1; i++)
                        {

                            if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != string.Empty)
                            {
                                infoCOntraDetails.LedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                            {
                                infoCOntraDetails.Amount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                            {
                                infoCOntraDetails.ChequeNo = dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString();
                            }
                            else
                            {
                                infoCOntraDetails.ChequeNo = string.Empty;
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoCOntraDetails.ChequeDate = Convert.ToDateTime(dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString());
                            }
                            else
                            {
                                infoCOntraDetails.ChequeDate = Convert.ToDateTime("1/1/1753");
                            }
                            infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                            decContraDetailsId = bllContraVoucherDetails.ContraDetailsAddReturnWithhIdentity(infoCOntraDetails);
                            //---------------------------------------------------------Ledger Posting-----------------------------------------/---------------------------------------------------/
                            if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != string.Empty)
                            {
                                decLedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                            }
                            if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                            {
                                decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value));
                                decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                                decConvertRate = decAmount * decSelectedCurrencyRate;

                                if (rbtnDeposit.Checked)
                                {
                                    decCredit = decConvertRate;
                                    decDebit = 0;
                                    LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                                }
                                else
                                {
                                    decDebit = decConvertRate;
                                    decCredit = 0;
                                    LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                                }
                            }
                        }
                        decAmount = Convert.ToDecimal(txtTotal.Text);
                        decContraDetailsId = 0;
                        if (rbtnDeposit.Checked)
                        {
                            decDebit = decAmount;
                            decCredit = 0;
                            LedgerPosting(infoContraMaster.LedgerId, decCredit, decDebit, decContraDetailsId, -1);
                        }
                        else
                        {
                            decCredit = decAmount;
                            decDebit = 0;
                            LedgerPosting(infoContraMaster.LedgerId, decCredit, decDebit, decContraDetailsId, -1);
                        }
                        //------------------------------------------------------------------Ledger Posting---end---------------------------------------------------------------------//
                        Messages.SavedMessage();
                        if (cbxPrintafterSave.Checked)
                        {
                            if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decIdentity);
                            }
                            else
                            {
                                Print(decIdentity);
                            }
                        }
                        Clear();
                    }
                    else
                    {
                        Messages.InformationMessage("Cannot save total debit and credit as 0");
                        dgvContraVoucher.Focus();
                    }
                }
                else
                {
                    Messages.InformationMessage("Cant save contra voucher without atleast one ledger with complete details");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }