private void btn_chon_ghe_Click(object sender, EventArgs e) { BUS_Ghe bus_ghe = new BUS_Ghe(); Ghe ghe = new Ghe(); DatVe ve = new DatVe(); if (this._idGhe == -1) { MessageBox.Show("Chưa chọn Ghế"); return; } DataTable dt = new DataTable(); dt = bus_ghe.getGheById(this._idGhe); if (dt == null) { MessageBox.Show("Không có thông tin Ghế được chọn"); return; } DataRow r = dt.Rows[0]; ve.GiaTien = Convert.ToInt32(cbx_giatien.Text); ve.IDChuyen = Convert.ToInt32(cbx_id_chuyen.Text); ghe.IDGhe = this._idGhe; ghe.Dong = Convert.ToInt32(r["Dong"]); ghe.Cot = Convert.ToInt32(r["Cot"]); ghe.Tang = Convert.ToInt32(r["Tang"]); ghe.SoGhe = Convert.ToInt32(r["So_ghe"]); ghe.IDXe = Convert.ToInt32(cbx_id_xe.Text); frmParent.getInfoChonGhe(ghe, ve); this.Close(); }
/// <summary> /// Bắt đầu chọn ghế theo tuyến xe và ngày đã chọn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_select_ghe_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cbx_location_start.Text) || string.IsNullOrEmpty(cbx_location_end.Text)) { MessageBox.Show("Không tìm thấy tuyến xe yêu cầu"); return; } int iTuyen = Convert.ToInt32(cbx_id_tuyen.Text); string ngayDi = dpk_ngay_di.Value.Date.ToString("yyyy-MM-dd"); BUS_Ghe bus_ghe = new BUS_Ghe(); DataTable dt = new DataTable(); // Lấy thông tin chuyến xe dể chọn loại ghế dt = bus_ghe.listChonGhe(iTuyen, ngayDi); if (dt.Rows.Count < 1) { MessageBox.Show("Không tìm thấy chuyến xe \n+ Đi từ : " + cbx_location_start.Text + "\n+ Đi đến: " + cbx_location_end.Text + "\nTrong ngày: " + dpk_ngay_di.Value.Date.ToString("dd / MM / yyyy")); return; } else { frmGhe frm = new frmGhe(dt, this); frm.ShowDialog(); } }
// Disable những ghế đã được đặt dựa theo ID chuyến và ngày đi private void DisableGheSelected() { List <int> IDsGhe = new List <int>(); BUS_Ghe bus_ghe = new BUS_Ghe(); int id_chuyen = Convert.ToInt32(cbx_id_chuyen.Text); int id_xe = Convert.ToInt32(cbx_id_xe.Text); IDsGhe = bus_ghe.getGheByChuyenAndXe(id_chuyen, id_xe); // show button Ghe is selected switch (id_xe) { case 1: foreach (Control button in xe1_map28_tang1.Controls) { if (button is Button) { Button btn = button as Button; foreach (int id in IDsGhe) { if (Convert.ToInt32(btn.Tag) == id) { btn.Enabled = false; break; } } } } break; case 2: foreach (Control button in xe2_map28_tang1.Controls) { if (button is Button) { Button btn = button as Button; foreach (int id in IDsGhe) { if (Convert.ToInt32(btn.Tag) == id) { btn.Enabled = false; break; } } } } break; case 3: foreach (Control button in xe3_map45_tang1.Controls) { if (button is Button) { Button btn = button as Button; foreach (int id in IDsGhe) { if (Convert.ToInt32(btn.Tag) == id) { btn.Enabled = false; break; } } } } break; case 4: foreach (Control button in xe4_map46_tang1.Controls) { if (button is Button) { Button btn = button as Button; foreach (int id in IDsGhe) { if (Convert.ToInt32(btn.Tag) == id) { btn.Enabled = false; break; } } } } foreach (Control button in xe4_map46_tang2.Controls) { if (button is Button) { Button btn = button as Button; foreach (int id in IDsGhe) { if (Convert.ToInt32(btn.Tag) == id) { btn.Enabled = false; break; } } } } break; default: break; } }