/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction.Date = Convert.ToDateTime(dtpDate.Text.ToString()); infoBonusDeduction.EmployeeId = Convert.ToDecimal(cmbEmployeeCode.SelectedValue.ToString()); infoBonusDeduction.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoBonusDeduction.BonusAmount = Convert.ToDecimal(txtBonusAmount.Text.ToString()); infoBonusDeduction.DeductionAmount = Convert.ToDecimal(txtDeductionAmount.Text.ToString()); infoBonusDeduction.Narration = txtNarration.Text; infoBonusDeduction.Extra1 = string.Empty; infoBonusDeduction.Extra2 = string.Empty; if (spBonusDeduction.BonusDeductionAddIfNotExist(infoBonusDeduction)) { Messages.SavedMessage(); Clear(); } else { Messages.InformationMessage(" Employee bonus deduction already exist"); cmbEmployeeCode.Focus(); } } catch (Exception ex) { MessageBox.Show("BD2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction.Date = Convert.ToDateTime(dtpDate.Text.ToString()); infoBonusDeduction.EmployeeId = Convert.ToDecimal(cmbEmployeeCode.SelectedValue.ToString()); infoBonusDeduction.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoBonusDeduction.BonusAmount = Convert.ToDecimal(txtBonusAmount.Text.ToString()); infoBonusDeduction.DeductionAmount = Convert.ToDecimal(txtDeductionAmount.Text.ToString()); infoBonusDeduction.Narration = txtNarration.Text; infoBonusDeduction.Extra1 = string.Empty; infoBonusDeduction.Extra2 = string.Empty; infoBonusDeduction.BonusDeductionId = decBonusId; spBonusDeduction.BonusDedutionEdit(infoBonusDeduction); Messages.UpdatedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; dtpDate.Focus(); if (frmBonusDeductionRegisterObj != null) { frmBonusDeductionRegisterObj.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show("BD3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to call this form from frmBonusDeductionRegister for updation /// </summary> /// <param name="decBonusDeductionId"></param> /// <param name="frm"></param> public void CallFromBonusDeductionRegister(decimal decBonusDeductionId, frmBonusDeductionRegister frm) { try { base.Show(); BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction = spBonusDeduction.BonusDeductionViewForUpdate(decBonusDeductionId); dtpDate.Text = infoBonusDeduction.Date.ToString(); cmbEmployeeCode.SelectedValue = infoBonusDeduction.EmployeeId; decEmployeeIdForEdit = infoBonusDeduction.EmployeeId; dtpMonth.Text = infoBonusDeduction.Month.ToString(); dtMonth = infoBonusDeduction.Month; txtBonusAmount.Text = infoBonusDeduction.BonusAmount.ToString(); txtDeductionAmount.Text = infoBonusDeduction.DeductionAmount.ToString(); txtNarration.Text = infoBonusDeduction.Narration; btnSave.Text = "Update"; dtpMonth.Enabled = false; cmbEmployeeCode.Enabled = false; btnDelete.Enabled = true; txtDate.Focus(); decBonusId = decBonusDeductionId; frmBonusDeductionRegisterObj = frm; frm.Enabled = false; } catch (Exception ex) { MessageBox.Show("BD9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to check existence of month and return value /// </summary> /// <param name="bonusdedutioninfo"></param> /// <returns></returns> public bool BonusDeductionMonthCheckExistance(BonusDedutionInfo bonusdedutioninfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("BonusDeductionMonthCheckExistance", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@month", SqlDbType.DateTime).Value = bonusdedutioninfo.Month; object obj = sqlcmd.ExecuteScalar(); if (obj != null) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isEdit); }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction.Date = Convert.ToDateTime(dtpDate.Text.ToString()); infoBonusDeduction.EmployeeId = Convert.ToDecimal(cmbEmployeeCode.SelectedValue.ToString()); infoBonusDeduction.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoBonusDeduction.BonusAmount = Convert.ToDecimal(txtBonusAmount.Text.ToString()); infoBonusDeduction.DeductionAmount = Convert.ToDecimal(txtDeductionAmount.Text.ToString()); infoBonusDeduction.Narration = txtNarration.Text; infoBonusDeduction.Extra1 = string.Empty; infoBonusDeduction.Extra2 = string.Empty; if (spBonusDeduction.BonusDeductionAddIfNotExist(infoBonusDeduction)) { Messages.SavedMessage(); Clear(); } else { Messages.InformationMessage(" Employee bonus deduction already exist"); cmbEmployeeCode.Focus(); } } catch (Exception ex) { MessageBox.Show("BD2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values if not exists and return id /// </summary> /// <param name="bonusdedutioninfo"></param> /// <returns></returns> public bool BonusDeductionAddIfNotExist(BonusDedutionInfo bonusdedutioninfo) { bool isSave = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BonusDeductionAddIfNotExist", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.EmployeeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = bonusdedutioninfo.Date; sprmparam = sccmd.Parameters.Add("@month", SqlDbType.DateTime); sprmparam.Value = bonusdedutioninfo.Month; sprmparam = sccmd.Parameters.Add("@bonusAmount", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.BonusAmount; sprmparam = sccmd.Parameters.Add("@deductionAmount", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.DeductionAmount; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Extra2; int ina = sccmd.ExecuteNonQuery(); if (ina > 0) { isSave = true; } else { isSave = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isSave); }
/// <summary> /// Function to insert values to BonusDeduction Table /// </summary> /// <param name="bonusdedutioninfo"></param> public void BonusDedutionAdd(BonusDedutionInfo bonusdedutioninfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BonusDedutionAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@bonusDeductionId", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.BonusDeductionId; sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.EmployeeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = bonusdedutioninfo.Date; sprmparam = sccmd.Parameters.Add("@month", SqlDbType.DateTime); sprmparam.Value = bonusdedutioninfo.Month; sprmparam = sccmd.Parameters.Add("@bonusAmount", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.BonusAmount; sprmparam = sccmd.Parameters.Add("@deductionAmount", SqlDbType.Decimal); sprmparam.Value = bonusdedutioninfo.DeductionAmount; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = bonusdedutioninfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = bonusdedutioninfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from BonusDeduction table based on the parameter /// </summary> /// <param name="bonusDeductionId"></param> /// <returns></returns> public BonusDedutionInfo BonusDedutionView(decimal bonusDeductionId) { BonusDedutionInfo bonusdedutioninfo = new BonusDedutionInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BonusDedutionView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@bonusDeductionId", SqlDbType.Decimal); sprmparam.Value = bonusDeductionId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { bonusdedutioninfo.BonusDeductionId = decimal.Parse(sdrreader[0].ToString()); bonusdedutioninfo.EmployeeId = decimal.Parse(sdrreader[1].ToString()); bonusdedutioninfo.Date = DateTime.Parse(sdrreader[2].ToString()); bonusdedutioninfo.Month = DateTime.Parse(sdrreader[3].ToString()); bonusdedutioninfo.BonusAmount = decimal.Parse(sdrreader[4].ToString()); bonusdedutioninfo.DeductionAmount = decimal.Parse(sdrreader[5].ToString()); bonusdedutioninfo.Narration = sdrreader[6].ToString(); bonusdedutioninfo.ExtraDate = DateTime.Parse(sdrreader[7].ToString()); bonusdedutioninfo.Extra1 = sdrreader[8].ToString(); bonusdedutioninfo.Extra2 = sdrreader[9].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(bonusdedutioninfo); }
/// <summary> /// Function to view details for update based on parameter /// </summary> /// <param name="decBonusDeductionId"></param> /// <returns></returns> public BonusDedutionInfo BonusDeductionViewForUpdate(decimal decBonusDeductionId) { BonusDedutionInfo BonusDeductionInfo = new BonusDedutionInfo(); EmployeeInfo InfoEmployee = new EmployeeInfo(); SqlDataReader sqldr = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("BonusDeductionViewForUpdate", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@bonusDeductionId", SqlDbType.Decimal).Value = decBonusDeductionId; sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { BonusDeductionInfo.EmployeeId = decimal.Parse(sqldr["employeeId"].ToString()); BonusDeductionInfo.Date = DateTime.Parse(sqldr["date"].ToString()); BonusDeductionInfo.Month = DateTime.Parse(sqldr["month"].ToString()); BonusDeductionInfo.BonusAmount = decimal.Parse(sqldr["bonusAmount"].ToString()); BonusDeductionInfo.DeductionAmount = decimal.Parse(sqldr["deductionAmount"].ToString()); BonusDeductionInfo.Narration = sqldr["narration"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqldr.Close(); sqlcon.Close(); } return(BonusDeductionInfo); }
/// <summary> /// Function to check existence of month and return value /// </summary> /// <param name="bonusdedutioninfo"></param> /// <returns></returns> public bool BonusDeductionMonthCheckExistance(BonusDedutionInfo bonusdedutioninfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("BonusDeductionMonthCheckExistance", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@month", SqlDbType.DateTime).Value = bonusdedutioninfo.Month; object obj = sqlcmd.ExecuteScalar(); if (obj != null) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return isEdit; }
/// <summary> /// Function to view details for update based on parameter /// </summary> /// <param name="decBonusDeductionId"></param> /// <returns></returns> public BonusDedutionInfo BonusDeductionViewForUpdate(decimal decBonusDeductionId) { BonusDedutionInfo BonusDeductionInfo = new BonusDedutionInfo(); EmployeeInfo InfoEmployee = new EmployeeInfo(); SqlDataReader sqldr = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("BonusDeductionViewForUpdate", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@bonusDeductionId", SqlDbType.Decimal).Value = decBonusDeductionId; sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { BonusDeductionInfo.EmployeeId = decimal.Parse(sqldr["employeeId"].ToString()); BonusDeductionInfo.Date = DateTime.Parse(sqldr["date"].ToString()); BonusDeductionInfo.Month = DateTime.Parse(sqldr["month"].ToString()); BonusDeductionInfo.BonusAmount = decimal.Parse(sqldr["bonusAmount"].ToString()); BonusDeductionInfo.DeductionAmount = decimal.Parse(sqldr["deductionAmount"].ToString()); BonusDeductionInfo.Narration = sqldr["narration"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqldr.Close(); sqlcon.Close(); } return BonusDeductionInfo; }
/// <summary> /// Function to get particular values from BonusDeduction table based on the parameter /// </summary> /// <param name="bonusDeductionId"></param> /// <returns></returns> public BonusDedutionInfo BonusDedutionView(decimal bonusDeductionId) { BonusDedutionInfo bonusdedutioninfo = new BonusDedutionInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BonusDedutionView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@bonusDeductionId", SqlDbType.Decimal); sprmparam.Value = bonusDeductionId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { bonusdedutioninfo.BonusDeductionId = decimal.Parse(sdrreader[0].ToString()); bonusdedutioninfo.EmployeeId = decimal.Parse(sdrreader[1].ToString()); bonusdedutioninfo.Date = DateTime.Parse(sdrreader[2].ToString()); bonusdedutioninfo.Month = DateTime.Parse(sdrreader[3].ToString()); bonusdedutioninfo.BonusAmount = decimal.Parse(sdrreader[4].ToString()); bonusdedutioninfo.DeductionAmount = decimal.Parse(sdrreader[5].ToString()); bonusdedutioninfo.Narration = sdrreader[6].ToString(); bonusdedutioninfo.ExtraDate = DateTime.Parse(sdrreader[7].ToString()); bonusdedutioninfo.Extra1 = sdrreader[8].ToString(); bonusdedutioninfo.Extra2 = sdrreader[9].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return bonusdedutioninfo; }
/// <summary> /// Function to call this form from frmBonusDeductionRegister for updation /// </summary> /// <param name="decBonusDeductionId"></param> /// <param name="frm"></param> public void CallFromBonusDeductionRegister(decimal decBonusDeductionId, frmBonusDeductionRegister frm) { try { base.Show(); BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction = spBonusDeduction.BonusDeductionViewForUpdate(decBonusDeductionId); dtpDate.Text = infoBonusDeduction.Date.ToString(); cmbEmployeeCode.SelectedValue = infoBonusDeduction.EmployeeId; decEmployeeIdForEdit = infoBonusDeduction.EmployeeId; dtpMonth.Text = infoBonusDeduction.Month.ToString(); dtMonth = infoBonusDeduction.Month; txtBonusAmount.Text = infoBonusDeduction.BonusAmount.ToString(); txtDeductionAmount.Text = infoBonusDeduction.DeductionAmount.ToString(); txtNarration.Text = infoBonusDeduction.Narration; btnSave.Text = "Update"; dtpMonth.Enabled = false; cmbEmployeeCode.Enabled = false; btnDelete.Enabled = true; txtDate.Focus(); decBonusId = decBonusDeductionId; frmBonusDeductionRegisterObj = frm; frm.Enabled = false; } catch (Exception ex) { MessageBox.Show("BD9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { BonusDedutionInfo infoBonusDeduction = new BonusDedutionInfo(); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); infoBonusDeduction.Date = Convert.ToDateTime(dtpDate.Text.ToString()); infoBonusDeduction.EmployeeId = Convert.ToDecimal(cmbEmployeeCode.SelectedValue.ToString()); infoBonusDeduction.Month = Convert.ToDateTime(dtpMonth.Text.ToString()); infoBonusDeduction.BonusAmount = Convert.ToDecimal(txtBonusAmount.Text.ToString()); infoBonusDeduction.DeductionAmount = Convert.ToDecimal(txtDeductionAmount.Text.ToString()); infoBonusDeduction.Narration = txtNarration.Text; infoBonusDeduction.Extra1 = string.Empty; infoBonusDeduction.Extra2 = string.Empty; infoBonusDeduction.BonusDeductionId = decBonusId; spBonusDeduction.BonusDedutionEdit(infoBonusDeduction); Messages.UpdatedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; dtpDate.Focus(); if (frmBonusDeductionRegisterObj != null) { frmBonusDeductionRegisterObj.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show("BD3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }