/// <summary> /// Function to Update values in MonthlySalaryVoucherDetails Table /// </summary> /// <param name="salaryvoucherdetailsinfo"></param> public void SalaryVoucherDetailsEdit(SalaryVoucherDetailsInfo salaryvoucherdetailsinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryVoucherDetailsEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryVoucherDetailsId", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.SalaryVoucherDetailsId; sprmparam = sccmd.Parameters.Add("@salaryVoucherMasterId", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.SalaryVoucherMasterId; sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.EmployeeId; sprmparam = sccmd.Parameters.Add("@bonus", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.Bonus; sprmparam = sccmd.Parameters.Add("@deduction", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.Deduction; sprmparam = sccmd.Parameters.Add("@advance", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.Advance; sprmparam = sccmd.Parameters.Add("@lop", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.Lop; sprmparam = sccmd.Parameters.Add("@salary", SqlDbType.Decimal); sprmparam.Value = salaryvoucherdetailsinfo.Salary; sprmparam = sccmd.Parameters.Add("@status", SqlDbType.VarChar); sprmparam.Value = salaryvoucherdetailsinfo.Status; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = salaryvoucherdetailsinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = salaryvoucherdetailsinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = salaryvoucherdetailsinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from MonthlySalaryVoucherDetails Table based on the parameter /// </summary> /// <param name="salaryVoucherDetailsId"></param> /// <returns></returns> public SalaryVoucherDetailsInfo SalaryVoucherDetailsView(decimal salaryVoucherDetailsId) { SalaryVoucherDetailsInfo salaryvoucherdetailsinfo = new SalaryVoucherDetailsInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryVoucherDetailsView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryVoucherDetailsId", SqlDbType.Decimal); sprmparam.Value = salaryVoucherDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { salaryvoucherdetailsinfo.SalaryVoucherDetailsId = decimal.Parse(sdrreader[0].ToString()); salaryvoucherdetailsinfo.SalaryVoucherMasterId = decimal.Parse(sdrreader[1].ToString()); salaryvoucherdetailsinfo.EmployeeId = decimal.Parse(sdrreader[2].ToString()); salaryvoucherdetailsinfo.Bonus = decimal.Parse(sdrreader[3].ToString()); salaryvoucherdetailsinfo.Deduction = decimal.Parse(sdrreader[4].ToString()); salaryvoucherdetailsinfo.Advance = decimal.Parse(sdrreader[5].ToString()); salaryvoucherdetailsinfo.Lop = decimal.Parse(sdrreader[6].ToString()); salaryvoucherdetailsinfo.Salary = decimal.Parse(sdrreader[7].ToString()); salaryvoucherdetailsinfo.Status = sdrreader[8].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(salaryvoucherdetailsinfo); }
/// <summary> /// Function for edit /// </summary> public void EditFunction() { try { SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP(); SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo(); SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP(); SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); infoMaster.SalaryVoucherMasterId = decIsEditModeMasterId; infoMaster.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString()); infoMaster.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString()); infoMaster.Narration = txtNarration.Text.Trim(); infoMaster.TotalAmount = Convert.ToDecimal(lblTotalAmount.Text.ToString()); if (isAutomatic) { infoMaster.VoucherNo = strVoucherNo; } else { infoMaster.VoucherNo = txtVoucherNo.Text; } if (isAutomatic) { infoMaster.InvoiceNo = strInvoiceNo; } else { infoMaster.InvoiceNo = txtVoucherNo.Text; } infoMaster.Extra1 = string.Empty; infoMaster.Extra2 = string.Empty; infoMaster.SuffixPrefixId = decMonthlySuffixPrefixId; infoMaster.VoucherTypeId = decMonthlyVoucherTypeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaster.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoDetails.Extra1 = string.Empty; infoDetails.Extra2 = string.Empty; int inRowCount = dgvMonthlySalary.RowCount; for (int i = 0; i < inRowCount; i++) { if (dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty) { infoDetails.EmployeeId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString() != string.Empty) { infoDetails.Bonus = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString() != string.Empty) { infoDetails.Deduction = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString() != string.Empty) { infoDetails.Advance = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtLop"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString() != string.Empty) { infoDetails.Lop = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString() != string.Empty) { infoDetails.Salary = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value != null && dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty) { infoDetails.Status = dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString(); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() != "0") { decimal SalaryVoucherDetailsId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDetailsId"].Value.ToString()); spDetails.SalaryVoucherDetailsDelete(SalaryVoucherDetailsId); spMaster.SalaryVoucherMasterEdit(infoMaster); LedgerUpdate(); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid" && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0") { infoDetails.SalaryVoucherMasterId = decIsEditModeMasterId; spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails); spMaster.SalaryVoucherMasterEdit(infoMaster); LedgerUpdate(); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0") { spMaster.SalaryVoucherMasterEdit(infoMaster); LedgerUpdate(); } } if (spDetails.SalaryVoucherDetailsCount(decIsEditModeMasterId) == 0) { spMaster.SalaryVoucherMasterDelete(decIsEditModeMasterId); } Messages.UpdatedMessage(); GridFill(isEditMode); if (frmMonthlySalaryRegisterObj != null) { this.Close(); } if (frmLedgerDetailsObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("MSV8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save /// </summary> public void SaveFunction() { try { SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP(); SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo(); SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP(); SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo(); //------------------------------- In the case of multi user check whether salary is paying for the sam person ----------------// int inCounts = dgvMonthlySalary.RowCount; int incont = 0; decimal decVal = 0; for (int i = 0; i < inCounts; i++) { decVal = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString()); if (spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) != "0") { strEployeeNames = strEployeeNames + spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) + ","; foreach (char ch in strEployeeNames) { if (ch == ',') { incont++; } } if (incont == 15) { incont = 0; strEployeeNames = strEployeeNames + Environment.NewLine; } } } if (spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) != "0") { Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames); GridFill(isEditMode); } infoMaster.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString()); if (isAutomatic) { infoMaster.VoucherNo = strVoucherNo; } else { infoMaster.VoucherNo = txtVoucherNo.Text; } infoMaster.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoMaster.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString()); infoMaster.Narration = txtNarration.Text.Trim(); if (isAutomatic) { infoMaster.InvoiceNo = strInvoiceNo; } else { infoMaster.InvoiceNo = txtVoucherNo.Text; } if (lblTotalAmount.Text.ToString() != string.Empty) { infoMaster.TotalAmount = Math.Round(Convert.ToDecimal(lblTotalAmount.Text.ToString()), PublicVariables._inNoOfDecimalPlaces); } infoMaster.Extra1 = string.Empty; // Fields not in design// infoMaster.Extra2 = string.Empty; // Fields not in design// infoMaster.SuffixPrefixId = decMonthlySuffixPrefixId; infoMaster.VoucherTypeId = decMonthlyVoucherTypeId; infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; int inCount = dgvMonthlySalary.RowCount; int inValue = 0; for (int i = 0; i < inCount; i++) { if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid") { inValue++; } } if (inValue > 0) { //-------------------------In the case of Multi-User Check the VoucherNo. again (Max of VoucherNumber )---------------------// DataTable dtbl = new DataTable(); dtbl = spMaster.MonthlySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic); 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 = txtVoucherNo.Text; } if (isAutomatic) { if (strUpdatedVoucherNo != "" && Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo)) { Messages.InformationMessage("Voucher number changed from " + strInvoiceNo + " to " + strUpdatedInvoiceNo); strVoucherNo = strUpdatedVoucherNo.ToString(); strInvoiceNo = strUpdatedInvoiceNo; } } LedgerPosting(Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString())); infoDetails.Extra1 = string.Empty; infoDetails.Extra2 = string.Empty; infoDetails.SalaryVoucherMasterId = decMasterId; int inRowCount = dgvMonthlySalary.RowCount; for (int i = 0; i < inRowCount; i++) { if (dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty) { infoDetails.EmployeeId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString() != string.Empty) { infoDetails.Bonus = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString() != string.Empty) { infoDetails.Deduction = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString() != string.Empty) { infoDetails.Advance = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtLop"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString() != string.Empty) { infoDetails.Lop = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString() != string.Empty) { infoDetails.Salary = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString()); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value != null && dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty) { infoDetails.Status = dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString(); } if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid" && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0") { infoDetails.SalaryVoucherMasterId = decMasterId; spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails); } } Messages.SavedMessage(); GridFill(isEditMode); Clear(); } else { Messages.InformationMessage("Can't save without atleast one employee"); strVoucherNo = spMaster.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId); } } catch (Exception ex) { MessageBox.Show("MSV7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from MonthlySalaryVoucherDetails Table based on the parameter /// </summary> /// <param name="salaryVoucherDetailsId"></param> /// <returns></returns> public SalaryVoucherDetailsInfo SalaryVoucherDetailsView(decimal salaryVoucherDetailsId) { SalaryVoucherDetailsInfo salaryvoucherdetailsinfo = new SalaryVoucherDetailsInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryVoucherDetailsView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryVoucherDetailsId", SqlDbType.Decimal); sprmparam.Value = salaryVoucherDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { salaryvoucherdetailsinfo.SalaryVoucherDetailsId = decimal.Parse(sdrreader[0].ToString()); salaryvoucherdetailsinfo.SalaryVoucherMasterId = decimal.Parse(sdrreader[1].ToString()); salaryvoucherdetailsinfo.EmployeeId = decimal.Parse(sdrreader[2].ToString()); salaryvoucherdetailsinfo.Bonus = decimal.Parse(sdrreader[3].ToString()); salaryvoucherdetailsinfo.Deduction = decimal.Parse(sdrreader[4].ToString()); salaryvoucherdetailsinfo.Advance = decimal.Parse(sdrreader[5].ToString()); salaryvoucherdetailsinfo.Lop = decimal.Parse(sdrreader[6].ToString()); salaryvoucherdetailsinfo.Salary = decimal.Parse(sdrreader[7].ToString()); salaryvoucherdetailsinfo.Status = sdrreader[8].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return salaryvoucherdetailsinfo; }