/// <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 check existence of month and return value
        /// </summary>
        /// <param name="bonusdedutioninfo"></param>
        /// <returns></returns>
        public bool BonusDeductionMonthCheckExistance(BonusDedutionInfo bonusdedutioninfo)
        {
            bool isEdit = false;
            try
            {

                isEdit = SPBonusDedution.BonusDeductionMonthCheckExistance(bonusdedutioninfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BDBll11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return isEdit;
        }
        /// <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
            {

                isSave= SPBonusDedution.BonusDeductionAddIfNotExist(bonusdedutioninfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BDBll10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return isSave;
        }
        /// <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();
            try
            {
                bonusdedutioninfo=SPBonusDedution.BonusDedutionView(bonusDeductionId);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BDBll4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return bonusdedutioninfo;
        }
        /// <summary>
        /// Function to Update values in BonusDeduction  Table
        /// </summary>
        /// <param name="bonusdedutioninfo"></param>
        public void BonusDedutionEdit(BonusDedutionInfo bonusdedutioninfo)
        {
            try
            {

                SPBonusDedution.BonusDedutionEdit(bonusdedutioninfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BDBll2:" + 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 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;
 }