Esempio n. 1
0
        /// <summary>
        /// Details ledger posting edit
        /// </summary>
        /// <param name="inA"></param>
        /// <param name="decLedgerPostingId"></param>
        /// <param name="decPaymentDetailsId"></param>
        public void DetailsLedgerPostingEdit(int inA, decimal decLedgerPostingId, decimal decPaymentDetailsId)
        {
            LedgerPostingInfo InfoLedgerPosting = new LedgerPostingInfo();
            LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
            ExchangeRateSP SpExchangRate = new ExchangeRateSP();
            decimal decOldExchange = 0;
            decimal decNewExchangeRate = 0;
            decimal decNewExchangeRateId = 0;
            decimal decOldExchangeId = 0;
            try
            {
                if (!dgvPaymentVoucher.Rows[inA].Cells["dgvtxtAmount"].ReadOnly)
                {
                    decSelectedCurrencyRate = SpExchangRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvPaymentVoucher.Rows[inA].Cells["dgvcmbCurrency"].Value.ToString()));
                    decAmount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inA].Cells["dgvtxtAmount"].Value.ToString());
                    decConvertRate = decAmount * decSelectedCurrencyRate;
                    InfoLedgerPosting.Credit = 0;
                    InfoLedgerPosting.Date = dtpDate.Value;
                    InfoLedgerPosting.Debit = decConvertRate;
                    InfoLedgerPosting.DetailsId = decPaymentDetailsId;
                    InfoLedgerPosting.Extra1 = string.Empty;
                    InfoLedgerPosting.Extra2 = string.Empty;
                    InfoLedgerPosting.InvoiceNo = strInvoiceNo;
                    InfoLedgerPosting.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inA].Cells["dgvcmbAccountLedger"].Value.ToString());
                    if (!isAutomatic)
                    {
                        InfoLedgerPosting.VoucherNo = txtVoucherNo.Text.Trim();
                    }
                    else
                    {
                        InfoLedgerPosting.VoucherNo = strVoucherNo;
                    }
                    if (dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        InfoLedgerPosting.ChequeNo = dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString();
                        if (dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            InfoLedgerPosting.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString());
                        }
                        else
                            InfoLedgerPosting.ChequeDate = DateTime.Now;
                    }
                    else
                    {
                        InfoLedgerPosting.ChequeNo = string.Empty;
                        InfoLedgerPosting.ChequeDate = DateTime.Now;
                    }

                    InfoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId;
                    InfoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    InfoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                    SpLedgerPosting.LedgerPostingEdit(InfoLedgerPosting);
                }
                else
                {
                    InfoLedgerPosting.Date = dtpDate.Value;

                    InfoLedgerPosting.Extra1 = string.Empty;
                    InfoLedgerPosting.Extra2 = string.Empty;
                    InfoLedgerPosting.InvoiceNo = strInvoiceNo;
                    InfoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId;
                    InfoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    InfoLedgerPosting.Credit = 0;
                    InfoLedgerPosting.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inA].Cells["dgvcmbAccountLedger"].Value.ToString());
                    InfoLedgerPosting.VoucherNo = strVoucherNo;
                    InfoLedgerPosting.DetailsId = decPaymentDetailsId;
                    InfoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();
                    if (dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        InfoLedgerPosting.ChequeNo = dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString();
                        if (dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            InfoLedgerPosting.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString());
                        }
                        else
                            InfoLedgerPosting.ChequeDate = DateTime.Now;
                    }
                    else
                    {
                        InfoLedgerPosting.ChequeNo = string.Empty;
                        InfoLedgerPosting.ChequeDate = DateTime.Now;
                    }

                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (InfoLedgerPosting.LedgerId == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            decOldExchange = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                            decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                            decSelectedCurrencyRate = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchange);
                            decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                            decConvertRate = decConvertRate + (decAmount * decSelectedCurrencyRate);

                        }
                    }
                    InfoLedgerPosting.Debit = decConvertRate;
                    InfoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                    SpLedgerPosting.LedgerPostingEdit(InfoLedgerPosting);
                    InfoLedgerPosting.LedgerId = 12;
                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (Convert.ToDecimal(dgvPaymentVoucher.Rows[inA].Cells["dgvcmbAccountLedger"].Value.ToString()) == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            if (dr["ReferenceType"].ToString() == "Against")
                            {
                                decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                                decNewExchangeRate = SpExchangRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId);
                                decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                                decOldExchange = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchangeId);
                                decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                                decimal decForexAmount = (decAmount * decNewExchangeRate) - (decAmount * decOldExchange);
                                if (decForexAmount >= 0)
                                {

                                    InfoLedgerPosting.Debit = decForexAmount;
                                    InfoLedgerPosting.Credit = 0;
                                }
                                else
                                {
                                    InfoLedgerPosting.Credit = -1 * decForexAmount;
                                    InfoLedgerPosting.Debit = 0;
                                }
                                SpLedgerPosting.LedgerPostingAdd(InfoLedgerPosting);
                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV24:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to update ledger posting table
        /// </summary>
        public void LedgerUpdate()
        {
            try
            {
                decimal decLedgerPostingId = 0;
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                DataTable dtbl = new DataTable();
                dtbl = spLedgerPosting.GetLedgerPostingIds(strVoucherNo, decMonthlyVoucherTypeId);
                int ini = 0;
                foreach (DataRow dr in dtbl.Rows)
                {
                    ini++;

                    if (ini == 2)
                    {
                        decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                        infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                        infoLedgerPosting.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString());
                        if (isAutomatic)
                        {
                            infoLedgerPosting.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            infoLedgerPosting.VoucherNo = txtVoucherNo.Text;
                        }
                        infoLedgerPosting.Debit = Convert.ToDecimal(lblTotalAmount.Text.ToString());
                        infoLedgerPosting.Credit = 0;
                        infoLedgerPosting.VoucherTypeId = decMonthlyVoucherTypeId;
                        infoLedgerPosting.LedgerId = 4;
                        infoLedgerPosting.DetailsId = 0;
                        if (isAutomatic)
                        {
                            infoLedgerPosting.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoLedgerPosting.InvoiceNo = txtVoucherNo.Text;
                        }

                        infoLedgerPosting.ChequeNo = string.Empty;
                        infoLedgerPosting.ChequeDate = DateTime.Now;

                        infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                        infoLedgerPosting.Extra1 = string.Empty;
                        infoLedgerPosting.Extra2 = string.Empty;

                        spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
                    }
                    if (ini == 1)
                    {
                        decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                        infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                        infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                        if (isAutomatic)
                        {
                            infoLedgerPosting.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            infoLedgerPosting.VoucherNo = txtVoucherNo.Text;
                        }
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.Credit = Convert.ToDecimal(lblTotalAmount.Text.ToString());
                        infoLedgerPosting.VoucherTypeId = decMonthlyVoucherTypeId;
                        infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString());
                        infoLedgerPosting.DetailsId = 0;
                        if (isAutomatic)
                        {
                            infoLedgerPosting.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoLedgerPosting.InvoiceNo = txtVoucherNo.Text;
                        }
                        infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                        infoLedgerPosting.Extra1 = string.Empty;
                        infoLedgerPosting.Extra2 = string.Empty;
                        infoLedgerPosting.ChequeNo = string.Empty;
                        infoLedgerPosting.ChequeDate = DateTime.Now;
                        spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Function to update values in ledgerposting table
 /// </summary>
 public void ledgerUpdate()
 {
     try
     {
         string strfinancialId;
         FinancialYearSP spFinancialYear = new FinancialYearSP();
         FinancialYearInfo infoFinancialYear = new FinancialYearInfo();
         infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1);
         strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy");
         decimal decLedgerPostingId = 0;
         if (txtOpeningBalance.Text.Trim() != string.Empty)
         {
             decOpeningBlnc = Convert.ToDecimal(txtOpeningBalance.Text.Trim());
         }
         else
         {
             decOpeningBlnc = 0;
         }
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
         DataTable dtbl = spLedgerPosting.GetLedgerPostingIds(decLedgerIdForEdit.ToString(), 1);
         foreach (DataRow dr in dtbl.Rows)
         {
             decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString());
         }
         if (cmbDrorCr.Text == "Dr")
         {
             infoLedgerPosting.Debit = decOpeningBlnc;
         }
         else
         {
             infoLedgerPosting.Credit = decOpeningBlnc;
         }
         infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
         infoLedgerPosting.VoucherTypeId = 1;
         infoLedgerPosting.VoucherNo = decLedgerIdForEdit.ToString();
         infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString());
         infoLedgerPosting.LedgerId = decLedgerIdForEdit;
         infoLedgerPosting.DetailsId = 0;
         infoLedgerPosting.InvoiceNo = decLedgerIdForEdit.ToString();
         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
         infoLedgerPosting.ChequeDate = DateTime.Now;
         infoLedgerPosting.ChequeNo = string.Empty;
         infoLedgerPosting.Extra1 = string.Empty;
         infoLedgerPosting.Extra2 = string.Empty;
         if (dtbl.Rows.Count > 0)
         {
             if (decOpeningBlnc > 0)
             {
                 spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
             }
             else
             {
                 AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                 spAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedgerIdForEdit.ToString(), 1);
             }
         }
         else
         {
             spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Cus16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Function for ledgerposting edit
        /// </summary>
        /// <param name="decLedgerPostingId"></param>
        /// <param name="decLedgerId"></param>
        /// <param name="decCredit"></param>
        /// <param name="decDebit"></param>
        /// <param name="decDetailsId"></param>
        /// <param name="inA"></param>
        public void LedgerPostingEdit(decimal decLedgerPostingId, decimal decLedgerId, decimal decCredit, decimal decDebit, decimal decDetailsId, int inA)
        {
            LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
            LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
            ExchangeRateSP SpExchangRate = new ExchangeRateSP();
            decimal decOldExchange = 0;
            decimal decNewExchangeRate = 0;
            decimal decNewExchangeRateId = 0;
            decimal decOldExchangeId = 0;
            try
            {


                if (!dgvCreditNote.Rows[inA].Cells["dgvtxtAmount"].ReadOnly)
                {
                    infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.VoucherTypeId = decCreditNoteVoucherTypeId;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.DetailsId = decDetailsId;
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();

                    if (dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        infoLedgerPosting.ChequeNo = dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString();
                        if (dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            infoLedgerPosting.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString());
                        }
                        else
                            infoLedgerPosting.ChequeDate = DateTime.Now;

                    }
                    else
                    {
                        infoLedgerPosting.ChequeNo = string.Empty;
                        infoLedgerPosting.ChequeDate = DateTime.Now;
                    }

                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;

                    infoLedgerPosting.LedgerId = decLedgerId;
                    infoLedgerPosting.Credit = decCredit;
                    infoLedgerPosting.Debit = decDebit;

                    spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
                }
                else
                {
                    infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.VoucherTypeId = decCreditNoteVoucherTypeId;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.DetailsId = decDetailsId;
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();

                    if (dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                    {
                        infoLedgerPosting.ChequeNo = dgvCreditNote.Rows[inA].Cells["dgvtxtChequeNo"].Value.ToString();
                        if (dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                        {
                            infoLedgerPosting.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inA].Cells["dgvtxtChequeDate"].Value.ToString());
                        }
                        else
                            infoLedgerPosting.ChequeDate = DateTime.Now;

                    }
                    else
                    {
                        infoLedgerPosting.ChequeNo = string.Empty;
                        infoLedgerPosting.ChequeDate = DateTime.Now;
                    }


                    infoLedgerPosting.ExtraDate = DateTime.Now;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    infoLedgerPosting.LedgerId = decLedgerId;

                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (infoLedgerPosting.LedgerId == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            decOldExchange = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                            decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                            decSelectedCurrencyRate = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchange);
                            decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                            decConvertRate = decConvertRate + (decAmount * decSelectedCurrencyRate);

                        }
                    }

                    if (decCredit == 0)
                    {
                        infoLedgerPosting.Credit = 0;
                        infoLedgerPosting.Debit = decConvertRate;
                    }
                    else
                    {
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.Credit = decConvertRate;
                    }


                    spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);

                    infoLedgerPosting.LedgerId = 12;
                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (Convert.ToDecimal(dgvCreditNote.Rows[inA].Cells["dgvcmbAccountLedger"].Value.ToString()) == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            if (dr["ReferenceType"].ToString() == "Against")
                            {
                                decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                                decNewExchangeRate = SpExchangRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId);
                                decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                                decOldExchange = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchangeId);
                                decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                                decimal decForexAmount = (decAmount * decNewExchangeRate) - (decAmount * decOldExchange);
                                if (dr["DebitOrCredit"].ToString() == "Dr")
                                {
                                    if (decForexAmount >= 0)
                                    {

                                        infoLedgerPosting.Debit = decForexAmount;
                                        infoLedgerPosting.Credit = 0;
                                    }
                                    else
                                    {
                                        infoLedgerPosting.Credit = -1 * decForexAmount;
                                        infoLedgerPosting.Debit = 0;
                                    }
                                }
                                else
                                {
                                    if (decForexAmount >= 0)
                                    {

                                        infoLedgerPosting.Credit = decForexAmount;
                                        infoLedgerPosting.Debit = 0;
                                    }
                                    else
                                    {
                                        infoLedgerPosting.Debit = -1 * decForexAmount;
                                        infoLedgerPosting.Credit = 0;
                                    }
                                }
                                spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                            }
                        }

                    }

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

        }
Esempio n. 5
0
 /// <summary>
 /// Function to edit the ledger posting
 /// </summary>
 /// <param name="decLedgerPostingId"></param>
 /// <param name="decLedgerId"></param>
 /// <param name="decCredit"></param>
 /// <param name="decDebit"></param>
 public void LedgerPostingEdit(decimal decLedgerPostingId, decimal decLedgerId, decimal decCredit, decimal decDebit) //  Function to  edit LedgerPosting table
 {
     try
     {
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
         infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
         infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
         infoLedgerPosting.VoucherTypeId = DecServicetVoucherTypeId;
         infoLedgerPosting.VoucherNo = strVoucherNo;
         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
         if (isAutomatic)  //  Checking voucher number generation is automatic or not
         {
             infoLedgerPosting.InvoiceNo = strInvoiceNo;
         }
         else
         {
             infoLedgerPosting.InvoiceNo = txtInvoiceNumber.Text; //For Manual mode
         }
         infoLedgerPosting.ChequeNo = string.Empty;
         infoLedgerPosting.ChequeDate = DateTime.Now;
         infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
         infoLedgerPosting.Extra1 = string.Empty;
         infoLedgerPosting.Extra2 = string.Empty;
         infoLedgerPosting.LedgerId = decLedgerId;
         infoLedgerPosting.Credit = decCredit;
         infoLedgerPosting.Debit = decDebit;
         spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 03: " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Ledger Posting edit function
        /// </summary>
        /// <param name="decpdcMasterId"></param>
        public void LedgerPostingEdit(decimal decpdcMasterId)
        {
            PDCReceivableMasterSP sppdcreceivable = new PDCReceivableMasterSP();
            DataTable dtblLedgerPostingId = new DataTable();
            LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
            LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
            ExchangeRateSP SpExchangRate = new ExchangeRateSP();
            decimal decOldExchange = 0;
            decimal decNewExchangeRate = 0;
            decimal decNewExchangeRateId = 0;
            decimal decSelectedCurrencyRate = 0;
            decimal decAmount = 0;
            decimal decConvertRate = 0;
            string strReferenceType = string.Empty;
            decimal decOldExchangeId = 0;
            try
            {
                
                dtblLedgerPostingId = sppdcreceivable.LedgerPostingIdByPDCReceivableId(decpdcMasterId);
                decimal decledgerpostingId1 = Convert.ToDecimal(dtblLedgerPostingId.Rows[0]["ledgerPostingId"].ToString());
                decimal decLedgerPostingId2 = Convert.ToDecimal(dtblLedgerPostingId.Rows[1]["ledgerPostingId"].ToString());
                if (!btnAgainRef.Enabled)
                {
                    infoLedgerPosting.LedgerPostingId = decledgerpostingId1;
                    infoLedgerPosting.VoucherTypeId = decPDCReceivableVoucherTypeId;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.Debit = 0;
                    infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text);
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text);
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    SpLedgerPosting.LedgerPostingEdit(infoLedgerPosting);

                }
                else
                {
                    infoLedgerPosting.LedgerPostingId = decledgerpostingId1;
                    infoLedgerPosting.VoucherTypeId = decPDCReceivableVoucherTypeId;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.Debit = 0;
                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (infoLedgerPosting.LedgerId == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            decOldExchange = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                            decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                            decSelectedCurrencyRate = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchange);
                            decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                            decConvertRate = decConvertRate + (decAmount * decSelectedCurrencyRate);

                        }
                    }
                    infoLedgerPosting.Credit = decConvertRate;
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text);
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    SpLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
                    
                    infoLedgerPosting.LedgerId = 12;
                    foreach (DataRow dr in dtblPartyBalance.Rows)
                    {
                        if (Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()) == Convert.ToDecimal(dr["LedgerId"].ToString()))
                        {
                            if (dr["ReferenceType"].ToString() == "Against")
                            {
                                decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString());
                                decNewExchangeRate = SpExchangRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId);
                                decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString());
                                decOldExchange = SpExchangRate.GetExchangeRateByExchangeRateId(decOldExchangeId);
                                decAmount = Convert.ToDecimal(dr["Amount"].ToString());
                                decimal decForexAmount = (decAmount * decNewExchangeRate) - (decAmount * decOldExchange);
                                if (decForexAmount >= 0)
                                {

                                    infoLedgerPosting.Credit = decForexAmount;
                                    infoLedgerPosting.Debit = 0;
                                }
                                else
                                {
                                    infoLedgerPosting.Debit = -1 * decForexAmount;
                                    infoLedgerPosting.Credit = 0;
                                }
                                SpLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                            }
                        }

                    }
                }

                infoLedgerPosting.LedgerPostingId = decLedgerPostingId2;
                infoLedgerPosting.VoucherNo = strVoucherNo;
                infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim();
                infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                infoLedgerPosting.LedgerId = 7;
                infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text);
                infoLedgerPosting.Credit = 0;
                infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text);
                infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                infoLedgerPosting.Extra1 = string.Empty;
                infoLedgerPosting.Extra2 = string.Empty;
                SpLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// LedgerPosting Update Function
 /// </summary>
 /// <param name="decLedgerPostingId"></param>
 /// <param name="decLedgerId"></param>
 /// <param name="decCredit"></param>
 /// <param name="decDebit"></param>
 /// <param name="decDetailsId"></param>
 /// <param name="inI"></param>
 public void LedgerPostingEdit(decimal decLedgerPostingId, decimal decLedgerId, decimal decCredit, decimal decDebit, decimal decDetailsId, int inI)
 {
     try
     {
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
         infoLedgerPosting.LedgerPostingId = decLedgerPostingId;
         infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
         infoLedgerPosting.VoucherTypeId = DecContraVoucherTypeId;
         infoLedgerPosting.VoucherNo = strVoucherNo;
         infoLedgerPosting.DetailsId = decDetailsId;
         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
         infoLedgerPosting.InvoiceNo = txtVoucherNo.Text;
         infoLedgerPosting.Extra1 = string.Empty;
         infoLedgerPosting.Extra2 = string.Empty;
         infoLedgerPosting.LedgerId = decLedgerId;
         infoLedgerPosting.Credit = decCredit;
         infoLedgerPosting.Debit = decDebit;
         if (inI > -1)
         {
             if (dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
             {
                 infoLedgerPosting.ChequeNo = dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
             }
             else
             {
                 infoLedgerPosting.ChequeNo = string.Empty;
             }
             if (dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
             {
                 infoLedgerPosting.ChequeDate = Convert.ToDateTime(dgvContraVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value);
             }
             else
             {
                 infoLedgerPosting.ChequeDate = DateTime.Now;
             }
         }
         else
         {
             infoLedgerPosting.ChequeNo = string.Empty;
             infoLedgerPosting.ChequeDate = DateTime.Now;
         }
         spLedgerPosting.LedgerPostingEdit(infoLedgerPosting);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }