public void TestAddAndDelete() { HanhKhach t1 = new HanhKhach("HK005", "Hanh Khach 5", "55555555", "0123321123"); Assert.AreEqual(true, manager.add(t1)); Assert.AreEqual(false, manager.add(t1)); Assert.AreEqual(true, manager.delete("HK005")); }
public void TestUpdate() { HanhKhach t1 = new HanhKhach("HK005", "Hanh Khach 5", "55555555", "0123321123"); manager.add(t1); HanhKhach t2 = new HanhKhach("HK005", "Hanh Khach thu 5", "50505050", "0123455432"); Assert.AreEqual(true, manager.update(t2)); Assert.AreEqual(true, manager.update(t1)); Assert.AreEqual(true, manager.delete("HK005")); }
private void btnTimKiem_Click(object sender, EventArgs e) { BUL_HanhKhach bUL_HanhKhach = new BUL_HanhKhach(); if (txtTraCuu.Text != "") { HanhKhach hk = new HanhKhach(txtTraCuu.Text); dGVtraCuuHK.DataSource = bUL_HanhKhach.getTimKiem(hk); } else { xemdulieu(); } }
private List <HanhKhach> listHK() { List <HanhKhach> listRT = new List <HanhKhach>(); for (int i = 0; i < lv_search.Items.Count; i++) { if (lv_search.Items[i].Checked == true) { HanhKhach hk = _hkRepo.getById(int.Parse(lv_search.Items[i].Text)); listRT.Add(hk); } } return(listRT); }
public bool ThemThongTinHanhKhach(HanhKhach hanhkhach) { string query = "INSERT INTO HANHKHACH VALUES (@MaHanhKhach, @TenHanhKhach, @CMND, @DienThoai)"; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters["@MaHanhKhach"] = hanhkhach.MaHanhKhach; parameters["@TenHanhKhach"] = hanhkhach.TenHanhKhach; parameters["@CMND"] = hanhkhach.CMND; parameters["@DienThoai"] = hanhkhach.DienThoai; try { ExecuteNonQuery(query, parameters); return(true); } catch (Exception) { return(false); } }
private void init() { switch (editState) { case EditState.View: { HanhKhach hk = _hanhKhach.getById(id); txt_id.Text = hk.MaKhach; txt_email.Text = hk.Email; txt_phone.Text = hk.SDT.ToString(); txt_name.Text = hk.Ten; title.Text = "CHI TIẾT HÀNH KHÁCH"; txt_name.ReadOnly = true; txt_email.ReadOnly = true; txt_id.ReadOnly = true; txt_phone.ReadOnly = true; btn.Enabled = false; break; } case EditState.Create: { break; } case EditState.Edit: { HanhKhach hk = _hanhKhach.getById(id); txt_id.Text = hk.MaKhach; txt_email.Text = hk.Email; txt_phone.Text = hk.SDT.ToString(); txt_name.Text = hk.Ten; title.Text = "SỬA HÀNH KHÁCH"; break; } } }
private void btn_Click(object sender, EventArgs e) { if (!validate()) { return; } if (id != 0) { HanhKhach hk = _hanhKhach.getById(id); hk.MaKhach = txt_id.Text; hk.Ten = txt_name.Text; hk.Email = txt_email.Text; hk.SDT = txt_phone.Text; _hanhKhach.Update(hk); MessageBox.Show("Sửa thành công Hành Khách có ID: " + hk.KhachId, "Hành Khách"); txt_id.Focus(); } else { HanhKhach hk = new HanhKhach(); hk.MaKhach = txt_id.Text; hk.Ten = txt_name.Text; hk.Email = txt_email.Text; hk.SDT = txt_phone.Text; _hanhKhach.Add(hk); MessageBox.Show("Đã thêm thành công", "Hành Khách"); txt_id.Text = ""; txt_email.Text = ""; txt_phone.Text = ""; txt_name.Text = ""; txt_id.Focus(); } }
private void btnXacNhan_Click(object sender, EventArgs e) { BUL_HanhKhach bUL_HanhKhach = new BUL_HanhKhach(); if (txtMaHK.Text != "" && txtTenHK.Text != "" && txtCMND.Text != "") { HanhKhach hk = new HanhKhach(txtMaHK.Text, txtTenHK.Text, txtCMND.Text, txtDienThoai.Text); if (bUL_HanhKhach.themHanhKhach(hk)) { MessageBox.Show("Thêm thành công"); dGVhanhKhach.DataSource = bUL_HanhKhach.getHK(); // refresh datagridview } else { MessageBox.Show("Đã có lỗi xảy ra", "Lỗi"); } } else { MessageBox.Show("Xin hãy nhập đầy đủ"); } }
private void btnSua_Click(object sender, EventArgs e) { BUL_HanhKhach bUL_HanhKhach = new BUL_HanhKhach(); if (txtMaHK.Text != "") { HanhKhach hk = new HanhKhach(txtMaHK.Text, txtTenHK.Text, txtCMND.Text, txtDienThoai.Text); if (bUL_HanhKhach.suaHK(hk)) { MessageBox.Show("Sửa thành công"); xemdulieu(); AddBinding(); } else { MessageBox.Show("Đã có lỗi xảy ra", "Lỗi"); } } else { MessageBox.Show("Kiểm tra lại"); } }
public void Add(HanhKhach entity) { _context.HanhKhachs.Add(entity); _context.SaveChanges(); }
public DataTable getTimKiem(HanhKhach hK) { Ultilies ultilies = new Ultilies(); return(ultilies.GetDataTimKiemHK(hK)); }
public bool xoaHK(HanhKhach hK) { Ultilies ultilies = new Ultilies(); return(ultilies.xoaHanhKhach(hK)); }
public bool themHanhKhach(HanhKhach hK) { Ultilies ultilies = new Ultilies(); return(ultilies.themHanhKhach(hK)); }
public void Delete(HanhKhach entity) { entity.isDeleted = Status.Deleted; _context.HanhKhachs.Update(entity); _context.SaveChanges(); }
public bool ThemHanhKhach(HanhKhach hanhkhach) { return(hanhkhachDAO.ThemThongTinHanhKhach(hanhkhach)); }
private void btn_Click(object sender, EventArgs e) { if (!validate()) { return; } if (id != 0) { HanhKhach hk = _hanhKhach.getById(id); hk.MaKhach = txt_id.Text; hk.Ten = txt_name.Text; hk.Email = txt_email.Text; hk.SDT = txt_phone.Text; hk.CMND = txt_cmnd.Text; hk.DiaChi = txt_diachi.Text; hk.Passport = txt_passport.Text; if (Radio_GT.Checked == true) { hk.GioiTinh = Radio_GT.Text; } else { hk.GioiTinh = Radio_GT1.Text; } _hanhKhach.Update(hk); MessageBox.Show("Sửa thành công Hành Khách có ID: " + hk.KhachId, "Hành Khách"); txt_id.Focus(); } else { HanhKhach hk = new HanhKhach(); hk.MaKhach = txt_id.Text; hk.Ten = txt_name.Text; hk.Email = txt_email.Text; hk.SDT = txt_phone.Text; hk.CMND = txt_cmnd.Text; hk.DiaChi = txt_diachi.Text; hk.Passport = txt_passport.Text; if (Radio_GT.Checked == true) { hk.GioiTinh = Radio_GT.Text; } else { hk.GioiTinh = Radio_GT1.Text; } _hanhKhach.Add(hk); MessageBox.Show("Đã thêm thành công", "Hành Khách"); txt_id.Text = ""; txt_email.Text = ""; txt_phone.Text = ""; txt_name.Text = ""; txt_cmnd.Text = ""; txt_diachi.Text = ""; txt_passport.Text = ""; Radio_GT.Checked = true; txt_id.Focus(); } }
private void init() { switch (editState) { case EditState.View: { HanhKhach hk = _hanhKhach.getById(id); txt_id.Text = hk.MaKhach; txt_email.Text = hk.Email; txt_phone.Text = hk.SDT.ToString(); txt_name.Text = hk.Ten; txt_cmnd.Text = hk.CMND; txt_diachi.Text = hk.DiaChi; if (hk.GioiTinh == "Nam") { Radio_GT.Checked = true; } else { Radio_GT1.Checked = true; } txt_passport.Text = hk.Passport; title.Text = "CHI TIẾT HÀNH KHÁCH"; txt_name.ReadOnly = true; txt_email.ReadOnly = true; txt_id.ReadOnly = true; txt_phone.ReadOnly = true; txt_diachi.ReadOnly = true; txt_cmnd.ReadOnly = true; txt_passport.ReadOnly = true; Radio_GT.Enabled = false; Radio_GT1.Enabled = false; btn.Enabled = false; break; } case EditState.Create: { break; } case EditState.Edit: { HanhKhach hk = _hanhKhach.getById(id); txt_id.Text = hk.MaKhach; txt_email.Text = hk.Email; txt_phone.Text = hk.SDT.ToString(); txt_name.Text = hk.Ten; txt_cmnd.Text = hk.CMND; txt_diachi.Text = hk.DiaChi; if (hk.GioiTinh == "Nam") { Radio_GT.Checked = true; } else { Radio_GT1.Checked = true; } txt_passport.Text = hk.Passport; title.Text = "SỬA HÀNH KHÁCH"; break; } } }
public void Update(HanhKhach entity) { _context.HanhKhachs.Update(entity); _context.SaveChanges(); }
private void save() { //init Create Type DoanKhach doan = new DoanKhach(); Tour tour1 = _tourRepository.getByName(tourd.SelectedItem.ToString()); //init Edit Type if (formType == EditState.Edit) { doan = _doanRepo.getById(id); if (tour1.TourId != doan.TourId) { doan.Gia = tour1.Gias.LastOrDefault(); } } //Add value to each of column doan doan.MaDoan = mad.Text; doan.TenDoan = tend.Text; doan.Tour = tour1; doan.Chitiet = statusd.Text; doan.DateStart = datestart.Value.Date; doan.DateEnd = dateend.Value.Date; //NhanVien List <NV_VT> doan_nvs = new List <NV_VT>(); foreach (DataGridViewRow row in data_nv.Rows) { NV_VT doan_nv = new NV_VT(); NhanVien nhanvien = _nvRepo.getById(0, row.Cells[0].Value.ToString()); doan_nv.NhanVien = nhanvien; doan_nv.DoanKhach = doan; doan_nv.ViTri = row.Cells[2].Value.ToString(); doan_nvs.Add(doan_nv); } doan.NV_VTs = doan_nvs; //HanhKhach List <CTDoan> cTDoans = new List <CTDoan>(); foreach (DataGridViewRow row in data_hk.Rows) { CTDoan cTDoan = new CTDoan(); HanhKhach hk = _hkRepo.getById(0, row.Cells[0].Value.ToString()); cTDoan.HanhKhach = hk; cTDoan.DoanKhach = doan; cTDoans.Add(cTDoan); } doan.CTDoans = cTDoans; //ChiTieu List <CTChitieu> cTChiTieus = new List <CTChitieu>(); foreach (DataGridViewRow row in data_cp.Rows) { CTChitieu cTChiTieu = new CTChitieu(); ChiTieu ct = _ctRepo.getByName(row.Cells[0].Value.ToString()); cTChiTieu.ChiTieu = ct; cTChiTieu.TienCT = row.Cells[1].Value.ToString(); cTChiTieu.DoanKhach = doan; cTChiTieus.Add(cTChiTieu); } doan.CTChitieus = cTChiTieus; if (formType == EditState.Edit) { _doanRepo.Update(doan); } else { doan.Gia = doan.Tour.Gias.LastOrDefault(); doan.DateCreated = DateTime.Now; _doanRepo.Add(doan); } }