protected void saveButton_Click(object sender, EventArgs e)
        {
            UserGroupBLL userGroup = new UserGroupBLL();

            try
            {
                if (userGroupNameTextBox.Text == "")
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Group Name field is required.";
                }
                else if (descriptionTextBox.Text == "")
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Description field is required.";
                }
                else
                {
                    userGroup.UserGroupName = userGroupNameTextBox.Text.Trim();
                    userGroup.Description = descriptionTextBox.Text.Trim();

                    if (!userGroup.CheckDuplicateUserGroup(userGroup.UserGroupName.Trim()))
                    {
                        DataTable dt = userGroup.SaveUserGroup();

                        if (dt.Rows.Count > 0)
                        {
                           // MyAlertBox("alert(\"User Group Created Successfully with User Group ID: " + dt.Rows[0][0].ToString() + " \"); window.location=\"/HRUI/UserGroup/List.aspx\"");

                            string message = " <span class='actionTopic'>" + " User Group Created Successfully with User Group ID: " + dt.Rows[0][0].ToString() + "</span>.";
                            MyAlertBox("var callbackOk = function () { window.location = \"/setting/UserGroup/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        }
                        else
                        {
                            msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Failed to Create User Group!!!"; msgDetailLabel.Text = "";
                        }
                    }
                    else
                    {
                        msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Duplicate!!!"; msgDetailLabel.Text = "This User Group already exist, try another one.";
                    }
                }
            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                userGroup = null;
            }
        }
        protected void updateButton_Click(object sender, EventArgs e)
        {
            UserGroupBLL userGroup = new UserGroupBLL();

            try
            {
                if (userGroupIdForUpdateHiddenField.Value.Trim() == "")
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "User Group not found to update.";
                }
                else if (userGroupNameTextBox.Text == "")
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Group Name field is required.";
                }
                else if (descriptionTextBox.Text == "")
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Description field is required.";
                }
                else
                {
                    userGroup.UserGroupId = userGroupIdForUpdateHiddenField.Value.Trim();
                    userGroup.UserGroupName = userGroupNameTextBox.Text.Trim();
                    userGroup.Description = descriptionTextBox.Text.Trim();

                    if (!userGroup.CheckDuplicateUserGroup(userGroupNameTextBox.Text.Trim()))
                    {
                        userGroup.UpdateUserGroup();

                        userGroupNameForUpdateHiddenField.Value = "";
                        userGroupIdForUpdateHiddenField.Value = "";

                        string message = " <span class='actionTopic'>" + " User Group Updated Successfully</span>.";
                        MyAlertBox("var callbackOk = function () { window.location = \"/setting/UserGroup/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                    }
                    else
                    {
                        if (userGroupNameForUpdateHiddenField.Value == userGroupNameTextBox.Text.Trim())
                        {
                            userGroup.UserGroupName = "WithOut";
                            userGroup.UpdateUserGroup();

                            userGroupNameForUpdateHiddenField.Value = "";
                            userGroupIdForUpdateHiddenField.Value = "";
                            //MyAlertBox("alert(\"User Group Updated Successfully.\"); window.location=\"/HRUI/UserGroup/List.aspx\"");

                            string message = " <span class='actionTopic'>" + " User Group Updated Successfully.</span>.";
                            MyAlertBox("var callbackOk = function () { window.location = \"/setting/UserGroup/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        }
                        else
                        {
                            msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Duplicate!!!"; msgDetailLabel.Text = "This User Group already exist, try another one.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                userGroup = null;
            }
        }