protected void GetUserList() { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserList(); userListGridView.DataSource = dt; userListGridView.DataBind(); //for (int i = 0; i < dt.Rows.Count; i++) //{ // if (dt.Rows[i]["UserId"].ToString() == LumexSessionManager.Get("ActiveUserId").ToString()) // { // LinkButton setMenuLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setMenuLinkButton"); // LinkButton setWarehouseLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setWarehouseLinkButton"); // LinkButton setSalesCenterLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setSalesCenterLinkButton"); // setMenuLinkButton.Visible = false; // setWarehouseLinkButton.Visible = false; // setSalesCenterLinkButton.Visible = false; // break; // } //} if (LumexSessionManager.Get("ActiveUserId").ToString() != "Developer") { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["UserId"].ToString() == "Developer") { LinkButton setMenuLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setMenuLinkButton"); LinkButton setWarehouseLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setWarehouseLinkButton"); //LinkButton setSalesCenterLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("setSalesCenterLinkButton"); setMenuLinkButton.Visible = false; setWarehouseLinkButton.Visible = false; //setSalesCenterLinkButton.Visible = false; break; } } } if (dt.Rows.Count < 1) { msgbox.Visible = true; msgTitleLabel.Text = "User List Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
public DataTable SaveUser(UserBLL user, LumexDBPlayer db) { try { db.AddParameters("@UserId", user.UserId.Trim()); db.AddParameters("@SalesCenterId", user.SalesCenterId.Trim()); db.AddParameters("@WareHouseId", user.warehouseId.Trim()); db.AddParameters("@UserName", user.UserName.Trim()); db.AddParameters("@EmployeeId", user.EmployeeId.Trim()); db.AddParameters("@UserGroupId", user.UserGroupId.Trim()); db.AddParameters("@Department", user.Department.Trim()); db.AddParameters("@Designation", user.Designation.Trim()); db.AddParameters("@Address", user.Address.Trim()); db.AddParameters("@ContactNumber", user.ContactNumber.Trim()); db.AddParameters("@Email", user.Email.Trim()); db.AddParameters("@NationalId", user.NationalId.Trim()); db.AddParameters("@PassportNumber", user.PassportNumber.Trim()); db.AddParameters("@Password", ProtectPassword(user.Password.Trim())); db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString()); db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal()); DataTable dt = db.ExecuteDataTable("INSERT_USER", true); return dt; } catch (Exception) { throw; } finally { user = null; } }
protected void GetUserList() { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserList(); userListGridView.DataSource = dt; userListGridView.DataBind(); if (dt.Rows.Count < 1) { msgbox.Visible = true; msgTitleLabel.Text = "User List Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void passwordUpdateButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { if (string.IsNullOrEmpty(currentPasswordTextBox.Text.Trim())) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Current Password field is required."; } else if (string.IsNullOrEmpty(newPasswordTextBox.Text.Trim())) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Password field is required."; } else if (string.IsNullOrEmpty(confirmNewPasswordTextBox.Text.Trim())) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Confirm New Password field is required."; } else if (newPasswordTextBox.Text.Trim() != confirmNewPasswordTextBox.Text.Trim()) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Password & Confirm New Password do not match."; } else { user.UserId = LumexSessionManager.Get("ActiveUserId").ToString(); user.Password = currentPasswordTextBox.Text.Trim(); if (user.ValidateUser()) { user.Password = newPasswordTextBox.Text.Trim(); user.UpdateUserPassword(user.UserId, user.Password); string message = "Password <span class='actionTopic'>Updated</span> Successfully."; MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/Logout.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);"); } else { string message = "<span class='actionTopic'>Invalid</span> Current Password. You can't change your password."; MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");"); } } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void deletedListButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { if (fromDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()) == "False") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date From field is required."; } else if (toDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()) == "False") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date To field is required."; } else { string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()); string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()); DataTable dt = user.GetDeletedUserListByDateRangeAll(fromDate, toDate, ""); deletedListGridView.DataSource = dt; deletedListGridView.DataBind(); if (deletedListGridView.Rows.Count > 0) { deletedListGridView.UseAccessibleHeader = true; deletedListGridView.HeaderRow.TableSection = TableRowSection.TableHeader; } else { msgbox.Visible = true; msgTitleLabel.Text = "Deleted User List Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-info"); } } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; MyAlertBox("MyOverlayStop();"); } }
protected void LoadUserInfoAndSalesCenterList(string userId) { UserBLL user = new UserBLL(); SalesCenterBLL salesCenter = new SalesCenterBLL(); try { DataTable dt = user.GetUserById(userId); if (dt.Rows.Count > 0) { userIdLabel.Text = dt.Rows[0]["UserId"].ToString(); userNameLabel.Text = dt.Rows[0]["UserName"].ToString(); employeeIdLabel.Text = dt.Rows[0]["EmployeeId"].ToString(); userGroupNameLabel.Text = dt.Rows[0]["UserGroupName"].ToString(); activeStatusLabel.Text = dt.Rows[0]["IsActive"].ToString(); userSalesCenterListListBox.Items.Clear(); DataTable dtSalesCenter = salesCenter.GetUserSalesCentersByUserId(userIdLabel.Text.Trim()); for (int i = 0; i < dtSalesCenter.Rows.Count; i++) { userSalesCenterListListBox.Items.Add(new ListItem(dtSalesCenter.Rows[i]["SalesCenterName"].ToString(), dtSalesCenter.Rows[i]["SalesCenterId"].ToString())); } userPriviligePane.Visible = true; } else { userPriviligePane.Visible = false; msgbox.Visible = true; msgTitleLabel.Text = "User Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; salesCenter = null; countUserSalesCenterLabel.Text = "Total: " + userSalesCenterListListBox.Items.Count.ToString(); } }
protected void GetUserById(string userId) { UserBLL user = new UserBLL(); try { DataTable dt = new DataTable(); if (userId != "developer" || userId != "Developer") { dt = user.GetUserById(userId); } if (dt.Rows.Count > 0) { userIdLabel.Text = dt.Rows[0]["UserId"].ToString(); userNameLabel.Text = dt.Rows[0]["UserName"].ToString(); //employeeIdLabel.Text = dt.Rows[0]["EmployeeId"].ToString(); userGroupLabel.Text = dt.Rows[0]["UserGroupName"].ToString(); contactNumberLabel.Text = dt.Rows[0]["ContactNumber"].ToString(); actionPane.Visible = true; } else { actionPane.Visible = false; msgbox.Visible = true; msgTitleLabel.Text = "User Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; MyAlertBox("MyOverlayStop();"); } }
protected void GetUserById(string userId) { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserById(userId); if (dt.Rows.Count > 0) { userIdLabel.Text = dt.Rows[0]["UserId"].ToString(); userNameLabel.Text = dt.Rows[0]["UserName"].ToString(); employeeIdLabel.Text = dt.Rows[0]["EmployeeId"].ToString(); departmentLabel.Text = dt.Rows[0]["Department"].ToString(); designationLabel.Text = dt.Rows[0]["Designation"].ToString(); addressLabel.Text = dt.Rows[0]["Address"].ToString(); contactNumberLabel.Text = dt.Rows[0]["ContactNumber"].ToString(); emailLabel.Text = dt.Rows[0]["Email"].ToString(); nationalIdLabel.Text = dt.Rows[0]["NationalId"].ToString(); passportNumberLabel.Text = dt.Rows[0]["PassportNumber"].ToString(); userGroupLabel.Text = dt.Rows[0]["UserGroupName"].ToString(); } else { msgbox.Visible = true; msgTitleLabel.Text = "User Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void passwordResetButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { if (string.IsNullOrEmpty(newPasswordTextBox.Text.Trim())) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Password field is required."; } else if (string.IsNullOrEmpty(confirmNewPasswordTextBox.Text.Trim())) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Confirm New Password field is required."; } else if (newPasswordTextBox.Text.Trim() != confirmNewPasswordTextBox.Text.Trim()) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Password & Confirm New Password do not match."; } else { user.UserId = userIdLabel.Text.Trim(); user.Password = newPasswordTextBox.Text.Trim(); user.UpdateUserPassword(user.UserId, user.Password); string message = "User <span class='actionTopic'>Password Reset</span> Successfully."; MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/User/ResetUserPassword.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
private void getUserById(string userId) { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserById(userId); lblUserId.Text = dt.Rows[0]["UserId"].ToString(); lblUserName.Text = dt.Rows[0]["UserName"].ToString(); lblUserGroup.Text = dt.Rows[0]["UserGroupName"].ToString(); lblContactNumber.Text = dt.Rows[0]["ContactNumber"].ToString(); lblEmail.Text = dt.Rows[0]["Email"].ToString(); ; lblAddress.Text = dt.Rows[0]["Address"].ToString(); //lblSalesCenterName.Text = dt.Rows[0]["SalesCenterName"].ToString(); lblWarehouseName.Text = dt.Rows[0]["WareHouseName"].ToString(); if (dt.Rows[0]["IsActive"].ToString() == "True") { lblStatus.Text = "Active"; lblStatus.CssClass = "bold text-success"; } else { lblStatus.Text = "Deactive"; lblStatus.CssClass = "bold text-error"; } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " Sorry Somthing going worng to get User. Try later!! "; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void activateLinkButton_Click(object sender, EventArgs e) { try { LinkButton lnkBtn = (LinkButton)sender; GridViewRow row = (GridViewRow)lnkBtn.NamingContainer; UserBLL user = new UserBLL(); user.UpdateUserActivation(userListGridView.Rows[row.RowIndex].Cells[0].Text.ToString(), "True"); userListGridView.Rows[row.RowIndex].Cells[5].Text = "True"; string message = "User <span class='actionTopic'>Activated</span> Successfully."; MyAlertBox("SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");"); } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } }
protected void LoadUserInfo(string userId) { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserById(userId); if (dt.Rows.Count > 0) { userIdLabel.Text = dt.Rows[0]["UserId"].ToString(); userNameLabel.Text = dt.Rows[0]["UserName"].ToString(); employeeIdLabel.Text = dt.Rows[0]["EmployeeId"].ToString(); userGroupNameLabel.Text = dt.Rows[0]["UserGroupName"].ToString(); activeStatusLabel.Text = dt.Rows[0]["IsActive"].ToString(); userPriviligePane.Visible = true; } else { userPriviligePane.Visible = false; msgbox.Visible = true; msgTitleLabel.Text = "User Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void unlockButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { // user.UserId = userIdLockTextBox.Text.Trim(); // user.Password = passwordLockTextBox.Text.Trim(); if (user.ValidateUser() && user.UserId == LumexSessionManager.Get("ActiveUserId").ToString()) { DataTable dt = user.GetUserById(user.UserId); if (dt.Rows[0]["IsActive"].ToString() == "True" && dt.Rows[0]["IsUserGroupActive"].ToString() == "True") { // screenLock.Visible = false; // main.Visible = true; if (Session["ScreenLockURL"] != null) { LumexSessionManager.Remove("ScreenLockURL"); } if (Session["ScreenLock"] != null) { LumexSessionManager.Remove("ScreenLock"); } } else { // screenStatusLabel.Text = "User Access Denied!!!"; } } else { // screenStatusLabel.Text = "Invalid User or Password"; } } catch (Exception) { LumexSessionManager.RemoveAll(); Response.Redirect("~/Login.aspx", false); } finally { user = null; } }
protected void GetUserList() { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserList(); userListGridView.DataSource = dt; userListGridView.DataBind(); //for (int i = 0; i < dt.Rows.Count; i++) //{ // if (dt.Rows[i]["UserId"].ToString() == LumexSessionManager.Get("ActiveUserId").ToString()) // { // LinkButton editLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("editLinkButton"); // LinkButton activateLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("activateLinkButton"); // LinkButton deactivateLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("deactivateLinkButton"); // LinkButton deleteLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("deleteLinkButton"); // editLinkButton.Visible = false; // activateLinkButton.Visible = false; // deactivateLinkButton.Visible = false; // deleteLinkButton.Visible = false; // break; // } //} //if (LumexSessionManager.Get("ActiveUserId").ToString() != "Developer") //{ // for (int i = 0; i < dt.Rows.Count; i++) // { // if (dt.Rows[i]["UserId"].ToString() == "Developer") // { // LinkButton editLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("editLinkButton"); // LinkButton deleteLinkButton = (LinkButton)userListGridView.Rows[i].FindControl("deleteLinkButton"); // editLinkButton.Visible = false; // deleteLinkButton.Visible = false; // break; // } // } //} if (userListGridView.Rows.Count > 0) { userListGridView.UseAccessibleHeader = true; userListGridView.HeaderRow.TableSection = TableRowSection.TableHeader; } else { msgbox.Visible = true; msgTitleLabel.Text = "User List Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void deleteLinkButton_Click(object sender, EventArgs e) { try { LinkButton lnkBtn = (LinkButton)sender; GridViewRow row = (GridViewRow)lnkBtn.NamingContainer; UserBLL user = new UserBLL(); user.DeleteUser(userListGridView.Rows[row.RowIndex].Cells[0].Text.ToString()); GetUserList(); string message = "User <span class='actionTopic'>Deleted</span> & User Menu(s), Warehouse(s) and Sales Center(s) Updated Successfully."; MyAlertBox("SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");"); } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } }
protected void btnlogin_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { user.UserId = txtbxUserName.Text.Trim(); user.Password = txtbxPass.Text.Trim(); if (user.ValidateUser()) { DataTable dt = user.GetUserById(user.UserId); if (dt.Rows[0]["IsActive"].ToString() == "True" && dt.Rows[0]["IsUserGroupActive"].ToString() == "True") { LumexSessionManager.Add("ActiveUserId", dt.Rows[0]["UserId"].ToString()); LumexSessionManager.Add("ActiveUserName", dt.Rows[0]["UserName"].ToString()); LumexSessionManager.Add("isMenu", "N"); LumexSessionManager.Add("ActiveMenuFor", "inv"); LumexSessionManager.Add("ScreenLock", "False"); LumexSessionManager.Add("ScreenLock", "False"); LumexSessionManager.Add("UserSalesCenterId", dt.Rows[0]["SalesCenterId"].ToString()); LumexSessionManager.Add("UserWareHouseId", dt.Rows[0]["WarehouseId"].ToString()); LumexSessionManager.Add("UserGroupId", dt.Rows[0]["UserGroupId"].ToString()); Response.Redirect("~/Default.aspx"); } else { lblnotify.Text = "User Access Denied!!!"; } } else { lblnotify.Text = "Invalid User or Password"; } //if (txtbxUserName.Text != "" && txtbxPass.Text != "") //{ // UserLogin user = new UserLogin(); // user.UserId = txtbxUserName.Text.Trim(); // user.Password = txtbxPass.Text.Trim(); // if (user.ValidateUser(user)) // { // LumexSessionManager.Add("ActiveUserId", user.UserId); // LumexSessionManager.Add("ActiveUserName", user.UserName); // LumexSessionManager.Add("ScreenLock", "False"); // LumexSessionManager.Add("UserDasignation", user.Designation); // Response.Redirect("~/Default.aspx"); // //statusLabel.Text = "Invalid User or Password"; // } // else // { // lblnotify.Text = "Invalid User or Password"; // } // } //else //{ // lblnotify.Text = "Enter UserID or Password"; //} } catch (Exception ex) { lblnotify.Text = ex.Message; } finally { // user = null; } }
protected void updateButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { if (userIdForUpdateHiddenField.Value.Trim() == "") { msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "User not found to update."; } if (userIdTextBox.Text == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User ID field is required."; } else if (userNameTextBox.Text == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Name field is required."; } else if (userGroupDropDownList.SelectedValue == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Group field is required."; } //else if (salesCenterDropDownList.SelectedValue == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Sales Center field is required."; //} //else if (contactNumberTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Contact Number field is required."; //} //else if (emailTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Email field is required."; //} //else if (addressTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Address field is required."; //} else { user.UserId = userIdTextBox.Text.Trim(); user.UserName = userNameTextBox.Text.Trim(); user.EmployeeId = ""; user.Department = ""; user.SalesCenterId = "";//salesCenterDropDownList.SelectedValue; user.warehouseId = warehouseDropDownList.SelectedValue; user.Designation = ""; user.Address = addressTextBox.Text.Trim(); user.ContactNumber = contactNumberTextBox.Text.Trim(); user.Email = emailTextBox.Text.Trim(); user.NationalId = ""; //nationalIdTextBox.Text.Trim(); user.PassportNumber = "";//passportNumberTextBox.Text.Trim(); user.UserGroupId = userGroupDropDownList.SelectedValue.Trim(); user.UpdateUser(); userIdForUpdateHiddenField.Value = ""; string message = "User <span class='actionTopic'>Updated</span> Successfully."; MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/User/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void GetUserById(string userId) { UserBLL user = new UserBLL(); try { DataTable dt = user.GetUserById(userId); if (dt.Rows.Count > 0) { userIdTextBox.Text = dt.Rows[0]["UserId"].ToString(); userNameTextBox.Text = dt.Rows[0]["UserName"].ToString(); // employeeIdTextBox.Text = dt.Rows[0]["EmployeeId"].ToString(); // salesCenterDropDownList.SelectedValue = "";//dt.Rows[0]["SalesCenterId"].ToString(); warehouseDropDownList.SelectedValue = dt.Rows[0]["WarehouseId"].ToString(); // designationTextBox.Text = dt.Rows[0]["Designation"].ToString(); addressTextBox.Text = dt.Rows[0]["Address"].ToString(); contactNumberTextBox.Text = dt.Rows[0]["ContactNumber"].ToString(); emailTextBox.Text = dt.Rows[0]["Email"].ToString(); // nationalIdTextBox.Text = dt.Rows[0]["NationalId"].ToString(); // passportNumberTextBox.Text = dt.Rows[0]["PassportNumber"].ToString(); userGroupDropDownList.SelectedValue = dt.Rows[0]["UserGroupId"].ToString(); } else { msgbox.Visible = true; msgTitleLabel.Text = "User Data Not Found!!!"; msgDetailLabel.Text = ""; msgbox.Attributes.Add("class", "alert alert-warning"); } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; } }
protected void saveButton_Click(object sender, EventArgs e) { UserBLL user = new UserBLL(); try { if (userIdTextBox.Text == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User ID field is required."; } else if (userNameTextBox.Text == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Name field is required."; } else if (userGroupDropDownList.SelectedValue == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "User Group field is required."; } //else if (contactNumberTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Contact Number field is required."; //} //else if (emailTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Email field is required."; //} //else if (addressTextBox.Text == "") //{ // msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Address field is required."; //} else if (passwordTextBox.Text == "") { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Password field is required."; } else if (passwordTextBox.Text != confirmPasswordTextBox.Text) { msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Password & Confirm Password do not match."; } else { user.UserId = userIdTextBox.Text.Trim(); user.UserName = userNameTextBox.Text.Trim(); user.EmployeeId = ""; user.Department = ""; user.Designation = ""; user.Address = addressTextBox.Text.Trim(); user.ContactNumber = contactNumberTextBox.Text.Trim(); user.Email = emailTextBox.Text.Trim(); user.NationalId ="";//nationalIdTextBox.Text.Trim(); user.PassportNumber = "";//passportNumberTextBox.Text.Trim(); user.Password = passwordTextBox.Text.Trim(); user.UserGroupId = userGroupDropDownList.SelectedValue.Trim(); user.SalesCenterId = "";//salesCenterDropDownList.SelectedValue; user.warehouseId = warehouseDropDownList.SelectedValue; if (!user.CheckDuplicateSalesCenter(user.UserId.Trim())) { DataTable dt = user.SaveUser(); if (dt.Rows.Count > 0) { string message = "User <span class='actionTopic'>Created</span> Successfully with User ID: <span class='actionTopic'>" + dt.Rows[0][0].ToString() + "</span>."; MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/User/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);"); } else { string message = "<span class='actionTopic'>Failed</span> to Create User."; MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");"); } } else { string message = "This User <span class='actionTopic'>already exist</span>, try another one."; MyAlertBox("WarningAlert(\"" + "Data Duplicate" + "\", \"" + message + "\");"); } } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; } MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");"); } finally { user = null; MyAlertBox(" MyOverlayStop();"); } }
public void UpdateUser(UserBLL user, LumexDBPlayer db) { try { db.AddParameters("@UserId", user.UserId.Trim()); db.AddParameters("@SalesCenterId", user.SalesCenterId.Trim()); db.AddParameters("@WareHouseId", user.warehouseId.Trim()); db.AddParameters("@UserName", user.UserName.Trim()); db.AddParameters("@EmployeeId", user.EmployeeId.Trim()); db.AddParameters("@UserGroupId", user.UserGroupId.Trim()); db.AddParameters("@Department", user.Department.Trim()); db.AddParameters("@Designation", user.Designation.Trim()); db.AddParameters("@Address", user.Address.Trim()); db.AddParameters("@ContactNumber", user.ContactNumber.Trim()); db.AddParameters("@Email", user.Email.Trim()); db.AddParameters("@NationalId", user.NationalId.Trim()); db.AddParameters("@PassportNumber", user.PassportNumber.Trim()); db.AddParameters("@ModifiedBy", LumexSessionManager.Get("ActiveUserId").ToString()); db.AddParameters("@ModifiedFrom", LumexLibraryManager.GetTerminal()); db.ExecuteNonQuery("UPDATE_USER_BY_ID", true); } catch (Exception) { throw; } finally { user = null; } }
public static bool ValidateUser(UserBLL user, LumexDBPlayer db) { bool isValid = false; try { db.AddParameters("@UserId", user.UserId); DataTable dt = db.ExecuteDataTable("GET_USER_PASSWORD_BY_ID", true); DataTableReader dtr = dt.CreateDataReader(); if (dtr.Read()) { if (ProtectPassword(user.Password) == dtr["Password"].ToString()) { isValid = true; } } } catch (Exception) { throw; } finally { user = null; } return isValid; }