/// <summary> /// Function to update values in ledgerposting table /// </summary> public void ledgerUpdate() { try { string strfinancialId; FinancialYearBll BllFinancialYear = new FinancialYearBll(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); infoFinancialYear = BllFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); decimal decLedgerPostingId = 0; if (txtOpeningBalance.Text.Trim() != string.Empty) { decOpeningBlnc = Convert.ToDecimal(txtOpeningBalance.Text.Trim()); } else { decOpeningBlnc = 0; } LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); List<DataTable> dtbl = BllLedgerPosting.GetLedgerPostingIds(decLedgerIdForEdit.ToString(), 1); foreach (DataRow dr in dtbl[0].Rows) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); } if (cmbDrorCr.Text == "Dr") { infoLedgerPosting.Debit = decOpeningBlnc; } else { infoLedgerPosting.Credit = decOpeningBlnc; } infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.VoucherNo = decLedgerIdForEdit.ToString(); infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerIdForEdit; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = decLedgerIdForEdit.ToString(); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; if (dtbl[0].Rows.Count > 0) { if (decOpeningBlnc > 0) { BllLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } else { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedgerIdForEdit.ToString(), 1); } } else { BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } catch (Exception ex) { MessageBox.Show("Cus16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (bllAccountLedger.AccountLedgerCheckReferences(decLedgerIdForEdit) == -1) { Messages.ReferenceExistsMessage(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decLedgerIdForEdit.ToString(), 1); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedgerIdForEdit.ToString(), 1); Messages.DeletedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("Cus9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete account ledger /// </summary> public void Delete() { try { if (!isDefault) { if (Messages.DeleteConfirmation()) { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decAccountLedgerId.ToString(), 1); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decAccountLedgerId.ToString(), 1); if (bllAccountLedger.AccountLedgerCheckReferences(decAccountLedgerId) == -1) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); Clear(); } } } else { Messages.InformationMessage("Can't delete build in account ledger"); } } catch (Exception ex) { MessageBox.Show("AL25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> ///Function to edit ledgerposting incase of opening balance /// </summary> public void LedgerPostingEdit() { try { string strfinancialId; decOpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim())); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); FinancialYearBll BllFinancialYear = new FinancialYearBll(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); infoFinancialYear = BllFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); if (cmbOpeningBalanceCrOrDr.Text == "Dr") { infoLedgerPosting.Debit = decOpeningBalance; } else { infoLedgerPosting.Credit = decOpeningBalance; } infoLedgerPosting.DetailsId = 0; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = decAccountLedgerId.ToString(); infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.LedgerId = decAccountLedgerId; infoLedgerPosting.VoucherNo = decAccountLedgerId.ToString(); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; List<DataTable> dtbl = BllLedgerPosting.GetLedgerPostingIds(decAccountLedgerId.ToString(), 1); if (dtbl[0].Rows.Count > 0) { if (decOpeningBalance > 0) { //Edit infoLedgerPosting.LedgerPostingId = Convert.ToDecimal(dtbl[0].Rows[0][0].ToString()); BllLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } else { //Delete bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decAccountLedgerId.ToString(), 1); } } else { //Add new row BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } catch (Exception ex) { MessageBox.Show("AL5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { DateValidation Objdatevalidation = new DateValidation(); OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction(); Objdatevalidation.DateValidationFunction(txtVoucherDate); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); SettingsBll BllSettings = new SettingsBll(); txtVoucherDate.Text = txtVoucherDate.Text.Trim(); cmbvouchertype.Text = cmbvouchertype.Text.Trim(); txtAmount.Text = txtAmount.Text.Trim(); txtBank.Text = txtBank.Text.Trim(); txtcheckdate.Text = txtcheckdate.Text.Trim(); txtcheckNo.Text = txtcheckNo.Text.Trim(); txtNarration.Text = txtNarration.Text.Trim(); DataTable dtblMaster = new DataTable(); PDCClearanceBll BllPdcClearance = new PDCClearanceBll(); PDCClearanceMasterInfo infoPdcclearance = new PDCClearanceMasterInfo(); infoPdcclearance.SuffixPrefixId = decSufixprefixPdcpayableID; infoPdcclearance.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoPdcclearance.VoucherNo = strVoucherNo; infoPdcclearance.InvoiceNo = txtvoucherNo.Text; if (txtVoucherDate.Text != string.Empty) infoPdcclearance.Date = Convert.ToDateTime(txtVoucherDate.Text); else infoPdcclearance.Date = DateTime.Now; infoPdcclearance.LedgerId = decimal.Parse(strledgerId.ToString()); infoPdcclearance.AgainstId = decmasterId; infoPdcclearance.UserId = PublicVariables._decCurrentUserId; infoPdcclearance.VoucherTypeId = decPDCclearanceVoucherTypeId; infoPdcclearance.Status = cmbStatus.Text.ToString(); infoPdcclearance.Type = cmbvouchertype.Text.ToString(); infoPdcclearance.ExtraDate = DateTime.Now; infoPdcclearance.Narration = txtNarration.Text; infoPdcclearance.Extra1 = string.Empty; infoPdcclearance.Extra2 = string.Empty; if (!isInEditMode) { decimal decIdentity = BllPdcClearance.PDCClearanceMasterAdd(infoPdcclearance); LedgerPostingAdd(); if (cmbStatus.Text.ToString() == "Bounced") { if (bllAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString())) { PartyBalanceAddOrEdit(); } } Messages.SavedMessage(); if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } ClearFunction(); } else { decimal decIdentity = decPDCClearanceEditId; infoPdcclearance.PDCClearanceMasterId = decPDCClearanceEditId; BllPdcClearance.PDCClearanceMasterEdit(infoPdcclearance); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decPDCclearanceVoucherTypeId); LedgerPostingAdd(); bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPDCclearanceVoucherTypeId); if (cmbStatus.Text.ToString() == "Bounced") { if (bllAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString())) { PartyBalanceAddOrEdit(); } } Messages.UpdatedMessage(); if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("PC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// delete function /// </summary> public void DeleteFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (bllAccountLedger.SupplierCheckreferenceAndDelete(Convert.ToDecimal(strLedgerId.ToString())) == -1) { Messages.ReferenceExistsMessage(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decLedger.ToString(), 1); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedger.ToString(), 1); bllAccountLedger.AccountLedgerDelete(decLedger); Messages.DeletedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("SUP11" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }