Esempio n. 1
0
 /// <summary>
 /// Function to Update values in DebitNoteMaster Table
 /// </summary>
 /// <param name="debitnotemasterinfo"></param>
 /// <returns></returns>
 public decimal DebitNoteMasterEdit(DebitNoteMasterInfo debitnotemasterinfo)
 {
     decimal decEffectRow = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DebitNoteMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.DebitNoteMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = debitnotemasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = debitnotemasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = debitnotemasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = debitnotemasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = debitnotemasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = debitnotemasterinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = debitnotemasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = debitnotemasterinfo.Extra2;
         decEffectRow = sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decEffectRow;
 }
Esempio n. 2
0
        /// <summary>
        /// Function to insert values to DebitNoteMaster Table
        /// </summary>
        /// <param name="debitnotemasterinfo"></param>
        /// <returns></returns>
        public decimal DebitNoteMasterAdd(DebitNoteMasterInfo debitnotemasterinfo)
        {
            decimal decDebitNoteMasterId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DebitNoteMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam            = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.VoucherNo;
                sprmparam            = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.InvoiceNo;
                sprmparam            = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.SuffixPrefixId;
                sprmparam            = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value      = debitnotemasterinfo.Date;
                sprmparam            = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.UserId;
                sprmparam            = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.TotalAmount;
                sprmparam            = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Narration;
                sprmparam            = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.FinancialYearId;
                sprmparam            = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Extra1;
                sprmparam            = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Extra2;
                sprmparam            = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.VoucherTypeId;
                decDebitNoteMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decDebitNoteMasterId);
        }
Esempio n. 3
0
        /// <summary>
        /// Function to get particular values from DebitNoteMaster table based on the parameter
        /// </summary>
        /// <param name="debitNoteMasterId"></param>
        /// <returns></returns>
        public DebitNoteMasterInfo DebitNoteMasterView(decimal debitNoteMasterId)
        {
            DebitNoteMasterInfo debitnotemasterinfo = new DebitNoteMasterInfo();
            SqlDataReader       sdrreader           = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DebitNoteMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal);
                sprmparam.Value = debitNoteMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    debitnotemasterinfo.DebitNoteMasterId = decimal.Parse(sdrreader[0].ToString());
                    debitnotemasterinfo.VoucherNo         = sdrreader[1].ToString();
                    debitnotemasterinfo.InvoiceNo         = sdrreader[2].ToString();
                    debitnotemasterinfo.SuffixPrefixId    = decimal.Parse(sdrreader[3].ToString());
                    debitnotemasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    debitnotemasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[5].ToString());
                    debitnotemasterinfo.UserId          = decimal.Parse(sdrreader[6].ToString());
                    debitnotemasterinfo.TotalAmount     = decimal.Parse(sdrreader[7].ToString());
                    debitnotemasterinfo.Narration       = sdrreader[8].ToString();
                    debitnotemasterinfo.FinancialYearId = decimal.Parse(sdrreader[9].ToString());
                    debitnotemasterinfo.ExtraDate       = DateTime.Parse(sdrreader[10].ToString());
                    debitnotemasterinfo.Extra1          = sdrreader[11].ToString();
                    debitnotemasterinfo.Extra2          = sdrreader[12].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(debitnotemasterinfo);
        }
Esempio n. 4
0
 /// <summary>
 /// Function to get particular values from DebitNoteMaster table based on the parameter
 /// </summary>
 /// <param name="debitNoteMasterId"></param>
 /// <returns></returns>
 public DebitNoteMasterInfo DebitNoteMasterView(decimal debitNoteMasterId)
 {
     DebitNoteMasterInfo debitnotemasterinfo = new DebitNoteMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DebitNoteMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = debitNoteMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             debitnotemasterinfo.DebitNoteMasterId = decimal.Parse(sdrreader[0].ToString());
             debitnotemasterinfo.VoucherNo = sdrreader[1].ToString();
             debitnotemasterinfo.InvoiceNo = sdrreader[2].ToString();
             debitnotemasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[3].ToString());
             debitnotemasterinfo.Date = DateTime.Parse(sdrreader[4].ToString());
             debitnotemasterinfo.VoucherTypeId = decimal.Parse(sdrreader[5].ToString());
             debitnotemasterinfo.UserId = decimal.Parse(sdrreader[6].ToString());
             debitnotemasterinfo.TotalAmount = decimal.Parse(sdrreader[7].ToString());
             debitnotemasterinfo.Narration = sdrreader[8].ToString();
             debitnotemasterinfo.FinancialYearId = decimal.Parse(sdrreader[9].ToString());
             debitnotemasterinfo.ExtraDate = DateTime.Parse(sdrreader[10].ToString());
             debitnotemasterinfo.Extra1 = sdrreader[11].ToString();
             debitnotemasterinfo.Extra2 = sdrreader[12].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return debitnotemasterinfo;
 }
