コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa khách hàng?", "Lời nhắc", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Khachhang kh = new Khachhang();
                kh.MaKH = int.Parse(txt_makh.Text);

                if (bllKH.Deletekhachhang(kh))
                {
                    ShowAllkhachhang();
                }
                else
                {
                    MessageBox.Show("Lỗi!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
コード例 #2
0
        public bool Deletekhachhang(Khachhang kh)
        {
            string        sql = "Delete khachhang Where MaKH=@MaKH";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MaKH", SqlDbType.Int).Value = kh.MaKH;
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Khachhang kh = new Khachhang();

            kh.MaKH     = int.Parse(txt_makh.Text);
            kh.TenKH    = txt_tenkh.Text;
            kh.Diachi   = cb_diachikh.Text;
            kh.Ngaysinh = dt_nskh.Value;
            kh.Gioitinh = cb_gtkh.Text;
            kh.Email    = txt_emailkh.Text;
            kh.SDTKH    = double.Parse(txt_sdtkh.Text);

            if (bllKH.Updatekhachhang(kh))
            {
                ShowAllkhachhang();
            }
            else
            {
                MessageBox.Show("Lỗi!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
コード例 #4
0
        public bool Updatekhachhang(Khachhang kh)
        {
            string        sql = "Update khachhang Set MaKH=@MaKH,TenKH=@TenKH,Diachi=@Diachi,Ngaysinh=@Ngaysinh,Gioitinh=@Gioitinh,Email=@Email,SDTKH=@SDTKH Where MaKH=@MaKH";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MaKH", SqlDbType.Int).Value          = kh.MaKH;
                cmd.Parameters.Add("@TenKH", SqlDbType.NVarChar).Value    = kh.TenKH;
                cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar).Value   = kh.Diachi;
                cmd.Parameters.Add("@Ngaysinh", SqlDbType.DateTime).Value = kh.Ngaysinh;
                cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar).Value = kh.Gioitinh;
                cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value    = kh.Email;
                cmd.Parameters.Add("@SDTKH", SqlDbType.Int).Value         = kh.SDTKH;
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
コード例 #5
0
ファイル: BTLL.cs プロジェクト: lehaianh3112/ProjectLeHaiAnh
 public bool Deletekhachhang(Khachhang kh)
 {
     return(dalKH.Deletekhachhang(kh));
 }
コード例 #6
0
ファイル: BTLL.cs プロジェクト: lehaianh3112/ProjectLeHaiAnh
 public bool Updatekhachhang(Khachhang kh)
 {
     return(dalKH.Updatekhachhang(kh));
 }