/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); infoExchangeRate.CurrencyId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoExchangeRate.Date = Convert.ToDateTime(dtpDate.Text.Trim().ToString()); infoExchangeRate.Rate = Convert.ToDecimal(txtExchangeRate.Text.Trim().ToString()); infoExchangeRate.Narration = txtNarration.Text.Trim(); infoExchangeRate.Extra1 = string.Empty; infoExchangeRate.Extra2 = string.Empty; if (BllExchangeRate.ExchangeRateCheckExistence(Convert.ToDateTime(txtDate.Text.Trim().ToString()), Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()), 0) == false) { if (ExchangeRateCheck()) { BllExchangeRate.ExchangeRateAddParticularFields(infoExchangeRate); Messages.SavedMessage(); Clear(); } } else { Messages.ReferenceExistsMessageForUpdate(); } } catch (Exception ex) { MessageBox.Show("ER2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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> /// Function to save the service voucher /// </summary> public void SaveFunction() { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { txtDiscount.Enabled = true; infoServiceMaster.InvoiceNo = txtInvoiceNumber.Text; if (isAutomatic) { infoServiceMaster.VoucherNo = strVoucherNo; } else { infoServiceMaster.VoucherNo = Convert.ToString(BllService.ServiceMasterGetMax(DecServicetVoucherTypeId) + 1); } infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text.Trim()); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; decServiceMasterId = BllService.ServiceMasterAddReturnWithIdentity(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); decAmount += Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); } decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(infoServiceMaster.ExchangeRateId); decConvertRate = decAmount * decSelectedCurrencyRate; decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPosting(decLedgerId, decCredit, decDebit, decServiceDetailsId, infoServiceMaster.VoucherNo); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } Clear(); } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); dgvServiceVoucher.ClearSelection(); dgvServiceVoucher.CurrentCell = dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"]; dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"].Selected = true; } } catch (Exception ex) { MessageBox.Show("SV 19 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Calculating the grand total amount calculation /// </summary> private void CalculateTotalAmount() { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { decimal decTotal = 0; if (dgvPurchaseOrder.RowCount > 1) { foreach (DataGridViewRow dgvrow in dgvPurchaseOrder.Rows) { if (dgvrow.Cells["dgvtxtAmount"].Value != null && dgvrow.Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { decimal decAmt = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString()); decimal decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decimal decRowTotal = decAmt; decTotal = decTotal + decRowTotal; decTotal = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces); txtTotalAmount.Text = decTotal.ToString(); } } } else { decTotal = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces); txtTotalAmount.Text = decTotal.ToString(); } } catch (Exception ex) { MessageBox.Show("PO22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Total amount calculation of Grid rows and the calculate the exchange rate if the currency conversion is available /// </summary> public void TotalAmount() { try { decimal decTotalAmount = 0; decimal decSelectedCurrencyRate = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); foreach (DataGridViewRow dr in dgvContraVoucher.Rows) { if (dr.Cells["dgvtxtAmount"].Value != null && dr.Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { if (dr.Cells["dgvcmbCurrency"].Value != null) { decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dr.Cells["dgvcmbCurrency"].Value.ToString()));//Exchange rate of grid's row decTotalAmount = decTotalAmount + (Convert.ToDecimal(dr.Cells["dgvtxtAmount"].Value.ToString()) * decSelectedCurrencyRate); } else { decTotalAmount = decTotalAmount + Convert.ToDecimal(dr.Cells["dgvtxtAmount"].Value.ToString()); } } } txtTotal.Text = Math.Round(decTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); } catch (Exception ex) { MessageBox.Show("CV:05" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger posting edit function /// </summary> public void ledgerPostingEdit() { LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); decimal decRate = 0; decimal decimalGrantTotal = 0; decimal decTotalAmount = 0; try { decimalGrantTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decimalGrantTotal = decimalGrantTotal * decRate; infoLedgerPosting.Debit = decimalGrantTotal; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decTotalAmount = TotalNetAmountForLedgerPosting(); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTotalAmount = decTotalAmount * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decTotalAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decimal decBillDis = 0; decBillDis = Convert.ToDecimal(txtBillDiscount.Text.Trim().ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decBillDis = decBillDis * decRate; if (decBillDis > 0) { infoLedgerPosting.Debit = decBillDis; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = 8; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { foreach (DataGridViewRow dgvrow in dgvSalesInvoiceTax.Rows) { if (dgvrow.Cells["dgvtxtTtaxId"].Value != null && dgvrow.Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { decimal decTaxAmount = 0; decTaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTtaxAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTaxAmount = decTaxAmount * decRate; if (decTaxAmount > 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decTaxAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxLedgerId"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } } if (cmbDrorCr.SelectedItem.ToString() != "Cr") { foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { decimal decAmount = 0; decAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = decAmount * decRate; if (decAmount > 0) { infoLedgerPosting.Debit = decAmount; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } if (cmbCashOrbank.Visible) { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmountForCr = decAmountForCr * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmountForCr; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = decBankOrCashId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = "AddCash"; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } else { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmountForCr = decAmountForCr * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmountForCr; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = decBankOrCashId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = "AddCash"; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } else { string strVno = string.Empty; strVno = infoLedgerPosting.VoucherNo; BllLedgerPosting.LedgerPostingDeleteByVoucherTypeIdAndLedgerIdAndVoucherNoAndExtra(DecSalesInvoiceVoucherTypeId, decBankOrCashIdForEdit, strVno, "AddCash"); foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { decimal decAmount = 0; decAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = decAmount * decRate; if (decAmount > 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } } } catch (Exception ex) { MessageBox.Show("SI: 82" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to update the details /// </summary> public void EditFunction() { try { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); InfoSalesMaster.SalesMasterId = decSalesMasterId; InfoSalesMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoSalesMaster.AdditionalCost = 0; InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text); InfoSalesMaster.CounterId = Convert.ToDecimal(cmbCounter.SelectedValue.ToString()); InfoSalesMaster.CreditPeriod = 0; InfoSalesMaster.CustomerName = ""; InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.Trim()); InfoSalesMaster.DeliveryNoteMasterId = 0; if (cmbSalesMan.SelectedValue.ToString() != null) { InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { InfoSalesMaster.EmployeeId = 0; } decimal decExachangeRateId = BllExchangeRate.ExchangerateViewByCurrencyId(PublicVariables._decCurrencyId); InfoSalesMaster.ExchangeRateId = decExachangeRateId; InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.LrNo = string.Empty; InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.OrderMasterId = 0; InfoSalesMaster.POS = true; InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoSalesMaster.QuotationMasterId = 0; InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); InfoSalesMaster.TransportationCompany = ""; InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.VoucherTypeId = DecPOSVoucherTypeId; if (isAutomatic) { InfoSalesMaster.SuffixPrefixId = decPOSSuffixPrefixId; } else { InfoSalesMaster.SuffixPrefixId = 0; } if (isAutomatic) { InfoSalesMaster.VoucherNo = strVoucherNo; } else { InfoSalesMaster.VoucherNo = txtVoucherNo.Text.Trim(); } InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; BllSalesInvoice.SalesMasterEdit(InfoSalesMaster); decimal dcAgainstVopucherTypeId = 0; string strAgainstVoucherNo = "NA"; BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(dcAgainstVopucherTypeId, strAgainstVoucherNo, strVoucherNo, InfoSalesMaster.VoucherTypeId); BllLedgerPosting.LedgerPostDelete(InfoSalesMaster.VoucherNo, InfoSalesMaster.VoucherTypeId); removeSalesInvoiceDetails(); SalesInvoiceDetailsEdit(); Messages.UpdatedMessage(); if (objfrmSalesInvoiceRegister != null) { if (cbxPrintAfterSave.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } objfrmSalesInvoiceRegister.gridFill(); } if (frmSalesReportObj != null) { if (cbxPrintAfterSave.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } frmSalesReportObj.gridFill(); } this.Close(); } catch (Exception ex) { MessageBox.Show("POS: 50" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Edit /// </summary> public void EditFunction() { try { CompanyInfo infoCompany = new CompanyInfo(); CompanyCreationBll BllCompanyCreation = new CompanyCreationBll(); CompanyPathInfo infoCompanyPath = new CompanyPathInfo(); CompanyPathBll BllCompanyPath = new CompanyPathBll(); UserInfo infoUser = new UserInfo(); UserBll bllUser = new UserBll(); infoCompany.CompanyName = txtCompanyName.Text.Trim(); infoCompany.MailingName = txtMailingName.Text.Trim(); infoCompany.Address = txtAddress.Text.Trim(); infoCompany.Phone = txtPhoneNo.Text.Trim(); infoCompany.Mobile = txtMobile.Text.Trim(); infoCompany.EmailId = txtEmail.Text.Trim(); infoCompany.Web = txtWeb.Text.Trim(); infoCompany.Country = txtCountry.Text.Trim(); infoCompany.State = txtState.Text.Trim(); infoCompany.Pin = txtPincode.Text.Trim(); infoCompany.CurrencyId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoCompany.FinancialYearFrom = Convert.ToDateTime(txtFinancialYearFrom.Text.Trim().ToString()); infoCompany.BooksBeginingFrom = Convert.ToDateTime(txtBooksBegining.Text.Trim().ToString()); infoCompany.Tin = txtTinNo.Text.Trim(); infoCompany.Cst = txtCstNo.Text.Trim(); infoCompany.Pan = txtPanNo.Text.Trim(); infoCompany.CurrentDate = DateTime.Now; infoCompany.Logo = logo; infoCompany.Extra1 = string.Empty; infoCompany.Extra2 = string.Empty; infoCompanyPath.CompanyName = txtCompanyName.Text.Trim(); infoCompanyPath.IsDefault = cbxSetAsDefault.Checked; strPath = Application.StartupPath + "\\Data\\" + PublicVariables._decCurrentCompanyId; infoCompanyPath.CompanyPath = strPath; infoCompanyPath.Extra1 = string.Empty; infoCompanyPath.Extra2 = string.Empty; infoCompanyPath.ExtraDate = DateTime.Now; infoCompanyPath.CompanyId = 1; infoCompany.CompanyId = 1; BllCompanyCreation.CompanyEdit(infoCompany); BllCompanyPath.CompanyPathEdit(infoCompanyPath); Messages.UpdatedMessage(); // To set default currencyId...........In exchangeRate..// ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo(); infoExchangeRate.ExchangeRateId = 1; infoExchangeRate.Date = PublicVariables._dtCurrentDate; infoExchangeRate.CurrencyId = infoCompany.CurrencyId; infoExchangeRate.ExtraDate = PublicVariables._dtCurrentDate; infoExchangeRate.Narration = string.Empty; infoExchangeRate.Rate = 1; infoExchangeRate.Extra1 = string.Empty; infoExchangeRate.Extra2 = string.Empty; BllExchangeRate.ExchangeRateEdit(infoExchangeRate); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); FinancialYearBll BllFinancialYear = new FinancialYearBll(); decimal decIdentity; infoFinancialYear.FromDate = PublicVariables._dtFromDate; infoFinancialYear.ToDate = PublicVariables._dtToDate; infoFinancialYear.ExtraDate = DateTime.Now; infoFinancialYear.Extra1 = string.Empty; infoFinancialYear.Extra2 = string.Empty; bool isExist = BllFinancialYear.FinancialYearExistenceCheck(PublicVariables._dtFromDate, PublicVariables._dtToDate); if (!isExist) { decIdentity = BllFinancialYear.FinancialYearAddWithReturnIdentity(infoFinancialYear); } //===========Add companyDetails in ExternalDb =====================// decimal decCompanyIdForTemp = PublicVariables._decCurrentCompanyId; PublicVariables._decCurrentCompanyId = 0; CompanyCreationBll bllExCompanyCreation = new CompanyCreationBll(); CompanyPathBll bllExCompanyPath = new CompanyPathBll(); CompanyInfo infoExCompany = new CompanyInfo(); CompanyPathInfo infoExCompanyPath = new CompanyPathInfo(); infoExCompany = infoCompany; infoExCompanyPath = infoCompanyPath; infoExCompany.CompanyId = decCompanyIdForTemp; infoExCompanyPath.CompanyId = decCompanyIdForTemp; bllExCompanyCreation.CompanyEdit(infoExCompany); bllExCompanyPath.CompanyPathEdit(infoExCompanyPath); PublicVariables._decCurrentCompanyId = decCompanyIdForTemp; this.Close(); } catch (Exception ex) { MessageBox.Show("CR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save /// </summary> public void SaveFunction() { try { CompanyInfo infoCompany = new CompanyInfo(); CompanyCreationBll BllCompanyCreation = new CompanyCreationBll(); CompanyPathInfo infoCompanyPath = new CompanyPathInfo(); CompanyPathBll BllCompanyPath = new CompanyPathBll(); UserInfo infoUser = new UserInfo(); UserBll bllUser = new UserBll(); ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo(); //ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); infoCompany.CompanyName = txtCompanyName.Text.Trim(); infoCompany.MailingName = txtMailingName.Text.Trim(); infoCompany.Address = txtAddress.Text.Trim(); infoCompany.Phone = txtPhoneNo.Text.Trim(); infoCompany.Mobile = txtMobile.Text.Trim(); infoCompany.EmailId = txtEmail.Text.Trim(); infoCompany.Web = txtWeb.Text.Trim(); infoCompany.Country = txtCountry.Text.Trim(); infoCompany.State = txtState.Text.Trim(); infoCompany.Pin = txtPincode.Text.Trim(); infoCompany.CurrencyId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decCurrencyIdForStatus = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoCompany.FinancialYearFrom = Convert.ToDateTime(txtFinancialYearFrom.Text.Trim().ToString()); infoCompany.BooksBeginingFrom = Convert.ToDateTime(txtBooksBegining.Text.Trim().ToString()); infoCompany.Tin = txtTinNo.Text.Trim(); infoCompany.Cst = txtCstNo.Text.Trim(); infoCompany.Pan = txtPanNo.Text.Trim(); infoCompany.CurrentDate = DateTime.Now; infoCompany.Logo = logo; infoCompany.Extra1 = string.Empty; infoCompany.Extra2 = string.Empty; infoCompanyPath.CompanyName = txtCompanyName.Text.Trim(); infoCompanyPath.IsDefault = cbxSetAsDefault.Checked; infoCompanyPath.Extra1 = string.Empty; infoCompanyPath.Extra2 = string.Empty; infoUser.UserName = txtAdminUserName.Text.Trim(); infoUser.Password = txtPassword.Text.Trim(); infoUser.Active = true; infoUser.Extra1 = string.Empty; infoUser.Extra2 = string.Empty; infoUser.Narration = string.Empty; infoUser.RoleId = 1; if (BllCompanyCreation.CompanyCheckExistence(txtCompanyName.Text.Trim().ToString(), 0) == false) { decimal decCompanyId = BllCompanyCreation.CompanyAddParticularFeilds(infoCompany); PublicVariables._decCurrentCompanyId = decCompanyId; infoCompanyPath.CompanyPath = Application.StartupPath + "\\Data\\" + PublicVariables._decCurrentCompanyId; BllCompanyPath.CompanyPathAdd(infoCompanyPath); if (formMDI.demoProject || CreateCompany()) { if (!formMDI.demoProject) { infoCompanyPath.CompanyPath = strPath; } else { infoCompanyPath.CompanyPath = Application.StartupPath + "\\Data"; PublicVariables._decCurrentCompanyId = 0; } CompanyInfo infoNewCompany = new CompanyInfo(); CompanyPathInfo infoNewCompanyPath = new CompanyPathInfo(); UserInfo infoNewUser = new UserInfo(); UserBll bllNewUser = new UserBll(); ExchangeRateInfo infoNewExchangeRate = new ExchangeRateInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); CompanyPathBll BllNewCompanyPath = new CompanyPathBll(); infoNewCompany = infoCompany; infoNewCompanyPath = infoCompanyPath; infoNewUser = infoUser; decCompanyId = BllCompanyCreation.CompanyAddParticularFeilds(infoNewCompany); bllNewUser.UserAdd(infoNewUser); BllNewCompanyPath.CompanyPathAdd(infoNewCompanyPath); Messages.SavedMessage(); formMDI.MDIObj.MenuStripEnabling(); // To set default currencyId.............// infoNewExchangeRate.CurrencyId = infoNewCompany.CurrencyId; infoNewExchangeRate.Rate = 1; infoNewExchangeRate.Narration = string.Empty; infoNewExchangeRate.Extra1 = string.Empty; infoNewExchangeRate.Extra2 = string.Empty; infoNewExchangeRate.ExtraDate = System.DateTime.Now; infoNewExchangeRate.Date = System.DateTime.Now; BllExchangeRate.ExchangeRateAdd(infoNewExchangeRate); CurrencyBll BllCurrency = new CurrencyBll(); BllCurrency.DefaultCurrencySet(decCurrencyIdForStatus); AfterCompanyCreation(); Clear(); this.Close(); } else { Messages.InformationMessage("Company creation failed"); } } else { Messages.InformationMessage("Companyname already exist"); txtCompanyName.Focus(); } } catch (Exception ex) { MessageBox.Show("CR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save and Edit /// </summary> public void SaveOrEdit() { try { PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll(); PurchaseReturnDetailsInfo infoPurchaseReturnDetails = new PurchaseReturnDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); //StockPostingSP spStockPosting = new StockPostingSP(); StockPostingBll BllStockPosting = new StockPostingBll(); UnitConvertionBll BllUnitConvertion = new UnitConvertionBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); PurchaseReturnBilltaxInfo infoPurchaseReturnBillTax = new PurchaseReturnBilltaxInfo(); SettingsBll BllSettings = new SettingsBll(); UnitBll bllUnit = new UnitBll(); List<DataTable> ListObj = new List<DataTable>(); string strAgainstVoucherNo = string.Empty; string strAgainstInvoiceNo = string.Empty; decimal decPurchaseReturnMasterIds = 0; decimal decPurchaseMasterId = 0; decimal decDiscount = 0; decimal decExchangeRate = 0; decimal decDis = 0; if (isAutomatic) { if (strVoucherNo != string.Empty) { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decPurchaseReturnVoucherTypeId != 0) { infoPurchaseReturnMaster.VoucherTypeId = decPurchaseReturnVoucherTypeId; } infoPurchaseReturnMaster.SuffixPrefixId = (decPurchaseReturnSuffixPrefixId != 0) ? decPurchaseReturnSuffixPrefixId : 0; infoPurchaseReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseReturnMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbInvoiceNo.SelectedValue != null && cmbInvoiceNo.Visible == true) { infoPurchaseReturnMaster.PurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); decPurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); } else { infoPurchaseReturnMaster.PurchaseMasterId = 0; } infoPurchaseReturnMaster.ExchangeRateId = (cmbCurrency.SelectedValue != null) ? Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()) : 0; infoPurchaseReturnMaster.Narration = txtNarration.Text.Trim(); infoPurchaseReturnMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseReturnMaster.LrNo = txtLrlNo.Text.Trim(); infoPurchaseReturnMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); infoPurchaseReturnMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseReturnMaster.TotalAmount = (txtTotalAmount.Text != string.Empty) ? Convert.ToDecimal(txtTotalAmount.Text) : 0; infoPurchaseReturnMaster.TotalTax = (lblTaxAmount.Text != string.Empty) ? Convert.ToDecimal(lblTaxAmount.Text) : 0; infoPurchaseReturnMaster.Discount = (txtBillDiscount.Text != string.Empty) ? Convert.ToDecimal(txtBillDiscount.Text) : 0; infoPurchaseReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseReturnMaster.Extra1 = string.Empty; infoPurchaseReturnMaster.Extra2 = string.Empty; infoPurchaseReturnMaster.ExtraDate = DateTime.Now; infoPurchaseReturnMaster.GrandTotal = (txtGrandTotal.Text != string.Empty) ? Convert.ToDecimal(txtGrandTotal.Text) : 0; if (btnSave.Text == "Save") { decPurchaseReturnMasterIds = BllPurchaseReturn.PurchaseReturnMasterAddWithReturnIdentity(infoPurchaseReturnMaster); } else { infoPurchaseReturnMaster.PurchaseReturnMasterId = decPurchaseReturnMasterId; decExchangeRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(infoPurchaseReturnMaster.ExchangeRateId); BllPurchaseReturn.PurchaseReturnMasterEdit(infoPurchaseReturnMaster); infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); BllLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseReturnVoucherTypeId); bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseReturnVoucherTypeId); } infoLedgerPosting.Date = infoPurchaseReturnMaster.Date; infoLedgerPosting.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.PurchaseAccount; infoLedgerPosting.Debit = 0; if (btnSave.Text == "Save") { infoLedgerPosting.Credit = TotalNetAmountCalculation() * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Credit = TotalNetAmountCalculation(); } BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.LedgerId; if (btnSave.Text == "Save") { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text) * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text); } infoLedgerPosting.Credit = 0; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvPurchaseReturnTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null && dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtledgerId"].Value.ToString()); infoLedgerPosting.Credit = (dgvrow.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(dgvrow.Cells["dgvtxtAmounts"].Value.ToString()); infoLedgerPosting.Debit = 0; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } if (txtBillDiscount.Text.Trim() != string.Empty) { decDis = Convert.ToDecimal(txtBillDiscount.Text); } if (decDis >= 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decDis; infoLedgerPosting.LedgerId = 9; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } if (btnSave.Text == "Update") { infoPurchaseReturnMaster = BllPurchaseReturn.PurchaseReturnMasterView(decPurchaseReturnMasterId); if (infoPurchaseReturnMaster.PurchaseMasterId == 0) { BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } if (infoPurchaseReturnMaster.PurchaseMasterId != 0) { infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, strInvoiceNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } } foreach (DataGridViewRow dgvrow in dgvPurchaseReturn.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null && dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { infoPurchaseReturnDetails.ExtraDate = DateTime.Now; infoPurchaseReturnDetails.Extra1 = string.Empty; infoPurchaseReturnDetails.Extra2 = string.Empty; infoPurchaseReturnDetails.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterId; infoPurchaseReturnDetails.ProductId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtproductId"].Value)); infoPurchaseReturnDetails.Qty = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtqty"].Value)); infoPurchaseReturnDetails.Rate = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtrate"].Value)); if (btnSave.Text == "Save") { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { if (Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value) == 0) { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } } infoPurchaseReturnDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value); } infoPurchaseReturnDetails.Discount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtdiscount"].Value)); if (dgvrow.Cells["dgvcmbTax"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value) != string.Empty && dgvrow.Cells["dgvcmbTax"].Value as string != "NA") { infoPurchaseReturnDetails.TaxId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value)); if (strTaxComboFill != string.Empty) { infoPurchaseReturnDetails.TaxAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtTaxAmount"].Value)); } } else { infoPurchaseReturnDetails.TaxId = 0; } if (dgvrow.Cells["dgvcmbBatch"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbBatch"].Value) != string.Empty) { infoPurchaseReturnDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value); } else { infoPurchaseReturnDetails.GodownId = 0; } if (dgvrow.Cells["dgvcmbGodown"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbGodown"].Value) != string.Empty) { infoPurchaseReturnDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value); } else { infoPurchaseReturnDetails.RackId = 0; } if (dgvrow.Cells["dgvcmbRack"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbRack"].Value) != string.Empty) { infoPurchaseReturnDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value); } infoPurchaseReturnDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtgrossValue"].Value.ToString()); infoPurchaseReturnDetails.NetAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtNetAmount"].Value)); infoPurchaseReturnDetails.Amount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtAmount"].Value)); infoPurchaseReturnDetails.SlNo = Convert.ToInt32(Convert.ToString(dgvrow.Cells["dgvtxtSlNo"].Value)); infoPurchaseReturnDetails.PurchaseDetailsId = (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) ? Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value)) : 0; if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == string.Empty) { BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } else { infoPurchaseReturnDetails.PurchaseReturnDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString()); BllPurchaseReturn.PurchaseReturnDetailsEdit(infoPurchaseReturnDetails); } } else { BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } if (btnSave.Text == "Save") { infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); } infoStockPosting.Date = infoPurchaseReturnMaster.Date; infoStockPosting.ProductId = infoPurchaseReturnDetails.ProductId; infoStockPosting.BatchId = infoPurchaseReturnDetails.BatchId; infoStockPosting.UnitId = infoPurchaseReturnDetails.UnitId; infoStockPosting.GodownId = infoPurchaseReturnDetails.GodownId; infoStockPosting.RackId = infoPurchaseReturnDetails.RackId; decimal decConversionId = BllUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseReturnDetails.UnitConversionId); //infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty / (decConversionId == 0 ? 1 : decConversionId); infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty; infoStockPosting.InwardQty = 0; infoStockPosting.Rate = infoPurchaseReturnDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (infoPurchaseReturnDetails.PurchaseDetailsId != 0) { infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtReturnNo.Text.Trim(); infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoStockPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = 0; } BllStockPosting.StockPostingAdd(infoStockPosting); } } if (btnSave.Text == "Update") { removePurchaseReturnDetails(); } infoAccountLedger = bllAccountLedger.AccountLedgerView(infoPurchaseReturnMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Date = infoPurchaseReturnMaster.Date; infoPartyBalance.LedgerId = infoPurchaseReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType = "New"; } infoPartyBalance.Debit = infoPurchaseReturnMaster.TotalAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoPurchaseReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } foreach (DataGridViewRow item in dgvPurchaseReturnTax.Rows) { if (item.Cells["dgvtxtTaxId"].Value != null) { if (Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()) > 0) { infoPurchaseReturnBillTax.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterIds; infoPurchaseReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseReturnBillTax.TaxAmount = (item.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()); infoPurchaseReturnBillTax.Extra1 = string.Empty; infoPurchaseReturnBillTax.Extra2 = string.Empty; BllPurchaseReturn.PurchaseReturnBilltaxAdd(infoPurchaseReturnBillTax); } } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterIds); } else { Print(decPurchaseReturnMasterIds); } } Clear(); } else { decDiscount = Convert.ToDecimal(txtBillDiscount.Text); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterId); } else { Print(decPurchaseReturnMasterId); } } if (frmPurchaseReturnRegisterObj != null) { frmPurchaseReturnRegisterObj.GridFill(); frmPurchaseReturnRegisterObj.Enabled = true; } if (ObjPurchaseReturnReport != null) { ObjPurchaseReturnReport.PurchaseReturnReportGridFill(); ObjPurchaseReturnReport.Enabled = true; } if (frmLedgerDetailsObj != null) { frmLedgerDetailsObj.LedgerDetailsView(); frmLedgerDetailsObj.Enabled = true; } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR:49" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Tax Amount calculation of tax type /// </summary> public void TaxAmountForTaxType() { decimal decTaxId = 0; decimal decAmount = 0; decimal decDefaultAmount = 0; decimal decRate = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { foreach (DataGridViewRow dgvTaxRow in dgvPurchaseReturnTax.Rows) { if (dgvTaxRow.Cells["dgvtxtTaxId"].Value != null && dgvTaxRow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty && dgvTaxRow.Cells["dgvtxtTaxId"].Value.ToString() != "0") { decTaxId = Convert.ToDecimal(dgvTaxRow.Cells["dgvtxtTaxId"].Value.ToString()); foreach (DataGridViewRow dgvPurchaseReturnRow in dgvPurchaseReturn.Rows) { if (dgvPurchaseReturnRow.Cells["dgvtxtProductId"].Value != null && dgvPurchaseReturnRow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty && dgvPurchaseReturnRow.Cells["dgvtxtProductId"].Value.ToString() != "0") { if (dgvPurchaseReturnRow.Cells["dgvcmbTax"].Value != null && dgvPurchaseReturnRow.Cells["dgvcmbTax"].Value as string != "NA" && dgvPurchaseReturnRow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgvPurchaseReturnRow.Cells["dgvcmbTax"].Value.ToString() != "0") { if (dgvPurchaseReturnRow.Cells["dgvtxttaxAmount"].Value != null && dgvPurchaseReturnRow.Cells["dgvtxttaxAmount"].Value.ToString() != string.Empty && dgvPurchaseReturnRow.Cells["dgvtxttaxAmount"].Value.ToString() != "0") { if (Convert.ToDecimal(dgvPurchaseReturnRow.Cells["dgvcmbTax"].Value.ToString()) == decTaxId) { decAmount = decAmount + Convert.ToDecimal(dgvPurchaseReturnRow.Cells["dgvtxttaxAmount"].Value.ToString()); } } } } } if (cmbCurrency.SelectedValue != null) { decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); } else { decRate = 0; } decDefaultAmount = decAmount * decRate; dgvTaxRow.Cells["dgvtxtAmounts"].Value = Math.Round(decDefaultAmount, PublicVariables._inNoOfDecimalPlaces); decAmount = 0; } } } catch (Exception ex) { MessageBox.Show("PR:60" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grand total amount calculation for production /// </summary> public void grandTotalAmountCalculationProduction() { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvConsumption.RowCount; try { decimal decTotalAmount = 0; decimal decGridTotalAmount = 0; foreach (DataGridViewRow dgrow in dgvProduction.Rows) { if (dgrow.Cells["dgvtxtProductionAmount"].Value != null) { if (dgrow.Cells["dgvtxtProductionAmount"].Value.ToString() != string.Empty && dgrow.Cells["dgvtxtProductionAmount"].Value.ToString() != "0") { decTotalAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtProductionAmount"].Value.ToString()); decGridTotalAmount = decGridTotalAmount + decTotalAmount; } } } lblProductionAmount.Text = Math.Round(decGridTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); } catch (Exception ex) { MessageBox.Show("SJ:16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save stockjournal /// </summary> public void Save() { try { StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo(); StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo(); StockJournalBll BllStockJournal = new StockJournalBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AditionalCostBll bllAdditionalCost = new AditionalCostBll(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); if (isAutomatic == true) { infoStockJournalMaster.SuffixPrefixId = decSuffixPrefixId; infoStockJournalMaster.VoucherNo = strVoucherNo; } else { infoStockJournalMaster.SuffixPrefixId = 0; infoStockJournalMaster.VoucherNo = strVoucherNo; } infoStockJournalMaster.ExtraDate = DateTime.Now; infoStockJournalMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockJournalMaster.Date = Convert.ToDateTime(txtDate.Text); infoStockJournalMaster.AdditionalCost = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoStockJournalMaster.VoucherNo = strVoucherNo; infoStockJournalMaster.VoucherTypeId = decVoucherTypeId; infoStockJournalMaster.Narration = txtNarration.Text.Trim(); infoStockJournalMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockJournalMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue); if (rbtnManufacturing.Checked) { infoStockJournalMaster.Extra1 = "Manufacturing"; } if (rbtnTransfer.Checked) { infoStockJournalMaster.Extra1 = "Transfer"; } if (rbtnStockOut.Checked) { infoStockJournalMaster.Extra1 = "Stock Out"; } infoStockJournalMaster.Extra2 = string.Empty; if (btnSave.Text == "Save") { decStockMasterId = BllStockJournal.StockJournalMasterAdd(infoStockJournalMaster); } else { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; BllStockJournal.StockJournalMasterEdit(infoStockJournalMaster); RemoveRowStockJournalConsumptionDetails(); RemoveRowStockJournalProductionDetails(); RemoveRowStockJournalAdditionalCostDetails(); BllStockPosting.DeleteStockPostingForStockJournalEdit(strVoucherNo, decVoucherTypeId); } if (dgvConsumption.Rows.Count > 0) { int inCount = dgvConsumption.Rows.Count; for (int i = 0; i < inCount - 1; i++) { if (btnSave.Text == "Save") { infoStockJournalDetails.StockJournalMasterId = decStockMasterId; } else { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; } infoStockJournalDetails.Extra1 = string.Empty; infoStockJournalDetails.Extra2 = string.Empty; infoStockJournalDetails.ExtraDate = DateTime.Now; infoStockJournalDetails.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockJournalDetails.Qty = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value); infoStockJournalDetails.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockJournalDetails.UnitId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value); infoStockJournalDetails.UnitConversionId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionunitConversionId"].Value); if (btnSave.Text == "Update") { infoStockJournalDetails.StockJournalMasterId = decStockJournalMasterIdForEdit; if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value == null || dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value.ToString() == string.Empty) { if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } else { infoStockJournalDetails.StockJournalDetailsId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value); if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsEdit(infoStockJournalDetails); } } else { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } //Stock Posting Add if (btnSave.Text == "Update") { infoStockPosting.BatchId = infoStockJournalDetails.BatchId; infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoStockJournalDetails.GodownId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockPosting.RackId = infoStockJournalDetails.RackId; infoStockPosting.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockPosting.UnitId = infoStockJournalDetails.UnitId; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } else { infoStockPosting.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockPosting.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); infoStockPosting.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockPosting.UnitId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value); infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } if (dgvProduction.Rows.Count > 0) { int inCount = dgvProduction.Rows.Count; for (int i = 0; i < inCount - 1; i++) { if (btnSave.Text == "Update") { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; } else { infoStockJournalDetails.StockJournalMasterId = decStockMasterId; } infoStockJournalDetails.Extra1 = string.Empty; infoStockJournalDetails.Extra2 = string.Empty; infoStockJournalDetails.ExtraDate = DateTime.Now; infoStockJournalDetails.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockJournalDetails.Qty = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionQty"].Value); infoStockJournalDetails.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockJournalDetails.UnitId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value); infoStockJournalDetails.UnitConversionId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionunitConversionId"].Value); if (btnSave.Text == "Update") { infoStockJournalDetails.StockJournalMasterId = decStockJournalMasterIdForEdit; if (dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value == null || dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value.ToString() == string.Empty) { if (dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } else { infoStockJournalDetails.StockJournalDetailsId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value); if (dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsEdit(infoStockJournalDetails); } } else { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } //Stock Posting Add if (btnSave.Text == "Save") { infoStockPosting.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); infoStockPosting.InwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockPosting.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); infoStockPosting.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockPosting.UnitId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value); infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } else { infoStockPosting.BatchId = infoStockJournalDetails.BatchId; infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoStockJournalDetails.GodownId; infoStockPosting.InwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockPosting.RackId = infoStockJournalDetails.RackId; infoStockPosting.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockPosting.UnitId = infoStockJournalDetails.UnitId; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } //....Additional Cost Add...//// if (btnSave.Text == "Update") { BllLedgerPosting.DeleteLedgerPostingForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete bllAdditionalCost.DeleteAdditionalCostForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete } decimal decGrandTotal = 0; decimal decRate = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (dgvAdditionalCost.Rows.Count > 1) { infoAdditionalCost.Credit = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoAdditionalCost.Debit = 0; infoAdditionalCost.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue); infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.VoucherTypeId = decVoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost); //....Ledger Posting Add.../// //------------------- Currency Conversion----------------------------- decGrandTotal = Convert.ToDecimal(lblAdditionalCostAmount.Text.Trim()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decGrandTotal = decGrandTotal * decRate; //--------------------------------------------------------------- infoLedgerPosting.Credit = decGrandTotal; infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue); infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.VoucherTypeId = decVoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; if (btnSave.Text == "Save") { infoLedgerPosting.ExtraDate = DateTime.Now; } BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value != null) { if (dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString() != string.Empty) { /*-----------------------------------------Additional Cost Add----------------------------------------------------*/ infoAdditionalCost.Credit = 0; infoAdditionalCost.Debit = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString()); infoAdditionalCost.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString()); infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.VoucherTypeId = decVoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost); /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/ decimal decTotal = 0; //------------------- Currency Conversion------------------------ decTotal = Convert.ToDecimal(infoAdditionalCost.Debit); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTotal = decTotal * decRate; //--------------------------------------------------------------- infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = decTotal; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString()); infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.VoucherTypeId = decVoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { Print(decStockMasterId); } Clear(); } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { Print(decStockJournalMasterIdForEdit); } this.Close(); } } catch (Exception ex) { MessageBox.Show("SJ:36" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On datagridview cell double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvExchangeRate_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (e.RowIndex != -1) { decId = Convert.ToDecimal(dgvExchangeRate.Rows[e.RowIndex].Cells["dgvtxtExchangeRateId"].Value.ToString()); bool Status = BllExchangeRate.ExchangeRateCheckExistanceForUpdationAndDelete(Convert.ToDateTime(txtDate.Text.ToString()), decId); if (Status) { FillControls(); btnSave.Text = "Update"; btnDelete.Enabled = true; cmbCurrency.Focus(); } else { Messages.ReferenceExistsMessageForUpdate(); } } } catch (Exception ex) { MessageBox.Show("ER25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); decimal decOldExchange = 0; decimal decNewExchangeRate = 0; decimal decNewExchangeRateId = 0; decimal decOldExchangeId = 0; try { if (!dgvPaymentVoucher.Rows[inA].Cells["dgvtxtAmount"].ReadOnly) { decSelectedCurrencyRate = BllExchangeRate.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; BllLedgerPosting.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 = BllExchangeRate.GetExchangeRateByExchangeRateId(decOldExchange); decAmount = Convert.ToDecimal(dr["Amount"].ToString()); decConvertRate = decConvertRate + (decAmount * decSelectedCurrencyRate); } } InfoLedgerPosting.Debit = decConvertRate; InfoLedgerPosting.LedgerPostingId = decLedgerPostingId; BllLedgerPosting.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 = BllExchangeRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId); decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString()); decOldExchange = BllExchangeRate.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; } BllLedgerPosting.LedgerPostingAdd(InfoLedgerPosting); } } } } } catch (Exception ex) { MessageBox.Show("PV24:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save values to partyBalance table /// </summary> public void partyBalance() { try { PartyBalanceInfo infoPatryBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (decOpeningBlnc > 0) { if (cmbBillbyBill.Text == "Yes") { infoPatryBalance.Date = PublicVariables._dtFromDate; infoPatryBalance.LedgerId = decledgerid; infoPatryBalance.VoucherTypeId = 1; infoPatryBalance.VoucherNo = decledgerid.ToString(); infoPatryBalance.AgainstVoucherTypeId = 0; infoPatryBalance.AgainstVoucherNo = "0"; infoPatryBalance.ReferenceType = "New"; if (cmbDrorCr.Text == "Dr") { infoPatryBalance.Debit = decOpeningBlnc; infoPatryBalance.Credit = 0; } else { infoPatryBalance.Debit = 0; infoPatryBalance.Credit = decOpeningBlnc; } infoPatryBalance.InvoiceNo = decledgerid.ToString(); infoPatryBalance.AgainstInvoiceNo = "0"; infoPatryBalance.CreditPeriod = 0; infoPatryBalance.ExchangeRateId = BllExchangeRate.ExchangerateViewByCurrencyId(PublicVariables._decCurrencyId); infoPatryBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPatryBalance.Extra1 = string.Empty; infoPatryBalance.Extra2 = string.Empty; } BllPartyBalance.PartyBalanceAdd(infoPatryBalance); } } catch (Exception ex) { MessageBox.Show("Cus15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger grid total amount calculation function /// </summary> public void LedgerGridTotalAmountCalculation() { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { if (dgvSalesInvoiceLedger.RowCount > 1) { if (dgvSalesInvoiceLedger.CurrentRow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.CurrentRow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty) { decimal decLedgerTotalAmount = 0; foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != "") { decLedgerTotalAmount = decLedgerTotalAmount + Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } } } lblLedgerTotalAmount.Text = Math.Round(decLedgerTotalAmount, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces.ToString())).ToString(); } else { decimal decLedgerTotalAmount = 0; foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != "") { decLedgerTotalAmount = decLedgerTotalAmount + Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } } } lblLedgerTotalAmount.Text = Math.Round(decLedgerTotalAmount, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces.ToString())).ToString(); } } else { decimal decLedgerTotalAmount1 = 0; foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != "") { decLedgerTotalAmount1 = decLedgerTotalAmount1 + Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } } } lblLedgerTotalAmount.Text = Math.Round(decLedgerTotalAmount1, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces.ToString())).ToString(); } } catch (Exception ex) { MessageBox.Show("SI: 41 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Save the voucher /// </summary> public void Save() { try { decimal decTotalDebit = 0; decimal decTotalCredit = 0; decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim()); decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim()); JournalVoucherBll bllJournalMaster = new JournalVoucherBll(); JournalVoucherBll bllJournalVoucher = new JournalVoucherBll(); JournalMasterInfo infoJournalMaster = new JournalMasterInfo(); JournalDetailsInfo infoJournalDetails = new JournalDetailsInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); infoJournalMaster.VoucherNo = strVoucherNo; infoJournalMaster.InvoiceNo = txtVoucherNo.Text; infoJournalMaster.SuffixPrefixId = decJournalSuffixPrefixId; infoJournalMaster.Date = Convert.ToDateTime(txtDate.Text); infoJournalMaster.Narration = txtNarration.Text.Trim(); infoJournalMaster.UserId = PublicVariables._decCurrentUserId; infoJournalMaster.VoucherTypeId = decJournalVoucherTypeId; infoJournalMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoJournalMaster.Extra1 = string.Empty; infoJournalMaster.Extra2 = string.Empty; infoJournalMaster.ExtraDate = DateTime.Now; infoJournalMaster.TotalAmount = decTotalDebit; decimal decJournalMasterId = bllJournalMaster.JournalMasterAdd(infoJournalMaster); /*******************JournalDetailsAdd and LedgerPosting*************************/ infoJournalDetails.JournalMasterId = decJournalMasterId; infoJournalDetails.ExtraDate = DateTime.Now; infoJournalDetails.Extra1 = string.Empty; infoJournalDetails.Extra2 = string.Empty; decimal decLedgerId = 0; decimal decDebit = 0; decimal decCredit = 0; int inRowCount = dgvJournalVoucher.RowCount; for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { infoJournalDetails.LedgerId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); decLedgerId = infoJournalDetails.LedgerId; } if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { //--------Currency conversion--------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString())); decAmount = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //===========================================// if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { infoJournalDetails.Debit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Credit = 0; decDebit = decConvertRate; decCredit = infoJournalDetails.Credit; } else { infoJournalDetails.Credit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Debit = 0; decDebit = infoJournalDetails.Debit; decCredit = decConvertRate; } } infoJournalDetails.ExchangeRateId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeNo = dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); } else { infoJournalDetails.ChequeNo = string.Empty; } if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeDate = Convert.ToDateTime(dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString()); } else { infoJournalDetails.ChequeDate = DateTime.Now; } decimal decJournalDetailsId = bllJournalVoucher.JournalDetailsAdd(infoJournalDetails); if (decJournalDetailsId != 0) { PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decJournalDetailsId, inI); } } } Messages.SavedMessage(); //----------------If print after save is enable-----------------------// if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decJournalMasterId); } else { Print(decJournalMasterId); } } //===================================================================// } catch (Exception ex) { MessageBox.Show("JV14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Sales invoice Total amount calculation function /// </summary> public void SiGridTotalAmountCalculation() { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { decimal decTotalAmount = 0; decimal dcQtyTotal = 0; decimal decGridTotalAmount = 0; decimal decTaxApplicableonBill = 0; decimal declblLedgeramt = 0; foreach (DataGridViewRow dgrow in dgvSalesInvoice.Rows) { if (dgrow.Cells["dgvtxtSalesInvoiceAmount"].Value != null) { if (dgrow.Cells["dgvtxtSalesInvoiceAmount"].Value.ToString() != string.Empty && dgrow.Cells["dgvtxtSalesInvoiceAmount"].Value.ToString() != "0") { decTotalAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); decGridTotalAmount = decGridTotalAmount + decTotalAmount; } } if (dgrow.Cells["dgvtxtSalesInvoiceQty"].Value != null && dgrow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { decimal dcTemp = dcQtyTotal; dcQtyTotal = Convert.ToDecimal(dgrow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); dcQtyTotal += dcTemp; } } decGridTotalAmount += decTaxApplicableonBill; txtTotalAmount.Text = Math.Round(decGridTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { decTaxApplicableonBill = TaxAmountApplicableOnBill(); decGridTotalAmount += decTaxApplicableonBill; } if (cmbDrorCr.SelectedIndex == 1) { declblLedgeramt = Convert.ToDecimal(lblLedgerTotalAmount.Text); } decGridTotalAmount += declblLedgeramt; txtTotalAmount.Text = Math.Round(decGridTotalAmount, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces.ToString())).ToString(); lblTotalQuantitydisplay.Text = Math.Round(dcQtyTotal, PublicVariables._inNoOfDecimalPlaces).ToString(); TotalTaxAmount(); } catch (Exception ex) { MessageBox.Show("SI: 39 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//PopUp /// <summary> /// To change the currency from currency popup /// </summary> /// <param name="frmCurrencyDetails"></param> /// <param name="decId"></param> public void CallFromCurrenCyDetails(frmCurrencyDetails frmCurrencyDetails, decimal decId) { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { frmCurrencyObj.Close(); CurrencyComboFill(); decId = BllExchangeRate.GetExchangeRateId(decId, Convert.ToDateTime(txtDate.Text)); dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value = decId; dgvJournalVoucher.Focus(); } catch (Exception ex) { MessageBox.Show("JV3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save An items to table /// </summary> public void SaveFunction() { LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); UnitConvertionBll bllUnitConversion = new UnitConvertionBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { InfoSalesMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoSalesMaster.AdditionalCost = 0; InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text); if (cmbCounter.SelectedIndex > -1) { InfoSalesMaster.CounterId = Convert.ToDecimal(cmbCounter.SelectedValue.ToString()); } else { InfoSalesMaster.CounterId = 0; } InfoSalesMaster.CreditPeriod = 0; InfoSalesMaster.CustomerName = string.Empty; InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text); InfoSalesMaster.DeliveryNoteMasterId = 0; if (cmbSalesMan.SelectedValue.ToString() != null) { InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { InfoSalesMaster.EmployeeId = 0; } decimal decExachangeRateId = BllExchangeRate.ExchangerateViewByCurrencyId(PublicVariables._decCurrencyId); InfoSalesMaster.ExchangeRateId = decExachangeRateId; InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.LrNo = string.Empty; InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.OrderMasterId = 0; InfoSalesMaster.POS = true; if (cmbPricingLevel.SelectedValue.ToString() != null) { InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } else { InfoSalesMaster.PricinglevelId = 0; } InfoSalesMaster.QuotationMasterId = 0; InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.ToString()); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); InfoSalesMaster.TransportationCompany = string.Empty; InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.VoucherTypeId = DecPOSVoucherTypeId; if (isAutomatic) { InfoSalesMaster.SuffixPrefixId = decPOSSuffixPrefixId; InfoSalesMaster.VoucherNo = strVoucherNo; } else { InfoSalesMaster.SuffixPrefixId = 0; InfoSalesMaster.VoucherNo = txtVoucherNo.Text; } InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; decSalesMasterId = BllSalesInvoice.SalesMasterAdd(InfoSalesMaster); int inRowCount = dgvPointOfSales.RowCount; InfoSalesDetails.SalesMasterId = decSalesMasterId; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; for (int inI = 0; inI < inRowCount; inI++) { if (dgvPointOfSales.Rows[inI].Cells["dgvtxtProductName"].Value != null && dgvPointOfSales.Rows[inI].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { if (dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value != null && dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value.ToString() != string.Empty) { InfoSalesDetails.SlNo = Convert.ToInt32(dgvPointOfSales.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtUnitId"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtunitconversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtDiscount"].Value.ToString()); InfoSalesDetails.TaxId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxttaxid"].Value.ToString()); InfoSalesDetails.BatchId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtBatchId"].Value.ToString()); InfoSalesDetails.GodownId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtGodownId"].Value.ToString()); InfoSalesDetails.RackId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtRackId"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtTaxAmount"].Value.ToString()); InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtTotalAmount"].Value.ToString()); BllSalesInvoice.SalesDetailsAdd(InfoSalesDetails); infoStockPosting.Date = InfoSalesMaster.Date; infoStockPosting.VoucherTypeId = DecPOSVoucherTypeId; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.ProductId = InfoSalesDetails.ProductId; infoStockPosting.BatchId = InfoSalesDetails.BatchId; infoStockPosting.UnitId = InfoSalesDetails.UnitId; infoStockPosting.GodownId = InfoSalesDetails.GodownId; infoStockPosting.RackId = InfoSalesDetails.RackId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / bllUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); ; infoStockPosting.Rate = InfoSalesDetails.Rate; infoStockPosting.FinancialYearId = InfoSalesMaster.FinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } int inTaxRowCount = dgvPOSTax.RowCount; InfoSalesBillTax.SalesMasterId = decSalesMasterId; InfoSalesBillTax.ExtraDate = DateTime.Now; InfoSalesBillTax.Extra1 = string.Empty; InfoSalesBillTax.Extra2 = string.Empty; for (int inI = 0; inI < inTaxRowCount; inI++) { if (dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value != null && dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value.ToString() != string.Empty) { if (dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value != null && dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value.ToString() != string.Empty) { InfoSalesBillTax.TaxId = Convert.ToInt32(dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value.ToString()); InfoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value.ToString()); BllSalesInvoice.SalesBillTaxAdd(InfoSalesBillTax); } } } ledgerPostingAdd(); if (BllSalesInvoice.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { partyBalanceAdd(); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } ClearFunctions(); } catch (Exception ex) { MessageBox.Show("POS:44" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to calculate total debit and credit /// </summary> public void DebitAndCreditTotal() { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvJournalVoucher.RowCount; decimal decTxtTotalDebit = 0; decimal decTxtTotalCredit = 0; try { for (int inI = 0; inI < inRowCount; inI++) { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != ".") { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { //--------Currency conversion--------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString())); decAmount = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //===========================================// decTxtTotalDebit = decTxtTotalDebit + decConvertRate; } else { //--------Currency conversion--------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString())); decAmount = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //===========================================// decTxtTotalCredit = decTxtTotalCredit + decConvertRate; } } } } } txtDebitTotal.Text = Math.Round(decTxtTotalDebit, PublicVariables._inNoOfDecimalPlaces).ToString(); txtCreditTotal.Text = Math.Round(decTxtTotalCredit, Convert.ToInt16(PublicVariables._inNoOfDecimalPlaces)).ToString(); } } catch (Exception ex) { MessageBox.Show("JV12:" + 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); } }
/// <summary> /// Function to edit the debitnote voucher /// </summary> /// <param name="decJournalMasterId"></param> public void Edit(decimal decJournalMasterId) { try { JournalVoucherBll bllJournalMaster = new JournalVoucherBll(); JournalMasterInfo infoJournalMaster = new JournalMasterInfo(); JournalVoucherBll bllJournalDetails = new JournalVoucherBll(); JournalDetailsInfo infoJournalDetails = new JournalDetailsInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); /*****************Update in JournalMaster table *************/ decimal decTotalDebit = 0; decimal decTotalCredit = 0; infoJournalMaster.JournalMasterId = decJournalMasterId; infoJournalMaster.VoucherNo = strVoucherNo; infoJournalMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoJournalMaster.SuffixPrefixId = decJournalSuffixPrefixId; infoJournalMaster.Date = Convert.ToDateTime(txtDate.Text); infoJournalMaster.Narration = txtNarration.Text.Trim(); infoJournalMaster.UserId = PublicVariables._decCurrentUserId; infoJournalMaster.VoucherTypeId = decJournalVoucherTypeId; infoJournalMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoJournalMaster.ExtraDate = DateTime.Now; infoJournalMaster.Extra1 = string.Empty; infoJournalMaster.Extra2 = string.Empty; decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim()); decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim()); infoJournalMaster.TotalAmount = decTotalDebit; decimal decEffectRow = bllJournalMaster.JournalMasterEdit(infoJournalMaster); /**********************JournalDetails Edit********************/ if (decEffectRow > 0) { infoJournalDetails.JournalMasterId = decJournalMasterId; infoJournalDetails.ExtraDate = DateTime.Now; infoJournalDetails.Extra1 = string.Empty; infoJournalDetails.Extra2 = string.Empty; //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------// LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); bllJournalDetails.JournalDetailsDelete(Convert.ToDecimal(str)); BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decJournalVoucherTypeId); } BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decJournalVoucherTypeId, 12); //=============================================================================================// decimal decLedgerId = 0; decimal decDebit = 0; decimal decCredit = 0; decimal decJournalDetailsId = 0; int inRowCount = dgvJournalVoucher.RowCount; for (int inI = 0; inI < inRowCount; inI++) { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { infoJournalDetails.LedgerId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); decLedgerId = infoJournalDetails.LedgerId; } if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { //------------------Currency conversion------------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value)); decAmount = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //======================================================// if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { infoJournalDetails.Debit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Credit = 0; decDebit = decConvertRate; decCredit = infoJournalDetails.Credit; } else { infoJournalDetails.Credit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Debit = 0; decDebit = infoJournalDetails.Debit; decCredit = decConvertRate; } infoJournalDetails.ExchangeRateId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeNo = dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); } else { infoJournalDetails.ChequeNo = string.Empty; } if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeDate = Convert.ToDateTime(dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString()); } else { infoJournalDetails.ChequeDate = DateTime.Now; } if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoJournalDetails.JournalDetailsId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString()); bllJournalDetails.JournalDetailsEdit(infoJournalDetails); PartyBalanceAddOrEdit(inI); decJournalDetailsId = infoJournalDetails.JournalDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decJournalDetailsId, inI); } else { decJournalDetailsId = bllJournalDetails.JournalDetailsAdd(infoJournalDetails); PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decJournalDetailsId, inI); } } } DeletePartyBalanceOfRemovedRow(); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(infoJournalMaster.JournalMasterId); } else { Print(infoJournalMaster.JournalMasterId); } } if (journalRegisterObj != null) { this.Close(); journalRegisterObj.Enabled = true; } else if (frmJournalReportObj != null) { this.Close(); frmJournalReportObj.Enabled = true; } else if (frmDayBookObj != null) { this.Close(); } else if (frmBillallocationObj != null) { this.Close(); } } //----------------If print after save is enable-----------------------// //===================================================================// } catch (Exception ex) { MessageBox.Show("JV16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Its for Search and fill the Currency's are available in current date /// </summary> /// <param name="frmCurrencyDetails"></param> /// <param name="decId"></param> public void CallFromCurrenCyDetails(frmCurrencyDetails frmCurrencyDetails, decimal decId) { try { decimal decExchangeRateId = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); decExchangeRateId = BllExchangeRate.GetExchangeRateId(decId, Convert.ToDateTime(txtContraVoucherDate.Text)); dgvContraVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value = decExchangeRateId; base.Show(); this.frmCurrencyObj = frmCurrencyDetails; frmCurrencyObj.Close(); frmCurrencyObj = null; } catch (Exception ex) { MessageBox.Show("CV:06" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger Posting Edit /// </summary> public void MasterLedgerPostingEdit() { try { LedgerPostingInfo InfoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); InfoLedgerPosting.Credit = Convert.ToDecimal(txtTotal.Text); InfoLedgerPosting.Date = dtpDate.Value; InfoLedgerPosting.Debit = 0; InfoLedgerPosting.DetailsId = 0; InfoLedgerPosting.Extra1 = string.Empty; InfoLedgerPosting.Extra2 = string.Empty; InfoLedgerPosting.InvoiceNo = strInvoiceNo; InfoLedgerPosting.ChequeNo = string.Empty; InfoLedgerPosting.ChequeDate = DateTime.Now; InfoLedgerPosting.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString()); if (!isAutomatic) { InfoLedgerPosting.VoucherNo = txtVoucherNo.Text.Trim(); } else { InfoLedgerPosting.VoucherNo = strVoucherNo; } InfoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; InfoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNo(InfoLedgerPosting); } catch (Exception ex) { MessageBox.Show("PV22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger Posting edit function /// </summary> /// <param name="decpdcMasterId"></param> public void LedgerPostingEdit(decimal decpdcMasterId) { PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll(); List<DataTable> listObjLedgerPostingId = new List<DataTable>(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); 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 { listObjLedgerPostingId = BllPdcRecieveble.LedgerPostingIdByPDCReceivableId(decpdcMasterId); decimal decledgerpostingId1 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[0]["ledgerPostingId"].ToString()); decimal decLedgerPostingId2 = Convert.ToDecimal(listObjLedgerPostingId[0].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; BllLedgerPosting.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 = BllExchangeRate.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; BllLedgerPosting.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 = BllExchangeRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId); decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString()); decOldExchange = BllExchangeRate.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; } BllLedgerPosting.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; BllLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } catch (Exception ex) { MessageBox.Show("PR10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// TotalAmountCalculation /// </summary> /// <returns></returns> public decimal TotalAmountCalculation() { decimal decTotal = 0; decimal decSelectedCurrencyRate = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { for (int inI = 0; inI < dgvPaymentVoucher.RowCount - 1; inI++) { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()));//Exchange rate of grid's row decTotal = decTotal + (Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()) * decSelectedCurrencyRate); } } } catch (Exception ex) { MessageBox.Show("PV16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return decTotal; }
/// <summary> /// Function to edit the service voucher /// </summary> /// <param name="decServiceMasterId"></param> public void EditFunction(decimal decServiceMasterId) { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; decimal decLedgerPostingId1 = 0; decimal decLedgerPostingId2 = 0; List<DataTable> listObjLedgerPostingId = new List<DataTable>(); listObjLedgerPostingId = BllService.LedgerPostingIdByServiceMaasterId(decServiceMasterId); decLedgerPostingId1 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[0]["ledgerPostingId"].ToString()); decLedgerPostingId2 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[1]["ledgerPostingId"].ToString()); for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { infoServiceMaster.ServiceMasterId = decServiceMasterId; infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; //------------------deleting removed rows----------------------------------------// BankReconciliationBll BllBankReconciliation = new BankReconciliationBll(); foreach (object obj in strArrOfRemove) { string str = Convert.ToString(obj); BllService.ServiceDetailsDelete(Convert.ToDecimal(str)); } BllService.ServiceMasterEdit(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); if (dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceDetailsId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString()); infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); BllService.ServiceDetailsEdit(infoServiceDetails); } else { infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); decConvertRate += decAmount * decSelectedCurrencyRate; } } decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId1, decLedgerId, decCredit, decDebit); decCredit = decConvertRate; decDebit = 0; decLedgerId = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId2, decLedgerId, decCredit, decDebit); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.PartyBalanceId = decPartyBalanceId; infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceEdit(infoPartyBalance); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } this.Close(); if (frmServiceVoucherRegisterObj != null) { frmServiceVoucherRegisterObj.Show(); frmServiceVoucherRegisterObj.GridFill(); } else if (frmServiceReportObj != null) { frmServiceReportObj.Show(); frmServiceReportObj.GridFill(); } } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); } } catch (Exception ex) { MessageBox.Show("SV 24 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int NoofDecimalPlacesFind() { int inNoOfDecimalPlaces = 0; try { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (cmbCurrency.SelectedValue != null) { inNoOfDecimalPlaces = BllExchangeRate.NoOfDecimalNumberViewByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); } } catch (Exception) { throw; } return inNoOfDecimalPlaces; }