public bool CheckSalaryAlreadyPaidOrNotForAdvancePayment(decimal decEmployeeId, DateTime date) { bool isPaid = false; try { isPaid = SPMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(decEmployeeId, date); } catch (Exception ex) { MessageBox.Show("MS6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(isPaid); }
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 })); }