public void AdvancePaymentEdit(AdvancePaymentInfo advancepaymentinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AdvancePaymentEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@advancePaymentId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.AdvancePaymentId; sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.EmployeeId; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = advancepaymentinfo.Date; sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.Amount; sprmparam = sccmd.Parameters.Add("@salaryMonth", SqlDbType.DateTime); sprmparam.Value = advancepaymentinfo.SalaryMonth; sprmparam = sccmd.Parameters.Add("@chequenumber", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.Chequenumber; sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam.Value = advancepaymentinfo.ChequeDate; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.Narration; //sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); //sprmparam.Value = advancepaymentinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = advancepaymentinfo.Extra2; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = advancepaymentinfo.FinancialYearId; //sccmd.ExecuteScalar(); sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
public DataTable AdvancePaymentAddWithIdentity(AdvancePaymentInfo advancepaymentinfo, bool IsAutomatic) { DataTable dtbl = new DataTable(); try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlDataAdapter sqlda = new SqlDataAdapter("AdvancePaymentAddWithIdentity", base.sqlcon); sqlda.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam17 = new SqlParameter(); sprmparam17 = sqlda.SelectCommand.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.EmployeeId; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.LedgerId; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.VoucherNo; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.InvoiceNo; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime); sprmparam17.Value = advancepaymentinfo.Date; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@amount", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.Amount; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@salaryMonth", SqlDbType.DateTime); sprmparam17.Value = advancepaymentinfo.SalaryMonth; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@chequenumber", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.Chequenumber; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam17.Value = advancepaymentinfo.ChequeDate; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.Narration; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.Extra1; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam17.Value = advancepaymentinfo.Extra2; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.SuffixPrefixId; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.VoucherTypeId; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam17.Value = advancepaymentinfo.FinancialYearId; sprmparam17 = sqlda.SelectCommand.Parameters.Add("@IsAutomatic", SqlDbType.Bit); sprmparam17.Value = IsAutomatic; sqlda.Fill(dtbl); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } return(dtbl); }
public void AdvancePaymentEdit(AdvancePaymentInfo infoAdvancePayment) { try { spAdvancePayment.AdvancePaymentEdit(infoAdvancePayment); } catch (Exception ex) { MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public AdvancePaymentInfo AdvancePaymentView(decimal decAdvancePaymentId) { AdvancePaymentInfo infoiAdvancePayment = new AdvancePaymentInfo(); try { infoiAdvancePayment = spAdvancePayment.AdvancePaymentView(decAdvancePaymentId); } catch (Exception ex) { MessageBox.Show("AP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoiAdvancePayment); }
public List <DataTable> AdvancePaymentAddWithIdentity(AdvancePaymentInfo infoAdvancePayment, bool IsAutomatic) { List <DataTable> ListObj = new List <DataTable>(); try { ListObj = spAdvancePayment.AdvancePaymentAddWithIdentity(infoAdvancePayment, IsAutomatic); } catch (Exception ex) { MessageBox.Show("AP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(ListObj); }
public AdvancePaymentInfo AdvancePaymentView(decimal advancePaymentId) { AdvancePaymentInfo advancepaymentinfo = new AdvancePaymentInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AdvancePaymentView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@advancePaymentId", SqlDbType.Decimal); sprmparam.Value = advancePaymentId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { advancepaymentinfo.AdvancePaymentId = Convert.ToDecimal(sdrreader[0].ToString()); advancepaymentinfo.EmployeeId = Convert.ToDecimal(sdrreader[1].ToString()); advancepaymentinfo.LedgerId = Convert.ToDecimal(sdrreader[2].ToString()); advancepaymentinfo.VoucherNo = sdrreader[3].ToString(); advancepaymentinfo.InvoiceNo = (sdrreader[4].ToString()); advancepaymentinfo.Date = Convert.ToDateTime(sdrreader[5].ToString()); advancepaymentinfo.Amount = Convert.ToDecimal(sdrreader[6].ToString()); advancepaymentinfo.SalaryMonth = Convert.ToDateTime(sdrreader[7].ToString()); advancepaymentinfo.Chequenumber = sdrreader[8].ToString(); advancepaymentinfo.ChequeDate = Convert.ToDateTime(sdrreader[9].ToString()); advancepaymentinfo.Narration = sdrreader[10].ToString(); advancepaymentinfo.ExtraDate = Convert.ToDateTime(sdrreader[11].ToString()); advancepaymentinfo.Extra1 = sdrreader[12].ToString(); advancepaymentinfo.Extra2 = sdrreader[13].ToString(); advancepaymentinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader[14].ToString()); advancepaymentinfo.VoucherTypeId = Convert.ToDecimal(sdrreader[15].ToString()); advancepaymentinfo.FinancialYearId = Convert.ToDecimal(sdrreader[16].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(advancepaymentinfo); }
public ActionResult GetAdvancePaymentEditDetails(string advancePaymentEditId) { try { decAdvancePaymentEditId = Convert.ToDecimal(advancePaymentEditId); AdvancePaymentSP spadvance = new AdvancePaymentSP(); AdvancePaymentInfo infoadvance = new AdvancePaymentInfo(); VoucherTypeSP spvouchertype = new VoucherTypeSP(); infoadvance = spadvance.AdvancePaymentView(decAdvancePaymentEditId); strVoucherNo = infoadvance.VoucherNo; string txtAdvanceVoucherNo = infoadvance.InvoiceNo; strInvoiceNo = infoadvance.InvoiceNo; string employeeId = infoadvance.EmployeeId.ToString(); string salaryMonth = infoadvance.SalaryMonth.ToString("yyyy-MM"); string txtDate = infoadvance.Date.ToString("yyyy-MM-dd"); string txtChequeDate = infoadvance.Date.ToString("yyyy-MM-dd"); string ledgerId = infoadvance.LedgerId.ToString(); string txtCheckNo = infoadvance.Chequenumber; string txtAmount = infoadvance.Amount.ToString(); string txtNarration = infoadvance.Narration; bool isBankAccount = false; decAdvancePaymentsId = decAdvancePaymentId; TransactionsGeneralFill obj = new TransactionsGeneralFill(); DataTable cashOrBank = obj.CashOrBankComboFill(false); DataTable employee = EmployeeComboFill(); string jsonCashOrBank = Utils.ConvertDataTabletoString(cashOrBank); string jsonEmployee = Utils.ConvertDataTabletoString(employee); if (cashOrBank.Rows.Count > 0) { decimal cashOrBankId = (decimal)cashOrBank.Rows[0][1]; string cashOrBankName = (string)cashOrBank.Rows[0][0]; isBankAccount = CheckWhetherBankOrCash(cashOrBankId, cashOrBankName); } decPaymentVoucherTypeId = infoadvance.VoucherTypeId; decPaymentSuffixPrefixId = infoadvance.SuffixPrefixId; isAutomatic = spvouchertype.CheckMethodOfVoucherNumbering(decPaymentVoucherTypeId); return(Json(new { success = "true", ex = "no", data = new { voucherNo = strVoucherNo, employee = jsonEmployee, employeeId, salaryMonth, chequeNo = txtCheckNo, date = txtDate, amount = txtAmount, cashOrBank = jsonCashOrBank, ledgerId, chequeDate = txtChequeDate, narration = txtNarration, isAutomatic, isBankAccount } })); } catch (Exception ex) { return(Json(new { success = "true", ex = "AP3:" + ex.Message })); } }
public void LedgerPosting(decimal decLedgerPostingId, decimal decAdvancePaymentId, string voucherNo, string selLedgerId, string amount) { try { AdvancePaymentSP spAdvancePayment = new AdvancePaymentSP(); AdvancePaymentInfo infoAdvancePayment = new AdvancePaymentInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = Convert.ToDecimal(selLedgerId); infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(amount); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ExtraDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = 3; infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = Convert.ToDecimal(amount); infoLedgerPosting.Credit = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } catch (Exception ex) { } }
public ActionResult EditAdvancePaymentFunction(string voucherNo, string employeeId, string salaryMonth, string chequeNo, string date, string amount, string ledgerId, string chequeDate, string narration, string advancePaymentEditId) { string message = string.Empty; string focus = string.Empty; bool amountReadOnly = false; try { employeeId = employeeId ?? string.Empty; salaryMonth = salaryMonth ?? string.Empty; chequeNo = chequeNo ?? string.Empty; date = date ?? string.Empty; amount = amount ?? string.Empty; ledgerId = ledgerId ?? string.Empty; chequeDate = chequeDate ?? string.Empty; narration = narration ?? string.Empty; decAdvancePaymentEditId = Convert.ToDecimal(advancePaymentEditId); MonthlySalarySP spMonthlySalary = new MonthlySalarySP(); decimal decEmployeeId = Convert.ToDecimal(employeeId); DateTime dtSalaryMonth = Convert.ToDateTime(salaryMonth); if (!spMonthlySalary.CheckSalaryStatusForAdvancePayment(decEmployeeId, dtSalaryMonth)) { AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP(); AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); if (spAdvancepayment.CheckSalaryAlreadyPaidOrNot(decEmployeeId, dtSalaryMonth)) { amountReadOnly = true; } infoAdvancepayment.AdvancePaymentId = decAdvancePaymentEditId; infoAdvancepayment.EmployeeId = decEmployeeId; infoAdvancepayment.SalaryMonth = dtSalaryMonth; infoAdvancepayment.Chequenumber = chequeNo; infoAdvancepayment.Date = Convert.ToDateTime(date); infoAdvancepayment.Amount = Convert.ToDecimal(amount); if (CheckAdvanceAmount(employeeId, amount)) { if (isAutomatic) { infoAdvancepayment.VoucherNo = strVoucherNo; } else { infoAdvancepayment.VoucherNo = voucherNo; } if (isAutomatic) { infoAdvancepayment.InvoiceNo = strInvoiceNo; } else { infoAdvancepayment.InvoiceNo = voucherNo; } infoAdvancepayment.LedgerId = Convert.ToDecimal(ledgerId); infoAdvancepayment.ChequeDate = Convert.ToDateTime(chequeDate); infoAdvancepayment.Narration = narration; 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; message = spAdvancepayment.AdvancePaymentEdit(infoAdvancepayment); message = LedgerUpdate(voucherNo, amount, ledgerId); } else { message = "Advance of this month exceeds than amount set for the employee"; focus = "new_amount"; } } else { message = "You can't update,reference exist"; focus = "edit_salaryMonth"; } } catch (Exception ex) { return(Json(new { success = "true", ex = "AP3" + ex.Message })); } return(Json(new { success = "true", ex = "no", focus, message, amountReadOnly })); }
public ActionResult SaveAdvancePaymentFunction(string voucherNo, string employeeId, string salaryMonth, string chequeNo, string date, string amount, string ledgerId, string chequeDate, string narration) { string exception = string.Empty; string message = string.Empty; string focus = string.Empty; string newVoucherNo = string.Empty; try { employeeId = employeeId ?? string.Empty; salaryMonth = salaryMonth ?? string.Empty; chequeNo = chequeNo ?? string.Empty; date = date ?? string.Empty; amount = amount ?? string.Empty; ledgerId = ledgerId ?? string.Empty; chequeDate = chequeDate ?? string.Empty; narration = narration ?? string.Empty; AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP(); AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); MonthlySalarySP spMonthlySalary = new MonthlySalarySP(); if (CheckAdvanceAmount(employeeId, amount)) { if (!spMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(Convert.ToDecimal(employeeId), Convert.ToDateTime(salaryMonth))) { if (!spAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(employeeId), Convert.ToDateTime(salaryMonth))) { if (isAutomatic == true) { infoAdvancepayment.VoucherNo = strVoucherNo; } else { infoAdvancepayment.VoucherNo = voucherNo; } infoAdvancepayment.EmployeeId = Convert.ToDecimal(employeeId); infoAdvancepayment.SalaryMonth = Convert.ToDateTime(salaryMonth); infoAdvancepayment.Chequenumber = chequeNo ?? string.Empty; infoAdvancepayment.Date = Convert.ToDateTime(date); infoAdvancepayment.Amount = Convert.ToDecimal(amount); if (isAutomatic) { infoAdvancepayment.InvoiceNo = strInvoiceNo; } else { infoAdvancepayment.InvoiceNo = voucherNo; } infoAdvancepayment.LedgerId = Convert.ToDecimal(ledgerId); infoAdvancepayment.ChequeDate = Convert.ToDateTime(chequeDate); infoAdvancepayment.Narration = narration; infoAdvancepayment.ExtraDate = DateTime.Now; infoAdvancepayment.Extra1 = string.Empty; infoAdvancepayment.Extra2 = string.Empty; infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId; infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId; infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId; if (decAdvancePaymentsId != -1) { DataTable dtbl = new DataTable(); dtbl = spAdvancepayment.AdvancePaymentAddWithIdentity(infoAdvancepayment, isAutomatic); foreach (DataRow dr in dtbl.Rows) { decAdvancePaymentId = Convert.ToDecimal(dr.ItemArray[0].ToString()); strUpdatedVoucherNumber = dr.ItemArray[1].ToString(); strUpdatedInvoiceNumber = dr.ItemArray[2].ToString(); } if (!isAutomatic) { strVoucherNo = voucherNo; } if (isAutomatic) { if (Convert.ToDecimal(strUpdatedVoucherNumber) != Convert.ToDecimal(strVoucherNo)) { message = "Voucher number changed from " + strInvoiceNo + " to " + strUpdatedInvoiceNumber + "."; strVoucherNo = strUpdatedVoucherNumber.ToString(); strInvoiceNo = strUpdatedInvoiceNumber; newVoucherNo = strVoucherNo; } } focus = "AdvanceVoucherNo"; } LedgerPosting(Convert.ToDecimal(ledgerId), decAdvancePaymentId, voucherNo, ledgerId, amount); } else { message = "Advance already paid for this month."; focus = "new_salaryMonth"; } } else { message = "Cant pay advance for this month,Salary already paid."; focus = "new_salaryMonth"; } } else { message = "Advance of this month exceeds than amount set for the employee"; focus = "new_amount"; } } catch (Exception ex) { return(Json(new { success = "true", ex = ex.Message })); } return(Json(new { success = "true", ex = "no", focus, message, newVoucherNo })); }
public void SaveFunction() { try { AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll(); AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll(); if (CheckAdvanceAmount()) { if (!BllMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value)) { if (!bllAdvancePayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value)) { if (isAutomatic == true) { infoAdvancepayment.VoucherNo = strVoucherNo; } else { infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim(); } 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 (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; if (btnAdvancePaymentSave.Text == "Save") { if (decAdvancePaymentsId != -1) { List<DataTable> ListObj = new List<DataTable>(); ListObj = bllAdvancePayment.AdvancePaymentAddWithIdentity(infoAdvancepayment, isAutomatic); foreach (DataRow dr in ListObj[0].Rows) { decAdvancePaymentId = Convert.ToDecimal(dr.ItemArray[0].ToString()); strUpdatedVoucherNumber = dr.ItemArray[1].ToString(); strUpdatedInvoiceNumber = dr.ItemArray[2].ToString(); } if (!isAutomatic) { strVoucherNo = txtAdvanceVoucherNo.Text.Trim(); } if (isAutomatic) { if (Convert.ToDecimal(strUpdatedVoucherNumber) != Convert.ToDecimal(strVoucherNo)) { Messages.InformationMessage("Voucher number changed from " + strInvoiceNo + " to " + strUpdatedInvoiceNumber); strVoucherNo = strUpdatedVoucherNumber.ToString(); strInvoiceNo = strUpdatedInvoiceNumber; } } txtAdvanceVoucherNo.Focus(); } LedgerPosting(Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()), decAdvancePaymentId); Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage(" Advance already paid for this month"); dtpSalaryMonth.Focus(); } } else { Messages.InformationMessage("Cant pay advance for this month,Salary already paid"); dtpSalaryMonth.Focus(); } } } catch (Exception ex) { MessageBox.Show("AP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Ledger Posting /// </summary> /// <param name="decLedgerPostingId"></param> /// <param name="decAdvancePaymentId"></param> public void LedgerPosting(decimal decLedgerPostingId, decimal decAdvancePaymentId) { try { AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll(); AdvancePaymentInfo infoAdvancePayment = new AdvancePaymentInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = txtAdvanceVoucherNo.Text.Trim(); } infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = txtAdvanceVoucherNo.Text.Trim(); } infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text.ToString()); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = txtAdvanceVoucherNo.Text.Trim(); } infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = 3; infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = txtAdvanceVoucherNo.Text.Trim(); } infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text.ToString()); infoLedgerPosting.Credit = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } catch (Exception ex) { MessageBox.Show("AP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill controls for update /// </summary> public void fillFunction() { try { AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll(); AdvancePaymentInfo infoadvance = new AdvancePaymentInfo(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); infoadvance = bllAdvancePayment.AdvancePaymentView(decAdvancePaymentEditId); strVoucherNo = infoadvance.VoucherNo; txtAdvanceVoucherNo.Text = infoadvance.InvoiceNo; strInvoiceNo = infoadvance.InvoiceNo; cmbEmployee.SelectedValue = infoadvance.EmployeeId.ToString(); dtpSalaryMonth.Value = Convert.ToDateTime(infoadvance.SalaryMonth.ToString()); txtDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy"); txtChequeDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy"); cmbCashOrBank.SelectedValue = infoadvance.LedgerId.ToString(); txtCheckNo.Text = infoadvance.Chequenumber; txtAmount.Text = infoadvance.Amount.ToString(); txtNarration.Text = infoadvance.Narration; btnAdvancePaymentSave.Text = "Update"; btnAdvancePaymentDelete.Enabled = true; decAdvancePaymentsId = decAdvancePaymentId; decPaymentVoucherTypeId = infoadvance.VoucherTypeId; decPaymentSuffixPrefixId = infoadvance.SuffixPrefixId; isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPaymentVoucherTypeId); if (isAutomatic) { txtAdvanceVoucherNo.Enabled = false; } else { txtAdvanceVoucherNo.Enabled = true; } } catch (Exception ex) { MessageBox.Show("AP8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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); } }