Beispiel #1
0
        private void grvData_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            GridView view = sender as GridView;

            try
            {
                #region checkvailidate
                if (view.GetRowCellValue(e.RowHandle, colTenHangMuc).ToString() == string.Empty)
                {
                    e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colThoiGianTK).ToString() == string.Empty)
                {
                    e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString() == string.Empty)
                {
                    e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colUserTK).ToString() == string.Empty)
                {
                    e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colThuTuUuTien).ToString() == string.Empty)
                {
                    e.Valid = false;
                    return;
                }

                int l  = Convert.ToInt32(view.GetRowCellValue(e.RowHandle, colThoiGianTK));
                int k  = l / 8;
                int lp = l % 8;
                if (lp == 0)
                {
                    k--;
                }
                if (view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString() != string.Empty)
                {
                    view.SetRowCellValue(e.RowHandle, colThoiGianKTDuKien, Convert.ToDateTime(view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien)).AddDays(k));
                }
                #endregion
                HangMucCongViecModel model = new HangMucCongViecModel();
                model.TenHangMuc       = view.GetRowCellValue(e.RowHandle, colTenHangMuc).ToString();                         // dtRemine.Rows[i]["TenHangMuc"].ToString();
                model.ThoiGianTK       = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianTK).ToString());        //dtRemine.Rows[i]["ThoiGianTK"].ToString());
                model.ThoiGianBDDuKien = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString()); //dtRemine.Rows[i]["ThoiGianBDDuKien"].ToString());
                model.ThoiGianKTDuKien = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianKTDuKien).ToString()); //dtRemine.Rows[i]["ThoiGianKTDuKien"].ToString());
                model.TinhTrang        = view.GetRowCellValue(e.RowHandle, colTinhTrang).ToString();                          // dtRemine.Rows[i]["TinhTrang"].ToString();
                model.NguoiThietKe     = view.GetRowCellValue(e.RowHandle, colUserTK).ToString();                             // dtRemine.Rows[i]["NguoiThietKe"].ToString();
                model.MucDoUuTien      = view.GetRowCellValue(e.RowHandle, colMucDoUuTien).ToString();                        // dtRemine.Rows[i]["MucDoUuTien"].ToString();
                model.KieuCongViec     = view.GetRowCellValue(e.RowHandle, colKieuCongViec).ToString();                       //dtRemine.Rows[i]["KieuCongViec"].ToString();
                model.Loi = view.GetRowCellValue(e.RowHandle, colLoi).ToString();                                             //dtRemine.Rows[i]["Loi"].ToString();
                if (XtraMessageBox.Show("Dữ liệu đã bị thay đổi\nBạn có muốn lưu vào cơ sở dữ liệu không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    model.SanPhamDAID = Convert.ToInt32(grvDataSP.GetRowCellValue(grvDataSP.FocusedRowHandle, colID).ToString());
                    if (view.GetRowCellValue(e.RowHandle, colID) == DBNull.Value) //add new
                    {
                        //insert
                        HangMucCongViecBO.Instance.Insert(model);
                    }
                    else
                    {
                        model.ID = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colID).ToString());
                        //update
                        HangMucCongViecBO.Instance.Update(model);
                    }
                }
                else
                {
                    e.Valid = false;
                }
                lookUpEdit1_EditValueChanged(null, null);
                tinhgio();
                grvNhanVien_CustomDrawCell(null, null);
                //grvNhanVien.FocusedRowHandle = -1; grvNhanVien.FocusedRowHandle = 0;
                ////DataTable hu = grdNhanVien.DataSource as DataTable;
            }
            catch (Exception)
            {
                throw;
            }
        }
 protected HangMucCongViecFacade(HangMucCongViecModel model) : base(model)
 {
 }