private void btnTimKiem_Click(object sender, System.EventArgs e) { if (deStart.EditValue == null) { MessageBox.Show("Bạn chưa chọn từ ngày"); deStart.Focus(); return; } if (deEnd.EditValue == null) { MessageBox.Show("Bạn chưa chọn đến ngày"); deEnd.Focus(); return; } if (deStart.DateTime > deEnd.DateTime) { MessageBox.Show("Từ ngày nhỏ hơn đến ngày"); deEnd.Focus(); return; } var trangthai = 0; if (lupTrangThai.EditValue != null) { int.TryParse(lupTrangThai.EditValue.ToString(), out trangthai); } var db = new DUONGDAI_KHACHHEN_XEDK().TimKiem(deStart.DateTime, deEnd.DateTime, txtSDT.Text, txtSoXe.Text, trangthai); shGridControl1.SetDataSource(db); }
public bool Luu() { try { if (ValidateData()) { Model.GhiChu = txtGhiChu.Text.Trim(); Model.UpdatedDate = DateTime.Now; Model.CreatedDate = DateTime.Now; Model.ThoiDiemGoi = ThoiDiemGoi; if (Model.Id > 0) { if (Quyen && ThongTinDangNhap.HasPermission(this.QuyenSua)) { SetError("Bạn không có quyền sửa"); return(false); } if (!IsChangeData) { btnXoa.Visible = false; btnLichSu.Visible = false; _model = null; MessageBox.Show("Lưu thành công"); return(true); } Model.UpdatedBy = ThongTinDangNhap.USER_ID; Model.Update(); } else { if (Quyen && ThongTinDangNhap.HasPermission(this.QuyenThem)) { SetError("Bạn không có quyền thêm"); return(false); } Model.TrangThai = 1; Model.CreatedBy = ThongTinDangNhap.USER_ID; Model.UpdatedBy = string.Empty; Model.Insert(); } MessageBox.Show("Lưu thành công"); _model = null; return(true); } } catch (Exception ex) { MessageBox.Show("Trong quá trình xử lý xảy ra lỗi ngoại lệ.\nVui lòng liên hệ với hỗ trợ viên.\nLỗi:" + ex.Message); } return(false); }
public void SetModel(DUONGDAI_KHACHHEN_XEDK model) { _model = model; if (_model == null || _model.Id == 0) { return; } btnXoa.Visible = true; btnLichSu.Visible = true; txtDienThoai.Text = _model.DienThoai; txtSoXe.Text = _model.SoXe; ThoiDiemGoi = _model.ThoiDiemGoi; lblThoiGianGoi.Text = ThoiDiemGoi.ToString("HH:mm dd/MM/yyyy"); deThoiGianDon.EditValue = _model.ThoiDiemDon; txtDiemDo.Text = _model.DiemDo; txtGhiChu.Text = _model.GhiChu; }
private void btnXoa_Click(object sender, EventArgs e) { SetError(""); if (MessageBox.Show("Bạn có muốn xóa bảng ghi này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (Quyen && ThongTinDangNhap.HasPermission(this.QuyenXoa)) { SetError("Bạn không có quyền xóa"); return; } Model.UpdatedBy = ThongTinDangNhap.USER_ID; Model.Delete(); btnLamMoi.PerformClick(); _model = null; this.Close(); } }
private void btnTimXeDon_Click(object sender, EventArgs e) { //if (deNgayXeDon.EditValue == null) //{ // MessageBox.Show("Bạn chưa chọn ngày xe đón để tìm kiếm"); // return; //} var db = new DUONGDAI_KHACHHEN_XEDK().DieuxeTimKiem(deNgayXeDon.EditValue == null ?(DateTime?)null:deNgayXeDon.DateTime, txtSoxe.Text, txtDiemDo.Text).OrderBy(p => p.ThoiDiemGoi).ToList(); shGridControl2.SetDataSource(db); shGridControl2.Refresh(); timeXeDon = 10; if (db.Count == 0) { MessageBox.Show("Không tìm thấy dữ liệu."); } }
private void XuLyDuLieu() { //if (timeKhachHen>-1) // timeKhachHen--; //if (timeXeDon > -1) // timeXeDon--; //Thêm dữ liệu var db = new DUONGDAI_KHACHHEN().GetByTime(_timeKhachHen); if (db.Count > 0) { _timeKhachHen = CommonBL.GetTimeServer(); db.ForEach(p => { var ldb = _khachhen.Where(p1 => p1.Id == p.Id).ToList(); //Khi có trạng thái chưa điều thì sẽ thêm mới hoặc là thay đổi. if (p.TrangThai == 1) { if (ldb.Count > 0) // tồn tại thì sẽ khi sửa { ldb.ForEach(p1 => _khachhen.Remove(p1)); } _khachhen.Add(p); } else { ldb.ForEach(p1 => _khachhen.Remove(p1)); } }); } var db1 = new DUONGDAI_KHACHHEN_XEDK().GetByTime(_timeXeDon); if (db1.Count > 0) { db1.ForEach(p => { var ldb = _khachhenXedk.Where(p1 => p1.Id == p.Id && p1.IsXeDangKy == p.IsXeDangKy).ToList(); if (p.TrangThai == 1) { if (ldb.Count > 0) { ldb.ForEach(p1 => _khachhenXedk.Remove(p1)); } _khachhenXedk.Add(p); } else { ldb.ForEach(p1 => _khachhenXedk.Remove(p1)); } }); _timeXeDon = CommonBL.GetTimeServer(); } if (timeKhachHen == -1) { shGridControl1.RefreshDataSource(); } if (timeKhachHen == 0) { shGridControl1.SetDataSource(_khachhen); shGridControl1.RefreshDataSource(); timeKhachHen = -1; } //-- if (timeXeDon == -1) { shGridControl2.RefreshDataSource(); } if (timeXeDon == 0) { shGridControl2.SetDataSource(_khachhenXedk); shGridControl2.RefreshDataSource(); timeXeDon = -1; } // Khách hẹn }
public void SetId(long id) { var db = new DUONGDAI_KHACHHEN_XEDK().GetLichSu(id); shGridControl1.SetDataSource(db); }