예제 #1
0
        private void Load_CongViec()
        {
            clsCongViec cls = new clsCongViec();

            cls.ID_CongViec = Convert.ToInt32(m_iID_CongViec);
            DataTable dt = cls.SelectOne();

            txtMaCV.EditValue           = dt.Rows[0]["Ma_CongViec"];
            txtTieuDe.EditValue         = dt.Rows[0]["TieuDe"];
            txtMoTa.EditValue           = dt.Rows[0]["MoTa"];
            cmbLoaiCongViec.EditValue   = dt.Rows[0]["ID_LoaiCV"];
            cmbDoUuTien.EditValue       = int.Parse(dt.Rows[0]["ID_MucDoUuTien"].ToString());
            cmbCongViecGoc.EditValue    = dt.Rows[0]["ID_CongViec_Goc"].ToString();
            cmbNguoiGiaoViec.EditValue  = dt.Rows[0]["ID_NguoiYeuCau"].ToString();
            dtNgayDenHan.Value          = dt.Rows[0]["Ngay_DenHan"];
            dtNgayYeuCauMoi.Value       = dt.Rows[0]["Ngay_YeuCau"];
            txtThoiGianDuKien.EditValue = dt.Rows[0]["ThoiGian_DuKien"];
            cmbDonViTG.SelectedValue    = short.Parse(dt.Rows[0]["ID_ThoiGian"].ToString());
            dtNgayBatDau.Value          = dt.Rows[0]["Ngay_BatDau"];
            dtNgayHT.Value          = dt.Rows[0]["Ngay_HoanThanh"];
            cmbTrangThai.EditValue  = int.Parse(dt.Rows[0]["ID_TrangThai"].ToString());
            txtDiaDiemMoi.EditValue = dt.Rows[0]["DiaDiem"];

            string[] nhanvien = dt.Rows[0]["DS_ID_NhanVien"].ToString().Split(',');
            cmbNhanVien.EditValue = nhanvien[0];

            cmbNguoiThucHien.SetEditValue(dt.Rows[0]["DS_ID_NhanVien"].ToString());
        }
예제 #2
0
        private void CB_CongViecHoanThanhTrongNgay()
        {
            var cls = new clsCongViec();
            var dt  = cls.CongViec_HoanThanhTrongNgay(GlobalVariables.GetID_NhanSu()
                                                      .ToString(CultureInfo.InvariantCulture));

            switch (dt.Rows.Count)
            {
            case 0:
                break;

            case 1:
                m_iCongViecTH    = 1;
                m_iID_CongViecTH = int.Parse(dt.Rows[0]["ID_CongViec"].ToString());
                alertControl1.Show(ActiveMdiChild, "Thông báo",
                                   "Có " + 1 + " công việc phải hoàn thành trong ngày hôm nay!");
                break;

            default:
                if (dt.Rows.Count > 1)
                {
                    m_iCongViecTH = dt.Rows.Count;
                    alertControl1.Show(ActiveMdiChild, "Thông báo",
                                       "Có " + m_iCongViecTH + " công việc phải hoàn thành trong ngày hôm nay!");
                }
                break;
            }
        }
예제 #3
0
        private void CB_ThongBao_DenHan_VaoForm()
        {
            //1. Lay cv chua hoan thanh va thoi gian can canh bao
            var cls        = new clsCongViec();
            var dt         = cls.Select_CongViec_ThongBaoTruocKhoangThoiGian(GlobalVariables.GetID_NhanSu().ToString());
            var strMessage = "";

            foreach (DataRow dataRow in dt.Rows)
            {
                strMessage = string.Format("Công việc '{0}' sắp đến hạn hoàn thành!", dataRow["TieuDe"]);
                alertControl2.Show(ActiveMdiChild, "Thông báo", strMessage);
            }
        }
예제 #4
0
        private void CB_ThongBao_KhiCoThayDoi_VaoForm()
        {
            //1. Lay cv chua hoan thanh va thoi gian can canh bao
            var cls        = new clsCongViec();
            var dt         = cls.Select_CongViec_ThongBao_KhiCoThayDoi(GlobalVariables.GetID_NhanSu().ToString());
            var strMessage = "";

            foreach (DataRow dataRow in dt.Rows)
            {
                strMessage = dataRow["NoiDung"].ToString();
                alertControl3.Show(ActiveMdiChild, "Thông báo", strMessage);
            }
        }
예제 #5
0
        private void LoadcmbCongViecGocCu()
        {
            var cmb = cmbCVGocCu;

            cmb.Tag = 0;
            clsCongViec cls = new clsCongViec();
            DataTable   dt  = cls.SelectAll();

            cmb.Properties.DataSource    = dt.DefaultView.ToTable();
            cmb.Properties.DisplayMember = "TieuDe";
            cmb.Properties.ValueMember   = "ID_CongViec";
            cmb.Properties.BestFitMode   = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
            cmb.Tag = 1;
        }
예제 #6
0
        private void CB_ThongBao_KhiCoThayDoi()
        {
            var cls = new clsCongViec();
            var dt  = cls.Select_CongViec_ThongBao_KhiCoThayDoi(GlobalVariables.GetID_NhanSu()
                                                                .ToString(CultureInfo.InvariantCulture));
            var strMessage = "";

            int iID_ThongBao;

            foreach (DataRow dataRow in dt.Rows)
            {
                iID_ThongBao = int.Parse(dataRow["ID_ThongBao"].ToString());
                if (!m_lstID_DaThongBao.Contains(iID_ThongBao))
                {
                    m_lstID_DaThongBao.Add(iID_ThongBao);
                    strMessage = dataRow["NoiDung"].ToString();
                    alertControl3.Show(ActiveMdiChild, "Thông báo", strMessage);
                }
            }
        }
예제 #7
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (fg.Row < fg.Rows.Fixed)
            {
                BaseMessages.ShowInformationMessage("Chưa chọn công việc!");
                return;
            }
            if (BaseMessages.ShowDeleteQuestionMessage() == DialogResult.No)
            {
                return;
            }
            clsCongViec cls = new clsCongViec();

            cls.ID_CongViec = Convert.ToInt32(fg[fg.Row, "ID_CongViec"]);
            cls.TonTai      = false;
            cls.Update();

            BaseMessages.ShowInformationMessage("Xóa thành công!");
            Loadfg();
            fg.ApplyFilters();
        }
예제 #8
0
        private void CB_ThongBao_DenHan()
        {
            //1. Lay cv chua hoan thanh va thoi gian can canh bao
            var cls = new clsCongViec();
            var dt  = cls.Select_CongViec_ThongBaoTruocKhoangThoiGian(GlobalVariables.GetID_NhanSu()
                                                                      .ToString(CultureInfo.InvariantCulture));
            var strMessage = "";

            int iID_CongViec;

            foreach (DataRow dataRow in dt.Rows)
            {
                iID_CongViec = int.Parse(dataRow["ID_CongViec_ThongBao"].ToString());
                if (!m_lstID_CongViec_DaThongBao.Contains(iID_CongViec))
                {
                    m_lstID_CongViec_DaThongBao.Add(iID_CongViec);
                    strMessage = string.Format("Công việc '{0}' sắp đến hạn hoàn thành!", dataRow["TieuDe"]);
                    alertControl2.Show(ActiveMdiChild, "Thông báo", strMessage);
                }
            }
        }
예제 #9
0
        private void LoadView(int cheDo)
        {
            InstalCsStyle();

            fg.BeginUpdate();

            fg.ClearRows();
            if (cheDo == 1)
            {
            }
            if (cheDo == 2)
            {
                fg.Cols[1].Caption = "Chủ nhật";
                fg.Cols[1].Width   = 205;
                fg.Cols[1].Style   = csNghi;
                for (int c = 0; c < 7; ++c)
                {
                    C1.Win.C1FlexGrid.Column col = fg.Cols.Add();
                    col.Width   = 200;
                    col.Caption = "Thứ " + (c + 2);
                    col.Name    = c.ToString();
                }
                for (int r = 1; r <= 30; ++r)
                {
                    C1.Win.C1FlexGrid.Row row = fg.Rows.Add();
                    for (int c = fg.Cols.Fixed; c < fg.Cols.Count; ++c)
                    {
                        if (r % 6 == 0)
                        {
                            this.fg.SetCellStyle(r, c, "b");
                        }
                    }
                }
                for (int c = fg.Cols.Fixed + 1; c < fg.Cols.Count; ++c)
                {
                    fg.Cols[c].Style = csNgayThuong;
                }
                fg.Cols[fg.Cols.Fixed].Style = csNghi;
                DateTime d = firstDayCalendar;
                for (int r = fg.Rows.Fixed; r < fg.Rows.Count; r += 6)
                {
                    for (int c = fg.Cols.Fixed; c < fg.Cols.Count; ++c)
                    {
                        if (d.Day == 1)
                        {
                            fg[r, c] = d.Day + " tháng " + d.Month;
                        }
                        else
                        {
                            fg[r, c] = d.Day;
                        }
                        d = d.AddDays(1);
                    }
                }
            }
            if (cheDo == 3)
            {
                DateTime date = monthCalendar.SelectionRange.Start;
                int      totalCalendarDays = 42; // matrix 7 x 5

                // set the first month day
                DateTime firstDayMonth = new DateTime(date.Year, date.Month, 1);

                // set the lastmonth day
                DateTime lastDayMonth = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));

                // now get the first day week of the first day month (0-6 Sun-Sat)
                byte firstDayWeek = (byte)firstDayMonth.DayOfWeek;

                // now get the first day week of the last day month (0-6 Sun-Sat)
                byte lastDayWeek = (byte)lastDayMonth.DayOfWeek;

                // now the first day show in calendar is the first day month minus the days to 0 (sunday)
                firstDayCalendar = firstDayMonth.Subtract(TimeSpan.FromDays(firstDayWeek));
                int tempDays = (lastDayMonth - firstDayCalendar).Days;

                lastDayCalendar = lastDayMonth.Add(TimeSpan.FromDays(totalCalendarDays - tempDays - 1));

                for (int r = 1; r <= 36; ++r)
                {
                    C1.Win.C1FlexGrid.Row row = fg.Rows.Add();
                    for (int c = fg.Cols.Fixed; c < fg.Cols.Count; ++c)
                    {
                        if (r % 6 == 0)
                        {
                            this.fg.SetCellStyle(r, c, "b");
                        }
                    }
                }
                for (int c = fg.Cols.Fixed + 1; c < fg.Cols.Count; ++c)
                {
                    fg.Cols[c].Style = csNgayThuong;
                }
                DateTime    d             = firstDayCalendar;
                clsCongViec cls           = new clsCongViec();
                DataTable   dt_DsNgayNghi = cls.DS_NgayNghi(firstDayCalendar, lastDayCalendar);

                for (int r = fg.Rows.Fixed; r < fg.Rows.Count; r += 6)
                {
                    for (int c = fg.Cols.Fixed; c < fg.Cols.Count; ++c)
                    {
                        if (d.Day == 1)
                        {
                            fg[r, c] = d.Day + "/" + d.Month;
                        }
                        else
                        {
                            fg[r, c] = d.Day + "/" + d.Month;
                        }
                        if (d.Date == dtNow.Date)
                        {
                            for (int i = 0; i < 1; ++i)
                            {
                                CellRange range = fg.GetCellRange(r + i, c);
                                range.Style = csNgayHomNay;
                            }
                        }
                        if (Trong_DsNgayNghi(dt_DsNgayNghi, d))
                        {
                            for (int i = 0; i < 1; ++i)
                            {
                                CellRange range = fg.GetCellRange(r + i, c);
                                range.Style = csNghi;
                            }
                        }
                        d = d.AddDays(1);
                    }
                }

                LoadCalendar(cheDo, firstDayCalendar);

                fg.AllowMerging = AllowMergingEnum.Custom;
                for (int i = fg.Rows.Fixed; i < fg.Rows.Count; ++i)
                {
                    fg.Rows[i].AllowMerging = true;
                }
            }

            fg.EndUpdate();
            fg.AllowMerging = AllowMergingEnum.Free;
        }
