Beispiel #1
0
        public bool DeleteLoaiKH(LoaiKH ttLoaiKh)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("delete from LoaiKhachHang where MaLoaiKH=@idLoaiKH", con);

            cmd.Parameters.AddWithValue("@idLoaiKH", ttLoaiKh.maLoaiKH);
            cmd.ExecuteNonQuery();
            con.Close();
            return(true);
        }
Beispiel #2
0
        public void UpdateLoaiKH(LoaiKH ttLoaiKh)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("update LoaiKhachHang set SoLuong=@soLuong  where MaLoaiKH=@idLoaiKH", con);

            cmd.Parameters.AddWithValue("@idLoaiKH", ttLoaiKh.maLoaiKH);
            cmd.Parameters.AddWithValue("@tenLoaiKH", ttLoaiKh.tenLoaiKH);
            cmd.Parameters.AddWithValue("@soLuong", ttLoaiKh.soLuong);
            cmd.ExecuteNonQuery();
            con.Close();
        }
Beispiel #3
0
        // 7. bang loai khach hang
        public string InsertLoaiKH(LoaiKH ttLoaiKh)
        {
            string        Message;
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into LoaiKhachHang(TenLoaiKH,SoLuong) values(@tenLoaiKH,@soLuong)", con);

            cmd.Parameters.AddWithValue("@tenLoaiKH", ttLoaiKh.tenLoaiKH);
            cmd.Parameters.AddWithValue("@soLuong", ttLoaiKh.soLuong);
            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                Message = ttLoaiKh.tenLoaiKH + " duoc them thanh cong";
            }
            else
            {
                Message = ttLoaiKh.tenLoaiKH + " them khong thanh cong";
            }
            con.Close();
            return(Message);
        }