protected void btn_CreateUser_Click(object sender, EventArgs e) { Result oResult = new Result(); try { SystemUser oSystemUser = new SystemUser(); SystemUserBO oSystemUserBO = new SystemUserBO(); if (IsValidSystemUserName(txt_UserName.Text) && IsValidSystemUserPassword(txt_Password.Text) && ISvalidEmail(txt_Email.Text)) { oSystemUser.SystemUserName = txt_UserName.Text; oSystemUser.SystemUserPassword = txt_Password.Text; oSystemUser.SystemUserEmail = txt_Email.Text; oResult = oSystemUserBO.SystemUserEntry(oSystemUser); if (oResult.ResultIsSuccess) { lbl_error.ForeColor = Color.Green; lbl_error.Text = oResult.ResultMessage; Object[] oObjArr = new Object[1]; oObjArr[0] = (SystemUser)oResult.ResultObject; object oObject = new object(); oObject = oObjArr; ThreadPool.QueueUserWorkItem(new WaitCallback(SendMailToSystemUser), oObject); clearControlValue(); } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = oResult.ResultMessage; } } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = "UserName, Password, Email cannot be empty."; } } catch (Exception oEx) { lbl_error.ForeColor = Color.Red; lbl_error.Text = "System User Entry Failed."; } }
protected void btn_Login_Click(object sender, EventArgs e) { try { if (IsValidLoginName(txt_LoginName.Text) && IsValidPassword(txt_Password.Text)) { SystemUser oSystemUser = new SystemUser(); SystemUserBO oSystemUserBO = new SystemUserBO(); Result oResult = new Result(); oSystemUser.SystemUserName = txt_LoginName.Text; oSystemUser.SystemUserPassword = txt_Password.Text; try { oResult = oSystemUserBO.SystemUserLogin(oSystemUser); if (oResult.ResultIsSuccess) { //Utils.csIsSystemUser = true; Utils.SetSession(SessionManager.csLoggedUser, oResult.ResultObject); //Utils.SetSession(SessionManager.csFromPage, PageNameManager.csDefault); Response.Redirect(ContainerManager.csMasterContainer+"?option="+OptionManager.csSystemUserMainPage); } else { lbl_Error.ForeColor = Color.Red; lbl_Error.Text = oResult.ResultMessage; } } catch (Exception oEx1) { lbl_Error.ForeColor = Color.Red; lbl_Error.Text = "Login Exception."; } } else { lbl_Error.ForeColor = Color.Red; lbl_Error.Text = "Login Name & Password Required."; } } catch (Exception oEx2) { lbl_Error.ForeColor = Color.Red; lbl_Error.Text = "Login Exception."; } }
private void LoadSystemUsersToGrid(bool bSendMail, int[] iArrCheck) { SystemUserBO oSystemUserBO = new SystemUserBO(); Result oResult = new Result(); List<SystemUser> oListSystemUser = new List<SystemUser>(); try { oResult = oSystemUserBO.ShowAllSystemUsers(); if (oResult.ResultIsSuccess) { oListSystemUser = (List<SystemUser>)oResult.ResultObject; //Utils.SetSession(SessionManager.csStoreGridView, oListSystemUser); this.ViewState.Add(SessionManager.csStoreGridView, oListSystemUser); Grid_SystemUsers.DataSource = oListSystemUser; Grid_SystemUsers.DataBind(); if (bSendMail && iArrCheck!=null) { SendMailToSystemUserForUpdateNotifiaction(oListSystemUser, iArrCheck); } } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = oResult.ResultMessage; } } catch (Exception oEx) { lbl_error.ForeColor = Color.Red; lbl_error.Text = "Grid Load Exception."; } }
protected void btn_Delete_Click(object sender, EventArgs e) { List<SystemUser> oListSystemUser = new List<SystemUser>(); SystemUserBO oSystemUserBO = new SystemUserBO(); Result oResult = new Result(); Boolean bAnyChecked = false; try { oListSystemUser = oListSystemUserForGrid; int[] iArrCheck = new int[oListSystemUser.Count]; for (int i = 0; i < iArrCheck.Length; i++) { iArrCheck[i] = 0; } foreach (GridViewRow oGridRow in Grid_SystemUsers.Rows) { CheckBox oCheckBox = oGridRow.FindControl("deleteRec") as CheckBox; if (oCheckBox.Checked && !oListSystemUser[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex].SystemUserName.ToLower().Equals("administrator")) { iArrCheck[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex] = 1; bAnyChecked = true; } //else //{ // iArrCheck[oGridRow.RowIndex] = 0; //} } if (bAnyChecked) { oResult = oSystemUserBO.SystemUserDelete(oListSystemUser, iArrCheck); if (oResult.ResultIsSuccess) { oListSystemUser = (List<SystemUser>)oResult.ResultObject; //Utils.SetSession(SessionManager.csStoreGridView, oListSystemUser); this.ViewState.Add(SessionManager.csStoreGridView, oListSystemUser); Grid_SystemUsers.DataSource = oListSystemUser; Grid_SystemUsers.DataBind(); lbl_error.ForeColor = Color.Green; lbl_error.Text = oResult.ResultMessage; } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = oResult.ResultMessage; } } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = "Please Select a System User Without Admin."; } } catch (Exception oEx) { lbl_error.ForeColor = Color.Red; lbl_error.Text = "SystemUser Delete Exception."; } }
protected void btn_Update_Click(object sender, EventArgs e) { List<SystemUser> oListSystemUser = new List<SystemUser>(); SystemUserBO oSystemUserBO = new SystemUserBO(); Result oResult = new Result(); Boolean bAnyChecked = false; try { oListSystemUser = oListSystemUserForGrid; int[] iArrCheck = new int[oListSystemUser.Count]; for (int i = 0; i < iArrCheck.Length; i++) { iArrCheck[i] = 0; } foreach (GridViewRow oGridRow in Grid_SystemUsers.Rows) { CheckBox oCheckBox = oGridRow.FindControl("deleteRec") as CheckBox; TextBox oTxtPassword = oGridRow.FindControl("txtPassword") as TextBox; TextBox oTxtName = oGridRow.FindControl("txtUserName") as TextBox; TextBox oTxtEmail = oGridRow.FindControl("txtEmail") as TextBox; if (oCheckBox.Checked) { bAnyChecked = true; //if (oListSystemUser[oGridRow.RowIndex].SystemUserName.ToLower().Equals("administrator") && IsValidSystemUserPassword(oTxtPassword.Text)) if (IsValidSystemUserPassword(oTxtPassword.Text)) { oListSystemUser[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex].SystemUserPassword = oTxtPassword.Text; } if (IsValidSystemUserName(oTxtName.Text, oListSystemUser)) { oListSystemUser[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex].SystemUserName = oTxtName.Text; } if (ISvalidEmail(oTxtEmail.Text)) { oListSystemUser[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex].SystemUserEmail = oTxtEmail.Text; } iArrCheck[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex] = 1; } //else //{ // iArrCheck[oGridRow.RowIndex] = 0; //} } if (bAnyChecked) { oResult = oSystemUserBO.UpdateSystemUser(oListSystemUser, iArrCheck); if (oResult.ResultIsSuccess) { //oListSystemUser = (List<SystemUser>)oResult.ResultObject; ////Utils.SetSession(SessionManager.csStoreGridView, oListSystemUser); //this.ViewState.Add(SessionManager.csStoreGridView, oListSystemUser); //Grid_SystemUsers.DataSource = oListSystemUser; //Grid_SystemUsers.DataBind(); lbl_error.ForeColor = Color.Green; lbl_error.Text = oResult.ResultMessage; LoadSystemUsersToGrid(true, iArrCheck); } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = oResult.ResultMessage; } } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = "Please Select a System User."; } } catch (Exception oEx) { lbl_error.ForeColor = Color.Red; lbl_error.Text = "System user Update Exception."; } }