private void LoadData()
 {
     try
     {
         rcb_Type.Items.Clear();
         rcb_Type.Text = string.Empty;
         LoadIdentificationType();
         rcb_Type.SelectedIndex      = 0;
         rdp_ExpiryDate.SelectedDate = null;
         rdp_IssueDate.SelectedDate  = null;
         rtb_Code.Text                      = string.Empty;
         rtxt_IssuedOrg.Text                = string.Empty;
         rtxt_Name.Text                     = string.Empty;
         rcb_Type.Enabled                   = true;
         rtb_Code.Enabled                   = true;
         rtxt_IssuedOrg.Enabled             = true;
         _obj_smhr_identification           = new SMHR_IDENTIFICATION();
         _obj_smhr_identification.OPERATION = operation.Check;
         //if (Convert.ToString(Session["SELF"]) == "SELF_IDENTIFICATION")
         if (Control != null)
         {
             if ((Convert.ToString(Session["SELFSERVICE"]) == "true" && Control.ToUpper() == "SELFIDENTIFICATION") || (Convert.ToString(Session["SELFSERVICE"]) == "" && Control.ToUpper() == "SELFIDENTIFICATION"))
             {
                 _obj_smhr_identification.IDNTMASTER_EMPID = Convert.ToInt32(Session["EMP_ID"]);
             }
         }
         else
         {
             _obj_smhr_identification.IDNTMASTER_EMPID = Convert.ToInt32(rcb_Employee.SelectedItem.Value);
         }
         _obj_smhr_identification.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         DataTable dt = BLL.get_IdentityDetails(_obj_smhr_identification);
         if (dt.Rows.Count != 0)
         {
             lbl_Message.Visible          = false;
             RG_Identification.Visible    = true;
             RG_Identification.DataSource = dt;
             RG_Identification.DataBind();
         }
         else
         {
             lbl_Message.Visible       = true;
             RG_Identification.Visible = false;
         }
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_Identification", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
         return;
     }
 }
 private void getDetails(string ID)
 {
     try
     {
         _obj_smhr_identification                 = new SMHR_IDENTIFICATION();
         _obj_smhr_identification.OPERATION       = operation.Select;
         _obj_smhr_identification.IDNTMASTER_ID   = Convert.ToInt32(ID);
         _obj_smhr_identification.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         DataTable dt = BLL.get_IdentityDetails(_obj_smhr_identification);
         if (dt.Rows.Count != 0)
         {
             rcb_Employee.SelectedIndex = rcb_Employee.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["IDNTMASTER_EMPID"]));
             rtb_Code.Text              = Convert.ToString(dt.Rows[0]["IDNTMASTER_CODE"]);
             rtxt_Name.Text             = Convert.ToString(dt.Rows[0]["IDNTMASTER_NAME"]);
             rcb_Type.SelectedItem.Text = Convert.ToString(dt.Rows[0]["IDNTMASTER_TYPE"]);
             if (dt.Rows[0]["IDNTMASTER_ISSUEDT"] != System.DBNull.Value)
             {
                 rdp_IssueDate.SelectedDate = Convert.ToDateTime(dt.Rows[0]["IDNTMASTER_ISSUEDT"]);
             }
             else
             {
                 rdp_IssueDate.SelectedDate = null;
             }
             if (dt.Rows[0]["IDNTMASTER_EXPIRYDT"] != System.DBNull.Value)
             {
                 rdp_ExpiryDate.SelectedDate = Convert.ToDateTime(dt.Rows[0]["IDNTMASTER_EXPIRYDT"]);
             }
             else
             {
                 rdp_ExpiryDate.SelectedDate = null;
             }
             if (Convert.ToString(dt.Rows[0]["IDNTMASTER_ISSUEDORG"]) != "")
             {
                 rtxt_IssuedOrg.Text = Convert.ToString(dt.Rows[0]["IDNTMASTER_ISSUEDORG"]);
             }
             else
             {
                 rtxt_IssuedOrg.Text = "";
             }
         }
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_Identification", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
         return;
     }
 }
 protected void btn_Submit_Click(object sender, EventArgs e)
 {
     try
     {
         if ((rcb_Employee.SelectedIndex > 0) && (rcb_BusinessUnit.SelectedIndex > 0))
         {
             SMHR_EMPLOYEE _obj_smhr_employee = new SMHR_EMPLOYEE();
             _obj_smhr_employee.OPERATION = operation.Select;
             _obj_smhr_employee.EMP_ID    = Convert.ToInt32(rcb_Employee.SelectedItem.Value);
             //dt_Details = new DataTable();
             _obj_smhr_employee.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
             DataTable dt_Details = BLL.get_Employee(_obj_smhr_employee);
             if (Convert.ToInt32(dt_Details.Rows[0]["EMP_STATUS"]) == 1)
             {
                 BLL.ShowMessage(this, "Employee is Resigned.You can not Submit the record.");
                 return;
             }
             else if (Convert.ToInt32(dt_Details.Rows[0]["EMP_STATUS"]) == 2)
             {
                 BLL.ShowMessage(this, "Employee is Relieved.You can not Submit the record.");
                 return;
             }
             else if (Convert.ToInt32(dt_Details.Rows[0]["EMP_STATUS"]) == 3)
             {
                 BLL.ShowMessage(this, "Employee is Rehired.You can not Submit the record.");
                 return;
             }
             else
             {
                 if (Mode == 1)
                 {
                     _obj_smhr_identification                  = new SMHR_IDENTIFICATION();
                     _obj_smhr_identification.OPERATION        = operation.Insert;
                     _obj_smhr_identification.IDNTMASTER_EMPID = Convert.ToInt32(rcb_Employee.SelectedItem.Value);
                     _obj_smhr_identification.IDNTMASTER_CODE  = Convert.ToString(rtb_Code.Text);
                     _obj_smhr_identification.IDNTMASTER_NAME  = Convert.ToString(rtxt_Name.Text);
                     _obj_smhr_identification.IDNTMASTER_TYPE  = Convert.ToString(rcb_Type.SelectedItem.Text);
                     if (rdp_IssueDate.SelectedDate.HasValue)
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDT = Convert.ToDateTime(rdp_IssueDate.SelectedDate.Value);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDT = null;
                     }
                     if (rdp_ExpiryDate.SelectedDate.HasValue)
                     {
                         _obj_smhr_identification.IDNTMASTER_EXPIRYDT = Convert.ToDateTime(rdp_ExpiryDate.SelectedDate.Value);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_EXPIRYDT = null;
                     }
                     if (Convert.ToString(rtxt_IssuedOrg.Text) != "")
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDORG = Convert.ToString(rtxt_IssuedOrg.Text);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDORG = "";
                     }
                     _obj_smhr_identification.IDNTMASTER_CREATEDBY   = Convert.ToInt32(Session["USER_ID"]);
                     _obj_smhr_identification.IDNTMASTER_CREATEDDATE = DateTime.Now;
                     _obj_smhr_identification.ORGANISATION_ID        = Convert.ToInt32(Session["ORG_ID"]);
                     //as user is able to add duplicate identification details this will restrict the user not to select same type
                     if (RG_Identification.Items.Count > 0)
                     {
                         for (int rows = 0; rows < RG_Identification.Items.Count; rows++)
                         {
                             if (RG_Identification.Items[rows]["IDNTMASTER_TYPE"].Text == _obj_smhr_identification.IDNTMASTER_TYPE)
                             {
                                 BLL.ShowMessage(this, "Selected Employee Has Already Submitted This Identification Type");
                                 return;
                             }
                         }
                     }
                     bool status = BLL.set_IdentityDetails(_obj_smhr_identification);
                     if (status == true)
                     {
                         BLL.ShowMessage(this, "Identity Element Inserted Successfully");
                         ClearFields();
                         LoadData();
                         Mode = 1;
                         rcb_Employee.Enabled     = false;
                         rcb_BusinessUnit.Enabled = false;
                     }
                 }
                 else
                 {
                     _obj_smhr_identification                  = new SMHR_IDENTIFICATION();
                     _obj_smhr_identification.OPERATION        = operation.Update;
                     _obj_smhr_identification.IDNTMASTER_EMPID = Convert.ToInt32(rcb_Employee.SelectedItem.Value);
                     _obj_smhr_identification.IDNTMASTER_CODE  = Convert.ToString(rtb_Code.Text);
                     _obj_smhr_identification.IDNTMASTER_NAME  = Convert.ToString(rtxt_Name.Text);
                     _obj_smhr_identification.IDNTMASTER_TYPE  = Convert.ToString(rcb_Type.SelectedItem.Text);
                     if (rdp_IssueDate.SelectedDate.HasValue)
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDT = Convert.ToDateTime(rdp_IssueDate.SelectedDate.Value);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDT = null;
                     }
                     if (rdp_ExpiryDate.SelectedDate.HasValue)
                     {
                         _obj_smhr_identification.IDNTMASTER_EXPIRYDT = Convert.ToDateTime(rdp_ExpiryDate.SelectedDate.Value);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_EXPIRYDT = null;
                     }
                     if (Convert.ToString(rtxt_IssuedOrg.Text) != "")
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDORG = Convert.ToString(rtxt_IssuedOrg.Text);
                     }
                     else
                     {
                         _obj_smhr_identification.IDNTMASTER_ISSUEDORG = "";
                     }
                     _obj_smhr_identification.IDNTMASTER_LASTMDFBY   = Convert.ToInt32(Session["USER_ID"]);
                     _obj_smhr_identification.IDNTMASTER_LASTMDFDATE = DateTime.Now;
                     _obj_smhr_identification.IDNTMASTER_ID          = Convert.ToInt32(HF_ID.Value); //Convert.ToInt32(_lbl_ID);
                     _obj_smhr_identification.ORGANISATION_ID        = Convert.ToInt32(Session["ORG_ID"]);
                     bool status = BLL.set_IdentityDetails(_obj_smhr_identification);
                     if (status == true)
                     {
                         BLL.ShowMessage(this, "Identity Element Updated Successfully");
                         ClearFields();
                         LoadData();
                         rcb_Type.Enabled         = true;
                         rtb_Code.Enabled         = true;
                         Mode                     = 1;
                         rcb_BusinessUnit.Enabled = false;
                         rcb_Employee.Enabled     = false;
                     }
                 }
             }
         }
         else
         {
             BLL.ShowMessage(this, "Select Employee");
         }
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_Identification", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
         return;
     }
 }