/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll(); if (!BllMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value)) { AdvancePaymentBll bllAdvancepayment = new AdvancePaymentBll(); AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); if (bllAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value)) { txtAmount.ReadOnly = true; } infoAdvancepayment.AdvancePaymentId = (Convert.ToDecimal(decAdvancePaymentEditId.ToString())); infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()); infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString()); infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString(); infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString()); if (CheckAdvanceAmount()) { if (isAutomatic) { infoAdvancepayment.VoucherNo = strVoucherNo; } else { infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim(); } if (isAutomatic) { infoAdvancepayment.InvoiceNo = strInvoiceNo; } else { infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim(); } infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString()); infoAdvancepayment.Narration = txtNarration.Text.Trim(); infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString()); infoAdvancepayment.Extra1 = string.Empty; infoAdvancepayment.Extra2 = string.Empty; infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId; infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId; infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId; bllAdvancepayment.AdvancePaymentEdit(infoAdvancepayment); LedgerUpdate(); Messages.UpdatedMessage(); txtAdvanceVoucherNo.Focus(); this.Close(); } } else { Messages.ReferenceExistsMessageForUpdate(); dtpSalaryMonth.Focus(); } } catch (Exception ex) { MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll(); if (!BllMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value)) { AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); bllAdvancePayment.AdvancePaymentDelete(Convert.ToDecimal(decAdvancePaymentEditId.ToString())); BllLedgerPosting.LedgerPostDelete(txtAdvanceVoucherNo.Text.Trim(), decAdvancePaymentEditId); Messages.DeletedMessage(); txtAdvanceVoucherNo.Focus(); Clear(); this.Close(); } else { Messages.ReferenceExistsMessage(); dtpSalaryMonth.Focus(); } } catch (Exception ex) { MessageBox.Show("AP14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }