Exemplo n.º 1
0
        public bool UpdateKhach(DTO_KHACHHANG khach)
        {
            try
            {
                _conn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = _conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "[UpdateDataIntoTblKhach]";
                cmd.Parameters.AddWithValue("sodienthoai", khach.SDTKH);
                cmd.Parameters.AddWithValue("tenKhach", khach.TENKH);
                cmd.Parameters.AddWithValue("email", khach.EMAILKH);
                cmd.Parameters.AddWithValue("ngaysinh", khach.NGAYSINH);



                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                _conn.Close();
            }
            return(false);
        }
Exemplo n.º 2
0
        private void btSuaKH_Click(object sender, EventArgs e)
        {
            float intDienThoai;
            bool  isInt = float.TryParse(txtSdtKH.Text.Trim().ToString(), out intDienThoai);

            if (!isInt || float.Parse(txtSdtKH.Text) < 0)
            {
                MessageBox.Show("Bạn phải nhập số điện thoại > 0, số nguyên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSdtKH.Focus();
                return;
            }
            else
            {
                DTO_KHACHHANG kh = new DTO_KHACHHANG(txtSdtKH.Text, txtTenKH.Text, txtEmailKH.Text, dtpNgaysinhKH.Value.Date);
                if (MessageBox.Show("Bạn có chắc muốn chỉnh sửa", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (busKhach.UpdateKhach(kh))
                    {
                        MessageBox.Show("Sửa thành công");
                        ResetValues();
                        LoadGirdview_Khach();
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công");
                    }
                }
                else
                {
                    ResetValues();
                }
            }
        }
Exemplo n.º 3
0
        private void btLuuKH_Click(object sender, EventArgs e)
        {
            float intDienThoai;
            bool  isInt = float.TryParse(txtSdtKH.Text.Trim().ToString(), out intDienThoai);

            if (!isInt || float.Parse(txtSdtKH.Text) < 0)
            {
                MessageBox.Show("Bạn phải nhập số điện thoại > 0, số nguyên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSdtKH.Focus();
                return;
            }
            else
            {
                DTO_KHACHHANG kh = new DTO_KHACHHANG(txtSdtKH.Text, txtTenKH.Text, txtEmailKH.Text, dtpNgaysinhKH.Value.Date);
                if (busKhach.InsertKhach(kh))
                {
                    MessageBox.Show("Thêm thành công");
                    ResetValues();
                    LoadGirdview_Khach();
                }
                else
                {
                    MessageBox.Show("Thêm không thành công");
                }
            }
        }
Exemplo n.º 4
0
 public bool UpdateKhach(DTO_KHACHHANG khach)
 {
     return(dalKhach.UpdateKhach(khach));
 }
Exemplo n.º 5
0
 public bool InsertKhach(DTO_KHACHHANG khach)
 {
     return(dalKhach.InsertKhach(khach));
 }