protected void lnk_Edit_Command(object sender, CommandEventArgs e)
 {
     try
     {
         RMP_PayrollPeriod.SelectedIndex = 1;
         rcmb_PeriodDetails.Enabled      = false;
         rcmb_Period.Enabled             = false;
         rcmb_BU.Enabled    = false;
         btn_Update.Visible = true;
         btn_Save.Visible   = false;
         LoadCombos();
         lbl_ID.Text             = Convert.ToString(Convert.ToInt32(e.CommandArgument));
         _obj_smhr_PayrollPeriod = new SMHR_PAYROLLPERIOD();
         _obj_smhr_PayrollPeriod.ORGANISATION_ID  = Convert.ToInt32(Session["ORG_ID"]);
         _obj_smhr_PayrollPeriod.PAYROLLPERIOD_ID = Convert.ToInt32(e.CommandArgument);
         _obj_smhr_PayrollPeriod.MODE             = 4;
         DataTable dt = BLL.get_PayrollPeriod(_obj_smhr_PayrollPeriod);
         if (dt.Rows.Count > 0)
         {
             rcmb_BU.SelectedIndex     = rcmb_BU.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["PAYROLLPERIOD_BU"]));
             rcmb_Period.SelectedIndex = rcmb_Period.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["PAYROLLPERIOD_PERIOD"]));
             rcmb_Period_SelectedIndexChanged(null, null);
             rcmb_PeriodDetails.SelectedIndex = rcmb_PeriodDetails.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["PAYROLLPERIOD_PERIODDETAILS"]));
             rdtp_StartDate.SelectedDate      = Convert.ToDateTime(dt.Rows[0]["PAYROLLPERIOD_STARTDATE"]);
             rdtp_EndDate.SelectedDate        = Convert.ToDateTime(dt.Rows[0]["PAYROLLPERIOD_ENDDATE"]);
         }
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_PayrollPeriod", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            _obj_smhr_PayrollPeriod = new SMHR_PAYROLLPERIOD();
            _obj_smhr_PayrollPeriod.PAYROLLPERIOD_BU            = Convert.ToInt32(rcmb_BU.SelectedItem.Value);
            _obj_smhr_PayrollPeriod.PAYROLLPERIOD_PERIOD        = Convert.ToInt32(rcmb_Period.SelectedItem.Value);
            _obj_smhr_PayrollPeriod.PAYROLLPERIOD_PERIODDETAILS = Convert.ToInt32(rcmb_PeriodDetails.SelectedItem.Value);
            _obj_smhr_PayrollPeriod.PAYROLLPERIOD_STARTDATE     = Convert.ToDateTime(rdtp_StartDate.SelectedDate);
            _obj_smhr_PayrollPeriod.PAYROLLPERIOD_ENDDATE       = Convert.ToDateTime(rdtp_EndDate.SelectedDate);
            _obj_smhr_PayrollPeriod.ORGANISATION_ID             = Convert.ToInt32(Session["ORG_ID"]);
            _obj_smhr_PayrollPeriod.CREATEDBY = Convert.ToInt32(Session["USER_ID"]);
            _obj_smhr_PayrollPeriod.LASTMDFBY = Convert.ToInt32(Session["USER_ID"]);
            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_SAVE":
                _obj_smhr_PayrollPeriod.MODE = 2;
                if (Convert.ToString(BLL.get_PayrollPeriod(_obj_smhr_PayrollPeriod).Rows[0]["COUNT"]) != "0")
                {
                    BLL.ShowMessage(this, "Details are already Saved for the Selected BU and Period Detials");
                    return;
                }
                _obj_smhr_PayrollPeriod.MODE = 1;
                if (BLL.set_PayrollPeriod(_obj_smhr_PayrollPeriod))
                {
                    BLL.ShowMessage(this, "Information Saved Successfully.");
                }
                break;

            case "BTN_UPDATE":
                _obj_smhr_PayrollPeriod.MODE = 2;
                if (Convert.ToString(BLL.get_PayrollPeriod(_obj_smhr_PayrollPeriod).Rows[0]["COUNT"]) != "1")
                {
                    BLL.ShowMessage(this, "Details are already Saved for the Selected BU and Period Details");
                    return;
                }
                _obj_smhr_PayrollPeriod.PAYROLLPERIOD_ID = Convert.ToInt32(lbl_ID.Text);
                _obj_smhr_PayrollPeriod.MODE             = 5;
                if (BLL.set_PayrollPeriod(_obj_smhr_PayrollPeriod))
                {
                    BLL.ShowMessage(this, "Information Updated Successfully.");
                }
                break;

            default:
                break;
            }
            ClearControls();
            RMP_PayrollPeriod.SelectedIndex = 0;
            LoadGrid();
            return;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_PayrollPeriod", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
 protected void rg_PayrollPeriod_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
 {
     try
     {
         _obj_smhr_PayrollPeriod = new SMHR_PAYROLLPERIOD();
         _obj_smhr_PayrollPeriod.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         _obj_smhr_PayrollPeriod.LOGIN_ID        = Convert.ToInt32(Session["USER_ID"]);
         _obj_smhr_PayrollPeriod.MODE            = 3;
         DataTable dt = BLL.get_PayrollPeriod(_obj_smhr_PayrollPeriod);
         rg_PayrollPeriod.DataSource = dt;
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_PayrollPeriod", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }