Пример #1
0
        public static bool SalePhieuDatCho(PhieuDatCho pdc)
        {
            string cmdText = string.Format("INSERT INTO VE(MaVe,MaCB,TenHK,CMND,DienThoai,ThoiGian,MaHV,GiaVe) VALUES ({7},{0},N'{1}','{2}','{3}','{4}',{5},{6})", pdc.maCB, pdc.TenHK, pdc.CMND, pdc.DienThoai, pdc.ThoiGian.ToString("MM/dd/yyyy HH:mm:ss"), pdc.HV.maHV, pdc.GiaVe, pdc.maVe);
            bool   insert  = DataProvider.ExecuteNonQuery(cmdText);

            return(insert);
        }
Пример #2
0
        public async Task <IActionResult> Edit(string PhieuDatChoID, [Bind("PhieuDatChoID,GiaTien,HangID,KhachHangID,ChuyenBayID")] PhieuDatCho phieuDatCho)
        {
            if (PhieuDatChoID != phieuDatCho.PhieuDatChoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phieuDatCho);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhieuDatChoExists(phieuDatCho.PhieuDatChoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HangID"]      = new SelectList(_context.HangVes, "HangID", "HangID", phieuDatCho.HangID);
            ViewData["KhachHangID"] = new SelectList(_context.KhachHangs, "KhachHangID", "KhachHangID", phieuDatCho.KhachHangID);
            ViewData["ChuyenBayID"] = new SelectList(_context.LichChuyenBays, "ChuyenBayID", "ChuyenBayID", phieuDatCho.ChuyenBayID);
            return(View(phieuDatCho));
        }
Пример #3
0
        public frmPhieuDatChoEditing(PhieuDatCho x)
        {
            InitializeComponent();
            pdc = x;
            Loadcb();
            checkState();
            PanelTT();
            tbMaVe.Text            = pdc.strMaVe;
            cbMaCB.SelectedValue   = pdc.maCB;
            tbGiaVe.Text           = pdc.GiaVe.ToString("###,###,### VND");
            tbNgayGio.Text         = pdc.ThoiGian.ToString("hh:mm tt dd/MM/yyyy");
            tbTenHK.Text           = pdc.TenHK;
            cbHangVe.SelectedValue = pdc.HV.maHV;
            tbCMND.Text            = pdc.CMND;
            tbDienThoai.Text       = pdc.DienThoai;

            if (pdc.tinhTrang == 1)
            {
                rbDat.Checked = true;
            }
            else if (pdc.tinhTrang == 2)
            {
                rbDaBan.Checked = true;
            }
            else if (pdc.tinhTrang == 3)
            {
                rbDaHuy.Checked = true;
            }
        }
Пример #4
0
        public bool insertPhieuDatCho(PhieuDatCho PDC)
        {
            string sql = "insert into PHIEUDATCHO(MaChuyenBay, HangVe, GiaTien, TrangThai, HoTen, CMND, SDT, Email, NgayHuy)" +
                         " VALUES(@MaChuyenBay, @HangVe, @GiaTien, @TrangThai, @HoTen, @CMND, @SDT, @Email, @NgayHuy)";

            using (SqlConnection con = dc.getConnect())
            {
                try
                {
                    cmd = new SqlCommand(sql, con);
                    con.Open();
                    cmd.Parameters.Add("@MaChuyenBay", SqlDbType.VarChar).Value = PDC.MaChuyenBay;
                    cmd.Parameters.Add("@HangVe", SqlDbType.NVarChar).Value     = PDC.HangVe;
                    cmd.Parameters.Add("@GiaTien", SqlDbType.Money).Value       = PDC.GiaTien;
                    cmd.Parameters.Add("@TrangThai", SqlDbType.NVarChar).Value  = PDC.TrangThai;
                    cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar).Value      = PDC.HoTen;
                    cmd.Parameters.Add("@CMND", SqlDbType.VarChar).Value        = PDC.CMND;
                    cmd.Parameters.Add("@SDT", SqlDbType.VarChar).Value         = PDC.SDT;
                    cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value       = PDC.Email;
                    cmd.Parameters.Add("@NgayHuy", SqlDbType.Date).Value        = PDC.NgayHuy;
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(true);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
        }
Пример #5
0
        public static bool UpdatePhieuDatCho(PhieuDatCho phieuDatCho)
        {
            string cmdText = string.Format("UPDATE PHIEUDATCHO SET MaCB= {0},TenHK= N'{1}',CMND= '{2}',DienThoai= '{3}',ThoiGian= '{4}',MaHV= {5},GiaVe= {6},TinhTrang= {7} WHERE MaVe = {8}", phieuDatCho.maCB, phieuDatCho.TenHK, phieuDatCho.CMND, phieuDatCho.DienThoai, phieuDatCho.ThoiGian.ToString("MM / dd / yyyy HH: mm:ss"), phieuDatCho.HV.maHV, phieuDatCho.GiaVe, phieuDatCho.tinhTrang, phieuDatCho.maVe);
            bool   update  = DataProvider.ExecuteNonQuery(cmdText);

            return(update);
        }
Пример #6
0
        public void UpdatePhieuDatCho(PhieuDatCho PDC)
        {
            string sql = "update PHIEUDATCHO set MaChuyenBay = @MaChuyenBay, HangVe = @HangVe, GiaTien = @GiaTien, " +
                         "TrangThai = @TrangThai, HoTen = @HoTen, CMND = @CMND, SDT = @SDT, Email = @Email " +
                         "where MaPhieuDatCho = @MaPhieuDatCho";

            using (SqlConnection con = dc.getConnect())
            {
                try
                {
                    cmd = new SqlCommand(sql, con);
                    con.Open();
                    cmd.Parameters.Add("@MaPhieuDatCho", SqlDbType.VarChar).Value = PDC.MaPhieuDatCho;
                    cmd.Parameters.Add("@MaChuyenBay", SqlDbType.VarChar).Value   = PDC.MaChuyenBay;
                    cmd.Parameters.Add("@HangVe", SqlDbType.NVarChar).Value       = PDC.HangVe;
                    cmd.Parameters.Add("@GiaTien", SqlDbType.Money).Value         = PDC.GiaTien;
                    cmd.Parameters.Add("@TrangThai", SqlDbType.NVarChar).Value    = PDC.TrangThai;
                    cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar).Value        = PDC.HoTen;
                    cmd.Parameters.Add("@CMND", SqlDbType.VarChar).Value          = PDC.CMND;
                    cmd.Parameters.Add("@SDT", SqlDbType.VarChar).Value           = PDC.SDT;
                    cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value         = PDC.Email;
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #7
0
        void SendMail(PhieuDatCho PDC)
        {
            string message = "Vui lòng xác nhận thông tin và thanh toán trước ngày " + PDC.NgayHuy.Date + " để tránh bị hủy phiếu đặt " +
                             "\n\nThông tin phiếu đặt chỗ" +
                             "\nMã phiếu đặt: " + PDC.MaPhieuDatCho +
                             "\nMã chuyến bay: " + PDC.MaChuyenBay +
                             "\nHạng vé: " + PDC.HangVe +
                             "\nTổng tiền: " + PDC.GiaTien +
                             "\n\nThông tin hành khách" +
                             "\nHọ và tên: " + PDC.HoTen +
                             "\nCMND: " + PDC.CMND +
                             "\nSDT: " + PDC.SDT;

            try
            {
                MailMessage mess   = new MailMessage("*****@*****.**", tbEmail.Text, "Phiếu đặt chỗ chuyến bay", message);
                SmtpClient  client = new SmtpClient("smtp.gmail.com", 587);
                client.EnableSsl = true;

                client.Credentials = new NetworkCredential("*****@*****.**", "Admin1412");

                client.Send(mess);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Thống báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        public static bool InsertPhieuDatCho(PhieuDatCho phieuDatCho, int maVe)
        {
            string cmdText = string.Format("INSERT INTO PHIEUDATCHO(MaVe,MaCB,TenHK,CMND,DienThoai,ThoiGian,MaHV,GiaVe,TinhTrang) VALUES ({8},{0},N'{1}','{2}','{3}','{4}',{5},{6},{7})", phieuDatCho.maCB, phieuDatCho.TenHK, phieuDatCho.CMND, phieuDatCho.DienThoai, phieuDatCho.ThoiGian.ToString("MM / dd / yyyy HH: mm:ss"), phieuDatCho.HV.maHV, phieuDatCho.GiaVe, 1, maVe);
            bool   insert  = DataProvider.ExecuteNonQuery(cmdText);

            return(insert);
        }
Пример #9
0
 public frmPhieuDatChoEditing()
 {
     InitializeComponent();
     pdc = new PhieuDatCho();
     Loadcb();
     checkState();
     PanelTT();
 }
        public void TestAddAndDelete()
        {
            DateTime    ngayDat = DateTime.Now;
            PhieuDatCho t1      = new PhieuDatCho("PDC05", "HCM-HN-001", "HK002", 750000, ngayDat);

            Assert.AreEqual(true, manager.add(t1));
            Assert.AreEqual(false, manager.add(t1));
            Assert.AreEqual(true, manager.delete("PDC05"));
        }
        public void TestUpdate()
        {
            DateTime    ngayDat = DateTime.Now;
            PhieuDatCho t1      = new PhieuDatCho("PDC05", "HCM-HN-001", "HK002", 750000, ngayDat);

            manager.add(t1);

            PhieuDatCho t2 = new PhieuDatCho("PDC05", "HN-HCM-001", "HK002", 750000, ngayDat);

            Assert.AreEqual(true, manager.update(t2));
            Assert.AreEqual(true, manager.update(t1));
            Assert.AreEqual(true, manager.delete("PDC05"));
        }
Пример #12
0
        public async Task <IActionResult> Create([Bind("PhieuDatChoID,GiaTien,HangID,KhachHangID,ChuyenBayID")] PhieuDatCho phieuDatCho)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phieuDatCho);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HangID"]      = new SelectList(_context.HangVes, "HangID", "HangID", phieuDatCho.HangID);
            ViewData["KhachHangID"] = new SelectList(_context.KhachHangs, "KhachHangID", "KhachHangID", phieuDatCho.KhachHangID);
            ViewData["ChuyenBayID"] = new SelectList(_context.LichChuyenBays, "ChuyenBayID", "ChuyenBayID", phieuDatCho.ChuyenBayID);
            return(View(phieuDatCho));
        }
Пример #13
0
        private void Edit(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 1 && (((DateTime)row.Cells["ThoiGian"].Value) - DateTime.Now).Hours < ThamSo.TGHuyDatVe)
            {
                Notification.Show("Phiếu đặt chỗ đã quá thời gian", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã quá thời gian\n-->Tiến hành hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán không thể chỉnh sửa", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán không thể chỉnh sửa");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy không thể chỉnh sửa", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy không thể chỉnh sửa");
                dialog1.ShowDialog();
                return;
            }
            AppState.state = Actions.EDIT;
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);

            var          dialog = new frmPhieuDatChoEditing(pdc);
            DialogResult res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (BLL_PhieuDatCho.UpdatePhieuDatCho(dialog.pdc))
                {
                    Notification.Show("Chỉnh sửa phiếu đặt chỗ thành công", Status.SUCCESS);
                }
                reloadData();
            }
            AppState.state = Actions.NOTHING;
        }
Пример #14
0
        private void Sale(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 1 && (((DateTime)row.Cells["ThoiGian"].Value) - DateTime.Now).Hours < ThamSo.TGHuyDatVe)
            {
                Notification.Show("Phiếu đặt chỗ đã quá thời gian", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã quá thời gian\n-->Tiến hành hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy không thể bán", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy không thể bán");
                dialog1.ShowDialog();
                return;
            }
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc    = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);
            var         dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn bán vé không?");
            var         res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                pdc.tinhTrang = 2;
                if (BLL_PhieuDatCho.SalePhieuDatCho(pdc))
                {
                    Notification.Show("Bán vé thành công", Status.SUCCESS);
                }
                BLL_PhieuDatCho.UpdatePhieuDatCho(pdc);
                reloadData();
            }
        }
Пример #15
0
        public static List <PhieuDatCho> SearchCMND(string cMND)
        {
            string    cmdText = String.Format("select * from PHIEUDATCHO where CMND like '%{0}%'", cMND);
            DataTable dt      = DataProvider.ExecuteReader(cmdText);

            if (dt != null && dt.Rows.Count > 0)
            {
                List <PhieuDatCho> phieudatcho = new List <PhieuDatCho>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    PhieuDatCho pdc = new PhieuDatCho((int)dt.Rows[i]["MaVe"], (int)dt.Rows[i]["MaCB"], dt.Rows[i]["TenHK"].ToString(), dt.Rows[i]["CMND"].ToString(), dt.Rows[i]["DienThoai"].ToString(), (DateTime)dt.Rows[i]["ThoiGian"], DAL_HangVe.GetHangVe((int)dt.Rows[i]["MaHV"]), (int)dt.Rows[i]["GiaVe"], (int)dt.Rows[i]["TinhTrang"]);
                    phieudatcho.Add(pdc);
                }
                return(phieudatcho);
            }
            return(null);
        }
        public bool ThemThongTinDatCho(PhieuDatCho phieu)
        {
            string query = "INSERT INTO PHIEUDATCHO VALUES (@MaPhieuDat, @MaChuyenBay, @MaHanhKhach, @MaHangVe, @GiaTien, @NgayDat)";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@MaPhieuDat"]  = phieu.MaPhieuDatCho;
            parameters["@MaChuyenBay"] = phieu.MaChuyenBay;
            parameters["@MaHangVe"]    = phieu.MaHangVe;
            parameters["@MaHanhKhach"] = phieu.MaHanhKhach;
            parameters["@GiaTien"]     = phieu.GiaTien;
            parameters["@NgayDat"]     = phieu.NgayDat;
            try
            {
                ExecuteNonQuery(query, parameters);
                return(true);
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }
Пример #17
0
        private void Detail(DataGridViewRow row)
        {
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);

            var          dialog = new frmPhieuDatChoEditing(pdc);
            DialogResult res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
            }
        }
