コード例 #1
0
        protected void btnSua_Click(object sender, EventArgs e)
        {
            KHang kh = new KHang(txtMaKH.Text, txtTenKH.Text, txtSDT.Text);

            if (qlbh.updateKH(kh))
            {
                lblThongBao.Text = "Sửa thành công";
                grvKH.DataSource = qlbh.getTable("select * from KHACHHANG");
                grvKH.DataBind();
            }
            else
            {
                lblThongBao.Text = "Không sửa được";
            }
        }
コード例 #2
0
ファイル: QLBHADO.cs プロジェクト: trieunguyen272/GKCNPM
        public bool updateKH(KHang kh)
        {
            string        sql = @"update KHACHHANG set HOTEN=@tenkh, SDT=@sdt where MAKH=@makh";
            SqlConnection con = new SqlConnection(connectString);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@makh", kh.MAKH);
            cmd.Parameters.AddWithValue("@tenkh", kh.TENKH);
            cmd.Parameters.AddWithValue("@sdt", kh.SDT);
            con.Open();
            int count = (int)cmd.ExecuteNonQuery();

            con.Close();
            return(count >= 1);
        }
コード例 #3
0
ファイル: QLBHADO.cs プロジェクト: trieunguyen272/GKCNPM
        public bool insertKH(KHang kh)
        {
            string        sql = @"insert into KHACHHANG values (@makh, @tenkh, @sdt)";
            SqlConnection con = new SqlConnection(connectString);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@makh", kh.MAKH);
            cmd.Parameters.AddWithValue("@tenkh", kh.TENKH);
            cmd.Parameters.AddWithValue("@sdt", kh.SDT);
            con.Open();
            int count = cmd.ExecuteNonQuery();

            con.Close();
            return(count >= 1);
        }
コード例 #4
0
 protected void btnThem_Click(object sender, EventArgs e)
 {
     if (qlbh.checkMaKH(txtMaKH.Text))
     {
         lblThongBao.Text = "Mã khách hàng đã tồn tại!";
     }
     else
     {
         KHang kh = new KHang(txtMaKH.Text, txtTenKH.Text, txtSDT.Text);
         if (qlbh.insertKH(kh))
         {
             lblThongBao.Text = "Thêm thành công";
             grvKH.DataSource = qlbh.getTable("select * from KHACHHANG");
             grvKH.DataBind();
         }
         else
         {
             lblThongBao.Text = "Không thêm được";
         }
     }
 }