public ActionResult DeleteAdvancePaymentFunction(string voucherNo, string employeeId, string salaryMonth) { string message = string.Empty; try { MonthlySalarySP spMonthlySalary = new MonthlySalarySP(); if (!spMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(employeeId), Convert.ToDateTime(salaryMonth))) { AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo(); AdvancePaymentSP spAdvancePayment = new AdvancePaymentSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); spAdvancePayment.AdvancePaymentDelete(Convert.ToDecimal(decAdvancePaymentEditId.ToString())); spLedgerPosting.LedgerPostDelete(voucherNo, decAdvancePaymentEditId); } else { message = "You can't delete,reference exist"; } } catch (Exception ex) { return(Json(new { success = "false", ex = "AP4" + ex.Message, message })); } return(Json(new { success = "true", ex = "no", message })); }
public ActionResult DeleteMonthlySalaryVoucher(string id, string strVoucherNo, string dptMonth, string dptVoucherDate, string cash, string editMode) { DataTable dtbl = new DataTable(); try { SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP(); SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); decimal masterId = Convert.ToDecimal(id); spMaster.SalaryVoucherMasterDelete(masterId); spDetails.SalaryVoucherDetailsDeleteUsingMasterId(masterId); int decMonthlyVoucherTypeId = 27; spLedgerPosting.LedgerPostDelete(strVoucherNo, Convert.ToDecimal(decMonthlyVoucherTypeId)); VoucherClear(strVoucherNo, dptVoucherDate, editMode); //dtbl = GridFillVoucher(Convert.ToBoolean(editMode), Convert.ToDateTime(dptMonth), strVoucherNo); return(Json(new { error = "success" })); } catch (Exception ex) { //MessageBox.Show("MSV16:" + ex.Message, "Masterfine", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(Json(new { error = "failed" })); }
/// <summary> /// Function to edit LedgerPosting table /// </summary> private void LedgerUpdate(DailySalaryVoucherMasterInfo infoMaster) { try { decimal decLedgerPostingId = 0; LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); DataTable dtbl = new DataTable(); dtbl = spLedgerPosting.GetLedgerPostingIds(infoMaster.VoucherNo, infoMaster.VoucherTypeId); int ini = 0; foreach (DataRow dr in dtbl.Rows) { ini++; if (ini == 2) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = infoMaster.Date; infoLedgerPosting.VoucherNo = infoMaster.VoucherNo; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = infoMaster.TotalAmount; infoLedgerPosting.VoucherTypeId = infoMaster.VoucherTypeId; infoLedgerPosting.LedgerId = 4; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoMaster.InvoiceNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = 0; //PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } if (ini == 1) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = infoMaster.Date; infoLedgerPosting.VoucherNo = infoMaster.VoucherNo; infoLedgerPosting.Debit = infoMaster.TotalAmount; infoLedgerPosting.Credit = 0; infoLedgerPosting.VoucherTypeId = infoMaster.VoucherTypeId; infoLedgerPosting.LedgerId = infoMaster.LedgerId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoMaster.InvoiceNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } } } catch (Exception ex) { } }
public ActionResult DeleteDailySalaryVoucher(string dailyMasterId, string voucherTypeId, string voucherNo, string salaryDate) { bool isSuccess = true; string message = string.Empty; try { DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP(); DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); spMaster.DailySalaryVoucherMasterDelete(Convert.ToDecimal(dailyMasterId)); spDetails.DailySalaryVoucherDetailsDeleteUsingMasterId(Convert.ToDecimal(dailyMasterId)); spLedgerPosting.LedgerPostDelete(voucherNo, Convert.ToDecimal(voucherTypeId)); DataTable dtbl = DailySalaryVoucherDetailsGridfill(true, voucherNo, salaryDate); } catch (Exception ex) { isSuccess = false; message = "DSV13:" + ex.Message; } return(Json(new { isSuccess, 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 string LedgerUpdate(string voucherNo, string amount, string selLedgerId) { string message = string.Empty; try { decimal decLedgerPostingId = 0; LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); DataTable dtbl = new DataTable(); dtbl = spLedgerPosting.GetLedgerPostingIds(strVoucherNo, decAdvancePaymentId); int ini = 0; foreach (DataRow dr in dtbl.Rows) { ini++; if (ini == 2) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = PublicVariables._dtCurrentDate; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Debit = Convert.ToDecimal(amount); infoLedgerPosting.Credit = 0; infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; infoLedgerPosting.LedgerId = 3; infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } if (ini == 1) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = PublicVariables._dtCurrentDate; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(amount); infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId; infoLedgerPosting.LedgerId = Convert.ToDecimal(selLedgerId); infoLedgerPosting.DetailsId = decAdvancePaymentId; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } } } catch (Exception ex) { message = ex.Message; } return(message); }
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 })); }
/// <summary> /// Function for edit /// </summary> public void EditFunction_MSV(string masterId, string tableData, string editMode) { try { List <Object> dgvMonthlySalary = JsonConvert.DeserializeObject <List <Object> >(tableData); JArray itemFirst = (JArray)dgvMonthlySalary[0]; string voucherNo = Convert.ToString(itemFirst[0]["voucherNo"].Value <string>()); string voucherDate = Convert.ToString(itemFirst[0]["voucherDate"].Value <string>()); string month = Convert.ToString(itemFirst[0]["month"].Value <string>()); string cash = Convert.ToString(itemFirst[0]["cash"].Value <string>()); string totalAmount = Convert.ToString(itemFirst[0]["totalAmount"].Value <string>()); string narration = Convert.ToString(itemFirst[0]["narration"].Value <string>()); SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP(); SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo(); SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP(); SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); decimal masterID = Convert.ToDecimal(masterId); infoMaster.SalaryVoucherMasterId = masterID; infoMaster.Date = Convert.ToDateTime(voucherDate); infoMaster.LedgerId = Convert.ToDecimal(cash); infoMaster.Narration = narration; infoMaster.TotalAmount = Convert.ToDecimal(totalAmount); bool isEditMode = Convert.ToBoolean(editMode); VoucherTypeSP spVoucherType = new VoucherTypeSP(); int decMonthlyVoucherTypeId = 27; decimal typeId = Convert.ToDecimal(decMonthlyVoucherTypeId); var isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(typeId); infoMaster.VoucherNo = voucherNo; infoMaster.InvoiceNo = voucherNo; infoMaster.Extra1 = string.Empty; infoMaster.Extra2 = string.Empty; infoMaster.SuffixPrefixId = Convert.ToDecimal(ViewData["decMonthlySuffixPrefixId"]); infoMaster.VoucherTypeId = typeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaster.Month = Convert.ToDateTime(month); infoDetails.Extra1 = string.Empty; infoDetails.Extra2 = string.Empty; int inRowCount = dgvMonthlySalary.Count; for (int i = 0; i < inRowCount; i++) { JArray item = (JArray)dgvMonthlySalary[i]; if (item[0]["txtEmployeeId"] != null) { infoDetails.EmployeeId = Convert.ToDecimal(item[0]["txtEmployeeId"].Value <string>()); } if (item[0]["txtBonus"] != null) { infoDetails.Bonus = Convert.ToDecimal(item[0]["txtBonus"].Value <string>()); } if (item[0]["txtDeduction"] != null) { infoDetails.Deduction = Convert.ToDecimal(item[0]["txtDeduction"].Value <string>()); } if (item[0]["txtAdvance"] != null) { infoDetails.Advance = Convert.ToDecimal(item[0]["txtAdvance"].Value <string>()); } if (item[0]["txtLop"] != null) { infoDetails.Lop = Convert.ToDecimal(item[0]["txtLop"].Value <string>()); } if (item[0]["txtSalary"] != null) { infoDetails.Salary = Convert.ToDecimal(item[0]["txtSalary"].Value <string>()); } if (item[0]["cmbStatus"] != null && Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid") { infoDetails.Status = Convert.ToString(item[0]["cmbStatus"].Value <string>()); } if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Pending" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) != "0") { decimal SalaryVoucherDetailsId = Convert.ToDecimal(item[0]["txtDetailsId"].Value <string>()); spDetails.SalaryVoucherDetailsDelete(SalaryVoucherDetailsId); spMaster.SalaryVoucherMasterEdit(infoMaster); //LedgerUpdate(); } if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) == "0") { infoDetails.SalaryVoucherMasterId = masterID; spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails); spMaster.SalaryVoucherMasterEdit(infoMaster); //LedgerUpdate(); } if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Pending" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) == "0") { spMaster.SalaryVoucherMasterEdit(infoMaster); //LedgerUpdate(); } } if (spDetails.SalaryVoucherDetailsCount(masterID) == 0) { spMaster.SalaryVoucherMasterDelete(masterID); } //GridFillVoucher(isEditMode, Convert.ToDateTime(month), voucherNo); } catch (Exception ex) { //MessageBox.Show("MSV8:" + ex.Message, "Masterfine", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save data to the database /// </summary> public void SaveFunction() { try { int inRowcount = dgvMultipleAccountLedger.RowCount;//edited by Runali int inRowcountDec = (dgvMultipleAccountLedger.RowCount) - 1; decimal decOpeningBalance = 0; decimal decLedgerId = 0; bool isSave = false; AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerSP spAccountledger = new AccountLedgerSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); FinancialYearSP spFinancialYear = new FinancialYearSP(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); for (int i = 0; i < inRowcount - 1; i++) { infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()); infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null) { infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); } else { infoAccountledger.OpeningBalance = 0; } infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null) { infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString(); } else { infoAccountledger.Narration = string.Empty; } infoAccountledger.MailingName = string.Empty; infoAccountledger.Address = string.Empty; infoAccountledger.State = string.Empty; infoAccountledger.Phone = string.Empty; infoAccountledger.Mobile = string.Empty; infoAccountledger.Email = string.Empty; infoAccountledger.CreditPeriod = 0; infoAccountledger.CreditLimit = 0; infoAccountledger.PricinglevelId = 0; infoAccountledger.BillByBill = false; infoAccountledger.Tin = string.Empty; infoAccountledger.Cst = string.Empty; infoAccountledger.Pan = string.Empty; infoAccountledger.RouteId = 0; infoAccountledger.BankAccountNumber = string.Empty; infoAccountledger.BranchName = string.Empty; infoAccountledger.BranchCode = string.Empty; infoAccountledger.Extra1 = string.Empty; infoAccountledger.Extra2 = string.Empty; infoAccountledger.AreaId = 0; infoAccountledger.IsDefault = false; decLedgerId = spAccountledger.AccountLedgerAddWithIdentity(infoAccountledger); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0") { if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty) { string strfinancialId; decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerId; infoLedgerPosting.VoucherNo = decLedgerId.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr") { infoLedgerPosting.Debit = decOpeningBalance; } else { infoLedgerPosting.Credit = decOpeningBalance; } infoLedgerPosting.DetailsId = 0; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = decLedgerId.ToString(); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } isSave = true; } if (isSave) { Messages.SavedMessage(); cmbAccountGroup.Focus(); cmbAccountGroup.SelectedIndex = -1; dgvMultipleAccountLedger.Rows.Clear(); } else { } } catch (Exception ex) { MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void LedgerPostingForDailySalary(decimal decid, string totalAmount, decimal decVoucherTypeId, string voucherNo, string date) { try { LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(totalAmount); infoLedgerPosting.VoucherTypeId = decVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Date = Convert.ToDateTime(date); infoLedgerPosting.LedgerId = decid; infoLedgerPosting.DetailsId = 0; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.Debit = Convert.ToDecimal(totalAmount); infoLedgerPosting.Credit = 0; infoLedgerPosting.VoucherTypeId = decVoucherTypeId; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = voucherNo; } infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = 4; infoLedgerPosting.DetailsId = 0; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = voucherNo; } infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } catch (Exception ex) { } }
public string EditDailySalaryVoucher(string dailyMasterId, string voucherTypeId, string voucherNo, string date, string salaryDate, string cash, string narration, string totalAmount, string details) { string message = string.Empty; try { DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo(); DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP(); DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo(); DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); infoMaster.DailySalaryVoucehrMasterId = Convert.ToDecimal(dailyMasterId); infoMaster.Date = Convert.ToDateTime(date); infoMaster.LedgerId = Convert.ToDecimal(cash); infoMaster.Narration = narration; infoMaster.TotalAmount = Convert.ToDecimal(totalAmount); infoMaster.VoucherNo = voucherNo; infoMaster.InvoiceNo = voucherNo; infoMaster.Extra1 = string.Empty; infoMaster.Extra2 = string.Empty; infoMaster.SuffixPrefixId = 0;//decDailySuffixPrefixId; infoMaster.VoucherTypeId = Convert.ToDecimal(voucherTypeId); infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaster.SalaryDate = Convert.ToDateTime(salaryDate); infoDetails.Extra1 = string.Empty; // Fields not in design// infoDetails.Extra2 = string.Empty; // Fields not in design// spMaster.DailySalaryVoucherMasterEdit(infoMaster); List <Dictionary <string, object> > detailsData = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(details); int inRowCount = detailsData.Count; for (int i = 0; i < inRowCount; i++) { if (detailsData[i]["employeeId"].GetType().Name != "JObject" && detailsData[i]["employeeId"].ToString() != string.Empty) { infoDetails.EmployeeId = Convert.ToDecimal(detailsData[i]["employeeId"].ToString()); } if (detailsData[i]["dailyWage"].GetType().Name != "JObject" && detailsData[i]["dailyWage"].ToString() != string.Empty) { infoDetails.Wage = Convert.ToDecimal(detailsData[i]["dailyWage"].ToString()); } if (detailsData[i]["status"].GetType().Name != "JObject" && detailsData[i]["status"].ToString() == "paid") { infoDetails.Status = detailsData[i]["status"].ToString(); } if (detailsData[i]["status"].ToString() == "pending" && detailsData[i]["masterId"].GetType().Name != "JObject") { decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(detailsData[i]["detailsId"].ToString()); spDetails.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId); LedgerUpdate(infoMaster); } else if (detailsData[i]["status"].ToString() == "pending" && detailsData[i]["masterId"].GetType().Name == "JObject") { spMaster.DailySalaryVoucherMasterEdit(infoMaster); LedgerUpdate(infoMaster); } else if (detailsData[i]["status"].ToString() == "paid" && detailsData[i]["masterId"].GetType().Name == "JObject") { infoDetails.DailySalaryVocherMasterId = infoMaster.DailySalaryVoucehrMasterId; spDetails.DailySalaryVoucherDetailsAdd(infoDetails); //spMaster.DailySalaryVoucherMasterEdit(infoMaster); LedgerUpdate(infoMaster); } } if (spDetails.DailySalaryVoucherDetailsCount(infoMaster.DailySalaryVoucehrMasterId) == 0) { spMaster.DailySalaryVoucherMasterDelete(infoMaster.DailySalaryVoucehrMasterId); } } catch (Exception ex) { message = ex.Message; } return(message); }