예제 #10
0
        private void LoadCalendar(int cheDo, DateTime ngayBatDau)
        {
            if (cheDo == 1)
            {
            }
            if (cheDo == 2)
            {
            }
            if (cheDo == 3)
            {
                cell_IDLich = new int[252];
                DateTime    ngayCuoi = ngayBatDau.AddDays(35);
                clsCongViec cls      = new clsCongViec();
                DataTable   dt_Lich  = cls.CongViec_Lich(ngayBatDau, ngayCuoi, id_NhanVien_DangNhap, ds_LoaiCV);
                //
                TinhSoCongViecTrongMoiNgay(dt_Lich);
                foreach (DataRow dr in dt_Lich.Rows)
                {
                    DateTime thoiGian_BatDau, thoiGian_KetThuc;
                    if (dr["Ngay_DenHan"].ToString() == "")
                    {
                        thoiGian_KetThuc = lastDayCalendar;
                    }
                    else
                    {
                        thoiGian_KetThuc = (DateTime)(dr["Ngay_DenHan"]);
                    }
                    if (dr["Ngay_YeuCau"].ToString() != "")
                    {
                        thoiGian_BatDau = (DateTime)(dr["Ngay_YeuCau"]);
                    }
                    else
                    {
                        thoiGian_BatDau = firstDayCalendar;
                    }
                    if (thoiGian_BatDau > thoiGian_KetThuc)
                    {
                        thoiGian_KetThuc = dtNow;
                    }
                    if (thoiGian_BatDau.Date > lastDayCalendar.Date || thoiGian_KetThuc.Date < firstDayCalendar.Date)
                    {
                        continue;
                    }
                    if (thoiGian_BatDau < firstDayCalendar)
                    {
                        thoiGian_BatDau = firstDayCalendar;
                    }
                    while ((thoiGian_BatDau) <= thoiGian_KetThuc)
                    {
                        if (thoiGian_BatDau.Date < firstDayCalendar || thoiGian_BatDau.Date > lastDayCalendar)
                        {
                            thoiGian_BatDau = thoiGian_BatDau.AddDays(1);
                            continue;
                        }
                        if (dr["DS_Thu"].ToString() == "" && dr["DS_Ngay"].ToString() == "" && dr["DS_Thang"].ToString() == "")
                        {
                        }
                        else
                        {
                            if (!TrongDSNgay(dr["DS_Thu"].ToString(), dr["DS_Ngay"].ToString(), dr["DS_Thang"].ToString(), thoiGian_BatDau))
                            {
                                thoiGian_BatDau = thoiGian_BatDau.AddDays(1);
                                continue;
                            }
                        }
                        if (dr["ID_TrangThai"].ToString() == "3" || dr["ID_TrangThai"].ToString() == "4")
                        {
                            thoiGian_BatDau = thoiGian_BatDau.AddDays(1);
                            continue;
                        }
                        int[] rc = DateToInt(thoiGian_BatDau);
                        bool  thoaManHienThiThanhMotHangNgang = true;
                        int   r = rc[0];
                        int   soNgayCuaCongViecTrongHang = 0;
                        int   soNgay = (int)(thoiGian_KetThuc - thoiGian_BatDau).TotalDays;
                        for (r = rc[0] + 1; r <= rc[0] + 5; ++r)
                        {
                            thoaManHienThiThanhMotHangNgang = true;
                            int c = rc[1];
                            while (c <= (rc[1] + soNgay) && c < fg.Cols.Count)
                            {
                                if (fg.GetDataDisplay(r, c) != "")
                                {
                                    thoaManHienThiThanhMotHangNgang = false;
                                    break;
                                }
                                ++c;
                            }
                            if (thoaManHienThiThanhMotHangNgang && (c == (rc[1] + soNgay + 1) || c == fg.Cols.Count))
                            {
                                soNgayCuaCongViecTrongHang = c - rc[1];
                                break;
                            }
                        }
                        if (r <= rc[0] + 5)
                        {
                            DateTime d;
                            for (d = thoiGian_BatDau.Date; d <= thoiGian_BatDau.Date.AddDays(soNgayCuaCongViecTrongHang - 1); d = d.AddDays(1))
                            {
                                //
                                if (dr["DS_Thu"].ToString() == "" && dr["DS_Ngay"].ToString() == "" && dr["DS_Thang"].ToString() == "")
                                {
                                }
                                else
                                {
                                    if (!TrongDSNgay(dr["DS_Thu"].ToString(), dr["DS_Ngay"].ToString(), dr["DS_Thang"].ToString(), d))
                                    {
                                        //thoiGian_BatDau = thoiGian_BatDau.AddDays(1);
                                        continue;
                                    }
                                }
                                //
                                int[] row_col = DateToInt(d);
                                int   index   = (r - 1) * 7 + row_col[1];
                                cell_IDLich[index] = int.Parse(dr["ID_CongViec"].ToString());

                                fg[r, row_col[1]] = dr["TieuDe"];
                                string[] loaiCV_Array = ds_LoaiCV.Split(',');
                                if (dr["ID_LoaiCV"].ToString() == "1")
                                {
                                    CellRange range = fg.GetCellRange(r, row_col[1]);
                                    range.Style = csHop;
                                    //fg.SetCellImage(r, row_col[1], ProjectManagements.Properties.Resources.ico_Blue_Rec_img);
                                }
                                if (dr["ID_LoaiCV"].ToString() == "2")
                                {
                                    CellRange range = fg.GetCellRange(r, row_col[1]);
                                    range.Style = csCongTac;
                                    //fg.SetCellImage(r, row_col[1], ProjectManagements.Properties.Resources.ico_Purple_Rec_img);
                                }
                                if (dr["ID_LoaiCV"].ToString() != "2" && dr["ID_LoaiCV"].ToString() != "1")
                                {
                                    CellRange range = fg.GetCellRange(r, row_col[1]);
                                    range.Style = csCongViec;
                                    //fg.SetCellImage(r, row_col[1], ProjectManagements.Properties.Resources.ico_Purple_Rec_img);
                                }
                                //
                            }
                            thoiGian_BatDau = d;
                            continue;
                        }
                        thoiGian_BatDau = thoiGian_BatDau.AddDays(1);
                    }
                }
            }
        }
