private void btnTimKiem_Click(object sender, EventArgs e)
 {
     if (txtEmailKhachHang.Text.Trim() == "" || txtTen.Text.Trim() == "")
     {
         MessageBox.Show("Bạn chưa nhập đủ\nVui lòng nhập đủ thông tin", "Lỗi");
     }
     else
     {
         KhachHang KH = dt.KhachHangs.Where(s => s.Email == txtEmailKhachHang.Text.Trim())
                        .Where(s => s.Ten == txtTen.Text.Trim()).FirstOrDefault();
         if (KH == null)
         {
             MessageBox.Show("Thông tin bạn nhập sai hoặc chưa có tài khoản.\nVui lòng kiểm tra lại", "Lỗi");
         }
         else if (KH != null)
         {
             TTKHC.Ma = KH.Ma;
             MessageBox.Show("Mời bạn vào mua hàng");
             FormLapHoaDon FLHD = new FormLapHoaDon();
             FLHD.Show();
             this.Hide();
         }
     }
 }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text.Trim() == "" || txtTen.Text.Trim() == "" || txtTen.Text.Trim() == null || txtEmail.Text.Trim() == null)
            {
                MessageBox.Show("Bạn chưa nhập tên hoặc gmail");
            }
            else
            {
                if (txtDiaChi.Text == "" || txtSoDienThoai.Text == "")
                {
                    DialogResult a = MessageBox.Show("Bạn chưa nhập đủ thông tin\nBạn có muốn tiếp tục không?", "Thiếu thông tin", MessageBoxButtons.YesNo);
                    if (a == DialogResult.Yes)
                    {
                        if (txtEmail.Text.Trim() != "")
                        {
                            Regex mRegxExpression;
                            if (txtEmail.Text.Trim() != string.Empty)
                            {
                                mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4]

                                                            [0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|

                                                            (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");

                                if (!mRegxExpression.IsMatch(txtEmail.Text.Trim()))
                                {
                                    MessageBox.Show("Lỗi định dạng email", "Lỗi");
                                    txtEmail.Focus();
                                }
                                else
                                {
                                    dt.insertKH(Convert.ToInt32(lbSoMa.Text), txtTen.Text, txtEmail.Text, txtDiaChi.Text, txtSoDienThoai.Text);
                                    MessageBox.Show("Thêm khách hàng thành công", "Thành công");
                                    TTKHM.Ma = Convert.ToInt32(lbSoMa.Text);
                                    FormLapHoaDon FLHD = new FormLapHoaDon();
                                    FLHD.Show();
                                    this.Close();
                                }
                            }
                        }
                        else if (txtEmail.Text.Trim() == "")
                        {
                            dt.insertKH(Convert.ToInt32(lbSoMa.Text), txtTen.Text, txtEmail.Text, txtDiaChi.Text, txtSoDienThoai.Text);
                            MessageBox.Show("Thêm khách hàng thành công", "Thành công");
                            TTKHM.Ma = Convert.ToInt32(lbSoMa.Text);
                            FormLapHoaDon FLHD = new FormLapHoaDon();
                            FLHD.Show();
                            this.Close();
                        }
                    }
                }
                else
                {
                    Regex mRegxExpression;
                    if (txtEmail.Text.Trim() != string.Empty)
                    {
                        mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4]

                                                            [0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|

                                                            (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");

                        if (!mRegxExpression.IsMatch(txtEmail.Text.Trim()))
                        {
                            MessageBox.Show("Lỗi định dạng email", "Lỗi");
                            txtEmail.Focus();
                        }
                        else
                        {
                            dt.insertKH(Convert.ToInt32(lbSoMa.Text), txtTen.Text, txtEmail.Text, txtDiaChi.Text, txtSoDienThoai.Text);
                            MessageBox.Show("Thêm khách hàng thành công", "Thành công");
                            TTKHM.Ma = Convert.ToInt32(lbSoMa.Text);
                            FormLapHoaDon FLHD = new FormLapHoaDon();
                            FLHD.Show();
                            this.Close();
                        }
                    }
                }
            }
        }