/// <summary>
 /// Function to insert values to SalaryPackage Table
 /// </summary>
 /// <param name="salarypackageinfo"></param>
 /// <returns></returns>
 public decimal SalaryPackageAdd(SalaryPackageInfo salarypackageinfo)
 {
     decimal decIdentity = -1;
        try
        {
        decIdentity = spSalaryPackage.SalaryPackageAdd(salarypackageinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        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 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();
        try
        {
        salarypackageinfo = spSalaryPackage.SalaryPackageView(salaryPackageId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return salarypackageinfo;
 }
 /// <summary>
 /// Function to Update values in SalaryPackage Table
 /// </summary>
 /// <param name="salarypackageinfo"></param>
 public void SalaryPackageEdit(SalaryPackageInfo salarypackageinfo)
 {
     try
        {
       spSalaryPackage.SalaryPackageEdit(salarypackageinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("AL2:" + 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;
 }
 /// <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();
     }
 }