/// <summary> /// Party balance Update function /// </summary> /// <param name="decPartyBalanceId"></param> /// <param name="inJ"></param> public void PartyBalanceEdit(decimal decPartyBalanceId, int inJ) { PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); try { InfopartyBalance.PartyBalanceId = decPartyBalanceId; InfopartyBalance.CreditPeriod = 0;// InfopartyBalance.Date = dtpVoucherDate.Value; InfopartyBalance.LedgerId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()); InfopartyBalance.ReferenceType = dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString(); if (dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString() == "New" || dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString() == "OnAccount") { InfopartyBalance.AgainstInvoiceNo = dtblPartyBalance.Rows[inJ]["AgainstInvoiceNo"].ToString(); InfopartyBalance.AgainstVoucherNo = dtblPartyBalance.Rows[inJ]["AgainstVoucherNo"].ToString(); InfopartyBalance.AgainstVoucherTypeId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["AgainstVoucherTypeId"].ToString());//decPaymentVoucherTypeId; InfopartyBalance.VoucherTypeId = decPDCReceivableVoucherTypeId; InfopartyBalance.InvoiceNo = strInvoiceNo; InfopartyBalance.VoucherNo = strVoucherNo; } else { InfopartyBalance.ExchangeRateId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["OldExchangeRate"].ToString()); InfopartyBalance.AgainstInvoiceNo = strInvoiceNo; InfopartyBalance.AgainstVoucherNo = strVoucherNo; InfopartyBalance.AgainstVoucherTypeId = decPDCReceivableVoucherTypeId; InfopartyBalance.VoucherTypeId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["AgainstVoucherTypeId"].ToString()); InfopartyBalance.VoucherNo = dtblPartyBalance.Rows[inJ]["AgainstVoucherNo"].ToString(); InfopartyBalance.InvoiceNo = dtblPartyBalance.Rows[inJ]["AgainstInvoiceNo"].ToString(); } InfopartyBalance.Credit = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["Amount"].ToString()); InfopartyBalance.Debit = 0; InfopartyBalance.ExchangeRateId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["CurrencyId"].ToString()); InfopartyBalance.Extra1 = string.Empty; InfopartyBalance.Extra2 = string.Empty; InfopartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; BllPartyBalance.PartyBalanceEdit(InfopartyBalance); } catch (Exception ex) { MessageBox.Show("PR14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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); } }
/// <summary> /// Party balance Save Or Edit /// </summary> /// <param name="inJ"></param> public void PartyBalanceAddOrEdit(int inJ) { try { int inTableRowCount = dtblPartyBalance.Rows.Count; PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); InfopartyBalance.Credit = 0; InfopartyBalance.CreditPeriod = 0; InfopartyBalance.Date = dtpDate.Value; InfopartyBalance.Debit = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["Amount"].ToString()); InfopartyBalance.ExchangeRateId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["CurrencyId"].ToString()); InfopartyBalance.Extra1 = string.Empty; InfopartyBalance.Extra2 = string.Empty; InfopartyBalance.ExtraDate = DateTime.Now; InfopartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfopartyBalance.LedgerId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()); InfopartyBalance.ReferenceType = dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString(); if (dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString() == "New" || dtblPartyBalance.Rows[inJ]["ReferenceType"].ToString() == "OnAccount") { InfopartyBalance.AgainstInvoiceNo = "0"; InfopartyBalance.AgainstVoucherNo = "0"; InfopartyBalance.AgainstVoucherTypeId = 0; InfopartyBalance.VoucherTypeId = decPaymentVoucherTypeId; InfopartyBalance.InvoiceNo = strInvoiceNo; if (!isAutomatic) { InfopartyBalance.VoucherNo = txtVoucherNo.Text.Trim(); } else { InfopartyBalance.VoucherNo = strVoucherNo; } } else { InfopartyBalance.ExchangeRateId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["OldExchangeRate"].ToString()); InfopartyBalance.AgainstInvoiceNo = strInvoiceNo; if (!isAutomatic) { InfopartyBalance.AgainstVoucherNo = txtVoucherNo.Text.Trim(); } else { InfopartyBalance.AgainstVoucherNo = strVoucherNo; } InfopartyBalance.AgainstVoucherTypeId = decPaymentVoucherTypeId; InfopartyBalance.VoucherTypeId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["AgainstVoucherTypeId"].ToString()); InfopartyBalance.VoucherNo = dtblPartyBalance.Rows[inJ]["AgainstVoucherNo"].ToString(); InfopartyBalance.InvoiceNo = dtblPartyBalance.Rows[inJ]["AgainstInvoiceNo"].ToString(); } if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() == "0") { BllPartyBalance.PartyBalanceAdd(InfopartyBalance); } else { InfopartyBalance.PartyBalanceId = Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["partyBalanceId"]); BllPartyBalance.PartyBalanceEdit(InfopartyBalance); } } catch (Exception ex) { MessageBox.Show("PV15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }