示例#1
0
        public static void SaveToTable(DataTable dt)
        {
            DataTable dtRemine;

            dtRemine = dt.GetChanges();
            if (dtRemine != null)
            {
                foreach (DataRow item in dtRemine.Rows)
                {
                    TheoDoiModel model = new TheoDoiModel();

                    //model.ID =TextUtils.ToInt(item["ID"]);
                    //model.TenCV = Convert.ToString(item["TenCV"]);
                    //model.MaDA = Convert.ToString(item["MaDA"]);
                    //model.MaTB = Convert.ToString(item["MaTB"]);
                    //model.NguoiPhuTrach = TextUtils.ToInt(item["NguoiPhuTrach"]);
                    //model.ThoiGianBD = TextUtils.ToDate(item["ThoiGianBD"].ToString());
                    //model.ThoiGianKT = TextUtils.ToDate(item["ThoiGianKT"].ToString());
                    //model.TinhTrang = Convert.ToString(item["TinhTrang"]);
                    //model.GhiChu = Convert.ToString(item["GhiChu"]);
                    //model.GioBD = TextUtils.ToInt(item["GioBD"]);
                    //model.ThoiGianDuKien = TextUtils.ToInt(item["ThoiGianDuKien"]);
                    //model.GioKT = TextUtils.ToInt(item["GioKT"]);
                    //if (item["ID"] == DBNull.Value) //add new
                    //{
                    //    TheoDoiBO.Instance.Insert(model);
                    //}
                    //else //Update
                    //{
                    //    model.ID = TextUtils.ToInt(item["ID"].ToString());
                    //    TheoDoiBO.Instance.Update(model);
                    //}
                }
            }
        }
示例#2
0
        private void btnNoComplete_Click(object sender, EventArgs e)
        {
            int userID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colUserID));

            if (userID != Global.UserID)
            {
                MessageBox.Show("Bạn không có quyền sửa công việc này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                return;
            }
            if (grvData.SelectedRowsCount == 0)
            {
                return;
            }
            foreach (int i in grvData.GetSelectedRows())
            {
                int id     = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                int status = TextUtils.ToInt(grvData.GetRowCellValue(i, colStatus));
                if (status == 0)
                {
                    continue;
                }
                TheoDoiModel model = (TheoDoiModel)TheoDoiBO.Instance.FindByPK(id);
                model.Status  = 0;
                model.EndDate = null;
                TheoDoiBO.Instance.Update(model);
            }
            LoadInfoSearch();
        }
示例#3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            int userID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colUserID));

            if (userID != Global.UserID)
            {
                MessageBox.Show("Bạn không có quyền sửa công việc này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                return;
            }
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            TheoDoiModel model = (TheoDoiModel)TheoDoiBO.Instance.FindByPK(id);

            _rownIndex = grvData.FocusedRowHandle;

            frmWorkDiary frm = new frmWorkDiary();

            frm.WorkDiary       = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
示例#4
0
        private void grvData_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                int      l    = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianDuKien));
                int      k    = l / 8;
                int      lp   = l % 8;
                if (lp == 0 && k != 0)
                {
                    k--;
                }
                //set tinh trang mac dinh
                if (view.GetRowCellValue(e.RowHandle, colTinhTrang).ToString() == string.Empty || view.GetRowCellValue(e.RowHandle, colTinhTrang) == null)
                {
                    view.SetRowCellValue(e.RowHandle, colTinhTrang, 0);
                }
                //set thoi gian bat dau neu bo trong
                if (view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString() == string.Empty)
                {
                    view.SetRowCellValue(e.RowHandle, colThoiGianBD, Convert.ToDateTime(DateTime.Now));
                }
                DateTime op = DateTime.Now;
                if (l <= 8)
                {
                    op = (Convert.ToDateTime(view.GetRowCellValue(e.RowHandle, colThoiGianBD)).AddHours(TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianDuKien))));
                }
                else
                {
                    op = (Convert.ToDateTime(view.GetRowCellValue(e.RowHandle, colThoiGianBD)).AddDays(k));
                }

                DateTime df = TextUtils.ToDate(TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString()).ToString("dd/MM/yyyy") + " 12:00:00");
                if (op.ToString("dd/MM/yyyy") == df.ToString("dd/MM/yyyy"))
                {
                    if (op.Hour >= 17 && op.Minute > 0)
                    {
                        int du = op.Hour;
                        int mi = op.Minute;
                        op = op.AddDays(1);

                        op = TextUtils.ToDate(op.ToString("dd/MM/yyyy") + " 8:00:00");
                        op = op.AddHours(du - 17).AddMinutes(mi);
                        view.SetRowCellValue(e.RowHandle, colThoiGianKT, op);
                    }
                    else
                    if (TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString()) <= df && op > df)
                    {
                        view.SetRowCellValue(e.RowHandle, colThoiGianKT, op.AddHours(1));
                    }
                    else
                    {
                        view.SetRowCellValue(e.RowHandle, colThoiGianKT, op);
                    }
                }
                else
                {
                    l = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianDuKien));

                    int kl = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString()).Hour;
                    l  = l - ThoiGianConLai(kl);
                    k  = l / 8;
                    lp = l % 8;
                    op = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString());
                    op = TextUtils.ToDate(op.ToString("dd/MM/yyyy") + " 8:00:00");


                    DateTime kh = op.AddDays(k + 1).AddHours(lp);
                    if (kh.Hour > 12)
                    {
                        kh.AddHours(1);
                    }
                    view.SetRowCellValue(e.RowHandle, colThoiGianKT, kh);
                }

                #region Add and update
                {
                    TheoDoiModel model = new TheoDoiModel();

                    //model.ID =TextUtils.ToInt(item["ID"]);
                    //model.TenCV = view.GetRowCellValue(e.RowHandle, colTenCV).ToString();//
                    //model.MaDA = view.GetRowCellValue(e.RowHandle, colMaDA).ToString();//Convert.ToString(item["MaDA"]);
                    //model.MaTB = view.GetRowCellValue(e.RowHandle, colMaTB).ToString();//Convert.ToString(item["MaTB"]);
                    //model.NguoiPhuTrach = TextUtils.ToInt(Global.UserID);//item["NguoiPhuTrach"]);
                    //model.ThoiGianBD = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBD).ToString());//item["ThoiGianBD"].ToString());
                    //model.ThoiGianKT = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianKT).ToString());//item["ThoiGianKT"].ToString());
                    //model.TinhTrang = view.GetRowCellValue(e.RowHandle, colTinhTrang).ToString();// Convert.ToString(item["TinhTrang"]);
                    //model.GhiChu = view.GetRowCellValue(e.RowHandle, colGhiChu).ToString();// Convert.ToString(item["GhiChu"]);
                    //model.GioBD = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colGioBD).ToString());//item["GioBD"]);
                    model.ThoiGianDuKien = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianDuKien).ToString()); //item["ThoiGianDuKien"]);
                    //model.GioKT = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colGioKT).ToString());//item["GioKT"]);
                    if (view.GetRowCellValue(e.RowHandle, colID) == DBNull.Value)                                            //add new
                    {
                        TheoDoiBO.Instance.Insert(model);
                    }
                    else //Update
                    {
                        if (view.GetRowCellValue(e.RowHandle, colNguoiPhuTrach).ToString() == Global.UserID.ToString())
                        {
                            model.ID = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colID).ToString());
                            TheoDoiBO.Instance.Update(model);
                        }
                        else
                        {
                            e.Valid = true;
                            XtraMessageBox.Show("Bạn không thể sửa dữ liệu của người khác");
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            SelectAll(ref m_DataSource, grdData);
        }
示例#5
0
 protected TheoDoiFacade(TheoDoiModel model) : base(model)
 {
 }