示例#1
0
        public void LoadData()
        {
            //
            var cls = new clsDM_LoaiCV();
            var dt  = new DataTable();

            cls.ID_DonVi = int.Parse(cmbDonVi.EditValue.ToString());
            dt           = cls.SelectAll_TheoDonVi();

            //
            fg.BeginUpdate();
            fg.Cols["ID_LoaiCV_Cha"].DataMap = null;
            fg.ClearRows();
            foreach (DataRow dr in dt.Rows)
            {
                var fgRow = fg.Rows.Add();
                fgRow["ID_LoaiCV"]     = dr["ID_LoaiCV"];
                fgRow["Ten_LoaiCV"]    = dr["Ten_LoaiCV"];
                fgRow["ID_LoaiCV_Cha"] = dr["ID_LoaiCV_Cha"];
                fgRow["TonTai"]        = dr["TonTai"];
                fgRow["SuDung"]        = dr["SuDung"];
                fgRow["ID_DonVi"]      = dr["ID_DonVi"];
                fgRow["STT_LoaiCV"]    = dr["STT_LoaiCV"];
            }
            //add combobox column

            //Add Node 0 công việc con
            for (var 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 (var r = fg.Rows.Fixed; r < fg.Rows.Count; r++)
            {
                if (!fg.Rows[r].Visible)
                {
                    fg.Rows.Remove(r);
                    r = r - 1;
                }
            }
            //
            for (var 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);
                }
            }
            var level = 1;

            while (TonTaiCongViecGoc(level))
            {
                for (var 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;

            ////////
            for (var r = fg.Rows.Fixed; r < fg.Rows.Count; ++r)
            {
                if (!fg.Rows[r].Visible)
                {
                    fg.Rows.Remove(r);
                    --r;
                }
            }
            SetSTT();
            fg.Tree.Show(0);
            var clsCha = new clsDM_LoaiCV();

            dt = clsCha.SelectAll();
            dt.DefaultView.RowFilter = "TonTai = 1";
            dt = dt.DefaultView.ToTable();
            var drow = dt.NewRow();

            drow["ID_LoaiCV"]  = 0;
            drow["Ten_LoaiCV"] = "";
            dt.Rows.Add(drow);
            dt.DefaultView.Sort = "Ten_LoaiCV ASC";
            //add datamap
            var datamap = new ListDictionary();

            for (var i = 0; i <= dt.DefaultView.ToTable().Rows.Count - 1; i++)
            {
                datamap.Add(dt.DefaultView.ToTable().Rows[i][0], dt.DefaultView.ToTable().Rows[i][1]);
            }
            fg.Cols["ID_LoaiCV_Cha"].DataMap = datamap;
            fg.EndUpdate();
        }
示例#2
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;
        }