/// <summary> /// Function to Update values in Designation Table /// </summary> /// <param name="designationinfo"></param> /// <returns></returns> public bool DesignationEdit(DesignationInfo designationinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DesignationEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@designationId", SqlDbType.Decimal); sprmparam.Value = designationinfo.DesignationId; sprmparam = sccmd.Parameters.Add("@designationName", SqlDbType.VarChar); sprmparam.Value = designationinfo.DesignationName; sprmparam = sccmd.Parameters.Add("@leaveDays", SqlDbType.Decimal); sprmparam.Value = designationinfo.LeaveDays; sprmparam = sccmd.Parameters.Add("@advanceAmount", SqlDbType.Decimal); sprmparam.Value = designationinfo.AdvanceAmount; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = designationinfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = designationinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = designationinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = designationinfo.Extra2; int inEffectedRow = sccmd.ExecuteNonQuery(); if (inEffectedRow > 0) { return(true); } else { return(false); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } finally { sqlcon.Close(); } }
/// <summary> /// Function for save /// </summary> private void SaveFunction() { try { DesignationInfo infoDesignation = new DesignationInfo(); DesignationSP spDesignation = new DesignationSP(); if (txtAdvanceAmount.Text == string.Empty) { infoDesignation.AdvanceAmount = 0; } else { infoDesignation.AdvanceAmount = Convert.ToDecimal(txtAdvanceAmount.Text.Trim()); } infoDesignation.DesignationName = txtDesignationName.Text.Trim(); if (txtCLInMonth.Text == string.Empty) { infoDesignation.LeaveDays = 0; } else { infoDesignation.LeaveDays = Convert.ToDecimal(txtCLInMonth.Text.Trim()); } decimal decD = infoDesignation.LeaveDays; infoDesignation.Narration = txtNarration.Text.Trim(); infoDesignation.Extra1 = string.Empty; infoDesignation.Extra2 = string.Empty; infoDesignation.ExtraDate = DateTime.Now; if (CheckExistanceOfDesignation(txtDesignationName.Text.Trim(), 0) == false) { decIdentity = spDesignation.DesignationAddWithReturnIdentity(infoDesignation); if (decIdentity > 0) { Messages.SavedMessage(); } } else { Messages.InformationMessage("Designation already exist"); } } catch (Exception ex) { MessageBox.Show("D8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Edit /// </summary> private void EditFunction() { try { DesignationInfo infoDesignation = new DesignationInfo(); DesignationSP spDesignation = new DesignationSP(); if (txtAdvanceAmount.Text == string.Empty) { infoDesignation.AdvanceAmount = 0; } else { infoDesignation.AdvanceAmount = Convert.ToDecimal(txtAdvanceAmount.Text.Trim()); } infoDesignation.DesignationName = txtDesignationName.Text.TrimEnd(); if (txtCLInMonth.Text == string.Empty) { infoDesignation.LeaveDays = 0; } else { infoDesignation.LeaveDays = Convert.ToDecimal(txtCLInMonth.Text.Trim()); } infoDesignation.Narration = txtNarration.Text.Trim(); infoDesignation.Extra1 = string.Empty; infoDesignation.Extra2 = string.Empty; infoDesignation.ExtraDate = DateTime.Now; if (CheckExistanceOfDesignation(txtDesignationName.Text.Trim(), decDesignationId) == false) { infoDesignation.DesignationId = decDesignationId; if (spDesignation.DesignationEdit(infoDesignation)) { Messages.UpdatedMessage(); } } else { Messages.InformationMessage("Designation already exist"); } } catch (Exception ex) { MessageBox.Show("D9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill controls fpor update /// </summary> private void FillControls() { try { DesignationInfo infoDesignaion = new DesignationInfo(); DesignationSP spDesignation = new DesignationSP(); infoDesignaion = spDesignation.DesignationView(decDesignationId); txtDesignationName.Text = infoDesignaion.DesignationName; txtCLInMonth.Text = infoDesignaion.LeaveDays.ToString(); txtAdvanceAmount.Text = infoDesignaion.AdvanceAmount.ToString(); txtNarration.Text = infoDesignaion.Narration; btnSave.Text = "Update"; } catch (Exception ex) { MessageBox.Show("D6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values and return id /// </summary> /// <param name="designationinfo"></param> /// <returns></returns> public decimal DesignationAddWithReturnIdentity(DesignationInfo designationinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DesignationAddWithReturnIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@designationName", SqlDbType.VarChar); sprmparam.Value = designationinfo.DesignationName; sprmparam = sccmd.Parameters.Add("@leaveDays", SqlDbType.Decimal); sprmparam.Value = designationinfo.LeaveDays; sprmparam = sccmd.Parameters.Add("@advanceAmount", SqlDbType.Decimal); sprmparam.Value = designationinfo.AdvanceAmount; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = designationinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = designationinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = designationinfo.Extra2; object obj = sccmd.ExecuteScalar(); if (obj != null) { decIdentity = Convert.ToDecimal(obj.ToString()); } return(decIdentity); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decIdentity); }
/// <summary> /// Function to get particular values from Designation Table based on the parameter /// </summary> /// <param name="designationId"></param> /// <returns></returns> public DesignationInfo DesignationView(decimal designationId) { DesignationInfo designationinfo = new DesignationInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DesignationView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@designationId", SqlDbType.Decimal); sprmparam.Value = designationId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { designationinfo.DesignationId = decimal.Parse(sdrreader[0].ToString()); designationinfo.DesignationName = sdrreader[1].ToString(); designationinfo.LeaveDays = decimal.Parse(sdrreader[2].ToString()); designationinfo.AdvanceAmount = decimal.Parse(sdrreader[3].ToString()); designationinfo.Narration = sdrreader[4].ToString(); designationinfo.ExtraDate = DateTime.Parse(sdrreader[5].ToString()); designationinfo.Extra1 = sdrreader[6].ToString(); designationinfo.Extra2 = sdrreader[7].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(designationinfo); }