protected void LoadZones()
        {
            //try
            //{
            //    dropPhongBan.SelectedValue = IDPhongBan.ToString();
            //    dropPhong.SelectedValue = IDPhongBan.ToString();
            //}
            //catch (Exception)
            //{
            //    dropPhongBan.SelectedIndex = -1;
            //    IDPhongBan = 0;
            //}

            lstCongViec.Items.Clear();
            QuanLyCongViecKTXVaPSController.LoadCongViec(lstCongViec.Items, ConvertUtility.ToInt32(dropTrungTam.SelectedValue), IDPhongBan, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));
            lstCongViec.Items.Insert(0, new ListItem("Root", "0"));

            dropCongViecKPI.Items.Clear();
            foreach (ListItem item in lstCongViec.Items)
            {
                dropCongViecKPI.Items.Add(new ListItem(item.Text, item.Value));
            }
            MiscUtility.SelectItemFromList(lstCongViec, zoneSelected.ToString());

            DataTable dt = QuanLyCongViecKTXVaPSController.GetAllByParentIDNew(zoneSelected, ConvertUtility.ToInt32(dropTrungTam.SelectedValue), IDPhongBan, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

            dgrCongViec.DataSource = dt;
            dgrCongViec.DataBind();
            LoadInfo(zoneSelected);
        }
