private void btnPayment_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtCusPay.Text) < Convert.ToInt32(cbCost.Text))
            {
                MessageBox.Show("Số tiền khách trả phải lớn hơn số tiền cần trả");
            }
            else
            {
                ArrayList temp  = new ArrayList();
                ArrayList temp2 = new ArrayList();
                foreach (var user in db.KhachHangs)
                {
                    temp.Add(Convert.ToInt32(user.stt));
                }
                KhachHang kh = new KhachHang()
                {
                    MaKH  = "KH" + Convert.ToString(temp.Count + 1),
                    TenKH = txtNameCus.Text
                };
                db.KhachHangs.Add(kh);
                db.SaveChanges();



                foreach (var user in db.PhieuVes)
                {
                    temp2.Add(Convert.ToInt32(user.stt));
                }
                PhieuVe pv = new PhieuVe()
                {
                    MaPhieu      = "PV" + Convert.ToString(temp2.Count + 1),
                    MaKH         = "KH" + Convert.ToString(temp.Count + 1),
                    TenKH        = txtNameCus.Text,
                    TenNVBV      = txtNameEmp.Text,
                    MaNVBV       = txtIdEmp.Text,
                    SoTien       = Convert.ToInt32(cbCost.Text),
                    ChoNgoi      = txtSit.Text,
                    NgayKhoiHanh = Convert.ToDateTime(dtTimeStart.Text),
                    MaChuyenxe   = cbIDveh.Text,


                    TenDD = cbLocation.Text
                };
                db.PhieuVes.Add(pv);
                db.SaveChanges();

                /*
                 * after add infor of hoaDon, move on QLKH to continue update data of customer
                 */
                ManageCustomer manageCustomer = new ManageCustomer();
                this.Hide();
                manageCustomer.ShowDialog();
                this.Show();
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Boolean flag = false;

            foreach (var user in db.TaiKhoans)
            {
                // if (user.TenTK.Equals(Convert.ToString(txtUsername.Text)) && user.MatKhau.Equals(Convert.ToString(txtPassword.Text)))
                if (user.TenTK == txtUsername.Text && user.MatKhau == txtPassword.Text)
                {
                    if (txtUsername.Text.Contains("admin"))
                    {
                        ManageEmployee manageEmployee = new ManageEmployee();
                        this.Hide();
                        manageEmployee.ShowDialog();
                        this.Show();
                    }
                    else if (txtUsername.Text.Contains("employee"))
                    {
                        ManageCustomer manageCustomer = new ManageCustomer();
                        manageCustomer.dataAdd = txtUsername.Text;
                        this.Hide();
                        manageCustomer.ShowDialog();
                        this.Show();
                    }
                    else if (txtUsername.Text.Contains("seller"))
                    {
                        Payment payment = new Payment();
                        payment.dataAdd = txtUsername.Text;
                        this.Hide();
                        payment.ShowDialog();
                        this.Show();
                    }
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                txtErrorMess.Text = "Sai tên tài khoản hoặc mật khẩu";
            }
            else
            {
                txtErrorMess.Text = "";
            }
        }