protected void BUHead_Init(object sender, EventArgs e) { DataTable dtRecord = AccountClass.UserList(); ASPxComboBox combo = sender as ASPxComboBox; combo.DataSource = dtRecord; ListBoxColumn l_ValueField = new ListBoxColumn(); l_ValueField.FieldName = "PK"; l_ValueField.Caption = "CODE"; l_ValueField.Width = 0; combo.Columns.Add(l_ValueField); ListBoxColumn l_TextField = new ListBoxColumn(); l_TextField.FieldName = "CompleteName"; l_TextField.Caption = "Employee Name"; combo.Columns.Add(l_TextField); combo.ValueField = "PK"; combo.TextField = "CompleteName"; combo.DataBind(); GridViewEditFormTemplateContainer container = combo.NamingContainer.NamingContainer as GridViewEditFormTemplateContainer; //MRPClass.PrintString("exp:" + !container.Grid.IsNewRowEditing); if (!container.Grid.IsNewRowEditing) { combo.Value = DataBinder.Eval(container.DataItem, "BUHead").ToString(); } }
private void BindUserList() { //MRPClass.PrintString("MRP is bind"); DataTable dtRecord = AccountClass.UserList(); UserListGrid.DataSource = dtRecord; UserListGrid.KeyFieldName = "PK"; UserListGrid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { CheckSessionExpire(); if (!Page.IsPostBack) { //ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Resize", "changeWidth.resizeWidth();", true); DataTable dtUser = AccountClass.UserList(); dtUser.CaseSensitive = true; string expression = "PK = '" + Session["CreatorKey"].ToString().Trim() + "'"; string sortOrder = "PK ASC"; DataRow[] foundRows; foundRows = dtUser.Select(expression, sortOrder); if (foundRows.Length > 0) { oldPasswordCHDB.Text = foundRows[0]["Password"].ToString(); } } }
protected void signUp_Click(object sender, EventArgs e) { int iEmployeeKey = 0; //MRPClass.PrintString("pass clicked signup"); if (captcha.IsValid && ASPxEdit.ValidateEditorsInContainer(this)) { ModalPopupExtenderLoading.Show(); //MRPClass.PrintString("pass inside validation"); DataTable dt = new DataTable(); SqlCommand cmd = null; SqlDataAdapter adp; string qry = ""; using (SqlConnection conHRIS = new SqlConnection(GlobalClass.SQLConnStringHRIS())) { //MRPClass.PrintString("pass inside hris"); qry = "SELECT PK, IDNumber FROM dbo.tbl_EmployeeIDNumber WHERE(IDNumber = '" + IDNumTextBox.Text.ToString() + "')"; cmd = new SqlCommand(qry); cmd.Connection = conHRIS; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { //MRPClass.PrintString("pass inside hris with id"); foreach (DataRow row in dt.Rows) { iEmployeeKey = Convert.ToInt32(row["PK"]); } } else { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('ID Number not found in Employee MasterList!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "ID Number not found in Employee MasterList!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } dt.Clear(); conHRIS.Close(); } DataTable dtUser = AccountClass.UserList(); //dtUser.CaseSensitive = true; string expressionID = "EmployeeKey = '" + iEmployeeKey.ToString().Trim() + "'"; string sortOrderID = "PK ASC"; DataRow[] foundRowsID; foundRowsID = dtUser.Select(expressionID, sortOrderID); if (foundRowsID.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate ID Number!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate ID Number!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } dtUser.CaseSensitive = true; string expressionName = "Lastname = '" + lastNameTextBox.Text.ToString().Trim() + "' AND Firstname = '" + firstNameTextBox.Text.ToString().Trim() + "'"; string sortOrderName = "PK ASC"; DataRow[] foundRowsName; foundRowsName = dtUser.Select(expressionName, sortOrderName); if (foundRowsName.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Lastname and Firstname!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Lastname and Firstname!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } string expressionEmail = "Email = '" + eMailTextBox.Text.ToString().Trim() + "'"; string sortOrderEmail = "PK ASC"; DataRow[] foundRowsEmail; foundRowsEmail = dtUser.Select(expressionEmail, sortOrderEmail); if (foundRowsEmail.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Email!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Email!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } string expressionUName = "Username = '******'"; string sortOrderUName = "PK ASC"; DataRow[] foundRowsUName; foundRowsUName = dtUser.Select(expressionUName, sortOrderUName); if (foundRowsUName.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Username!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Username!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } using (SqlConnection con = new SqlConnection(GlobalClass.SQLConnString())) { string _sLastName, _sFirstName, _sEmail, _sUserName, _sPassword, _sIDNum; int _Gender = 0; _sLastName = EncryptionClass.Encrypt(GlobalClass.UpperCaseFirstLetter(lastNameTextBox.Text.ToString().Trim())); _sFirstName = EncryptionClass.Encrypt(GlobalClass.UpperCaseFirstLetter(firstNameTextBox.Text.ToString().Trim())); _Gender = gender_int; _sEmail = EncryptionClass.Encrypt(eMailTextBox.Text.ToString().Trim()); _sUserName = EncryptionClass.Encrypt(userNameTextBox.Text.ToString().Trim()); _sPassword = EncryptionClass.Encrypt(passwordTextBox.Text.ToString().Trim()); _sIDNum = EncryptionClass.Encrypt(IDNumTextBox.Text.ToString().Trim()); con.Open(); qry = "INSERT INTO tbl_Users " + " (Lastname, Firstname, Username, Password, Email, EmployeeKey, Gender) " + " VALUES ('" + _sLastName + "', '" + _sFirstName + "', '" + _sUserName + "', " + " '" + _sPassword + "', '" + _sEmail + "', " + iEmployeeKey + ", " + _Gender + ")";; try { cmd = new SqlCommand(qry); cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('You have successfully registered')},0);</script>"); //MRPClass.PrintString("pass saved"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Info"; CreateAccntNotifyLbl.Text = "You is successfully registered."; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Black; CreateAccntNotify.ShowOnPageLoad = true; Response.Redirect("default.aspx"); } catch (SqlException ex) { //MRPClass.PrintString(ex.ToString()); con.Close(); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('" + ex.ToString() + "')},0);</script>"); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = ex.ToString(); CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; } } } }
protected void btnLogIn_Click(object sender, EventArgs e) { if (txtUserName.Text.ToString().Trim() == "") { lblerror.Text = "Please supply username"; txtUserName.Focus(); return; } if (txtPassword.Text.ToString().Trim() == "") { lblerror.Text = "Please supply password"; txtPassword.Focus(); return; } DataTable dtUser = AccountClass.UserList(); dtUser.CaseSensitive = true; string expression = "UserName = '******' AND Password = '******'"; string sortOrder = "PK ASC"; DataRow[] foundRows; foundRows = dtUser.Select(expression, sortOrder); if (foundRows.Length > 0) { Session["CreatorKey"] = foundRows[0]["PK"].ToString(); Session["UserName"] = foundRows[0]["UserName"].ToString(); Session["UserCompleteName"] = foundRows[0]["Lastname"].ToString() + ", " + foundRows[0]["Firstname"].ToString(); Session["EmployeeKey"] = foundRows[0]["EmployeeKey"].ToString(); Session["FirstName"] = foundRows[0]["Firstname"].ToString(); if (Convert.ToInt32(foundRows[0]["UserType"]) == 1) { Session["EntityCode"] = foundRows[0]["EntityCode"].ToString(); Session["EntityCodeDesc"] = foundRows[0]["EntityCodeDesc"].ToString(); Session["BUCode"] = foundRows[0]["BUCode"].ToString(); Session["BUCodeDesc"] = foundRows[0]["BUCodeDesc"].ToString(); Session["isAdmin"] = foundRows[0]["UserLevelKey"].ToString(); Session["viewAllMRP"] = "0"; //if (GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) //{ // Session["viewAllMRP"] = "1"; //} //else //{ if (GlobalClass.IsAdmin(Convert.ToInt32(foundRows[0]["PK"])) || GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) { Session["viewAllMRP"] = "1"; } else { if (GlobalClass.IsAllowed(Convert.ToInt32(foundRows[0]["PK"]), "MOPInventoryAnalyst", DateTime.Now, foundRows[0]["EntityCode"].ToString(), foundRows[0]["BUCode"].ToString(), "") || GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) { Session["viewAllMRP"] = "1"; } else { if (GlobalClass.IsAllowed(Convert.ToInt32(foundRows[0]["PK"]), "MOPSCMLead", DateTime.Now, foundRows[0]["EntityCode"].ToString(), foundRows[0]["BUCode"].ToString(), "") || GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) { Session["viewAllMRP"] = "1"; } else { if (GlobalClass.IsAllowed(Convert.ToInt32(foundRows[0]["PK"]), "MOPFinanceLead", DateTime.Now, foundRows[0]["EntityCode"].ToString(), foundRows[0]["BUCode"].ToString(), "") || GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) { Session["viewAllMRP"] = "1"; } else { if (GlobalClass.IsAllowed(Convert.ToInt32(foundRows[0]["PK"]), "MOPExecutive", DateTime.Now, foundRows[0]["EntityCode"].ToString(), foundRows[0]["BUCode"].ToString(), "") || GlobalClass.IsSuperAdmin(Convert.ToInt32(foundRows[0]["PK"]))) { Session["viewAllMRP"] = "1"; } } } } } //} if (Convert.ToUInt32(foundRows[0]["StatusKey"]) == 1) { Response.Redirect("home.aspx"); } else { lblerror.Text = "Your account is inactive, Please call administrator."; } } } else { lblerror.Text = "Invalid Login Details. Try to enter Username/password Carefully"; } }
protected void btnChangePW_Click(object sender, EventArgs e) { if (txtOldPassword.Text.ToString().Trim() == "") { lblerror.Text = "Please supply old password"; txtOldPassword.Focus(); return; } if (txtNewPassword.Text.ToString().Trim() == "") { lblerror.Text = "Please supply new password"; txtOldPassword.Focus(); return; } if (txtConfirmPassword.Text.ToString().Trim() == "") { lblerror.Text = "Please supply confirm password"; txtOldPassword.Focus(); return; } //if (txtNewPassword.Text.ToString().Trim() != txtConfirmPassword.Text.ToString().Trim()) //{ // lblerror.Text = "Password not match"; // txtConfirmPassword.Focus(); // return; //} string NewPW = txtNewPassword.Text.ToString().Trim(); string ConPW = txtConfirmPassword.Text.ToString().Trim(); bool result = NewPW.Equals(ConPW, StringComparison.CurrentCulture); if (result == false) { lblerror.Text = "Password not match"; txtOldPassword.Focus(); return; } DataTable dtUser = AccountClass.UserList(); dtUser.CaseSensitive = true; string expression = "UserName = '******' AND Password = '******'"; string sortOrder = "PK ASC"; DataRow[] foundRows; foundRows = dtUser.Select(expression, sortOrder); if (foundRows.Length > 0) { SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); string update_User = "******" + " SET [Password] = @Password " + " WHERE [PK] = @PK"; SqlCommand cmd = new SqlCommand(update_User, conn); cmd.Parameters.AddWithValue("@PK", Session["CreatorKey"].ToString()); cmd.Parameters.AddWithValue("@Password", EncryptionClass.Encrypt(txtNewPassword.Text.ToString().Trim())); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); Response.Redirect("home.aspx"); } else { lblerror.Text = "Incorrect old password"; txtOldPassword.Focus(); return; } }