/// <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 void DailySalaryVoucherMasterEdit(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo) { try { SpMaster.DailySalaryVoucherMasterEdit(dailysalaryvouchermasterinfo); } catch (Exception ex) { MessageBox.Show("BR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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 } })); }
/// <summary> /// Function to insert values to DailySalaryVoucherMaster Table and return the Curresponding row's Id /// </summary> /// <param name="dailysalaryvouchermasterinfo"></param> /// <param name="IsAutomatic"></param> /// <returns></returns> public List <DataTable> DailySalaryVoucherMasterAddWithIdentity(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo, bool IsAutomatic) { List <DataTable> listObj = new List <DataTable>(); try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } DataTable dtbl = new DataTable(); SqlDataAdapter sqlda = new SqlDataAdapter("DailySalaryVoucherMasterAddWithIdentity", sqlcon); sqlda.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = dailysalaryvouchermasterinfo.LedgerId; sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = dailysalaryvouchermasterinfo.VoucherNo; sprmparam = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = dailysalaryvouchermasterinfo.InvoiceNo; sprmparam = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = dailysalaryvouchermasterinfo.Date; sprmparam = sqlda.SelectCommand.Parameters.Add("@salaryDate", SqlDbType.DateTime); sprmparam.Value = dailysalaryvouchermasterinfo.SalaryDate; sprmparam = sqlda.SelectCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = dailysalaryvouchermasterinfo.TotalAmount; sprmparam = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = dailysalaryvouchermasterinfo.Narration; sprmparam = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = dailysalaryvouchermasterinfo.Extra1; sprmparam = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = dailysalaryvouchermasterinfo.Extra2; sprmparam = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = dailysalaryvouchermasterinfo.SuffixPrefixId; sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = dailysalaryvouchermasterinfo.VoucherTypeId; sprmparam = sqlda.SelectCommand.Parameters.Add("@isAutomatic", SqlDbType.Bit); sprmparam.Value = IsAutomatic; sprmparam = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = dailysalaryvouchermasterinfo.FinancialYearId; sqlda.Fill(dtbl); listObj.Add(dtbl); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(listObj); }
public List <DataTable> DailySalaryVoucherMasterAddWithIdentity(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo, bool IsAutomatic) { DailyAttendanceDetailsSP spDailyAttendanceDetails = new DailyAttendanceDetailsSP(); try { return(SpMaster.DailySalaryVoucherMasterAddWithIdentity(dailysalaryvouchermasterinfo, IsAutomatic)); } catch (Exception) { throw; } }
public void DailySalaryVoucherMasterAdd(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterAdd", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam15 = new SqlParameter(); sprmparam15 = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId; sprmparam15 = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.LedgerId; sprmparam15 = sccmd.Parameters.Add("@voucherNumber", SqlDbType.VarChar); sprmparam15.Value = dailysalaryvouchermasterinfo.VoucherNo; sprmparam15 = sccmd.Parameters.Add("@invoiceNumber", SqlDbType.VarChar); sprmparam15.Value = dailysalaryvouchermasterinfo.InvoiceNo; sprmparam15 = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam15.Value = dailysalaryvouchermasterinfo.Date; sprmparam15 = sccmd.Parameters.Add("@salaryDate", SqlDbType.DateTime); sprmparam15.Value = dailysalaryvouchermasterinfo.SalaryDate; sprmparam15 = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.TotalAmount; sprmparam15 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam15.Value = dailysalaryvouchermasterinfo.Narration; sprmparam15 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam15.Value = dailysalaryvouchermasterinfo.ExtraDate; sprmparam15 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam15.Value = dailysalaryvouchermasterinfo.Extra1; sprmparam15 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam15.Value = dailysalaryvouchermasterinfo.Extra2; sprmparam15 = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.SuffixPrefixId; sprmparam15 = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.VoucherTypeId; sprmparam15 = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam15.Value = dailysalaryvouchermasterinfo.FinancialYearId; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
public List <DataTable> DailySalaryVoucherMasterAddWithIdentity(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo, bool IsAutomatic) { List <DataTable> listObj = new List <DataTable>(); try { listObj = SpDailySalaryVoucherMaster.DailySalaryVoucherMasterAddWithIdentity(dailysalaryvouchermasterinfo, IsAutomatic); } catch (Exception ex) { MessageBox.Show("DSV11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(listObj); }
public DailySalaryVoucherMasterInfo DailySalaryVoucherViewFromRegister(decimal decDailySalaryVoucehrMasterId) { DailySalaryVoucherMasterInfo infoDailySalaryVoucherMaster = new DailySalaryVoucherMasterInfo(); try { infoDailySalaryVoucherMaster = SpDailySalaryVoucherMaster.DailySalaryVoucherViewFromRegister(decDailySalaryVoucehrMasterId); } catch (Exception ex) { MessageBox.Show("DSV9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoDailySalaryVoucherMaster); }
public DailySalaryVoucherMasterInfo DailySalaryVoucherMasterView(decimal dailySalaryVoucehrMasterId) { DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo = new DailySalaryVoucherMasterInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal); sprmparam2.Value = dailySalaryVoucehrMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString()); dailysalaryvouchermasterinfo.LedgerId = decimal.Parse(((DbDataReader)sdrreader)[1].ToString()); dailysalaryvouchermasterinfo.VoucherNo = ((DbDataReader)sdrreader)[2].ToString(); dailysalaryvouchermasterinfo.InvoiceNo = ((DbDataReader)sdrreader)[3].ToString(); dailysalaryvouchermasterinfo.Date = DateTime.Parse(((DbDataReader)sdrreader)[4].ToString()); dailysalaryvouchermasterinfo.SalaryDate = DateTime.Parse(((DbDataReader)sdrreader)[5].ToString()); dailysalaryvouchermasterinfo.TotalAmount = decimal.Parse(((DbDataReader)sdrreader)[6].ToString()); dailysalaryvouchermasterinfo.Narration = ((DbDataReader)sdrreader)[7].ToString(); dailysalaryvouchermasterinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)[8].ToString()); dailysalaryvouchermasterinfo.Extra1 = ((DbDataReader)sdrreader)[9].ToString(); dailysalaryvouchermasterinfo.Extra2 = ((DbDataReader)sdrreader)[10].ToString(); dailysalaryvouchermasterinfo.SuffixPrefixId = decimal.Parse(((DbDataReader)sdrreader)[11].ToString()); dailysalaryvouchermasterinfo.VoucherTypeId = decimal.Parse(((DbDataReader)sdrreader)[12].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(dailysalaryvouchermasterinfo); }
public DailySalaryVoucherMasterInfo DailySalaryVoucherViewFromRegister(decimal decDailySalaryVoucehrMasterId) { DailySalaryVoucherMasterInfo infoDailySalaryVoucherMaster = new DailySalaryVoucherMasterInfo(); SqlDataReader sqldr = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("DailySalaryVoucherViewFromRegister", base.sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal).Value = decDailySalaryVoucehrMasterId; sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { infoDailySalaryVoucherMaster.Date = Convert.ToDateTime(((DbDataReader)sqldr)["date"].ToString()); infoDailySalaryVoucherMaster.VoucherNo = ((DbDataReader)sqldr)["voucherNo"].ToString(); infoDailySalaryVoucherMaster.InvoiceNo = ((DbDataReader)sqldr)["invoiceNo"].ToString(); infoDailySalaryVoucherMaster.SalaryDate = Convert.ToDateTime(((DbDataReader)sqldr)["salaryDate"].ToString()); infoDailySalaryVoucherMaster.LedgerId = Convert.ToDecimal(((DbDataReader)sqldr)["ledgerId"].ToString()); infoDailySalaryVoucherMaster.TotalAmount = Convert.ToDecimal(((DbDataReader)sqldr)["totalAmount"].ToString()); infoDailySalaryVoucherMaster.Narration = ((DbDataReader)sqldr)["narration"].ToString(); infoDailySalaryVoucherMaster.VoucherTypeId = Convert.ToDecimal(((DbDataReader)sqldr)["voucherTypeId"].ToString()); infoDailySalaryVoucherMaster.SuffixPrefixId = Convert.ToDecimal(((DbDataReader)sqldr)["suffixPrefixId"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqldr.Close(); base.sqlcon.Close(); } return(infoDailySalaryVoucherMaster); }
/// <summary> /// Function to Save /// </summary> public void SaveFunction() { try { DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo(); DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll(); DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo(); DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll(); //-------------In multi user case check whether salary is paying for the same persone--------------// int inCounts = dgvDailySalaryVoucher.RowCount; int incont = 0; decimal decVal = 0; for (int i = 0; i < inCounts; i++) { decVal = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString()); if (BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0") { strEployeeNames = strEployeeNames + BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) + ","; foreach (char ch in strEployeeNames) { if (ch == ',') { incont++; } } if (incont == 15) { incont = 0; strEployeeNames = strEployeeNames + Environment.NewLine; } } } if (BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0") { Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames); DailySalaryVoucherDetailsGridfill(isEditmode); } else { if (isAutomatic) { infoMaster.VoucherNo = strVoucherNo; } else { infoMaster.VoucherNo = txtVoucherNo.Text.Trim(); } infoMaster.Date = DateTime.Parse(dtpDate.Text.ToString()); infoMaster.SalaryDate = DateTime.Parse(dtpSalaryDate.Text.ToString()); infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString()); infoMaster.Narration = txtNarration.Text.Trim(); infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString()); infoMaster.Extra1 = string.Empty; // Fields not in design// infoMaster.Extra2 = string.Empty; // Fields not in design// if (isAutomatic) { infoMaster.InvoiceNo = strInvoiceNo; } else { infoMaster.InvoiceNo = txtVoucherNo.Text.Trim(); } infoMaster.SuffixPrefixId = decDailySuffixPrefixId; infoMaster.VoucherTypeId = decDailyVoucherTypeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; int inval = 0; int inCount = dgvDailySalaryVoucher.RowCount; for (int i = 0; i < inCount; i++) { if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid") { inval++; } } if (inval >= 0) { //-------------checks Voucher No. repeating in Multi user case----------// List<DataTable> listObj = new List<DataTable>(); listObj = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic); foreach (DataRow dr in listObj[0].Rows) { decMasterId = Convert.ToDecimal(dr.ItemArray[0].ToString()); strUpdatedVoucherNo = dr.ItemArray[1].ToString(); strUpdatedInvoiceNo = dr.ItemArray[2].ToString(); } if (!isAutomatic) { strVoucherNo = txtVoucherNo.Text; } if (isAutomatic) { if (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo)) { Messages.InformationMessage("Voucher number changed from " + strInvoiceNo + " to " + strUpdatedInvoiceNo); strVoucherNo = strUpdatedVoucherNo.ToString(); strInvoiceNo = strUpdatedInvoiceNo; } } //-------------------------------------// LedgerPosting(Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString())); infoDetails.DailySalaryVocherMasterId = decMasterId; infoDetails.Extra1 = string.Empty;// Fields not in design// infoDetails.Extra2 = string.Empty;// Fields not in design// int inRowCount = dgvDailySalaryVoucher.RowCount; for (int i = 0; i < inRowCount; i++) { if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty) { infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString()); } if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty) { infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString()); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty) { infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString(); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty) { infoDetails.DailySalaryVocherMasterId = decMasterId; BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails); } } Messages.SavedMessage(); DailySalaryVoucherDetailsGridfill(isEditmode); Clear(); } else { strVoucherNo = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId); Messages.InformationMessage("Can't save without atleast one employee"); Clear(); } } } catch (Exception ex) { MessageBox.Show("DSV11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill controls for updation /// </summary> public void fillFunction() { try { DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll(); DailySalaryVoucherMasterInfo InfoMaster = new DailySalaryVoucherMasterInfo(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); InfoMaster = BllDailySalaryVoucherMaster.DailySalaryVoucherViewFromRegister(decMasterIdforEdit); strVoucherNoforEdit = InfoMaster.VoucherNo; strVoucherNo = InfoMaster.VoucherNo; txtVoucherNo.Text = InfoMaster.InvoiceNo; strInvoiceNo = InfoMaster.InvoiceNo; dtpDate.Text = InfoMaster.Date.ToString(); dtpSalaryDate.Text = InfoMaster.SalaryDate.ToString(); lblShowTotelamount.Text = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString("0.00000")), PublicVariables._inNoOfDecimalPlaces).ToString(); txtNarration.Text = InfoMaster.Narration; decDailySuffixPrefixId = InfoMaster.SuffixPrefixId; decDailyVoucherTypeId = InfoMaster.VoucherTypeId; cmbCashorBankAccount.SelectedValue = InfoMaster.LedgerId.ToString(); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId); if (isAutomatic) { txtVoucherNo.Enabled = false; } else { txtVoucherNo.Enabled = true; } dtpSalaryDate.Enabled = false; txtSalaryDate.Enabled = false; DailySalaryVoucherDetailsGridfill(isEditmode); } catch (Exception ex) { MessageBox.Show("DSV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Edit /// </summary> public void EditFunction() { try { DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo(); DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll(); DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo(); DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); infoMaster.DailySalaryVoucehrMasterId = decMasterIdforEdit; infoMaster.Date = Convert.ToDateTime(dtpDate.Value.ToString()); infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString()); infoMaster.Narration = txtNarration.Text; infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString()); if (isAutomatic) { infoMaster.VoucherNo = strVoucherNo; } else { infoMaster.VoucherNo = txtVoucherNo.Text.Trim(); } if (isAutomatic) { infoMaster.InvoiceNo = strInvoiceNo; } else { infoMaster.InvoiceNo = txtVoucherNo.Text.Trim(); } infoMaster.Extra1 = string.Empty; infoMaster.Extra2 = string.Empty; infoMaster.SuffixPrefixId = decDailySuffixPrefixId; infoMaster.VoucherTypeId = decDailyVoucherTypeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaster.SalaryDate = Convert.ToDateTime(dtpSalaryDate.Text.ToString()); infoDetails.Extra1 = string.Empty;// Fields not in design// infoDetails.Extra2 = string.Empty;// Fields not in design// BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster); int inRowCount = dgvDailySalaryVoucher.RowCount; for (int i = 0; i < inRowCount; i++) { if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty) { infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString()); } if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty) { infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString()); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty) { infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString(); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() != string.Empty) { decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtdailySalaryVoucherDetailsId"].Value.ToString()); BllDailySalaryVoucher.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId); LedgerUpdate(); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty) { infoDetails.DailySalaryVocherMasterId = decMasterIdforEdit; BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails); //spMaster.DailySalaryVoucherMasterEdit(infoMaster); LedgerUpdate(); } if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty) { BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster); LedgerUpdate(); } } if (BllDailySalaryVoucher.DailySalaryVoucherDetailsCount(decMasterIdforEdit) == 0) { BllDailySalaryVoucherMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit); } Messages.UpdatedMessage(); Clear(); if (frmDailySalaryRegisterobj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("DSV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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); }