示例#1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            class_khachhang kh = new class_khachhang();

            if (kh.kiemtra(txtMaKH.Text, txtTen.Text, txtDiaChi.Text, txtDienThoai.Text, txtFax.Text) == false)
            {
                kh.sua(txtMaKH.Text, txtTen.Text, txtDiaChi.Text, txtDienThoai.Text, txtFax.Text);
                MessageBox.Show("Sua Thanh Cong ", "Thông Báo");
                update();
            }
            else
            {
                MessageBox.Show("Loi Sua", "Thong Bao");
            }

            //try
            //{
            //    cn.Open();
            //    string Update = "update KhachHang set TenKH ='" + txtTen.Text + "',DiaChi='" + txtDiaChi.Text + "',DienThoai='" + txtDienThoai.Text + "',Fax='" + txtFax.Text + "' where MaKH='" + txtMaKH.Text + "'";
            //    SqlCommand cmdUpdate = new SqlCommand(Update, cn);

            //    cmdUpdate.ExecuteNonQuery();
            //    Connect();
            //    MessageBox.Show("Sua Thanh Cong ", "Thông Báo");
            //}
            //catch (SqlException ex)
            //{
            //    MessageBox.Show("Loi Sua", "thong Bao\n" + ex.Message);

            //}
            //finally
            //{
            //    cn.Close();
            //}
        }
示例#2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            class_khachhang kh = new class_khachhang();

            if (kh.kiemtra(txtMaKH.Text, txtTen.Text, txtDiaChi.Text, txtDienThoai.Text, txtFax.Text) == false)
            {
                kh.xoa(txtTen.Text);
                MessageBox.Show("Xoa Thanh Cong ", "Thông Báo");
                update();
            }
            else
            {
                MessageBox.Show("Loi Xoa", "Thong Bao");
            }

            //try
            //{
            //    cn.Open();
            //    string Delete = "Delete KhachHang WHERE TenKH ='" + txtTen.Text + "'";
            //    SqlCommand cmddel = new SqlCommand(Delete, cn);

            //    cmddel.ExecuteNonQuery();
            //    Connect();
            //    MessageBox.Show("Xóa Thành Công ", "Thông Báo");



            //}
            //catch (SqlException ex)
            //{
            //    MessageBox.Show("Loi Xoa", "Thông Báo\n" + ex.Message);
            //}
            //finally
            //{
            //    cn.Close();
            //}
        }