public bool Update(DtoStaff dtoStaff) { using (SqlConnection sqlConnection = data.GetConnect()) { try { sqlConnection.Open(); string sql = @"UPDATE STAFF SET StaffName = @StaffName, Gender = @Gender, DateOfBirth = @DateOfBirth, Phone = @Phone, Address = @Address, UserName = @UserName, Status = @Status, Avatar = @Avatar WHERE StaffID = @StaffID"; SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection); sqlCommand.Parameters.Add("@StaffID", SqlDbType.NChar).Value = dtoStaff.StaffID; sqlCommand.Parameters.Add("@StaffName", SqlDbType.NVarChar).Value = dtoStaff.StaffName; sqlCommand.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = dtoStaff.Gender; sqlCommand.Parameters.Add("@DateOfBirth", SqlDbType.Date).Value = dtoStaff.DateOfBirth; sqlCommand.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = dtoStaff.Phone; sqlCommand.Parameters.Add("@Address", SqlDbType.NVarChar).Value = dtoStaff.Address; sqlCommand.Parameters.Add("@UserName", SqlDbType.NChar).Value = dtoStaff.UserName; sqlCommand.Parameters.Add("@Status", SqlDbType.NVarChar).Value = dtoStaff.Status; if (dtoStaff.Avatar == null) { sqlCommand.Parameters.Add("@Avatar", SqlDbType.Image).Value = DBNull.Value; } else { sqlCommand.Parameters.Add("@Avatar", SqlDbType.Image).Value = dtoStaff.Avatar; } sqlCommand.ExecuteNonQuery(); } catch { return(false); } } return(true); }
public bool Add(DtoStaff dtoStaff) { using (SqlConnection sqlConnection = data.GetConnect()) { try { sqlConnection.Open(); string sql = @"INSERT INTO STAFF VALUES(@StaffID, @StaffName, @Gender, @DateOfBirth, @Phone, @Address, @Role, @UserName, @Status, @Avatar)"; SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection); sqlCommand.Parameters.Add("@StaffID", SqlDbType.NChar).Value = dtoStaff.StaffID; sqlCommand.Parameters.Add("@StaffName", SqlDbType.NVarChar).Value = dtoStaff.StaffName; sqlCommand.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = dtoStaff.Gender; sqlCommand.Parameters.Add("@DateOfBirth", SqlDbType.Date).Value = dtoStaff.DateOfBirth; sqlCommand.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = dtoStaff.Phone; sqlCommand.Parameters.Add("@Address", SqlDbType.NVarChar).Value = dtoStaff.Address; sqlCommand.Parameters.Add("@Role", SqlDbType.NVarChar).Value = StringHelper.Role.Admin.Key; sqlCommand.Parameters.Add("@UserName", SqlDbType.NChar).Value = dtoStaff.UserName; sqlCommand.Parameters.Add("@Status", SqlDbType.NVarChar).Value = StringHelper.ActionStatus.Active.Key; if (dtoStaff.Avatar == null) { sqlCommand.Parameters.Add("@Avatar", SqlDbType.Image).Value = DBNull.Value; } else { sqlCommand.Parameters.Add("@Avatar", SqlDbType.Image).Value = dtoStaff.Avatar; } sqlCommand.ExecuteNonQuery(); } catch { return(false); } } return(true); }
private void DgwIssueBook_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgwIssueBook.Rows.Count.Equals(0)) { return; } string issueID = dgwIssueBook.CurrentRow.Cells["IssueID"].Value.ToString(); dtoIssue = bllIssue.GetByID(issueID); txtIssueID.Text = dtoIssue.IssueID; txtLendingStaffID.Text = dtoIssue.StaffID; dtoLendingStaff = bllStaff.GetByID(dtoIssue.StaffID); txtLendingStaffName.Text = dtoLendingStaff.StaffName; txtIssueBookDate.Text = dtoIssue.IssueDate.ToString("dd / MM / yyyy"); txtIssueNotes.Text = dtoIssue.Notes; // btnReturn.Enabled = true; btnLost.Enabled = true; }
private void BtnLogin_Click(object sender, EventArgs e) { dtoAccount.Username = txtUserName.Text; dtoAccount.Password = txtPassword.Text; if (bllAccount.CanLogin(dtoAccount)) { dtoStaff = bllStaff.GetByUserName(txtUserName.Text); Close(); Thread thread = new Thread( delegate() { Application.Run(new Main(dtoStaff)); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else { labelFail.Visible = true; } }
private void DgwStaffInfo_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgwStaffInfo.Rows.Count.Equals(0)) { return; } // staff string staffID = dgwStaffInfo.CurrentRow.Cells["StaffID"].Value.ToString(); dtoStaff = bllStaff.GetByID(staffID); txtStaffID.Text = dtoStaff.StaffID; txtDateOfBirth.Text = dtoStaff.DateOfBirth.ToString("dd/MM/yyyy"); txtAddress.Text = dtoStaff.Address; txtEnable.Text = StringHelper.ActionStatus.GetByKey(dtoStaff.Status).Display; txtStaffName.Text = dtoStaff.StaffName; txtGender.Text = StringHelper.Gender.GetByKey(dtoStaff.Gender).Display; txtPhone.Text = dtoStaff.Phone; txtUserName.Text = dtoStaff.UserName; // btnUpdateStaff.Enabled = true; LoadImage(); }
public Update(string userName, DtoStaff dtoStaff) { InitializeComponent(); this.dtoAccount = bllAccount.GetByUserName(userName); this.dtoStaff = dtoStaff; }
public Main(DtoStaff dtoStaff) { InitializeComponent(); Session.StaffWorking = dtoStaff; }
public bool Update(DtoStaff dtoStaff) { return(dalStaff.Update(dtoStaff)); }
public bool Add(DtoStaff dtoStaff) { return(dalStaff.Add(dtoStaff)); }