Пример #18
0
        private void cancel(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán không thể hủy", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán không thể hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy");
                dialog1.ShowDialog();
                return;
            }
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc    = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);
            var         dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn hủy phiếu đặt ghế không?");
            var         res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                pdc.tinhTrang = 3;
                if (BLL_PhieuDatCho.UpdatePhieuDatCho(pdc))
                {
                    Notification.Show("Hủy phiếu đặt chỗ thành công", Status.SUCCESS);
                }
                reloadData();
            }
        }
Пример #19
0
        private void btReservate_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                PhieuDatCho PDC = new PhieuDatCho();

                PDC.MaChuyenBay   = tbMaChuyenBay.Text;
                PDC.HangVe        = cbHangVe.Text;
                PDC.GiaTien       = decimal.Parse(lbGiaTien.Text);
                PDC.TrangThai     = "Chưa xuất vé";
                PDC.HoTen         = tbHoTen.Text;
                PDC.CMND          = tbCMND.Text;
                PDC.SDT           = tbSDT.Text;
                PDC.Email         = tbEmail.Text;
                PDC.NgayHuy       = bllCB.getNgayKhoiHanh(tbMaChuyenBay.Text);
                PDC.MaPhieuDatCho = bllPDC.getMaPhieuDatCho();

                if (bllPDC.insertPhieuDatCho(PDC))
                {
                    lbNotify.Text      = "Thành công, vui lòng kiểm tra mail để xác nhận thông tin";
                    lbNotify.ForeColor = Color.FromArgb(8, 186, 29);

                    DanhSachGhe DSG = new DanhSachGhe();
                    DSG.MaChuyenBay = PDC.MaChuyenBay;
                    DSG.HangVe      = PDC.HangVe;
                    DSG.SoGheTrong  = bllDSG.getSoGheTrong(tbMaChuyenBay.Text, cbHangVe.Text) - 1;

                    bllDSG.UpdateSoGheTrong(DSG);

                    SendMail(PDC);
                }
                else
                {
                    lbNotify.ForeColor = Color.Red;
                    lbNotify.Text      = "Đã có lỗi xảy ra, vui lòng thử lại sau";
                }
            }
        }
