protected void btnUpdateCongViecVaoKeHoach_Click(object sender, EventArgs e) { #region Cap nhat cong viec vao ke hoach thang cua nhan vien va bo phan DataTable dt = DotDanhGiaController.GetAllNhanVienTemp(ConvertUtility.ToInt32(dropTrungTam.SelectedValue), 0);//ConvertUtility.ToInt32(dropPhongBan.SelectedValue)); int idDotDanhGia = ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue); foreach (DataRow item in dt.Rows) { try { string[] array = item["UserID"].ToString().Split('_'); int idNhanVien = ConvertUtility.ToInt32(array[0]); DataTable dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 3, idDotDanhGia); if (dtCongViec != null && dtCongViec.Rows.Count > 0) { foreach (DataRow row in dtCongViec.Rows) { DanhGiaThang_DGCBCNVDanhGiaTTCVInfo info = new DanhGiaThang_DGCBCNVDanhGiaTTCVInfo(); info.IDDotDanhGia = idDotDanhGia; info.IDNhanVien = idNhanVien; info.TenCongViec = ConvertUtility.ToString(row["Ten"]); int idCongViecKPI = ConvertUtility.ToInt32(row["IDCongViecKPI"]); info.TyTrongCV = ConvertUtility.ToDouble(row["TyTrong"]); info.SoGio = ConvertUtility.ToDouble(row["SoGio"]); info.SoLieuCamKet = ConvertUtility.ToString(row["KeHoach"]); info.YeuCauHoTro = ""; info.Loai = 3; info.IDCongViec = idCongViecKPI; info.IDBoPhanHoTro = 0; info.IDBoPhan = ConvertUtility.ToInt32(row["IDBoPhan"]); info.IDPhongBan = ConvertUtility.ToInt32(row["IDPhongBan"]); info.NgayBatDau = ConvertUtility.ToDateTime(row["NgayBatDau"]); info.NgayKetThuc = ConvertUtility.ToDateTime(row["NgayKetThuc"]); DanhGiaThang_DGCBCNVDanhGiaTTCVController.InsertKeHoachThang(info); } } } catch (Exception) { continue; } } #endregion Session["Nav"] = "3"; }
protected void btnExport_Click(object sender, EventArgs e) { DataTable dtNhanVien = DotDanhGiaController.GetAllNhanVien(ConvertUtility.ToInt32(dropTrungTam.SelectedValue), ConvertUtility.ToInt32(dropPhongBan.SelectedValue)); if (dtNhanVien == null) { return; } object misValue = System.Reflection.Missing.Value; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue); int sheet = 1; foreach (DataRow itemNhanVien in dtNhanVien.Rows) { int idNhanVien = ConvertUtility.ToInt32(itemNhanVien["UserID"]); #region Cong viec thuong xuyen DataTable dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 1, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); DataTable dtCongViecNew = dtCongViec.Clone(); dtCongViecNew.Columns.Add("TyTrongCaNhan", typeof(string)); dtCongViecNew.Columns.Add("TyTrongCaNhanSoVoiPhong", typeof(string)); dtCongViecNew.Columns.Add("GioLamViec", typeof(string)); DataSet ds = DotDanhGiaController.GetPTDG(idNhanVien, 0, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue)); DataTable dtSoNhanVien = ds.Tables[1]; DataTable dtTyTrong = ds.Tables[2]; DataTable dtSoNhanVienPhong = ds.Tables[3]; int tongSoNhanVien = 0; if (dtSoNhanVien != null && dtSoNhanVien.Rows.Count > 0) { tongSoNhanVien = ConvertUtility.ToInt32(dtSoNhanVien.Rows[0]["TongSoNhanVien"]); } int tyTrongCVPhongVoiTrungTam = 0; if (dtTyTrong != null && dtTyTrong.Rows.Count > 0) { tyTrongCVPhongVoiTrungTam = ConvertUtility.ToInt32(dtTyTrong.Rows[0]["TyTrong"]); } if (tyTrongCVPhongVoiTrungTam == 0) { tyTrongCVPhongVoiTrungTam = 100; } int tongSoNhanVienPhong = 0; if (dtSoNhanVienPhong != null && dtSoNhanVienPhong.Rows.Count > 0) { tongSoNhanVienPhong = ConvertUtility.ToInt32(dtSoNhanVienPhong.Rows[0]["TongSoNhanVien"]); } DataRow rowHeader = dtCongViecNew.NewRow(); rowHeader["TenCVCha"] = "-----------------Công việc thường xuyên----------------"; rowHeader["Ten"] = "---------------------------"; rowHeader["TyTrong"] = "0"; rowHeader["KeHoach"] = ""; rowHeader["TyTrongCaNhan"] = "0"; rowHeader["GioLamViec"] = "0"; rowHeader["TyTrongCaNhanSoVoiPhong"] = "0"; dtCongViecNew.Rows.Add(rowHeader); foreach (DataRow item in dtCongViec.Rows) { DataRow row = dtCongViecNew.NewRow(); int idCongViecKPI = ConvertUtility.ToInt32(item["IDCongViecKPI"]); DataTable dtTyTrongKPI = DotDanhGiaController.GetTyTrongCongViec(idCongViecKPI, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue), ConvertUtility.ToInt32(dropPhongBan.SelectedValue), idNhanVien); double tyTrongCVDuocGiao = 0; row["TenCVCha"] = ConvertUtility.ToString(item["TenCVCha"]); row["Ten"] = item["Ten"]; double tyTrongCVDuocGiaoCaNhan = 0; double tyTrongCVDuocGiaoCaNhanSoVoiPhong = 0; if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } else { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } row["KeHoach"] = item["KeHoach"].ToString(); row["TyTrongCaNhan"] = Math.Round(tyTrongCVDuocGiaoCaNhan, 3).ToString().Replace(",", ".");// tyTrongCVDuocGiaoCaNhan.ToString().Replace(",", "."); row["GioLamViec"] = Math.Round(tyTrongCVDuocGiaoCaNhan * 22 * 8 / 100, 3).ToString().Replace(",", "."); //if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) //{ // tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} //else //{ // tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} row["TyTrongCaNhanSoVoiPhong"] = tyTrongCVDuocGiaoCaNhanSoVoiPhong.ToString().Replace(",", "."); dtCongViecNew.Rows.Add(row); } #endregion rowHeader = dtCongViecNew.NewRow(); rowHeader["TenCVCha"] = "-----------------Công việc kế hoạch tháng----------------"; rowHeader["Ten"] = "---------------------------"; rowHeader["TyTrong"] = "0"; rowHeader["KeHoach"] = ""; rowHeader["TyTrongCaNhan"] = "0"; rowHeader["GioLamViec"] = "0"; rowHeader["TyTrongCaNhanSoVoiPhong"] = "0"; dtCongViecNew.Rows.Add(rowHeader); #region Cong viec ke hoach thang dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 2, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); ds = DotDanhGiaController.GetPTDG(idNhanVien, 0, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue)); dtSoNhanVien = ds.Tables[1]; dtTyTrong = ds.Tables[2]; dtSoNhanVienPhong = ds.Tables[3]; tongSoNhanVien = 0; if (dtSoNhanVien != null && dtSoNhanVien.Rows.Count > 0) { tongSoNhanVien = ConvertUtility.ToInt32(dtSoNhanVien.Rows[0]["TongSoNhanVien"]); } tyTrongCVPhongVoiTrungTam = 0; if (dtTyTrong != null && dtTyTrong.Rows.Count > 0) { tyTrongCVPhongVoiTrungTam = ConvertUtility.ToInt32(dtTyTrong.Rows[0]["TyTrong"]); } if (tyTrongCVPhongVoiTrungTam == 0) { tyTrongCVPhongVoiTrungTam = 100; } tongSoNhanVienPhong = 0; if (dtSoNhanVienPhong != null && dtSoNhanVienPhong.Rows.Count > 0) { tongSoNhanVienPhong = ConvertUtility.ToInt32(dtSoNhanVienPhong.Rows[0]["TongSoNhanVien"]); } double tyTrongCVKeHoachThang = 0; foreach (DataRow item in dtCongViec.Rows) { DataRow row = dtCongViecNew.NewRow(); int idCongViecKPI = ConvertUtility.ToInt32(item["IDCongViecKPI"]); DataTable dtTyTrongKPI = DotDanhGiaController.GetTyTrongCongViec(idCongViecKPI, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue), ConvertUtility.ToInt32(dropPhongBan.SelectedValue), idNhanVien); double tyTrongCVDuocGiao = 0; row["TenCVCha"] = ConvertUtility.ToString(item["TenCVCha"]); row["Ten"] = item["Ten"]; //double tyTrongCVDuocGiaoCaNhan = 0; //double tyTrongCVDuocGiaoCaNhanSoVoiPhong = 0; //if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) //{ // tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien; // tyTrongCVKeHoachThang += tyTrongCVDuocGiaoCaNhan; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} //else //{ // tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien; // tyTrongCVKeHoachThang += tyTrongCVDuocGiaoCaNhan; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} //row["KeHoach"] = item["KeHoach"].ToString(); //row["TyTrongCaNhan"] = tyTrongCVDuocGiaoCaNhan.ToString().Replace(",", "."); //row["GioLamViec"] = Math.Round(tyTrongCVDuocGiaoCaNhan * 22 * 8 / 100, 2); double tyTrongCVDuocGiaoCaNhan = 0; double tyTrongCVDuocGiaoCaNhanSoVoiPhong = 0; if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } else { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } row["KeHoach"] = item["KeHoach"].ToString(); row["TyTrongCaNhan"] = Math.Round(tyTrongCVDuocGiaoCaNhan, 3).ToString().Replace(",", ".");// tyTrongCVDuocGiaoCaNhan.ToString().Replace(",", "."); row["GioLamViec"] = Math.Round(tyTrongCVDuocGiaoCaNhan * 22 * 8 / 100, 3).ToString().Replace(",", "."); row["TyTrongCaNhanSoVoiPhong"] = tyTrongCVDuocGiaoCaNhanSoVoiPhong.ToString().Replace(",", "."); dtCongViecNew.Rows.Add(row); } #endregion rowHeader = dtCongViecNew.NewRow(); rowHeader["TenCVCha"] = "-----------------Công việc phát sinh----------------"; rowHeader["Ten"] = "---------------------------"; rowHeader["TyTrong"] = "0"; rowHeader["KeHoach"] = ""; rowHeader["TyTrongCaNhan"] = "0"; rowHeader["GioLamViec"] = "0"; rowHeader["TyTrongCaNhanSoVoiPhong"] = "0"; dtCongViecNew.Rows.Add(rowHeader); #region Cong viec phat sinh dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienKTXVaPS(idNhanVien, 3, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); ds = DotDanhGiaController.GetPTDG(idNhanVien, 0, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue)); dtSoNhanVien = ds.Tables[1]; dtTyTrong = ds.Tables[2]; dtSoNhanVienPhong = ds.Tables[3]; tongSoNhanVien = 0; if (dtSoNhanVien != null && dtSoNhanVien.Rows.Count > 0) { tongSoNhanVien = ConvertUtility.ToInt32(dtSoNhanVien.Rows[0]["TongSoNhanVien"]); } tyTrongCVPhongVoiTrungTam = 0; if (dtTyTrong != null && dtTyTrong.Rows.Count > 0) { tyTrongCVPhongVoiTrungTam = ConvertUtility.ToInt32(dtTyTrong.Rows[0]["TyTrong"]); } if (tyTrongCVPhongVoiTrungTam == 0) { tyTrongCVPhongVoiTrungTam = 100; } tongSoNhanVienPhong = 0; if (dtSoNhanVienPhong != null && dtSoNhanVienPhong.Rows.Count > 0) { tongSoNhanVienPhong = ConvertUtility.ToInt32(dtSoNhanVienPhong.Rows[0]["TongSoNhanVien"]); } tyTrongCVKeHoachThang = 0; foreach (DataRow item in dtCongViec.Rows) { DataRow row = dtCongViecNew.NewRow(); int idCongViecKPI = ConvertUtility.ToInt32(item["IDCongViecKPI"]); DataTable dtTyTrongKPI = DotDanhGiaController.GetTyTrongCongViec(idCongViecKPI, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), ConvertUtility.ToInt32(dropTrungTam.SelectedValue), ConvertUtility.ToInt32(dropPhongBan.SelectedValue), idNhanVien); double tyTrongCVDuocGiao = 0; row["TenCVCha"] = ConvertUtility.ToString(item["TenCVCha"]); row["Ten"] = item["Ten"]; //double tyTrongCVDuocGiaoCaNhan = 0; //double tyTrongCVDuocGiaoCaNhanSoVoiPhong = 0; //if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) //{ // tyTrongCVDuocGiaoCaNhan = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien, 2); // tyTrongCVKeHoachThang += tyTrongCVDuocGiaoCaNhan; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} //else //{ // tyTrongCVDuocGiaoCaNhan = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien, 2); // tyTrongCVKeHoachThang += tyTrongCVDuocGiaoCaNhan; // double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 2); // double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 2); // tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 2); // tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 2); // row["TyTrong"] = tyTrongCVDuocGiao.ToString(); //} //row["KeHoach"] = item["KeHoach"].ToString(); //row["TyTrongCaNhan"] = tyTrongCVDuocGiaoCaNhan.ToString().Replace(",", "."); //row["GioLamViec"] = Math.Round(tyTrongCVDuocGiaoCaNhan * 22 * 8 / 100, 2); double tyTrongCVDuocGiaoCaNhan = 0; double tyTrongCVDuocGiaoCaNhanSoVoiPhong = 0; if (dtTyTrongKPI != null && dtTyTrongKPI.Rows.Count > 0) { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(dtTyTrongKPI.Rows[0]["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } else { tyTrongCVDuocGiaoCaNhan = ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien; double songaylamvieccuaNV = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]) * tongSoNhanVien * 22 / 100, 3); double tongsongaylamvieccuaphong = Math.Round(ConvertUtility.ToDouble(tongSoNhanVien) * 22 * tyTrongCVPhongVoiTrungTam / 100, 3); tyTrongCVDuocGiaoCaNhanSoVoiPhong = Math.Round(songaylamvieccuaNV * 100 / tongsongaylamvieccuaphong, 3); tyTrongCVDuocGiao = Math.Round(ConvertUtility.ToDouble(item["TyTrong"]), 3); row["TyTrong"] = tyTrongCVDuocGiao; } row["KeHoach"] = item["KeHoach"].ToString(); row["TyTrongCaNhan"] = Math.Round(tyTrongCVDuocGiaoCaNhan, 3).ToString().Replace(",", ".");// tyTrongCVDuocGiaoCaNhan.ToString().Replace(",", "."); row["GioLamViec"] = Math.Round(tyTrongCVDuocGiaoCaNhan * 22 * 8 / 100, 3).ToString().Replace(",", "."); row["TyTrongCaNhanSoVoiPhong"] = tyTrongCVDuocGiaoCaNhanSoVoiPhong.ToString().Replace(",", "."); dtCongViecNew.Rows.Add(row); } #endregion XmlDocument doc = BuildXmlDocument(dtCongViecNew); if (!Directory.Exists(Server.MapPath("/UpLoad/Temp/" + itemNhanVien["UserID"].ToString() + "/"))) { Directory.CreateDirectory(Server.MapPath("/UpLoad/Temp/" + itemNhanVien["UserID"].ToString() + "/")); } ////ds.Dispose(); string datetime = DateTime.Now.ToString("yyyyMMddHHmmss"); FileStream downloadFile = File.Create(Server.MapPath("/UpLoad/Temp/" + itemNhanVien["UserID"].ToString() + "/") + "ReportCongViecNhanVien_" + datetime + ".xls"); // transform XslTransform xsl = new XslTransform(); xsl.Load(Server.MapPath("/Template/" + "ReportCongViecNhanVien.xsl")); DateConverter objDateConverter = new DateConverter(); XsltArgumentList args = new XsltArgumentList(); args.AddExtensionObject("urn:ms-kb", objDateConverter); xsl.Transform(doc, args, downloadFile, null); downloadFile.Flush(); downloadFile.Close(); HyperLink hplDownload = new HyperLink(); hplDownload.Text = "Công việc của " + itemNhanVien["Username"].ToString() + ", click vào link để Tải file về"; hplDownload.Visible = true; hplDownload.NavigateUrl = "/UpLoad/Temp/" + itemNhanVien["UserID"].ToString() + "/ReportCongViecNhanVien_" + datetime + ".xls"; Literal lit = new Literal(); lit.Text = "<br />"; pnLink.Controls.Add(hplDownload); pnLink.Controls.Add(lit); CreateExcelDoc excell_app = new CreateExcelDoc(sheet, xlWorkBook, itemNhanVien["UserName"].ToString()); //creates the main header excell_app.createHeaders(1, 1, "Nhóm công việc", "A1", "A1", 0, "YELLOW", true, 40, ""); excell_app.createHeaders(1, 2, "Tên công việc", "B1", "B1", 0, "YELLOW", true, 40, ""); excell_app.createHeaders(1, 3, "Kế hoạch", "C1", "C1", 0, "YELLOW", true, 40, ""); excell_app.createHeaders(1, 4, "Tỷ Trọng so với trung tâm", "D1", "D1", 0, "YELLOW", true, 20, ""); excell_app.createHeaders(1, 5, "Tỷ Trọng so với phòng", "E1", "E1", 0, "YELLOW", true, 20, ""); excell_app.createHeaders(1, 6, "Tỷ Trọng công việc cá nhân trong tháng", "F1", "F1", 0, "YELLOW", true, 20, ""); excell_app.createHeaders(1, 7, "Giờ làm việc", "G1", "G1", 0, "YELLOW", true, 20, ""); int rowIndex = 2; foreach (DataRow item in dtCongViecNew.Rows) { excell_app.addData(rowIndex, 1, item["TenCVCha"].ToString(), "A" + rowIndex.ToString(), "A" + rowIndex.ToString(), ""); excell_app.addData(rowIndex, 2, item["Ten"].ToString(), "B" + rowIndex.ToString(), "B" + rowIndex.ToString(), ""); excell_app.addData(rowIndex, 3, item["KeHoach"].ToString(), "C" + rowIndex.ToString(), "C" + rowIndex.ToString(), ""); excell_app.addData(rowIndex, 4, item["TyTrong"].ToString(), "D" + rowIndex.ToString(), "D" + rowIndex.ToString(), "#,##0"); excell_app.addData(rowIndex, 5, item["TyTrongCaNhanSoVoiPhong"].ToString(), "E" + rowIndex.ToString(), "E" + rowIndex.ToString(), "#,##0"); excell_app.addData(rowIndex, 6, item["TyTrongCaNhan"].ToString(), "F" + rowIndex.ToString(), "F" + rowIndex.ToString(), "#,##0"); excell_app.addData(rowIndex, 7, item["GioLamViec"].ToString(), "G" + rowIndex.ToString(), "G" + rowIndex.ToString(), ""); rowIndex++; } sheet++; } string datetimeTTPhong = DateTime.Now.ToString("yyyyMMddHHmmss"); string fileName = "/UpLoad/Temp/ReportCongViecNhanVien_" + datetimeTTPhong + ".xls"; CreateExcelDoc.SaveExcel(Server.MapPath(fileName), xlWorkBook); HyperLink hplDownloadCVPhongTT = new HyperLink(); hplDownloadCVPhongTT.Text = "Công việc của Trung Tâm hoặc phòng, click vào link để Tải file về"; hplDownloadCVPhongTT.Visible = true; hplDownloadCVPhongTT.NavigateUrl = fileName; pnLink.Controls.Add(hplDownloadCVPhongTT); }
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(); }