private bool process()
 {
     try
     {
         Label             lbl_ID      = new Label();
         Label             lbl_taxName = new Label();
         RadNumericTextBox rntxt_Value = new RadNumericTextBox();
         Label             lbl_MaxAmt  = new Label();
         bool status1 = false;
         int  index   = 0;
         for (index = 0; index <= RG_Employee.Items.Count - 1; index++)
         {
             lbl_ID      = RG_Employee.Items[index].FindControl("lbl_tax_id") as Label;
             rntxt_Value = RG_Employee.Items[index].FindControl("rntxt_Number") as RadNumericTextBox;
             lbl_MaxAmt  = RG_Employee.Items[index].FindControl("lbl_tax_maxlimit") as Label;
             if (rntxt_Value.Value != 0.00)
             {
                 status2                  = true;
                 _obj_smhr_tax_trans      = new SMHR_TAX_TRANS();
                 _obj_smhr_tax_trans.Mode = 2;
                 _obj_smhr_tax_trans.SMHR_EMPTAX_EMPID     = Convert.ToInt32(rcb_Employee.SelectedValue);
                 _obj_smhr_tax_trans.SMHR_EMPTAX_TAXID     = Convert.ToInt32(Convert.ToString(lbl_ID.Text));
                 _obj_smhr_tax_trans.SMHR_EMPTAX_PERIOD_ID = Convert.ToInt32(rcmb_period.SelectedItem.Value);
                 //added
                 _obj_smhr_tax_trans.BUID = Convert.ToInt32(rcb_BusinessUnit.SelectedValue);
                 // Verifying whether the Entered Exemption value is greater than the max limit
                 // if Entered Value is greater than the max limit then take max limit value
                 // else take entered value
                 if (Convert.ToDouble(rntxt_Value.Value) > Convert.ToDouble(Convert.ToString(lbl_MaxAmt.Text)))
                 {
                     _obj_smhr_tax_trans.SMHR_EMPTAX_AMOUNT = Convert.ToDouble(rntxt_Value.Value);
                     _obj_smhr_tax_trans.SMHR_EMPTAX_AMT    = Convert.ToDouble(Convert.ToString(lbl_MaxAmt.Text));
                 }
                 else
                 {
                     _obj_smhr_tax_trans.SMHR_EMPTAX_AMOUNT = Convert.ToDouble(rntxt_Value.Value);
                     _obj_smhr_tax_trans.SMHR_EMPTAX_AMT    = Convert.ToDouble(rntxt_Value.Value);
                 }
                 _obj_smhr_tax_trans.SMHR_EMPTAX_CREATEDBY   = Convert.ToInt32(Convert.ToString(Session["EMP_ID"]));
                 _obj_smhr_tax_trans.SMHR_EMPTAX_CREATEDDATE = DateTime.Now;
                 status1 = BLL.set_Tax_Trans(_obj_smhr_tax_trans);
             }
         }
         return(status1);
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_TDSExempt", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
         return(false);
     }
 }
 private void LoadGrid()
 {
     try
     {
         _obj_smhr_tax_trans      = new SMHR_TAX_TRANS();
         _obj_smhr_tax_trans.Mode = 1;
         _obj_smhr_tax_trans.SMHR_EMPTAX_EMPID     = Convert.ToInt32(rcb_Employee.SelectedValue);
         _obj_smhr_tax_trans.SMHR_EMPTAX_PERIOD_ID = Convert.ToInt32(rcmb_period.SelectedItem.Value);
         _obj_smhr_tax_trans.SMHR_EMPTAX_BU        = Convert.ToInt32(rcb_BusinessUnit.SelectedItem.Value);
         DataTable dt = BLL.get_Tax_trans(_obj_smhr_tax_trans);
         RG_Employee.DataSource = dt;
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_TDSExempt", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            Label             lbl_ID      = new Label();
            Label             lbl_taxName = new Label();
            RadNumericTextBox rntxt_Value = new RadNumericTextBox();
            Label             lbl_MaxAmt  = new Label();
            //int index = 0;
            //int Counter = 0;

            //for (index = 0; index <= RG_Employee.Items.Count - 1; index++)
            //{
            //    rntxt_Value = RG_Employee.Items[index].FindControl("rntxt_Number") as RadNumericTextBox;
            //    if (rntxt_Value.Value == 0.00)
            //    {
            //        Counter = Counter + 1;
            //    }
            //}

            //if (Counter == RG_Employee.Items.Count)
            //{
            //    BLL.ShowMessage(this, "Please Enter atleast one Exemption Value");
            //    return;
            //}
            //else
            //{
            bool status  = false;
            bool status1 = false;
            _obj_smhr_tax_trans      = new SMHR_TAX_TRANS();
            _obj_smhr_tax_trans.Mode = 4;
            _obj_smhr_tax_trans.BUID = Convert.ToInt32(rcb_BusinessUnit.SelectedValue);
            _obj_smhr_tax_trans.SMHR_EMPTAX_EMPID     = Convert.ToInt32(rcb_Employee.SelectedValue);
            _obj_smhr_tax_trans.SMHR_EMPTAX_PERIOD_ID = Convert.ToInt32(rcmb_period.SelectedItem.Value);
            DataTable dt = BLL.get_Tax_trans(_obj_smhr_tax_trans);
            if (dt.Rows.Count != 0)
            {
                _obj_smhr_tax_trans      = new SMHR_TAX_TRANS();
                _obj_smhr_tax_trans.Mode = 3;
                _obj_smhr_tax_trans.BUID = Convert.ToInt32(rcb_BusinessUnit.SelectedValue);
                _obj_smhr_tax_trans.SMHR_EMPTAX_EMPID     = Convert.ToInt32(rcb_Employee.SelectedValue);
                _obj_smhr_tax_trans.SMHR_EMPTAX_PERIOD_ID = Convert.ToInt32(rcmb_period.SelectedItem.Value);
                status  = BLL.set_Tax_Trans(_obj_smhr_tax_trans);
                status1 = process();
                if (status1 == true)
                {
                    BLL.ShowMessage(this, "Tax Exemptions Added Successfully");
                    RG_Employee.Visible = false;
                    btn_Cancel.Visible  = false;
                    btn_Save.Visible    = false;
                    rcb_BusinessUnit.ClearSelection();
                    //rcb_Employee.Items.Remove(rcb_Employee.SelectedIndex);
                    rcmb_period.Items.Clear();
                    rcmb_period.Items.Insert(0, new RadComboBoxItem("", ""));
                    rcmb_period.SelectedIndex = 0;
                    // rcb_Employee.ClearSelection();
                    //rcb_Employee.Items.Remove(rcb_Employee.SelectedItem);
                    rcb_Employee.Items.Clear();
                    rcb_Employee.Items.Insert(0, new RadComboBoxItem("", ""));
                    rcb_Employee.SelectedIndex = 0;
                }
                else if (status2 == false)
                {
                    //BLL.ShowMessage(this, "Enter the amount for Tax Elements to process");
                    BLL.ShowMessage(this, "Tax Exemptions Added Successfully");
                    return;
                }
                else
                {
                    BLL.ShowMessage(this, "An Error Occured while doing the process");
                    return;
                }
            }
            else
            {
                status1 = process();
                if (status1 == true)
                {
                    BLL.ShowMessage(this, "Tax Exemptions Added Successfully");
                    RG_Employee.Visible = false;
                    btn_Cancel.Visible  = false;
                    btn_Save.Visible    = false;
                    rcb_Employee.Items.Clear();
                    rcb_Employee.Items.Insert(0, new RadComboBoxItem("", ""));
                    rcb_Employee.SelectedIndex = 0;
                    //rcb_Employee.SelectedItem.Text = null;
                    //rcb_BusinessUnit.SelectedIndex = 0;
                    //rcmb_period.SelectedIndex = 0;
                    rcmb_period.Items.Clear();
                    //rcb_BusinessUnit.Items.Clear();
                    rcb_BusinessUnit.ClearSelection();
                    return;
                }
                else
                {
                    //BLL.ShowMessage(this, "Enter the amount for Tax Elements to process");
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_TDSExempt", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }

        //}
    }