Esempio n. 5
0
        /// <summary>
        /// Function to fill the fields for edit or delete
        /// </summary>
        public void FillFunction()
        {
            try
            {
                DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo();
                DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP();
                infoDebitNoteMaster = spDebitNoteMaster.DebitNoteMasterView(decDebitNoteMasterIdForEdit);

                txtVoucherNo.ReadOnly = false;
                strVoucherNo = infoDebitNoteMaster.VoucherNo;

                strInvoiceNo = infoDebitNoteMaster.InvoiceNo;
                txtVoucherNo.Text = strInvoiceNo;
                decDebitNoteSuffixPrefixId = infoDebitNoteMaster.SuffixPrefixId;
                decDebitNoteVoucherTypeId = infoDebitNoteMaster.VoucherTypeId;
                dtpVoucherDate.Value = infoDebitNoteMaster.Date;
                txtNarration.Text = infoDebitNoteMaster.Narration;
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decDebitNoteVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                }

                //GridFill
                DataTable dtbl = new DataTable();
                DebitNoteDetailsSP spDebitNoteDetailsSp = new DebitNoteDetailsSP();
                dtbl = spDebitNoteDetailsSp.DebitNoteDetailsViewByMasterId(decDebitNoteMasterIdForEdit);

                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                for (int inI = 0; inI < dtbl.Rows.Count; inI++)
                {
                    dgvDebitNote.Rows.Add();
                    dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString());

                    if (Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString()) == 0)
                    {
                        dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr";
                        dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["credit"].ToString());
                    }
                    else
                    {
                        dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr";
                        dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString());
                    }
                    dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString());
                    if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty)
                    {
                        dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString();
                        dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString())).ToString();
                    }
                    dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value = dtbl.Rows[inI]["DebitNoteDetailsId"].ToString();

                    decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["DebitNoteDetailsId"].ToString());
                    decimal decLedgerPostingId = spLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decDebitNoteVoucherTypeId);
                    dgvDebitNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                    btnSave.Text = "Update";

                }

                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                DataTable dtbl1 = new DataTable();
                dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decDebitNoteVoucherTypeId, strVoucherNo, infoDebitNoteMaster.Date);

                dtblPartyBalance = dtbl1;

                dgvDebitNote.ClearSelection();
                txtDate.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DRNT37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Esempio n. 6
