public JsonResult GetDailySalaryVoucher(string dailySalaryMasterId) { bool isSuccess = true; string message = "success"; string jsonResults = ""; string jsonCombo = ""; DailySalaryVoucherMasterInfo info = new DailySalaryVoucherMasterInfo(); bool isAutomatic = false; try { DailySalaryVoucherMasterSP SpMaster = new DailySalaryVoucherMasterSP(); VoucherTypeSP spVoucherType = new VoucherTypeSP(); DataTable dtbl = new DataTable(); DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP(); int nDailySalaryMasterId = int.Parse(dailySalaryMasterId); info = SpMaster.DailySalaryVoucherViewFromRegister(nDailySalaryMasterId); info.DailySalaryVoucehrMasterId = nDailySalaryMasterId; isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(info.VoucherTypeId); bool isEditMode = nDailySalaryMasterId > 0 ? true : false; dtbl = spDetails.DailySalaryVoucherDetailsGridViewAll(info.SalaryDate.ToString(), isEditMode, info.VoucherNo); jsonResults = Utils.ConvertDataTabletoString(dtbl); DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP(); DataTable newDtbl = new DataTable(); newDtbl = spMaster.DailySalaryVoucherCashOrBankLedgersComboFill(); jsonCombo = Utils.ConvertDataTabletoString(newDtbl); } catch (Exception ex) { isSuccess = false; message = ex.Message; } return(Json(new { isSuccess = isSuccess, message = message, data = new { dailySalaryMasterId = info.DailySalaryVoucehrMasterId, voucherNo = info.VoucherNo, invoiceNo = info.InvoiceNo, date = info.Date.ToString("yyyy-MM-dd"), salaryDate = info.SalaryDate.ToString("yyyy-MM-dd"), totalAmount = info.TotalAmount, narration = info.Narration, suffixPrefixId = info.SuffixPrefixId, voucherTypeId = info.VoucherTypeId, ledgerId = info.LedgerId, jsonDetails = jsonResults, jsonCombo = jsonCombo } })); }
public DataTable DailySalaryVoucherDetailsGridfill(bool @isEditmode, string voucherNo, string salaryDate) { DataTable dtbl = new DataTable(); try { DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP(); dtbl = spDetails.DailySalaryVoucherDetailsGridViewAll(salaryDate, isEditmode, voucherNo); } catch (Exception ex) { } return(dtbl); }
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 string SaveDailySalaryVoucher(string dailyMasterId, string voucherTypeId, string voucherNo, string date, string salaryDate, string cash, string narration, string totalAmount, string details) { string message = string.Empty; try { decimal decDailyVoucherTypeId = 0; VoucherTypeSP spVoucherType = new VoucherTypeSP(); DataTable dtblVouchetType = new DataTable(); dtblVouchetType = spVoucherType.VoucherTypeSelectionComboFill("Daily Salary Voucher"); int nCount = dtblVouchetType.Rows.Count; string voucherType = string.Empty; if (nCount == 1) { voucherType = dtblVouchetType.Rows[0].ItemArray[0].ToString(); decDailyVoucherTypeId = decimal.Parse(voucherType); } string strEployeeNames = string.Empty; DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo(); DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP(); DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo(); DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP(); //-------------In multi user case check whether salary is paying for the same persone--------------// List <Dictionary <string, object> > detailsData = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(details); int inCounts = detailsData.Count; int incont = 0; decimal decVal = 0; DateTime dtSalaryDate = Convert.ToDateTime(salaryDate); for (int i = 0; i < inCounts; i++) { decVal = Convert.ToDecimal(detailsData[i]["employeeId"].ToString()); if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) != "0") { strEployeeNames = strEployeeNames + spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) + ","; foreach (char ch in strEployeeNames) { if (ch == ',') { incont++; } } if (incont == 15) { incont = 0; strEployeeNames = strEployeeNames + Environment.NewLine; } } } if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) != "0") { message = "Salary already paid for - " + " " + strEployeeNames; } else { DateTime dtDate = Convert.ToDateTime(date); if (isAutomatic) { infoMaster.VoucherNo = strVoucherNo; } else { infoMaster.VoucherNo = voucherNo; } infoMaster.Date = dtDate; infoMaster.SalaryDate = dtSalaryDate; infoMaster.LedgerId = Convert.ToDecimal(cash); infoMaster.Narration = narration ?? string.Empty; infoMaster.TotalAmount = Convert.ToDecimal(totalAmount); infoMaster.Extra1 = string.Empty; // Fields not in design// infoMaster.Extra2 = string.Empty; // Fields not in design// if (isAutomatic) { infoMaster.InvoiceNo = strInvoiceNo; } else { infoMaster.InvoiceNo = voucherNo; } infoMaster.SuffixPrefixId = 0;//decDailySuffixPrefixId; infoMaster.VoucherTypeId = decDailyVoucherTypeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; int inval = 0; int inCount = detailsData.Count; for (int i = 0; i < inCount; i++) { if (detailsData[i]["status"].ToString() == "paid") { inval++; } } if (inval >= 0) { decimal decMasterId = 0; string strUpdatedVoucherNo = string.Empty; string strUpdatedInvoiceNo = string.Empty; //-------------checks Voucher No. repeating in Multi user case----------// DataTable dtbl = new DataTable(); dtbl = spMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, true); foreach (DataRow dr in dtbl.Rows) { decMasterId = Convert.ToDecimal(dr.ItemArray[0].ToString()); strUpdatedVoucherNo = dr.ItemArray[1].ToString(); strUpdatedInvoiceNo = dr.ItemArray[2].ToString(); } if (!isAutomatic) { strVoucherNo = voucherNo; } if (isAutomatic) { if (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo)) { message = "Voucher number changed from " + strInvoiceNo + " to " + strUpdatedInvoiceNo; strVoucherNo = strUpdatedVoucherNo.ToString(); strInvoiceNo = strUpdatedInvoiceNo; } } //-------------------------------------// LedgerPostingForDailySalary(Convert.ToDecimal(cash), totalAmount, decDailyVoucherTypeId, voucherNo, date); infoDetails.DailySalaryVocherMasterId = decMasterId; infoDetails.Extra1 = string.Empty; // Fields not in design// infoDetails.Extra2 = string.Empty; // Fields not in design// 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() == "paid" && detailsData[i]["masterId"].ToString() == string.Empty) { infoDetails.DailySalaryVocherMasterId = decMasterId; spDetails.DailySalaryVoucherDetailsAdd(infoDetails); } } } else { strVoucherNo = spMaster.DailySalaryVoucherMasterGetMax(Convert.ToDecimal(decDailyVoucherTypeId)); message = "Can't save without at least one employee"; } } } catch (Exception ex) { message = "DSV11:" + ex.Message; } return(message); }
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); }