private void btnDongY_Click(object sender, EventArgs e) { if (Them) {//Thêm ThietBi temp = new ThietBi(); temp.MaThietBi = txtMa.Text; temp.TenThietBi = txtTen.Text; if (!CheckLoi(temp)) return; int kq = ThietBiBiz.AddThietBi(temp); if (kq > 0) MSG.ThemThanhCong(); else MSG.ThemThatBai(); } else {//Sửa ThietBi temp = new ThietBi(); temp.MaThietBi = txtMa.Text; temp.TenThietBi = txtTen.Text; int kq = ThietBiBiz.EditThietBi(temp); if (kq > 0) MSG.SuaThanhCong(); else MSG.SuaThatBai(); } this.Close(); }
public ThietBi Copy() { ThietBi kq = new ThietBi(); kq.MaThietBi = maThietBi; kq.TenThietBi = tenThietBi; return kq; }
public ThietBi Copy() { ThietBi kq = new ThietBi(); kq.MaThietBi = maThietBi; kq.TenThietBi = tenThietBi; return(kq); }
public static List<ThietBi> getListThietBi() { List<ThietBi> kq = new List<ThietBi>(); string sql = "SELECT [MaThietBi],[TenThietBi] FROM [VNAAccounting].[dbo].[ThietBi]"; System.Data.DataTable dt = DAL.CSDL.hienthi(sql); for (int i = 0; i < dt.Rows.Count; i++) { ThietBi temp = new ThietBi(); temp.MaThietBi = dt.Rows[i]["MaThietBi"].ToString(); temp.TenThietBi = dt.Rows[i]["TenThietBi"].ToString(); kq.Add(temp); } return kq; }
bool CheckLoi(ThietBi data) { bool kq = true; //mã thiết bị rỗng if (string.IsNullOrEmpty(data.MaThietBi)) { MSG.ErrorStand("Bạn chưa nhập mã thiết bị!"); txtMa.Focus(); return false; } //mã thiết bị đã có trong cơ sở dữ liệu foreach (ThietBi item in frmDMThietBi.Ldata) { if (item.MaThietBi.ToUpper().Equals(txtMa.Text.ToUpper())) { MSG.ErrorStand("Mã thiết bị đã có trong cơ sở dữ liệu!"); txtMa.Focus(); return false; } } return kq; }
public static int EditThietBi(ThietBi input) { string sql = "UPDATE [VNAAccounting].[dbo].[ThietBi] SET TenThietBi = N'" + input.TenThietBi + "' WHERE MaThietBi = N'" + input.MaThietBi.ToUpper() + "'"; return DAL.CSDL.ThemSuaXoa(sql); }
public static int DeleteThietBi(ThietBi input) { string sql = "DELETE FROM [VNAAccounting].[dbo].[ThietBi] WHERE MaThietBi = N'" + input.MaThietBi.ToUpper() + "'"; return DAL.CSDL.ThemSuaXoa(sql); }
public static int AddThietBi(ThietBi input) { string sql = "INSERT INTO [VNAAccounting].[dbo].[ThietBi]([MaThietBi],[TenThietBi]) VALUES(N'" + input.MaThietBi.ToUpper() + "',N'" + input.TenThietBi + "')"; return DAL.CSDL.ThemSuaXoa(sql); }
public static ThietBi DataGridViewRow_to_ThietBi(System.Windows.Forms.DataGridViewRow Input) { ThietBi kq = new ThietBi(); kq.MaThietBi = Input.Cells["MaThietBi"].Value.ToString(); kq.TenThietBi = Input.Cells["TenThietBi"].Value.ToString(); return kq; }