private void BuildCongViec() { dropCongViecKPI.Items.Clear(); DataTable dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienTheoNgay(CurrentUser.UserID, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); DataTable dtCongViecClone = dtCongViec.Clone(); foreach (DataRow item in dtCongViec.Rows) { DataTable lstCongViec = new DataTable(); lstCongViec.Columns.Add("IDCongViecKPI", typeof(string)); lstCongViec.Columns.Add("Ten", typeof(string)); lstCongViec.Columns.Add("ParentID", typeof(string)); lstCongViec.Columns.Add("LevelDeep", typeof(string)); GetTenCongViec(lstCongViec, ConvertUtility.ToInt32(item["IDCongViecKPI"]), ConvertUtility.ToString(item["Ten"]), ConvertUtility.ToInt32(item["ParentID"]), ConvertUtility.ToInt32(item["LevelDeep"])); lstCongViec = resort(lstCongViec, "LevelDeep", "DESC"); int i = 0; foreach (DataRow _item in lstCongViec.Rows) { DataRow row = dtCongViecClone.NewRow(); row["IDCongViecKPI"] = item["IDCongViecKPI"]; row["Ten"] = MiscUtility.StringIndent(i) + _item["Ten"]; ListItem itemStyle = new ListItem(); itemStyle.Text = MiscUtility.StringIndent(i) + _item["Ten"]; itemStyle.Value = item["IDCongViecKPI"].ToString(); if (i == lstCongViec.Rows.Count - 1) { itemStyle.Attributes.Add("style", "font-weight:bold; color:blue"); } else { itemStyle.Attributes.Add("style", "font-style: italic;"); } dropCongViecKPI.Items.Add(itemStyle); i++; } } dropCongViecKPI.Items.Add(new ListItem("Công việc khác hoặc công việc phát sinh", "0")); }
protected void Page_Load(object sender, EventArgs e) { DataTable dtCongViec = DotDanhGiaController.GetAllCongViecGiaoChoNhanVienTheoNgay(CurrentUser.UserID, 0); string[] color = new string[10]; color[0] = "#FFB848"; color[1] = "#852B99"; color[2] = "#E02222"; color[3] = "#69A4E0"; color[4] = "#35AA47"; color[5] = "#FFB848"; color[6] = "#852B99"; color[7] = "#E02222"; color[8] = "#69A4E0"; color[9] = "#35AA47"; Event[] arrEvent = new Event[dtCongViec.Rows.Count]; int i = 0; int colorIndex = 0; foreach (DataRow item in dtCongViec.Rows) { Event objEvent = new Event(); objEvent.title = item["CongViecCha"].ToString().TrimStart() + " > " + item["Ten"].ToString().Trim(); objEvent.start = item["NgayBatDau"].ToString(); objEvent.end = item["NgayKetThuc"].ToString(); if (colorIndex > 9) { colorIndex = 0; } objEvent.backgroundColor = color[colorIndex]; objEvent.url = ""; objEvent.allDay = false; arrEvent[i] = objEvent; i++; colorIndex++; } string json = JsonConvert.SerializeObject(arrEvent); Response.Write(json); }