/// <summary> /// Function to insert values to SalaryPackage Table /// </summary> /// <param name="salarypackageinfo"></param> /// <returns></returns> public decimal SalaryPackageAdd(SalaryPackageInfo salarypackageinfo) { decimal decIdentity = -1; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryPackageWithRetunIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryPackageName", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.SalaryPackageName; sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit); sprmparam.Value = salarypackageinfo.IsActive; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Narration; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = salarypackageinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra2; object obj = sccmd.ExecuteScalar(); if (obj != null) { decIdentity = Convert.ToDecimal(obj.ToString()); } else { decIdentity = -1; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decIdentity); }
/// <summary> /// Function to insert values to SalaryPackage Table /// </summary> /// <param name="salarypackageinfo"></param> /// <returns></returns> public decimal SalaryPackageAdd(SalaryPackageInfo salarypackageinfo) { decimal decIdentity = -1; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryPackageWithRetunIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryPackageName", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.SalaryPackageName; sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit); sprmparam.Value = salarypackageinfo.IsActive; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Narration; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = salarypackageinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra2; object obj = sccmd.ExecuteScalar(); if (obj != null) { decIdentity = Convert.ToDecimal(obj.ToString()); } else { decIdentity = -1; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decIdentity; }
/// <summary> /// Function to call this form from frmSalaryPackageRegister for updation /// </summary> /// <param name="decSalaryPackageIdFromRegister"></param> /// <param name="frm"></param> public void CallFromSalaryPackageRegister(decimal decSalaryPackageIdFromRegister, frmSalaryPackageRegister frm) { try { frmSalaryPackageRegisterObj = frm; DataTable dtblSalaryPackageDetails = new DataTable(); infoSalaryPackage = spSalaryPackage.SalaryPackageView(decSalaryPackageIdFromRegister); decSalaryPackageId = infoSalaryPackage.SalaryPackageId; txtPackageName.Text = infoSalaryPackage.SalaryPackageName; strSalaryPackageName = infoSalaryPackage.SalaryPackageName; txtNarration.Text = infoSalaryPackage.Narration; dtblSalaryPackageDetails = spSalarypackageDetails.SalaryPackageDetailsViewWithSalaryPackageId(decSalaryPackageIdFromRegister); foreach (DataRow dtblRow in dtblSalaryPackageDetails.Rows) { if (dtblRow != null) { dgvSalaryPackage.Rows.Add(); dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtSlNo"].Value = dtblRow["SL.NO"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvcmbPayHead"].Value = dtblRow["payHeadId"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtAmount"].Value = dtblRow["amount"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtStatus"].Value = "Complete"; } } btnSave.Text = "Update"; btnDelete.Enabled = true; base.Show(); if (infoSalaryPackage.IsActive) { cmbActive.SelectedIndex = 0; } else { cmbActive.SelectedIndex = 1; } } catch (Exception ex) { formMDI.infoError.ErrorString = "SPC3:" + ex.Message; } }
/// <summary> /// Function to get particular values from SalaryPackage table based on the parameter /// </summary> /// <param name="salaryPackageId"></param> /// <returns></returns> public SalaryPackageInfo SalaryPackageView(decimal salaryPackageId) { SalaryPackageInfo salarypackageinfo = new SalaryPackageInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryPackageView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryPackageId", SqlDbType.Decimal); sprmparam.Value = salaryPackageId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { salarypackageinfo.SalaryPackageId = Convert.ToDecimal(sdrreader[0].ToString()); salarypackageinfo.SalaryPackageName = sdrreader[1].ToString(); salarypackageinfo.IsActive = Convert.ToBoolean(sdrreader[2].ToString()); salarypackageinfo.Narration = sdrreader[3].ToString(); salarypackageinfo.Extra1 = sdrreader[4].ToString(); salarypackageinfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(salarypackageinfo); }
/// <summary> /// Function to Update values in SalaryPackage Table /// </summary> /// <param name="salarypackageinfo"></param> public void SalaryPackageEdit(SalaryPackageInfo salarypackageinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryPackageEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryPackageId", SqlDbType.Decimal); sprmparam.Value = salarypackageinfo.SalaryPackageId; sprmparam = sccmd.Parameters.Add("@salaryPackageName", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.SalaryPackageName; sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit); sprmparam.Value = salarypackageinfo.IsActive; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Narration; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = salarypackageinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = salarypackageinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to call this form from frmSalaryPackageRegister for updation /// </summary> /// <param name="decSalaryPackageIdFromRegister"></param> /// <param name="frm"></param> public void CallFromSalaryPackageRegister(decimal decSalaryPackageIdFromRegister, frmSalaryPackageRegister frm) { try { frmSalaryPackageRegisterObj = frm; DataTable dtblSalaryPackageDetails = new DataTable(); infoSalaryPackage = spSalaryPackage.SalaryPackageView(decSalaryPackageIdFromRegister); decSalaryPackageId = infoSalaryPackage.SalaryPackageId; txtPackageName.Text = infoSalaryPackage.SalaryPackageName; strSalaryPackageName = infoSalaryPackage.SalaryPackageName; txtNarration.Text = infoSalaryPackage.Narration; dtblSalaryPackageDetails = spSalarypackageDetails.SalaryPackageDetailsViewWithSalaryPackageId(decSalaryPackageIdFromRegister); foreach (DataRow dtblRow in dtblSalaryPackageDetails.Rows) { if (dtblRow != null) { dgvSalaryPackage.Rows.Add(); dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtSlNo"].Value = dtblRow["SL.NO"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvcmbPayHead"].Value = dtblRow["payHeadId"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtAmount"].Value = dtblRow["amount"]; dgvSalaryPackage.Rows[dgvSalaryPackage.NewRowIndex - 1].Cells["dgvtxtStatus"].Value = "Complete"; } } btnSave.Text = "Update"; btnDelete.Enabled = true; base.Show(); if (infoSalaryPackage.IsActive) { cmbActive.SelectedIndex = 0; } else { cmbActive.SelectedIndex = 1; } } catch (Exception ex) { MessageBox.Show("SPC2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from SalaryPackage table based on the parameter /// </summary> /// <param name="salaryPackageId"></param> /// <returns></returns> public SalaryPackageInfo SalaryPackageView(decimal salaryPackageId) { SalaryPackageInfo salarypackageinfo = new SalaryPackageInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalaryPackageView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salaryPackageId", SqlDbType.Decimal); sprmparam.Value = salaryPackageId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { salarypackageinfo.SalaryPackageId = Convert.ToDecimal(sdrreader[0].ToString()); salarypackageinfo.SalaryPackageName = sdrreader[1].ToString(); salarypackageinfo.IsActive = Convert.ToBoolean(sdrreader[2].ToString()); salarypackageinfo.Narration = sdrreader[3].ToString(); salarypackageinfo.Extra1 = sdrreader[4].ToString(); salarypackageinfo.Extra2 = sdrreader[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return salarypackageinfo; }