//insert public bool insertnhanVienSuaXe(nhanVienSuaXeDTO nhanVienSuaXeDTO) { try { this.openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO THOSUAXE(id, username, password, status)" + "VALUES (@id, @username, @password, @status)", this.getConnection); cmd.Parameters.Add("@id", SqlDbType.NChar).Value = nhanVienSuaXeDTO.id; cmd.Parameters.Add("@username", SqlDbType.NChar).Value = nhanVienSuaXeDTO.username; cmd.Parameters.Add("@password", SqlDbType.NChar).Value = nhanVienSuaXeDTO.password; cmd.Parameters.Add("@status", SqlDbType.Bit).Value = nhanVienSuaXeDTO.status; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (Exception ex) { MessageBox.Show("Error: ", ex.Message); } finally { this.closeConnection(); } return(false); }
public bool insertnhanVienSuaXe(nhanVienSuaXeDTO nhanVienSuaXeDTO) { return(this.nhanVienSuaXeDAL.insertnhanVienSuaXe(nhanVienSuaXeDTO)); }
private void insertTho_NhanVien(int flag, string id_cmnd, string username, string password, int status) { try { if (status == 0) { if (flag == 0) //bảo vệ { nhanVienBaoVeDTO nhanVienBaoVeDTO = new nhanVienBaoVeDTO(id_cmnd, username, password, status); if (this.nhanVienBaoVeBUS.insertnhanVienBaoVe(nhanVienBaoVeDTO)) { MessageBox.Show("Thêm tài khoản Bảo Vệ thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Bảo Vệ không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (flag == 1) //nhân viên sửa xe { nhanVienSuaXeDTO nhanVienSuaXeDTO = new nhanVienSuaXeDTO(id_cmnd, username, password, status); if (this.nhanVienSuaXeBUS.insertnhanVienSuaXe(nhanVienSuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (flag == 2) //nhân viên rửa xe { nhanVienRuaXeDTO nhanVienRuaXeDTO = new nhanVienRuaXeDTO(id_cmnd, username, password, status); if (this.nhanVienRuaXeBUS.insertnhanVienRuaXe(nhanVienRuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //nhân viên phòng hợp đồng { nhanVienHopDongDTO nhanVienHopDongDTO = new nhanVienHopDongDTO(id_cmnd, username, password, status); if (this.nhanVienHopDongBUS.insertnhanVienHopDong(nhanVienHopDongDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { if (flag == 0) //bảo vệ { if (this.nhanVienBaoVeBUS.leaderExist()) // tồn tại { MessageBox.Show("Ban Bảo Vệ đã có Trưởng Phòng", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Warning); nhanVienBaoVeDTO nhanVienBaoVeDTO = new nhanVienBaoVeDTO(id_cmnd, username, password, 0); if (this.nhanVienBaoVeBUS.insertnhanVienBaoVe(nhanVienBaoVeDTO)) { MessageBox.Show("Thêm tài khoản Bảo Vệ thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Bảo Vệ không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { nhanVienBaoVeDTO nhanVienBaoVeDTO = new nhanVienBaoVeDTO(id_cmnd, username, password, status); if (this.nhanVienBaoVeBUS.insertnhanVienBaoVe(nhanVienBaoVeDTO)) { MessageBox.Show("Thêm tài khoản Bảo Vệ_Trưởng Phòng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Bảo Vệ_Trưởng Phòng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else if (flag == 1) { if (this.nhanVienSuaXeBUS.leaderExist()) { MessageBox.Show("Ban Sửa Xe đã có Trưởng Phòng", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Warning); nhanVienSuaXeDTO nhanVienSuaXeDTO = new nhanVienSuaXeDTO(id_cmnd, username, password, 0); if (this.nhanVienSuaXeBUS.insertnhanVienSuaXe(nhanVienSuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { nhanVienSuaXeDTO nhanVienSuaXeDTO = new nhanVienSuaXeDTO(id_cmnd, username, password, status); if (this.nhanVienSuaXeBUS.insertnhanVienSuaXe(nhanVienSuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe_Trưởng Phòng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Sửa Xe_Trưởng Phòng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else if (flag == 2) //rửa { if (this.nhanVienRuaXeBUS.leaderExist()) { MessageBox.Show("Ban Rửa Xe đã có Trưởng Phòng", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Warning); nhanVienRuaXeDTO nhanVienRuaXeDTO = new nhanVienRuaXeDTO(id_cmnd, username, password, 0); if (this.nhanVienRuaXeBUS.insertnhanVienRuaXe(nhanVienRuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { nhanVienRuaXeDTO nhanVienRuaXeDTO = new nhanVienRuaXeDTO(id_cmnd, username, password, status); if (this.nhanVienRuaXeBUS.insertnhanVienRuaXe(nhanVienRuaXeDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe_Trưởng Phòng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Rửa Xe_Trưởng Phòng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else //hợp đồng { if (this.nhanVienHopDongBUS.leaderExist()) { MessageBox.Show("Ban Nhân Viên Hợp Đồng đã có Trưởng Phòng", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Warning); nhanVienHopDongDTO nhanVienHopDongDTO = new nhanVienHopDongDTO(id_cmnd, username, password, 0); if (this.nhanVienHopDongBUS.insertnhanVienHopDong(nhanVienHopDongDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { nhanVienHopDongDTO nhanVienHopDongDTO = new nhanVienHopDongDTO(id_cmnd, username, password, status); if (this.nhanVienHopDongBUS.insertnhanVienHopDong(nhanVienHopDongDTO)) { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng_Trưởng Phòng thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm tài khoản Nhân viên Hợp Đồng_Trưởng Phòng không thành công", "Tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } catch (Exception e) { MessageBox.Show("Error: ", e.Message); } }