public bool insertChitietBH(ChiTietBaoHanh nv) { string strInsert = "insert into CTBaoHanh values( "; strInsert += "'" + nv.MaCTBH + "',"; strInsert += "'" + nv.MaPhieuBH + "',"; strInsert += "'" + nv.NgayBH + "',"; strInsert += "N'" + nv.NoiDungBH + "')"; if (!data.UpdateData(strInsert)) { Error = data.Error; return(false); } return(true); }
public bool updateChitietBH(ChiTietBaoHanh nv, string ma1, string ma2) { string strUpdate = "update CTBaoHanh set "; strUpdate += "MACTBH='" + nv.MaCTBH + "',"; strUpdate += "MAPHIEUBH='" + nv.MaPhieuBH + "',"; strUpdate += "NGAYBH='" + nv.NgayBH + "',"; strUpdate += "NOIDUNGBH=N'" + nv.NoiDungBH + "'"; strUpdate += "where MACTBH='" + ma1 + "'"; strUpdate += "and MAPHIEUBH='" + ma2 + "'"; if (!data.UpdateData(strUpdate)) { Error = data.Error; return(false); } return(true); }
private void btLuu_Click(object sender, EventArgs e) { ChiTietBaoHanh tk = new ChiTietBaoHanh(); if (txtmaphieubh.Text == "") { MessageBox.Show("Hãy mã phiếu bảo hành", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtnoidungbh.Text == "") { MessageBox.Show("Hãy Nhập Mật Khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { bool a = true; tk.MaCTBH = txtMachitietbh.Text; tk.MaPhieuBH = txtmaphieubh.Text; tk.NgayBH = txt_thoigianbh.Text; tk.NoiDungBH = txtnoidungbh.Text; try { } catch { a = false; } if (a == false) { MessageBox.Show("Số Điện Thoại Chưa Đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (kt == true) { if (!blo.insertChitietBH(tk)) { MessageBox.Show("Tên Tài Khoản Này Đã Tồn Tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Đã Thêm Tài Khoản Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); UC_Chitietbaohanh_Load(sender, e); } } else { if (!blo.updateChitietBH(tk, txtMachitietbh.Text, txtmaphieubh.Text)) { MessageBox.Show(blo.Error, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Đã Sửa Tài Khoản Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); UC_Chitietbaohanh_Load(sender, e); } } } } }