Пример #2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            dropDotDanhGia.DataSource = DotDanhGiaController.GetAll(1);
            dropDotDanhGia.DataBind();

            if (Session["IDDotDanhGia"] != null)
            {
                dropDotDanhGia.SelectedValue = Session["IDDotDanhGia"].ToString();
            }
            else
            {
                int idDotDanhActive = ConvertUtility.ToInt32(DotDanhGiaController.GetDaultDotDanhGia().Rows[0]["ID"]);
                dropDotDanhGia.SelectedValue = idDotDanhActive.ToString();
            }

            dropTrungTam.DataSource = BoPhanController.GetAll();
            dropTrungTam.DataBind();


            if (Session["IDTrungTam"] != null)
            {
                dropTrungTam.SelectedValue = Session["IDTrungTam"].ToString();
            }
            else
            {
                dropTrungTam.SelectedValue = CurrentUser.IDTrungTam.ToString();
            }

            lstNhanVien.Items.Clear();
            DataTable dtNhanVien = null;

            if (!CurrentUser.IsAdmin && !CurrentUser.IsSuperAdmin)
            {
                dtNhanVien = DotDanhGiaController.QuanLyNhanVienTheoNDG_ByNhanVienQuanLy(CurrentUser.UserID, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue));
            }
            else
            {
                dtNhanVien = DotDanhGiaController.GetAllNhanVien(ConvertUtility.ToInt32(dropTrungTam.SelectedValue), 0, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));
            }

            if (dtNhanVien != null && dtNhanVien.Rows.Count > 0)
            {
                DataTable dtNew = dtNhanVien.Clone();

                foreach (DataRow item in dtNhanVien.Rows)
                {
                    DataRow rowNew = dtNew.NewRow();
                    rowNew["UserID"] = item["UserID"];

                    DataTable dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS_6_11_2014(ConvertUtility.ToInt32(item["UserID"]), 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                    double tyTrongCVDuocGiao = 0;
                    foreach (DataRow row in dtCongViec.Rows)
                    {
                        tyTrongCVDuocGiao += Math.Round(ConvertUtility.ToDouble(row["TyTrong"]), 3);
                    }

                    rowNew["UserName"] = "******" + tyTrongCVDuocGiao + "%) " + item["UserName"].ToString();

                    dtNew.Rows.Add(rowNew);
                }

                lstNhanVien.DataSource = dtNew;
                lstNhanVien.DataBind();

                int idNhanVien = 0;

                if (Session["IDNhanVien"] != null)
                {
                    idNhanVien = ConvertUtility.ToInt32(Session["IDNhanVien"]);
                    try
                    {
                        lstNhanVien.SelectedValue = idNhanVien.ToString();
                    }
                    catch
                    {
                    }
                }

                lstCongViecDuocGiao.Items.Clear();
                QuanLyCongViecKTXVaPSController.LoadCongViec(lstCongViecDuocGiao.Items, ConvertUtility.ToInt32(dropTrungTam.SelectedValue), 0, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                lstCongViec.Items.Clear();
                QuanLyCongViecKTXVaPSController.LoadCongViecChuaDuocGiao(lstCongViec.Items, ConvertUtility.ToInt32(dropTrungTam.SelectedValue), 0, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                if (idNhanVien > 0)
                {
                    DataTable dtCongViecTX = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS_6_11_2014(idNhanVien, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                    DataTable dtCongViecTXNew = dtCongViecTX.Clone();

                    try
                    {
                        lstNhanVien.SelectedValue = idNhanVien.ToString();
                    }
                    catch (Exception)
                    {
                        lstNhanVien.SelectedIndex = -1;
                    }

                    #region Cong Viec Thuong Xuyen

                    foreach (ListItem item in lstCongViecDuocGiao.Items)
                    {
                        if (dtCongViecTX.Select("IDCongViecKPI = " + item.Value).Length > 0)
                        {
                            item.Attributes.Add("style", "color:blue");
                        }
                    }

                    foreach (DataRow item in dtCongViecTX.Rows)
                    {
                        DataRow row = dtCongViecTXNew.NewRow();

                        row["ID"]          = ConvertUtility.ToString(item["ID"]);
                        row["TenCVCha"]    = ConvertUtility.ToString(item["TenCVCha"]);
                        row["Ten"]         = item["Ten"];
                        row["NgayBatDau"]  = ConvertUtility.ToDateTime(item["NgayBatDau"]);  //.ToString("dd/MM/yyyy");
                        row["NgayKetThuc"] = ConvertUtility.ToDateTime(item["NgayKetThuc"]); //.ToString("dd/MM/yyyy");
                        row["KeHoach"]     = item["KeHoach"].ToString().Replace("\n", "<br /><br />").Replace("\r", "<br /><br />");
                        row["TyTrong"]     = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 2).ToString();
                        row["SoGio"]       = Math.Round(ConvertUtility.ToDouble(item["SoGio"]), 2).ToString();
                        dtCongViecTXNew.Rows.Add(row);
                    }
                    dgrNhanVienCVTX.DataSource = dtCongViecTXNew;

                    #endregion

                    #region ty trong cong viec da giao

                    DataTable dtCongViecThuongXuyen = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                    double tyTrongCVThuongXuyen = 0;
                    double SoGioCVThuongXuyen   = 0;
                    foreach (DataRow item in dtCongViecThuongXuyen.Rows)
                    {
                        tyTrongCVThuongXuyen += ConvertUtility.ToDouble(item["TyTrong"]);
                        SoGioCVThuongXuyen   += ConvertUtility.ToDouble(item["SoGio"]);
                    }

                    DataTable dtCongViecKTH = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 2, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                    double tyTrongCVKeHoachThang = 0;
                    double SoGioCVKeHoachThang   = 0;
                    foreach (DataRow item in dtCongViecKTH.Rows)
                    {
                        tyTrongCVKeHoachThang += ConvertUtility.ToDouble(item["TyTrong"]);
                        SoGioCVKeHoachThang   += ConvertUtility.ToDouble(item["SoGio"]);
                    }

                    DataTable dtCongViecPhatSinh = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 3, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue));

                    double tyTrongCVPhatSinh = 0;
                    double SoGioCVPhatSinh   = 0;
                    foreach (DataRow item in dtCongViecPhatSinh.Rows)
                    {
                        tyTrongCVPhatSinh += ConvertUtility.ToDouble(item["TyTrong"]);
                        SoGioCVPhatSinh   += ConvertUtility.ToDouble(item["SoGio"]);
                    }

                    lblTyTrongCVThuongXuyen.Text  = Math.Round(tyTrongCVThuongXuyen, 2).ToString() + "% <br/>" + Math.Round(SoGioCVThuongXuyen, 2).ToString() + "h";
                    lblTyTrongCVKeHoachThang.Text = Math.Round(tyTrongCVKeHoachThang, 2).ToString() + "% <br/>" + Math.Round(SoGioCVKeHoachThang, 2).ToString() + "h";
                    lblTyTrongCVPhatSinh.Text     = Math.Round(tyTrongCVPhatSinh, 2).ToString() + "% <br/>" + Math.Round(SoGioCVPhatSinh, 2).ToString() + "h";
                    lblTongTyTrong.Text           = Math.Round((tyTrongCVThuongXuyen + tyTrongCVKeHoachThang + tyTrongCVPhatSinh), 2) + "% <br />" + Math.Round((SoGioCVThuongXuyen + SoGioCVKeHoachThang + SoGioCVPhatSinh), 2) + "h";

                    #endregion
                }
            }
            dgrNhanVienCVTX.DataBind();
        }