예제 #11
0
        private void Loadfg()
        {
            fg.Tag = 0;
            fg.BeginUpdate();
            clsCongViec cls = new clsCongViec();

            SqlDateTime TuNgay  = SqlDateTime.Null;
            SqlDateTime DenNgay = SqlDateTime.Null;

            SqlDateTime BatDauTuNgay  = SqlDateTime.Null;
            SqlDateTime BatDauDenNgay = SqlDateTime.Null;

            if (dtmTuNgay.Text.Length == dtmTuNgay.CustomFormat.Length)
            {
                TuNgay = DateTime.Parse(dtmTuNgay.Text);
            }
            if (dtmDenNgay.Text.Length == dtmDenNgay.CustomFormat.Length)
            {
                DenNgay = DateTime.Parse(dtmDenNgay.Text).AddDays(1);
            }


            if (dtmBatDauTuNgay.Text.Length == dtmBatDauTuNgay.CustomFormat.Length)
            {
                BatDauTuNgay = DateTime.Parse(dtmBatDauTuNgay.Text);
            }
            if (dtmBatDauDenNgay.Text.Length == dtmBatDauDenNgay.CustomFormat.Length)
            {
                BatDauDenNgay = DateTime.Parse(dtmBatDauDenNgay.Text).AddDays(1);
            }
            DataTable dt;

            //if (!isView)
            //{
            //    dt = cls.SelectDS_CongViec(TuNgay, DenNgay, BatDauTuNgay, BatDauDenNgay, id_NhanSu);
            //}
            //else
            //{
            //    dt = cls.SelectDS_CongViec_Trong1Ngay(ngayLuaChon, id_NhanSu);
            //}


            //dt = cls.SelectDS_CongViec(TuNgay, DenNgay, BatDauTuNgay, BatDauDenNgay, id_NhanSu);

            dt = cls.SelectDS_CongViec_Trong1Ngay(ds_ID_CongViec);
            fg.ClearRows();
            fg.SetDataSource(dt);

            for (int i = fg.Rows.Fixed; i < fg.Rows.Count; i++)
            {
                int ID_TrangThai = Convert.ToInt32(fg[i, "ID_TrangThai"]);

                if (ID_TrangThai == (int)TrangThai.ChuaThucHien)
                {
                    fg.Rows[i].Style = csChuaThucHien;
                }
                else if (ID_TrangThai == (int)TrangThai.DangThucHien)
                {
                    fg.Rows[i].Style = csDangThucHien;
                }
                else if (ID_TrangThai == (int)TrangThai.Huy)
                {
                    fg.Rows[i].Style = csHuy;
                }
                else if (ID_TrangThai == (int)TrangThai.DaXong)
                {
                    fg.Rows[i].Style = csDaXong;
                }

                if ((fg[i, "DS_Ten_NhanVien"] ?? "").ToString() != "")
                {
                    string[] tenNhanVien = fg[i, "DS_Ten_NhanVien"].ToString().Split(',');
                    fg[i, "DS_Ten_NhanVien"] = "";
                    foreach (var name in tenNhanVien)
                    {
                        fg[i, "DS_Ten_NhanVien"] += name.Trim() + "\n";
                    }
                }

                if ((fg[i, "ThoiGian_DuKien"] ?? "").ToString() != "")
                {
                    fg[i, "ThoiGian_DuKien"] += " " + fg[i, "Ten_ThoiGian"];
                }
            }
            fg.Row = -1;
            fg.AutoSizeRows();
            fg.EndUpdate();
            fg.Tag = 1;
        }
