Beispiel #1
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            string sdt = textBox1.Text;

            if (string.IsNullOrWhiteSpace(sdt))
            {
                MessageBox.Show("Vui lòng nhập sđt");
                return;
            }
            using (DBEntites db = new DBEntites())
            {
                var kh = db.KhachHangs.Select(s => s).Where(s => s.SDT == sdt).FirstOrDefault();
                if (kh == null)
                {
                    frmQLKH frmqlkh = new frmQLKH(sdt, tk);
                    frmqlkh.ShowDialog();
                    List <KhachHang> khs   = db.KhachHangs.ToList();
                    KhachHang        newKH = khs[khs.Count - 1];
                    frmLapHoaDon     form  = new frmLapHoaDon(newKH, tk, false);
                    form.ShowDialog();
                    Close();
                }
                else
                {
                    frmLapHoaDon form = new frmLapHoaDon((KhachHang)kh, tk, true);
                    form.ShowDialog();
                    Close();
                }
            }
        }
Beispiel #2
0
 private void btnCreateBill_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow viewRow = dgvKhachHang.CurrentRow;
         string          sdt     = viewRow.Cells[2].Value + "";
         var             kh      = db.KhachHangs.Select(s => s).Where(s => s.SDT == sdt).FirstOrDefault();
         frmLapHoaDon    form    = new frmLapHoaDon((KhachHang)kh, user, true);
         form.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }