protected void btnSave_Click(object sender, EventArgs e) { var obj = new USER(); obj.USER_NAME = popTxtUsername.Text; obj.PASSWORD = popTxtPassword.Text; obj.EMPLOYEE_ID = Convert.ToInt32(dllEmp.SelectedValue); obj.ROLE_ID = Convert.ToInt32(dllRole.SelectedValue); var cmd = new UserService(obj); if (flag.Text.Equals("Add")) { obj.Action = ActionEnum.Create; obj.CREATE_DATE = DateTime.Now; obj.CREATE_EMPLOYEE_ID = 0; obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; cmd.Add(); } else { obj.Action = ActionEnum.Update; obj.USER_ID = Convert.ToInt32(ViewState["userId"].ToString()); obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; cmd.Edit(); } ViewState["userId"] = null; Response.Redirect("SearchUser.aspx"); }
public UserService(USER item) { _item = item; }
private void InitialDataPopup() { dllEmp.Items.Clear(); dllRole.Items.Clear(); var emp = new EmployeeService(); foreach (var item in emp.GetALL()) { dllEmp.Items.Add(new ListItem(item.EMPLOYEE_NAME + " " + item.EMPLOYEE_SURNAME, item.EMPLOYEE_ID.ToString())); } var role = new RoleService(); foreach (var item in role.GetALL()) { dllRole.Items.Add(new ListItem(item.ROLE_NAME, item.ROLE_ID.ToString())); } if (ViewState["userId"] != null) { var cmd = new UserService(); _item = cmd.Select(Convert.ToInt32(ViewState["userId"].ToString())); if (_item != null) { popTxtUsername.Text = _item.USER_NAME; popTxtPassword.TextMode = TextBoxMode.SingleLine; popTxtPassword.Text = "*************"; popTxtPassword.Enabled = false; dllEmp.SelectedValue = _item.EMPLOYEE_ID.ToString(); dllRole.SelectedValue = _item.ROLE_ID.ToString(); flag.Text = "Edit"; } } else { popTxtPassword.TextMode = TextBoxMode.Password; popTxtPassword.Enabled = true; } }