예제 #12
0
        public void LoadData()
        {
            fg.Tag = 0;
            //m_iSelectedRow = fg.Row;
            //for (int i = 2; i < cmbTuyChonHienThi.Properties.Items.Count; i++)
            //{
            //    if (cmbTuyChonHienThi.Properties.Items[i].CheckState == CheckState.Checked)
            //    {
            //        string nameCol = cmbTuyChonHienThi.Properties.Items[i].Value.ToString();
            //        fg.Cols[nameCol].Visible = true;
            //    }
            //    else
            //    {
            //        string nameCol = cmbTuyChonHienThi.Properties.Items[i].Value.ToString();
            //        fg.Cols[nameCol].Visible = false;
            //    }
            //}
            m_irowDateOfTimeline = 30;
            fg.Cols.RemoveRange(m_irowDateOfTimeline, (fg.Cols.Count - m_irowDateOfTimeline));
            m_dtD1 = (DateTime)dteNgayBatDau.Value;
            m_dtD2 = (DateTime)dteNgayKetThuc.Value;
            if (m_dtD1.Date > m_dtD2.Date)
            {
                BaseMessages.ShowWarningMessage("Ngày bắt đầu phải nhỏ hơn ngày kết thúc");
                return;
            }
            if ((int)(m_dtD2.Date - m_dtD1.Date).TotalDays > 365)
            {
                BaseMessages.ShowWarningMessage("Khoảng thời gian quá dài");
                return;
            }
            //
            clsCongViec cls = new clsCongViec();

            dt = new DataTable();
            dt = cls.CongViec_SelecAll_List_IDNhanVien_IDTrangThai(m_dtD1, m_dtD2, m_sds_NhanVien, m_sds_TrangThai,
                                                                   m_sds_LoaiCV, m_sds_MucDoUuTien, m_sds_NguoiYeuCau);

            //
            fg.BeginUpdate();
            fg.ClearRows();
            clsDM_LoaiCV cls_LoaiCV = new clsDM_LoaiCV();
            //DataTable dt_LoaiCV = cls_LoaiCV.SelectAll(); // Lay tat ca loai cong viec
            DataTable dt_LoaiCV = new DataTable();

            cls_LoaiCV.ID_DonVi = GlobalVariables.uID_DonVi;        // lay don vi cua nguoi dang nhap
            dt_LoaiCV           = cls_LoaiCV.SelectAll_TheoDonVi(); // Lay tat ca loai cong viec theo don vi
            foreach (DataRow dr in dt_LoaiCV.Rows)
            {
                Row fgRow = fg.Rows.Add();

                fgRow["ID_CongViec"] = "-" + dr["ID_LoaiCV"];
                fgRow["TieuDe"]      = dr["Ten_LoaiCV"];
                fgRow["ID_LoaiCV"]   = dr["ID_LoaiCV"];
                if (dr["ID_LoaiCV_Cha"].ToString() == "")
                {
                }
                else
                {
                    fgRow["ID_CongViec_Goc"] = "-" + dr["ID_LoaiCV_Cha"];
                }
            }
            decimal giaTri = 0;

            foreach (DataRow dr in dt.Rows)
            {
                DateTime d = m_dtD1;
                if (fg.Rows.Count > 1)
                {
                    if (fg.GetDataDisplay(fg.Rows.Count - 1, "Ma_CongViec").ToString() ==
                        dr["Ma_CongViec"].ToString() &&
                        fg.GetDataDisplay(fg.Rows.Count - 1, "Ma_CongViec").ToString() != "")
                    {
                        decimal giaTri_Sau = 0;
                        decimal.TryParse(dr["GiaTri"].ToString(), out giaTri_Sau);
                        giaTri = giaTri + giaTri_Sau;
                        fg.Rows[fg.Rows.Count - 1]["GiaTri"] = giaTri;
                        continue;
                    }
                    decimal.TryParse(dr["GiaTri"].ToString(), out giaTri);
                }

                Row fgRow = fg.Rows.Add();
                //


                fgRow["ID_CongViec"] = dr["ID_CongViec"];
                fgRow["Ma_CongViec"] = dr["Ma_CongViec"];
                fgRow["GiaTri"]      = giaTri;

                fgRow["DS_ID_NhanVien"]  = dr["DS_ID_NhanVien"];
                fgRow["ID_MucDoUuTien"]  = dr["ID_MucDoUuTien"];
                fgRow["TieuDe"]          = dr["TieuDe"];
                fgRow["MoTa"]            = dr["MoTa"];
                fgRow["Ngay_YeuCau"]     = dr["Ngay_YeuCau"];
                fgRow["Ngay_DenHan"]     = dr["Ngay_DenHan"];
                fgRow["ThoiGian_DuKien"] = dr["ThoiGian_DuKien"];
                fgRow["ID_ThoiGian"]     = dr["ID_ThoiGian"];
                if (dr["PhanTramHoanThanh"].ToString() == "")
                {
                    dr["PhanTramHoanThanh"] = 0;
                }
                fgRow["PhanTramHoanThanh"] = dr["PhanTramHoanThanh"] + " %";
                fgRow["Ngay_BatDau"]       = dr["Ngay_BatDau"];
                fgRow["ID_TrangThai"]      = dr["ID_TrangThai"];
                fgRow["ID_LoaiCV"]         = dr["ID_LoaiCV"];
                fgRow["ID_CongViec_Goc"]   = dr["ID_CongViec_Goc"];
                fgRow["Ngay_HoanThanh"]    = dr["Ngay_HoanThanh"];
                fgRow["Ngay_Lap"]          = dr["Ngay_Lap"];
                fgRow["ID_NguoiLap"]       = dr["ID_NguoiLap"];
                fgRow["Ngay_SuaCuoi"]      = dr["Ngay_SuaCuoi"];
                fgRow["ID_NguoiSuaCuoi"]   = dr["ID_NguoiSuaCuoi"];
                fgRow["ID_NguoiYeuCau"]    = dr["ID_NguoiYeuCau"];
                fgRow["Ten_TrangThai"]     = dr["Ten_TrangThai"];
                fgRow["Ten_MucDo"]         = dr["Ten_MucDo"];
                fgRow["ID_NGuoiYeuCau"]    = dr["ID_NGuoiYeuCau"];

                fgRow["Ten_KetQua_DonVi"] = dr["Ten_KetQua_DonVi"];
                fgRow["SoLuong_KeHoach"]  = dr["SoLuong_KeHoach"];
                clsNhanSu clsNS = new clsNhanSu();
                //dt_NhanSu = cls.GetNhanSu(SystemModule.HeThong.GlobalVariables.uID_DonVi, 0);
                dt_NhanSu = clsNS.SelectW_ID_NguoiQuanLy(DataAccess.QLCV.Global.GlobalVariables.GetID_NhanSu(), GlobalVariables.uID_DonVi);
                for (int j = 0; j < dt_NhanSu.Rows.Count; ++j)
                {
                    if (dr["ID_NGuoiYeuCau"].ToString() == dt_NhanSu.Rows[j]["ID_NhanSu"].ToString().Trim())
                    {
                        fgRow["NGuoi_YeuCau"] = dt_NhanSu.Rows[j]["HoTen"].ToString().Trim();
                    }
                }
                //Lấy tên nhân viên
                string   ds_Ten_NhanVien = "";
                string[] ds_ID_NhanVien  = dr["DS_ID_NhanVien"].ToString().Split(',');
                if (ds_ID_NhanVien.Length > 1)
                {
                    for (int i = 0; i < ds_ID_NhanVien.Length; ++i)
                    {
                        foreach (DataRow drNV in dt_NhanSu.Select("ID_NhanSu = " + ds_ID_NhanVien[i].Trim()))
                        {
                            ds_Ten_NhanVien += drNV["HoTen"].ToString().Trim() + ", ";
                            break;
                        }
                    }
                }


                if (ds_Ten_NhanVien.Length > 2)
                {
                    fgRow["ds_NhanVien"] = ds_Ten_NhanVien.Remove(ds_Ten_NhanVien.Length - 2, 1); // Xoa  2 ky tu o cuoi
                }
            }
            //insert loaiCV

            //Add ID_COngViec_Goc bằng ID_LoaiCV
            for (int r = fg.Rows.Fixed; r < fg.Rows.Count; ++r)
            {
                if (fg.GetDataDisplay(r, "ID_CongViec_Goc").ToString() == "" &&
                    int.Parse(fg.GetDataDisplay(r, "ID_CongViec").ToString()) > 0)
                {
                    if (fg.GetDataDisplay(r, "ID_LoaiCV").ToString() == "")
                    {
                    }
                    else
                    {
                        fg.Rows[r]["ID_CongViec_Goc"] = "-" + fg.Rows[r]["ID_LoaiCV"];
                    }
                }
            }
            //Add Node công việc con
            for (int r = fg.Rows.Fixed; r < fg.Rows.Count; ++r)
            {
                fg.Rows[r].Visible = false;
                fg.Rows.InsertNode(r + 1, 0);
                GetDataTwoRow(r + 1, r);
                ++r;
            }
            for (int r = fg.Rows.Fixed; r < fg.Rows.Count; r++)
            {
                if (!fg.Rows[r].Visible)
                {
                    fg.Rows.Remove(r);
                    r = r - 1;
                }
            }
            for (int r = fg.Rows.Fixed; r < fg.Rows.Count; ++r)
            {
                if (fg.Rows[r].Node.Level == 0 && fg.Rows[r].Visible && IsNode0(r))
                {
                    r = TimCongViecGoc(r, 1);
                }
            }
            int level = 1;

            while (TonTaiCongViecGoc(level))
            {
                for (int r1 = fg.Rows.Fixed; r1 < fg.Rows.Count; ++r1)
                {
                    if (fg.Rows[r1].Node.Level == level && fg.Rows[r1].Visible)
                    {
                        r1 = TimCongViecGoc(r1, level + 1);
                    }
                }
                ++level;
            }
            fg.Tree.Column = 1;
            //ShowTimeline(m_dtDtNow);
            DoiMauTrangThai(fg);
            ChiHienThiCoCongViec(chkHienThiKhiCoCV.Checked);
            HienThi_ChuaDoc_Comment();
            SetSTT();
            fg.Row = -1;
            fg.EndUpdate();
            fg.Tag = 1;
            //fg.Row = m_iSelectedRow;
        }