Пример #20
0
        Create2(
            [Bind("PhieuDatChoId,KhachHangId,HangID,ChuyenBayID")] PhieuDatCho phieuDatCho,
            KhachHang KhachHang)
        {
            if (ModelState.IsValid)
            {
                KhachHang.KhachHangID = phieuDatCho.ChuyenBayID + KhachHang.CMND;
                _context.Add(KhachHang);
                await _context.SaveChangesAsync();

                var x = _context.LichChuyenBays.SingleOrDefault(p => p.ChuyenBayID == phieuDatCho.ChuyenBayID).GiaVe;
                phieuDatCho.KhachHangID = phieuDatCho.ChuyenBayID + KhachHang.CMND;
                phieuDatCho.GiaTien     = _context.HangVes.SingleOrDefault(p => p.HangID == phieuDatCho.HangID).TiLeGia *x / 100 + x;
                _context.Add(phieuDatCho);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HangID"]      = new SelectList(_context.HangVes, "HangID", "HangID", phieuDatCho.HangID);
            ViewData["KhachHangID"] = new SelectList(_context.KhachHangs, "KhachHangID", "KhachHangID", phieuDatCho.KhachHangID);
            ViewData["ChuyenBayID"] = new SelectList(_context.LichChuyenBays, "ChuyenBayID", "ChuyenBayID", phieuDatCho.ChuyenBayID);
            return(View(phieuDatCho));
        }
Пример #21
0
        private void btPrintTicket_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                DialogResult result = MessageBox.Show("Vé đã in sẽ không được thay đổi, bạn chắc chắn thông tin đã chính xác", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    if (btEdit.Text != "Hủy" && btSell.Text != "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            bllPDC.UpdateTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString(), "Đã xuất vé");
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            return;
                        }
                    }
                    else
                    if (btEdit.Text == "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            PhieuDatCho PDC = new PhieuDatCho();

                            PDC.MaPhieuDatCho = dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString();
                            PDC.MaChuyenBay   = tbMaChuyenBay.Text;
                            PDC.HangVe        = cbHangVe.Text;
                            PDC.GiaTien       = decimal.Parse(lbGiaTien.Text);
                            PDC.TrangThai     = "Đã xuất vé";
                            PDC.HoTen         = tbHoTen.Text;
                            PDC.CMND          = tbCMND.Text;
                            PDC.SDT           = tbSDT.Text;
                            PDC.Email         = tbEmail.Text;
                            bllPDC.UpdatePhieuDatCho(PDC);

                            btEdit.Text    = "Chỉnh sửa";
                            btSell.Enabled = true;
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            btEdit.Text        = "Chỉnh sửa";
                            btSell.Enabled     = true;
                            return;
                        }
                    }
                    else if (btSell.Text == "Hủy")
                    {
                        LockCotrol();
                        btSell.Text    = "Bán vé";
                        btEdit.Enabled = true;
                    }

                    VeChuyenBay VCB = new VeChuyenBay();

                    VCB.MaChuyenBay = tbMaChuyenBay.Text;
                    VCB.HangVe      = cbHangVe.Text;
                    VCB.GiaTien     = decimal.Parse(lbGiaTien.Text);
                    VCB.HoTen       = tbHoTen.Text;
                    VCB.CMND        = tbCMND.Text;
                    VCB.SDT         = tbSDT.Text;
                    VCB.Email       = tbEmail.Text;

                    if (bllVCB.insertVeChuyenBay(VCB))
                    {
                        lbNotify.Visible   = true;
                        lbNotify.Text      = "Thành công";
                        lbNotify.ForeColor = Color.FromArgb(8, 186, 29);

                        DanhSachGhe DSG = new DanhSachGhe();
                        DSG.MaChuyenBay = VCB.MaChuyenBay;
                        DSG.HangVe      = VCB.HangVe;
                        DSG.SoGheTrong  = bllDSG.getSoGheTrong(tbMaChuyenBay.Text, cbHangVe.Text) - 1;

                        bllDSG.UpdateSoGheTrong(DSG);
                        tbMaChuyenBay.Text = "";
                        tbHoTen.Text       = "";
                        tbSDT.Text         = "";
                        tbCMND.Text        = "";
                        tbEmail.Text       = "";
                        lbGiaTien.Text     = "0";
                    }
                    else
                    {
                        lbNotify.ForeColor = Color.Red;
                        lbNotify.Text      = "Đã có lỗi xảy ra, vui lòng thử lại sau";
                    }
                }
            }
        }
Пример #22
0
 public static bool SalePhieuDatCho(PhieuDatCho pdc)
 {
     return(DAL_PhieuDatCho.SalePhieuDatCho(pdc));
 }
Пример #23
0
 public static bool UpdatePhieuDatCho(PhieuDatCho phieuDatCho)
 {
     return(DAL_PhieuDatCho.UpdatePhieuDatCho(phieuDatCho));
 }
Пример #24
0
 public static bool InsertPhieuDatCho(PhieuDatCho phieuDatCho, int maVe)
 {
     return(DAL_PhieuDatCho.InsertPhieuDatCho(phieuDatCho, maVe));
 }
Пример #25
0
 public bool insertPhieuDatCho(PhieuDatCho PDC)
 {
     return dalPDC.insertPhieuDatCho(PDC);
 }
Пример #26
0
 public void UpdatePhieuDatCho(PhieuDatCho PDC)
 {
     dalPDC.UpdatePhieuDatCho(PDC);
 }
Пример #27
0
 public void ThemThongTinDatCho(PhieuDatCho phieu)
 {
 }