Beispiel #1
0
        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_DONKHACH_XEDITINH().TimKiem(deStart.DateTime, deEnd.DateTime, txtXe.Text, txtSDT.Text, TxtDiaChi.Text, trangthai);

            shGridControl1.SetDataSource(db);
        }
        public void SetId(long id)
        {
            reTrangThai.DataSource    = CommonDuongDai.GetTrangThaiXeDiTinh();
            reTrangThaiXoa.DataSource = CommonDuongDai.GetTrangThaiXoa();
            var db = new DUONGDAI_DONKHACH_XEDITINH().GetLichSu(id);

            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;
             Model.TrangThai   = int.Parse(lupTrangThai.EditValue.ToString());
             long tong = 0;
             long.TryParse(txtTongTien.Text, out tong);
             Model.TongTien = tong;
             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.CreatedBy = ThongTinDangNhap.USER_ID;
                 Model.UpdatedBy = string.Empty;
                 Model.IsDelete  = false;
                 Model.Insert();
             }
             btnXoa.Visible    = false;
             btnLichSu.Visible = false;
             _model            = null;
             MessageBox.Show("Lưu thành công");
             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);
 }
 private void btnXoa_Click(object sender, System.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();
     }
 }
 public void SetModel(DUONGDAI_DONKHACH_XEDITINH model)
 {
     _model = model;
     if (_model == null || _model.Id == 0)
     {
         return;
     }
     btnXoa.Visible          = true;
     btnLichSu.Visible       = true;
     deThoiDiemBao.EditValue = _model.ThoiDiemDon;
     txtDienThoai.Text       = _model.DienThoai;
     txtSoXe.Text            = _model.SoXe;
     txtDiaChi.Text          = _model.DiaChiDon;
     txtTongTien.EditValue   = _model.TongTien;
     lupTrangThai.EditValue  = _model.TrangThai;
     txtNguoiNhap.Text       = _model.NguoiNhap;
     ThoiDiemGoi             = _model.ThoiDiemGoi;
     txtGhiChu.Text          = _model.GhiChu;
     if (_model.TrangThai == 2)// nếu trạng thái đã điều thì sẽ không cho sửa trạng thái.
     {
         lupTrangThai.Properties.ReadOnly = true;
     }
 }