예제 #13
0
        private void LoadfgBaoCaoNgay()
        {
            var fg = fgBaoCaoNgay;

            fg.Tag = 0;
            fg.BeginUpdate();
            var cls = new clsCongViec();

            m_dtD3 = (DateTime)dtmTuNgay.Value;
            m_dtD4 = (DateTime)dtmDenNgay.Value;
            if (m_dtD3.Date > m_dtD4.Date)
            {
                BaseMessages.ShowWarningMessage("Ngày bắt đầu phải nhỏ hơn ngày kết thúc");
                return;
            }
            if ((int)(m_dtD4.Date - m_dtD3.Date).TotalDays > 365)
            {
                BaseMessages.ShowWarningMessage("Khoảng thời gian quá dài");
                return;
            }

            DataTable dt;

            dt = cls.SelectAll_CongViec_BaoCaoNgay(m_dtD3, m_dtD4, m_sds_NhanVien);
            fg.ClearRows();
            fg.SetDataSource(dt);
            var ID_NhanVien = m_sds_NhanVien.ToString().Split(',');

            for (var i = fg.Rows.Fixed; i < fg.Rows.Count; i++)
            {
                var ID_TrangThai = Convert.ToInt32(fg[i, "ID_TrangThai"]);

                if (ID_TrangThai == (int)TrangThai.ChuaThucHien)
                {
                    fg.Rows[i].Style = csChuaThucHien;
                }
                else if (ID_TrangThai == (int)TrangThai.DangThucHien)
                {
                    fg.Rows[i].Style = csDangThucHien;
                }
                else if (ID_TrangThai == (int)TrangThai.Huy)
                {
                    fg.Rows[i].Style = csHuy;
                }
                else if (ID_TrangThai == (int)TrangThai.DaXong)
                {
                    fg.Rows[i].Style = csDaXong;
                }
                if ((fg[i, "DS_Ten_NhanVien"] ?? "").ToString() != "")
                {
                    string[] tenNhanVien = fg[i, "DS_Ten_NhanVien"].ToString().Split(',');
                    fg[i, "DS_Ten_NhanVien"] = "";
                    foreach (var name in tenNhanVien)
                    {
                        fg[i, "DS_Ten_NhanVien"] += name.Trim() + "\n";
                    }
                }

                if ((fg[i, "ThoiGian_DuKien"] ?? "").ToString() != "")
                {
                    fg[i, "ThoiGian_DuKien"] += " " + fg[i, "Ten_ThoiGian"];
                }
            }
            LoadTree(fgBaoCaoNgay);
            int iSTT = 0;

            for (int i = fg.Rows.Fixed; i < fg.Rows.Count; i++)
            {
                if (fg.Rows[i].IsNode)
                {
                    iSTT = 0;
                }
                else
                {
                    fg[i, "STT"] = iSTT;
                }
                iSTT++;
            }

            fg.Row = -1;
            fg.AutoSizeRows();
            LocTheoNhanVien(fgBaoCaoNgay);
            fg.Cols.Frozen = fg.Cols["TieuDe"].Index + 1;
            fg.EndUpdate();
            fg.Tag = 1;
        }