本文整理汇总了C#中BanVeXePhuongTrang.DAL.QUANLYXEKHACHEntities类的典型用法代码示例。如果您正苦于以下问题:C# QUANLYXEKHACHEntities类的具体用法?C# QUANLYXEKHACHEntities怎么用?C# QUANLYXEKHACHEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QUANLYXEKHACHEntities类属于BanVeXePhuongTrang.DAL命名空间,在下文中一共展示了QUANLYXEKHACHEntities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: frmThemTuyenXe
public frmThemTuyenXe(tblTuyenXe tuyenXe)
{
InitializeComponent();
editMode = true;
cbbBenXeDen.Enabled = false;
cbbBenXeDi.Enabled = false;
foreach (var item in new QUANLYXEKHACHEntities().tblBenXes.ToList())
{
cbbBenXeDen.Items.Add(item.TenBenXe);
cbbBenXeDi.Items.Add(item.TenBenXe);
}
// Edit mode
cbbBenXeDi.SelectedItem = tuyenXe.tblBenXe.TenBenXe;
cbbBenXeDen.SelectedItem = tuyenXe.tblBenXe1.TenBenXe;
txtMaTuyen.Text = tuyenXe.MaTuyen;
dtgChiTietTuyen.Rows.Clear();
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
List<tblChiTietTuyen> listChiTietTuyen = tuyenXe.tblChiTietTuyens.ToList();
for (int i = 0; i < listChiTietTuyen.Count; i++)
{
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dtgChiTietTuyen.Rows[i].Cells["BenXeTrungGian"];
foreach (var row in db.tblBenXes.Select(t => t.TenBenXe).ToList())
cell.Items.Add(row);
cell.Value = listChiTietTuyen[i].tblBenXe.TenBenXe;
dtgChiTietTuyen.Rows[i].Cells["ThoiGianDung"].Value = listChiTietTuyen[i].ThoiGianDung;
dtgChiTietTuyen.Rows[i].Cells["GhiChu"].Value = listChiTietTuyen[i].GhiChu;
}
}
示例2: frmLichChuyenDi
public frmLichChuyenDi(tblChuyenDi chuyenDi)
{
InitializeComponent();
editMode = true;
try
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
txtMaChuyenDi.Text = chuyenDi.MaChuyenDi.ToString();
txtGiaVe.Text = chuyenDi.DonGia.ToString();
cbbMaTuyen.DataSource = db.tblTuyenXes.Select(t => t.MaTuyen).ToList();
cbbMaTuyen.SelectedItem = chuyenDi.tblXeKhach.MaTuyen;
txtTuyen.Text = chuyenDi.tblXeKhach.tblTuyenXe.tblBenXe.TenBenXe + "-" + chuyenDi.tblXeKhach.tblTuyenXe.tblBenXe1.TenBenXe;
dtpKhoiHanh.Value = chuyenDi.KhoiHanh.Value;
dtpKetThuc.Value = chuyenDi.KhoiHanh.Value.AddMinutes(chuyenDi.tblXeKhach.tblTuyenXe.ThoiGianDi);
dtgBXTrungGian.Rows.Clear();
foreach (var item in db.tblChiTietTuyens.Where(t => t.MaTuyen == chuyenDi.tblXeKhach.MaTuyen).ToList())
{
dtgBXTrungGian.Rows.Add(item.tblBenXe.TenBenXe,
item.ThoiGianDung,
item.GhiChu);
}
cbbMaXe.DataSource = db.tblXeKhaches.Where(t => t.MaTuyen == chuyenDi.tblXeKhach.MaTuyen).Select(t => t.MaXe).ToList();
}
catch
{ }
}
示例3: btnThem_Click
private void btnThem_Click(object sender, EventArgs e)
{
try
{
BLL_BenXe temp = new BLL_BenXe();
if (temp.canInsert(txtMaBenXe.Text.ToString(), txtTenBenXe.Text.ToString()))
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
tblBenXe t = new tblBenXe();
t.MaBenXe = txtMaBenXe.Text.ToString();
t.TenBenXe = txtTenBenXe.Text.ToString();
db.tblBenXes.Add(t);
db.SaveChanges();
btnTaoMoi_Click(sender, e);
MessageBox.Show("Thêm thành công");
}
else
{
MessageBox.Show("Không thành công");
}
}
catch { }
}
示例4: btThem_Click
private void btThem_Click(object sender, EventArgs e)
{
tblChiTietTrungChuyen temp = new tblChiTietTrungChuyen();
temp.MaPhieu = int.Parse(dtgKhachHang.CurrentRow.Cells["MaPhieu_KH"].Value.ToString());
dynamic selectedItem = cbbXeTrungChuyen.SelectedItem;
string bienSoXe = selectedItem.BienSo;
temp.SoLuong = int.Parse(dtgKhachHang.CurrentRow.Cells["SoVe_KH"].Value.ToString());
try
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
tblXeTrungChuyen xeTC = db.tblXeTrungChuyens.Where(t => t.BienSoXe == bienSoXe).SingleOrDefault();
if(xeTC != null)
{
temp.MaXe = xeTC.MaXe;
temp.DaRuoc = false;
db.tblChiTietTrungChuyens.Add(temp);
db.SaveChanges();
dtgDanhSachTC.Rows.Add(dtgKhachHang.CurrentRow.Cells["HoTen_KH"].Value,
dtgKhachHang.CurrentRow.Cells["MaPhieu_KH"].Value,
dtgKhachHang.CurrentRow.Cells["SDT_KH"].Value,
dtgKhachHang.CurrentRow.Cells["DiaDiem_KH"].Value,
dtgKhachHang.CurrentRow.Cells["SoVe_KH"].Value);
dtgKhachHang.Rows.RemoveAt(dtgKhachHang.CurrentRow.Index);
}
}
catch
{
MessageBox.Show("Lỗi");
}
}
示例5: cbMaChuyenDi_SelectedIndexChanged
private void cbMaChuyenDi_SelectedIndexChanged(object sender, EventArgs e)
{
khoiPhucTinhTrangGhe();
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
int maChuyen = int.Parse(cbbMaChuyenDi.SelectedItem.ToString());
tblChuyenDi chuyenDi = db.tblChuyenDis.Where(t => t.MaChuyenDi == maChuyen).SingleOrDefault();
txtTuyen.Text = chuyenDi.tblXeKhach.tblTuyenXe.tblBenXe.TenBenXe.ToString() + "-" + chuyenDi.tblXeKhach.tblTuyenXe.tblBenXe1.TenBenXe.ToString();
txtKhoiHanh.Text = chuyenDi.KhoiHanh.Value.ToString();
txtGia.Text = chuyenDi.DonGia.ToString();
foreach (var item in chuyenDi.tblChiTietPhieuDatChoes.ToList())
{
if(chuyenDi.tblXeKhach.MaLoaiXe == 1) // ghế ngồi
{
if (item.LayVe.Value)
capNhatTinhTrangGhe(idGheThuong + item.ViTriGhe, Color.Red, pnlXeThuong);
else
capNhatTinhTrangGhe(idGheThuong + item.ViTriGhe, Color.Green, pnlXeThuong);
}
else
{
if (item.LayVe.Value)
capNhatTinhTrangGhe(idGheNam + item.ViTriGhe, Color.Red, pnlGiuongNam);
else
capNhatTinhTrangGhe(idGheNam + item.ViTriGhe, Color.Green, pnlGiuongNam);
}
}
tabXeThuong.Visible = tabXeGiuongNam.Visible = true;
if (chuyenDi.tblXeKhach.MaLoaiXe == 1) // ghế ngồi
tabXeGiuongNam.Visible = false;
else
tabXeThuong.Visible = false;
}
示例6: btSua_Click
private void btSua_Click(object sender, EventArgs e)
{
frmSuaXe form = null;
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
if(dtgDanhSachXeKhachSelected)
{
int maXe = int.Parse(dtgDSXeKhach.CurrentRow.Cells["MaXe"].Value.ToString());
tblXeKhach xe = db.tblXeKhaches.Where(t => t.MaXe == maXe).SingleOrDefault();
if(xe != null)
{
form = new frmSuaXe(xe);
}
}
else
{
int maXe = int.Parse(dtgDSXeTrungChuyen.CurrentRow.Cells["MaXeTC"].Value.ToString());
tblXeTrungChuyen xe = db.tblXeTrungChuyens.Where(t => t.MaXe == maXe).SingleOrDefault();
if (xe != null)
{
form = new frmSuaXe(xe);
}
}
form.ShowDialog();
frmQuanLyXe_Load(sender, e);
}
示例7: frmTraCuuTrungChuyen
public frmTraCuuTrungChuyen()
{
InitializeComponent();
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
cbbXeTrungChuyen.DataSource = db.tblXeTrungChuyens.Select(t => new { BienSo = t.BienSoXe, DiaDiem = t.DiaDiemTrungChuyen }).ToList();
}
示例8: btnXoa_Click
private void btnXoa_Click(object sender, EventArgs e)
{
int rowIndex = dtgChuyenDi.CurrentCell.RowIndex;
DataGridViewRow row = dtgChuyenDi.Rows[rowIndex];
int maChuyenDi = int.Parse(row.Cells["MaChuyenDi"].Value.ToString());
string message = string.Format("Bạn muốn xóa chuyến đi\nBiển sô xe: {0}\nTuyến: {1}\nKhởi hành: {2}", row.Cells["BienSoXe"].Value, row.Cells["TuyenXe"].Value, row.Cells["KhoiHanh"].Value);
DialogResult result = MessageBox.Show(message, "Thông báo", MessageBoxButtons.YesNo);
if(result == System.Windows.Forms.DialogResult.Yes)
{
BLL.BLL_ChuyenDi temp = new BLL.BLL_ChuyenDi();
if (temp.canDelete(maChuyenDi))
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
tblChuyenDi chuyenDi = db.tblChuyenDis.Where(t => t.MaChuyenDi == maChuyenDi).SingleOrDefault();
if (chuyenDi != null)
{
// Xóa báo cáo
tblBaoCaoDoanhThuChuyenDi bcChuyenDi = db.tblBaoCaoDoanhThuChuyenDis.Where(t => t.MaChuyenDi == chuyenDi.MaChuyenDi).SingleOrDefault();
if(bcChuyenDi != null)
db.tblBaoCaoDoanhThuChuyenDis.Remove(bcChuyenDi);
db.tblChuyenDis.Remove(chuyenDi);
db.SaveChanges();
MessageBox.Show("Xóa thành công");
frmQuanLyChuyenDi_Load(sender, e);
}
}
else
MessageBox.Show("Chuyến đi đã có khách hàng đặt vé hoặc mua, không thể xóa");
}
}
示例9: solveDataInputChiTietTuyen
private List<tblChiTietTuyen> solveDataInputChiTietTuyen()
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
List<tblChiTietTuyen> list = new List<tblChiTietTuyen>();
foreach (DataGridViewRow row in dtgChiTietTuyen.Rows)
{
if (string.IsNullOrEmpty(row.Cells[0].Value + "") && string.IsNullOrEmpty(row.Cells[1].Value + ""))
break;
string MaBenXeTrungGian = "";
string tenBenXe = row.Cells[0].Value.ToString();
tblBenXe benXe = db.tblBenXes.Where(t => t.TenBenXe == tenBenXe).SingleOrDefault();
if (benXe != null)
MaBenXeTrungGian = benXe.MaBenXe;
tblChiTietTuyen temp = new tblChiTietTuyen();
temp.MaBenXeTrungGiang = MaBenXeTrungGian;
if (!string.IsNullOrEmpty(row.Cells[1].Value + ""))
temp.ThoiGianDung = int.Parse(row.Cells[1].Value.ToString());
else
temp.ThoiGianDung = 0;
temp.MaTuyen = txtMaTuyen.Text.ToString();
if (row.Cells[2].Value != null)
temp.GhiChu = row.Cells[2].Value.ToString();
else
temp.GhiChu = "";
list.Add(temp);
}
return list;
}
示例10: frmDanhSachDatVe_Load
private void frmDanhSachDatVe_Load(object sender, EventArgs e)
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
cbbBenXeDen.DataSource = db.tblBenXes.Select(t => t.TenBenXe).ToList();
cbbBenXeDi.DataSource = db.tblBenXes.Select(t => t.TenBenXe).ToList();
}
示例11: canDelete
public bool canDelete(int maNV)
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
if (db.tblNhanViens.Where(t => t.MaNhanVien == maNV).ToArray().Length != 0)
return true;
return false;
}
示例12: canUpdate
public bool canUpdate(int maNV, int cmnd)
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
if (db.tblNhanViens.Where(t => t.MaNhanVien != maNV && t.CMND == cmnd).ToArray().Length != 0)
return false;
return true;
}
示例13: btSua_Click
private void btSua_Click(object sender, EventArgs e)
{
string maTuyen = dtgDanhSachTuyen.CurrentRow.Cells["MaTuyen"].Value.ToString();
tblTuyenXe tuyenXe = new QUANLYXEKHACHEntities().tblTuyenXes.Where(t => t.MaTuyen == maTuyen).SingleOrDefault();
frmThemTuyenXe form = new frmThemTuyenXe(tuyenXe);
form.ShowDialog();
frmQuanLyTuyenXe_Load(sender, e);
}
示例14: canDelete
public bool canDelete(string maBen)
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
if (db.tblBenXes.Where(t => t.MaBenXe == maBen).ToArray().Length != 0)
return true;
return false;
}
示例15: getLastestIndex
public int getLastestIndex()
{
QUANLYXEKHACHEntities db = new QUANLYXEKHACHEntities();
if (db.tblChiTietPhieuDatChoes.ToArray().Length == 0)
return 1;
else
return db.tblChiTietPhieuDatChoes.Max(t => t.MaCTPhieu) + 1;
}