public UserED() { InitializeComponent(); txt_name.KeyPress += EnterKeyPressEventOccure; txt_email.KeyPress += EnterKeyPressEventOccure; txt_username.KeyPress += EnterKeyPressEventOccure; txt_password.KeyPress += EnterKeyPressEventOccure; txt_newPassword.KeyPress += EnterKeyPressEventOccure; this.Text = "Add User"; users = new Users(); cb_userRole.DataSource = users.getUserRole(); cb_userRole.ValueMember = "code"; cb_userRole.DisplayMember = "name"; cb_userRole.DropDownStyle = ComboBoxStyle.DropDownList; DataTable data = users.getUserStatus(); foreach (DataRow row in data.Rows) { row["name"] = Encrption.UppercaseFirst(row["name"].ToString()); } cb_userStatus.DataSource = data; cb_userStatus.ValueMember = "id"; cb_userStatus.DisplayMember = "name"; cb_userStatus.DropDownStyle = ComboBoxStyle.DropDownList; passwordlbl.Text = "Password"; confirmPasswordlbl.Hide(); txt_newPassword.Hide(); btn_update.Text = "ADD"; btn_delete.Text = "CANCEL"; is_edit = false; }
public EmployeeED() { InitializeComponent(); txt_name.KeyPress += EnterKeyPressEventOccure; txt_email.KeyPress += EnterKeyPressEventOccure; txt_address.KeyPress += EnterKeyPressEventOccure; txt_fathername.KeyPress += EnterKeyPressEventOccure; txt_mobile.KeyPress += EnterKeyPressEventOccure; txt_nic.KeyPress += EnterKeyPressEventOccure; this.isEditEmployee = false; this.removeImage = false; this.fileExt = ""; this.filePath = ""; users = new Users(); DataTable dataUserRole = users.getUserRole(); cb_role.DataSource = dataUserRole; cb_role.ValueMember = "code"; cb_role.DisplayMember = "name"; cb_role.SelectedIndex = 0; DataTable data = users.getUserStatus(); foreach (DataRow row in data.Rows) { row["name"] = Encrption.UppercaseFirst(row["name"].ToString()); } cb_status.DataSource = data; cb_status.ValueMember = "id"; cb_status.DisplayMember = "name"; cb_status.SelectedIndex = 0; this.appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\EmployeesImages\"; }
public EmployeeED(string employee_id) { InitializeComponent(); txt_name.KeyPress += EnterKeyPressEventOccure; txt_email.KeyPress += EnterKeyPressEventOccure; txt_address.KeyPress += EnterKeyPressEventOccure; txt_fathername.KeyPress += EnterKeyPressEventOccure; txt_mobile.KeyPress += EnterKeyPressEventOccure; txt_nic.KeyPress += EnterKeyPressEventOccure; this.isEditEmployee = true; this.removeImage = false; this.employeeId = employee_id; this.fileExt = ""; this.filePath = ""; btn_add.Text = "UPDATE"; btn_cancel.Text = "DELETE"; users = new Users(); DataTable dataUserRole = users.getUserRole(); cb_role.DataSource = dataUserRole; cb_role.ValueMember = "code"; cb_role.DisplayMember = "name"; cb_role.SelectedIndex = 0; DataTable data = users.getUserStatus(); foreach (DataRow row in data.Rows) { row["name"] = Encrption.UppercaseFirst(row["name"].ToString()); } cb_status.DataSource = data; cb_status.ValueMember = "id"; cb_status.DisplayMember = "name"; cb_status.SelectedIndex = 0; this.appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\EmployeesImages\"; employee = new Employee(employee_id); DataTable dataTable = employee.getEmployeeById(); if (dataTable.Rows.Count > 0) { this.employeeName = dataTable.Rows[0]["name"].ToString(); txt_name.Text = dataTable.Rows[0]["name"].ToString(); txt_fathername.Text = dataTable.Rows[0]["father_name"].ToString(); txt_address.Text = dataTable.Rows[0]["address"].ToString(); txt_email.Text = dataTable.Rows[0]["email"].ToString(); txt_mobile.Text = dataTable.Rows[0]["mobile_no"].ToString(); this.mobile_no = dataTable.Rows[0]["mobile_no"].ToString(); txt_nic.Text = dataTable.Rows[0]["cnic_no"].ToString(); this.cnic_no = dataTable.Rows[0]["cnic_no"].ToString(); cb_role.SelectedValue = dataTable.Rows[0]["user_role_code"].ToString(); cb_status.SelectedValue = dataTable.Rows[0]["user_status_id"].ToString(); this.previousImage = dataTable.Rows[0]["profile_image"].ToString(); if (!dataTable.Rows[0]["profile_image"].ToString().Equals("")) { image.Image = Bitmap.FromFile(Path.Combine(this.appPath, dataTable.Rows[0]["profile_image"].ToString())); } } else { MessageBox.Show(String.Format("Employee contain id : {0} were not found", employee_id), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
public UserED(int user_id) { InitializeComponent(); txt_name.KeyPress += EnterKeyPressEventOccure; txt_email.KeyPress += EnterKeyPressEventOccure; txt_username.KeyPress += EnterKeyPressEventOccure; txt_password.KeyPress += EnterKeyPressEventOccure; txt_newPassword.KeyPress += EnterKeyPressEventOccure; //this.Text = name.ToUpper(); this.verifiedUser = false; this.role = Login.user_role; this.selectedUserId = user_id; users = new Users(user_id); DataTable currentUser = users.getUserById(); cb_userRole.DataSource = users.getUserRole(); cb_userRole.ValueMember = "code"; cb_userRole.DisplayMember = "name"; cb_userRole.DropDownStyle = ComboBoxStyle.DropDownList; DataTable data = users.getUserStatus(); foreach (DataRow row in data.Rows) { row["name"] = Encrption.UppercaseFirst(row["name"].ToString()); } cb_userStatus.DataSource = data; cb_userStatus.ValueMember = "id"; cb_userStatus.DisplayMember = "name"; cb_userStatus.DropDownStyle = ComboBoxStyle.DropDownList; passwordlbl.Visible = false; txt_password.Visible = false; confirmPasswordlbl.Visible = false; txt_newPassword.Visible = false; btn_delete.Enabled = false; is_edit = true; if (currentUser.Rows.Count > 0) { this.Text = currentUser.Rows[0]["name"].ToString(); txt_name.Text = currentUser.Rows[0]["name"].ToString(); txt_username.Text = currentUser.Rows[0]["username"].ToString(); login_id = currentUser.Rows[0]["username"].ToString(); txt_email.Text = currentUser.Rows[0]["email"].ToString(); cb_userRole.SelectedValue = currentUser.Rows[0]["user_role_code"].ToString(); cb_userStatus.SelectedValue = currentUser.Rows[0]["user_status_id"].ToString(); if (role.Equals("admin")) { passwordlbl.Visible = true; txt_password.Visible = true; if (this.selectedUserId.Equals(Login.user_id)) { passwordlbl.Text = "Old Password"; btn_delete.Enabled = false; } else { passwordlbl.Text = "Password"; btn_delete.Enabled = true; } } } }