public DataTable CreateTbKH(EC_KhachHang _kh) { string sqlquery = "SELECT * FROM tb_Khachhang where makh like N'%{0}%' and tenkh like N'%{1}%' and diachi like N'%{2}%' and dienthoai like N'%{3}%'"; sqlquery = string.Format(sqlquery, _kh.MaKH, _kh.TenKH, _kh.DiaChi, _kh.DienThoai); return(Connect.CreateTable(sqlquery)); }
public static bool updateKH(EC_KhachHang khach) { conn = GetData.KetNoi(); string sTruyVan = "KhachHang_Update"; cmd = new SqlCommand(sTruyVan, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value = khach.MaKH; cmd.Parameters.Add("@TENKH", SqlDbType.NVarChar).Value = khach.TenKH; cmd.Parameters.Add("@DIENTHOAI", SqlDbType.NVarChar).Value = khach.DienThoai; cmd.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value = khach.DiaChi; cmd.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value = khach.Email; cmd.ExecuteNonQuery(); cmd.Dispose(); try { GetData.ThucThiTruyVanNonQuery(sTruyVan, conn); //Đóng kết nối GetData.DongKetNoi(conn); return(true); } catch (Exception ex) { //Đóng kết nối GetData.DongKetNoi(conn); return(false); } }
public static bool deleteKH(EC_KhachHang khach) { conn = GetData.KetNoi(); string sTruyVan = "KhachHang_Delete"; cmd = new SqlCommand(sTruyVan, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value = khach.MaKH; cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Close(); try { GetData.ThucThiTruyVanNonQuery(sTruyVan, conn); //Đóng kết nối GetData.DongKetNoi(conn); return(true); } catch (Exception ex) { //Đóng kết nối GetData.DongKetNoi(conn); return(false); } }
public void AddKH(EC_KhachHang _kh) { string sqlquery = (@"INSERT INTO tb_Khachhang ( makh, tenkh, diachi, dienthoai) VALUES (N'{0}',N'{1}',N'{2}',N'{3}')"); sqlquery = string.Format(sqlquery, _kh.MaKH, _kh.TenKH, _kh.DiaChi, _kh.DienThoai); Connect.ExcuteNonQuery(sqlquery); }
public void UpdateKH(EC_KhachHang _kh) { string sqlquery = (@"UPDATE tb_Khachhang SET tenkh =N'{0}', diachi =N'{1}', dienthoai =N'{2}' where makh=N'{3}'"); sqlquery = string.Format(sqlquery, _kh.TenKH, _kh.DiaChi, _kh.DienThoai, _kh.MaKH); Connect.ExcuteNonQuery(sqlquery); }
private void btnSave_Click(object sender, EventArgs e) { if (themmoi) { EC_KhachHang a = new EC_KhachHang(); a.MaKH = cbMaKH.Text.Trim(); a.TenKH = txtName.Text.Trim(); a.NgaySinh = dtp.Value.Year.ToString() + "-" + dtp.Value.Month.ToString() + "-" + dtp.Value.Day.ToString(); a.GT = cbGT.Text.Trim(); a.SoDT = txtSDT.Text.Trim(); a.CMND = txtCMND.Text.Trim(); a.DiaChi = txtDiaChi.Text.Trim(); if (cbMaKH.Text != "") { if (KhachHang.Them(a) > 0) { MessageBox.Show("Thêm Mới Thành Công !!!", "Thông Báo", MessageBoxButtons.OK); dt = KhachHang.getAllKhachHang(); dgvKhachHang.DataSource = dt; } else { MessageBox.Show("Khong them duoc !!!", "Thông Báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Bạn chưa nhập thông tin MaKH!!!", "Thông Báo", MessageBoxButtons.OK); return; } } else { EC_KhachHang a = new EC_KhachHang(); a.MaKH = cbMaKH.Text.Trim(); a.TenKH = txtName.Text.Trim(); a.NgaySinh = dtp.Value.Year.ToString() + "-" + dtp.Value.Month.ToString() + "-" + dtp.Value.Day.ToString(); a.GT = cbGT.Text.Trim(); a.SoDT = txtSDT.Text.Trim(); a.CMND = txtCMND.Text.Trim(); a.DiaChi = txtDiaChi.Text.Trim(); if (KhachHang.Sua(a) != 0) { MessageBox.Show("Đã Sửa Thành Công !!!", "Thông Báo", MessageBoxButtons.OK); dt = KhachHang.getAllKhachHang(); dgvKhachHang.DataSource = dt; } else { MessageBox.Show("khong sua duoc !!!", "Thông Báo", MessageBoxButtons.OK); } } btnRefresh_Click(null, null); KhoaDieuKhien(); }
public void AddKhachHang(EC_KhachHang _khachhang) { if (!sqlkhachhang.CheckKH(_khachhang.MaKH)) { sqlkhachhang.AddKH(_khachhang); } else { MessageBox.Show("Mã này đã tồn tại,xin chọn Mã khác", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//sửa dữ liệu public int SuaDuLieu(EC_KhachHang et) { return(cn.ThucThiCauLenhSQL(@"UPDATE KhachHang SET TenKH =N'" + et.TenKH + "', NgaySinh =N'" + et.NgaySinh + "', GT =N'" + et.GT + "', SDT =N'" + et.SDT + "', SoCMND =N'" + et.SoCMND + "', DiaChi =N'" + et.DiaChi + "', NgheNgiep =N'" + et.NgheNghiep + "', QuocTich =N'" + et.QuocTich + "' where MaKH=N'" + et.MaKH + "'")); }
public void DeleteKH(EC_KhachHang _kh) { Connect.ExcuteNonQuery("DELETE FROM [tb_Khachhang] WHERE makh=N'" + _kh.MaKH + "'"); }
public bool deleteKH(EC_KhachHang khach) { return(DA_KhachHang.deleteKH(khach)); }
public int XoaduLieu(EC_KhachHang ec) { return(this.sql.XoaDulieu(ec)); }
public void SuaDuLieu(EC_KhachHang ec) { sql.SuaDuLieu(ec); }
public void DeleteKhachHang(EC_KhachHang _khachhang) { sqlkhachhang.DeleteKH(_khachhang); }
public void ThemDuLieu(EC_KhachHang ec) { sql.ThemDuLieu(ec); }
public bool updateKH(EC_KhachHang khach) { return(DA_KhachHang.updateKH(khach)); }
public void UpdateKhachHang(EC_KhachHang _khachhang) { sqlkhachhang.UpdateKH(_khachhang); }
public void SuaDuLieu(EC_KhachHang ec) { cn.ThucHienCauLenh("UPDATE KhachHang SET TenKH = '" + ec.TenKhach + "', CMND = '" + ec.CMND + "', SDT = '" + ec.SDT + "',DiaChi='" + ec.DiaChi + "' WHERE MaKH = '" + ec.MaKhachHang + "'"); }
//sửa dữ liệu public int SuaDuLieu(EC_KhachHang et) { return(sql.SuaDuLieu(et)); }
public void ThemDuLieu(EC_KhachHang ec) { cn.ThucHienCauLenh("INSERT INTO KhachHang ( TenKH, SDT, CMND, DiaChi) VALUES (N'" + ec.TenKhach + "', '" + ec.SDT + "', '" + ec.CMND + "', N'" + ec.DiaChi + "')"); }
//Hàm thêm dữ liệu public int ThemDuLieu(EC_KhachHang et) { return(cn.ThucThiCauLenhSQL(@"INSERT INTO KhachHang(MaKH,TenKH, NgaySinh, GT, SDT, SoCMND, DiaChi, NgheNghiep, QuocTich) VALUES (N'" + et.MaKH + "',N'" + et.TenKH + "',N'" + et.NgaySinh + "',N'" + et.GT + "',N'" + et.SDT + "',N'" + et.SoCMND + "',N'" + et.DiaChi + "',N'" + et.NgheNghiep + "',N'" + et.QuocTich + "')")); }
public void Xoa(EC_KhachHang et) { cn.ThucHienLenh(@"DELETE FROM tblKhachHang where MaKH = '" + et.MaKH + "'"); }
public void Sua(EC_KhachHang et) { cn.ThucHienLenh(@"UPDATE tblKhachHang SET TenKH = N'" + et.TenKH + "',NgaySinh = '" + et.NgaySinh + "',GT = N'" + et.GT + "', SoDT = '" + et.SoDT + "',CMND = '" + et.CMND + "',DiaChi = N'" + et.DiaChi + "' where MaKH = '" + et.MaKH + "'"); }
public void Them(EC_KhachHang et) { cn.ThucHienLenh(@"INSERT INTO tblKhachHang (MaKH,TenKH,NgaySinh,GT,SoDT,CMND,DiaChi) VALUES ('" + et.MaKH + "',N'" + et.TenKH + "','" + et.NgaySinh + "',N'" + et.GT + "','" + et.SoDT + "','" + et.CMND + "',N'" + et.DiaChi + "')"); }
public int XoaDulieu(EC_KhachHang ec) { return(this.cn.Query("delete from KhachHang where MaKH = '" + ec.MaKhachHang + "'")); }
//xóa dữ liệu public void XoaDuLieu(EC_KhachHang et) { cn.ThucThiCauLenhSQL(@"DELETE from KhachHang where MaKH=N'" + et.MaKH + "'"); }
//Hàm thêm dữ liệu public int ThemDuLieu(EC_KhachHang et) { return(sql.ThemDuLieu(et)); }
public DataTable CreateTbKH(EC_KhachHang _kh) { return(sqlkhachhang.CreateTbKH(_kh)); }
//xóa dữ liệu public void XoaDuLieu(EC_KhachHang et) { sql.XoaDuLieu(et); }
public bool insertKH(EC_KhachHang khach) { return(DA_KhachHang.insertKH(khach)); }