0
        /// <summary>
        /// Function to edit the debitnote voucher
        /// </summary>
        /// <param name="decDebitNoteMasterId"></param>
        public void Edit(decimal decDebitNoteMasterId)
        {
            try
            {

                DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP();
                DebitNoteDetailsSP spDebitNoteDetails = new DebitNoteDetailsSP();
                DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo();
                DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo();
                ExchangeRateSP spExchangeRate = new ExchangeRateSP();

                /*****************Update in DebitNoteMaster table *************/

                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                infoDebitNoteMaster.DebitNoteMasterId = decDebitNoteMasterId;
                infoDebitNoteMaster.VoucherNo = strVoucherNo;
                infoDebitNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoDebitNoteMaster.SuffixPrefixId = decDebitNoteSuffixPrefixId;
                infoDebitNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoDebitNoteMaster.Narration = txtNarration.Text;
                infoDebitNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoDebitNoteMaster.VoucherTypeId = decDebitNoteVoucherTypeId;
                infoDebitNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoDebitNoteMaster.ExtraDate = DateTime.Now;
                infoDebitNoteMaster.Extra1 = string.Empty;
                infoDebitNoteMaster.Extra2 = string.Empty;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());
                infoDebitNoteMaster.TotalAmount = decTotalDebit;
                decimal decEffectRow = spDebitNoteMaster.DebitNoteMasterEdit(infoDebitNoteMaster);

                /**********************DebitNoteDetails Edit********************/
                if (decEffectRow > 0)
                {
                    infoDebitNoteDetails.DebitNoteMasterId = decDebitNoteMasterId;
                    infoDebitNoteDetails.ExtraDate = DateTime.Now;
                    infoDebitNoteDetails.Extra1 = string.Empty;
                    infoDebitNoteDetails.Extra2 = string.Empty;

                    //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------// 
                    LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                    BankReconciliationSP spBankReconciliation = new BankReconciliationSP();

                    foreach (object obj in arrlstOfRemove)
                    {
                        string str = Convert.ToString(obj);
                        spDebitNoteDetails.DebitNoteDetailsDelete(Convert.ToDecimal(str));
                        spLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decDebitNoteVoucherTypeId);
                    }
                    spLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decDebitNoteVoucherTypeId, 12);
                    //=============================================================================================//

                    decimal decLedgerId = 0;
                    decimal decDebit = 0;
                    decimal decCredit = 0;
                    decimal decDebitNoteDetailsId = 0;
                    int inRowCount = dgvDebitNote.RowCount;
                    for (int inI = 0; inI < inRowCount; inI++)
                    {
                        if (dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            infoDebitNoteDetails.LedgerId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                            decLedgerId = infoDebitNoteDetails.LedgerId;
                        }
                        if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                        {
                            //------------------Currency conversion------------------//
                            decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value));
                            decAmount = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //======================================================//

                            if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoDebitNoteDetails.Debit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoDebitNoteDetails.Credit = 0;

                                decDebit = decConvertRate;
                                decCredit = infoDebitNoteDetails.Credit;
                            }
                            else
                            {
                                infoDebitNoteDetails.Credit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoDebitNoteDetails.Debit = 0;
                                decDebit = infoDebitNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                            infoDebitNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                            if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                            {
                                infoDebitNoteDetails.ChequeNo = dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                            }
                            else
                            {
                                infoDebitNoteDetails.ChequeNo = string.Empty;
                            }
                            if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoDebitNoteDetails.ChequeDate = Convert.ToDateTime(dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                infoDebitNoteDetails.ChequeDate = DateTime.Now;
                            }
                            if (dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty)
                            {
                                infoDebitNoteDetails.DebitNoteDetailsId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString());
                                spDebitNoteDetails.DebitNoteDetailsEdit(infoDebitNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                decDebitNoteDetailsId = infoDebitNoteDetails.DebitNoteDetailsId;
                                decimal decLedgerPostId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                                LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI);

                            }
                            else
                            {
                                decDebitNoteDetailsId = spDebitNoteDetails.DebitNoteDetailsAdd(infoDebitNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI);
                            }

                        }

                    }
                    Messages.UpdatedMessage();
                    

                }
                //----------------If print after save is enable-----------------------//
                SettingsSP spSettings = new SettingsSP();
                if (cbxPrintAfterSave.Checked == true)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(infoDebitNoteMaster.DebitNoteMasterId);
                    }
                    else
                    {
                        Print(infoDebitNoteMaster.DebitNoteMasterId);
                    }
                }

                //===================================================================//

                if (frmDebitNoteRegisterObj != null)
                {
                    this.Close();
                    frmDebitNoteRegisterObj.Enabled = true;
                }
                else if (frmDebitNoteReportObj != null)
                {
                    this.Close();
                    frmDebitNoteReportObj.Enabled = true;
                }
                else
                {
                    Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DRNT34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Function to save the debitnote voucher
        /// </summary>
        public void Save()
        {
            try
            {
                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());

                DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP();
                DebitNoteDetailsSP spDebitNoteDetails = new DebitNoteDetailsSP();
                DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo();
                DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                ExchangeRateSP spExchangeRate = new ExchangeRateSP();

                infoDebitNoteMaster.VoucherNo = strVoucherNo;
                infoDebitNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoDebitNoteMaster.SuffixPrefixId = decDebitNoteSuffixPrefixId;
                infoDebitNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoDebitNoteMaster.Narration = txtNarration.Text;
                infoDebitNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoDebitNoteMaster.VoucherTypeId = decDebitNoteVoucherTypeId;
                infoDebitNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoDebitNoteMaster.Extra1 = string.Empty;
                infoDebitNoteMaster.Extra2 = string.Empty;


                infoDebitNoteMaster.TotalAmount = decTotalDebit;
                decimal decJDebitNoteMasterId = spDebitNoteMaster.DebitNoteMasterAdd(infoDebitNoteMaster);

                /*******************DebitNoteDetailsAdd and LedgerPosting*************************/
                infoDebitNoteDetails.DebitNoteMasterId = decJDebitNoteMasterId;
                infoDebitNoteDetails.ExtraDate = DateTime.Now;
                infoDebitNoteDetails.Extra1 = string.Empty;
                infoDebitNoteDetails.Extra2 = string.Empty;


                decimal decLedgerId = 0;
                decimal decDebit = 0;
                decimal decCredit = 0;
                int inRowCount = dgvDebitNote.RowCount;
                for (int inI = 0; inI < inRowCount - 1; inI++)
                {
                    if (dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {
                        infoDebitNoteDetails.LedgerId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        decLedgerId = infoDebitNoteDetails.LedgerId;
                    }
                    if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                    {
                        if (dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                        {
                            //--------Currency conversion--------------//
                            decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()));
                            decAmount = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //===========================================//
                            if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoDebitNoteDetails.Debit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoDebitNoteDetails.Credit = 0;
                                decDebit = decConvertRate;
                                decCredit = infoDebitNoteDetails.Credit;
                            }
                            else
                            {
                                infoDebitNoteDetails.Credit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoDebitNoteDetails.Debit = 0;
                                decDebit = infoDebitNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                        }
                        infoDebitNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            infoDebitNoteDetails.ChequeNo = dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                        }
                        else
                        {
                            infoDebitNoteDetails.ChequeNo = string.Empty;
                        }
                        if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            infoDebitNoteDetails.ChequeDate = Convert.ToDateTime(dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                        }
                        else
                        {
                            infoDebitNoteDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decDebitNoteDetailsId = spDebitNoteDetails.DebitNoteDetailsAdd(infoDebitNoteDetails);

                        if (decDebitNoteDetailsId != 0)
                        {
                            PartyBalanceAddOrEdit(inI);
                            LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI);
                        }
                    }

                }

                Messages.SavedMessage();


                //----------------If print after save is enable-----------------------//
                SettingsSP spSettings = new SettingsSP();
                if (cbxPrintAfterSave.Checked == true)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decJDebitNoteMasterId);
                    }
                    else
                    {
                        Print(decJDebitNoteMasterId);
                    }
                }

                //===================================================================//
            }
            catch (Exception ex)
            {
                MessageBox.Show("DRNT31:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }