Esempio n. 1
0
        /// <summary>
        /// Load two combobox Ten Tram by Tuyen Xe
        /// </summary>
        void loadComboboxTuyenXe()
        {
            DataTable dt        = new DataTable();
            BUS_DatVe bus_datve = new BUS_DatVe();

            dt = bus_datve.getTenTrambyTuyen();

            foreach (DataRow r in dt.Rows)
            {
                cbx_location_start.Items.Add(r["TramBatDau"]);
                cbx_location_end.Items.Add(r["TramKetThuc"]);
                cbx_id_location_start.Items.Add(r["IDTramBatDau"]);
                cbx_id_location_end.Items.Add(r["IDTramKetThuc"]);
                cbx_id_tuyen.Items.Add(r["ID_Tuyen"]);
            }

            if (cbx_id_tuyen.Items.Count > 0)
            {
                cbx_location_end.SelectedIndex    = 0;
                cbx_location_start.SelectedIndex  = 0;
                cbx_id_location_end.SelectedIndex = 0;
                cbx_id_location_end.SelectedIndex = 0;
                cbx_id_tuyen.SelectedIndex        = 0;
            }
        }
Esempio n. 2
0
        private void loadGridViewVeBan()
        {
            BUS_DatVe bus_datve = new BUS_DatVe();
            DataTable dt        = bus_datve.listVe();

            for (int i = 0; i < dgvVe.ColumnCount; ++i)
            {
                dgvVe.Columns[i].DataPropertyName = dgvVe.Columns[i].Name;
            }

            dgvVe.DataSource = dt;
        }
Esempio n. 3
0
        private void menu_danhSachVe_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            int       iRow   = dgvVe.CurrentCell.RowIndex;
            int       idVe   = Convert.ToInt32(dgvVe.Rows[iRow].Cells[0].Value);
            BUS_DatVe bus_ve = new BUS_DatVe();

            switch (e.ClickedItem.Text)
            {
            case "Xóa":
                if (principal.IsInRole("client  "))
                {
                    MessageBox.Show("Bạn không có quyền thực hiện chức năng này");
                    break;
                }

                if (bus_ve.deleteVe(idVe))
                {
                    MessageBox.Show("Xóa vé thành công");
                }
                else
                {
                    MessageBox.Show("Thất bại, có lỗi xảy ra");
                }
                break;

            case "Cập nhật tình trạng Vé":
                int tinhTrang = Convert.ToInt32(dgvVe.Rows[iRow].Cells[3].Value);
                tinhTrang = tinhTrang == 1 ? 0 : 1;

                if (bus_ve.updateTinhtrangVe(idVe, tinhTrang))
                {
                    MessageBox.Show("Cập nhật tình trạng thành công");
                }
                else
                {
                    MessageBox.Show("Thất bại, có lỗi xảy ra");
                }
                break;

            default:
                break;
            }

            //re-load gridview
            loadGridViewVeBan();
        }
Esempio n. 4
0
        /// <summary>
        /// Thực hiện đặt vé
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_submit_datve_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbx_location_start.Text) ||
                string.IsNullOrEmpty(cbx_location_end.Text) ||
                string.IsNullOrEmpty(so_luong_ve.Value.ToString()) ||
                string.IsNullOrEmpty(dpk_ngay_di.Value.ToString()) ||
                string.IsNullOrEmpty(txt_gia_tien.Text) ||
                string.IsNullOrEmpty(txt_phone.Text) ||
                string.IsNullOrEmpty(txt_name.Text) ||
                string.IsNullOrEmpty(cbx_type.Text))
            {
                MessageBox.Show("Điền đầy đủ thông tin");
                return;
            }

            this._datve.GhiChu     = txt_ghichu.Text;
            this._datve.TinhTrang  = chbx_thanhtoan.Checked ? 1 : 0;
            this._datve.NgayXuatVe = dpk_ngay_di.Value.Date.ToString();
            this._datve.GiaTien    = Convert.ToInt32(txt_gia_tien.Text);

            // Nếu chưa là Khách hàng thì tại mới
            if (!this._isKhachHang)
            {
                // Create new Khách hàng và lấy ra new ID
                this._khachHang.DIENTHOAI = txt_phone.Text;
                this._khachHang.HOTEN     = txt_name.Text;
                this._khachHang.EMAIL     = txt_email.Text;
                if (cbx_type.SelectedIndex == 1)
                {
                    this._khachHang.LOAI = 1;
                }
                else
                {
                    this._khachHang.LOAI = 0;
                }

                BUS_KhachHang bus_kh = new BUS_KhachHang();
                this._idKH = bus_kh.ThemKhachHang(this._khachHang);
                MessageBox.Show("Tạo mới Khách hàng ID: " + this._idKH.ToString());
            }

            // Tạo mới Vé xe
            DatVe ve = new DatVe();

            ve.IDGhe       = this._datve.IDGhe;
            ve.IDChuyen    = this._datve.IDChuyen;
            ve.TinhTrang   = this._datve.TinhTrang;
            ve.GiaTien     = this._datve.GiaTien;
            ve.IDKhachHang = this._idKH;
            ve.NgayXuatVe  = this._datve.NgayXuatVe;
            ve.GhiChu      = this._datve.GhiChu;

            // valid id Ghế
            if (this._datve.IDGhe <= 0)
            {
                MessageBox.Show("ID Ghế không hợp lệ: " + this._datve.IDGhe.ToString());
                return;
            }

            // valid id khách hàng
            if (this._idKH <= 0)
            {
                MessageBox.Show("ID khách hàng không hợp lệ: " + this._idKH.ToString());
                return;
            }

            BUS_DatVe bus_ve = new BUS_DatVe();

            if (bus_ve.newVe(ve))
            {
                MessageBox.Show("Đặt vé thành công");
                this._datve.IDGhe        = 0;
                this._datve.IDChuyen     = 0;
                this._datve.GiaTien      = 0;
                this._idKH               = 0;
                this._datve.GhiChu       = "";
                btn_submit_datve.Enabled = false;

                return;
            }
            MessageBox.Show("Đặt vé thất bại, có lỗi xảy ra !!!");
        }