/// <summary> /// Bind biểu đồ trình độ /// </summary> private void BieuDoTrinhDo(int height, int size) { string departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); // DataTable table = DataHandler.GetInstance().ExecuteDataTable("BieuDo_ThongKeNhanSuTheoTrinhDo", "@MaDonVi", "@UserID", "@MenuID", maDV, userID, menuID); var table = SQLHelper.ExecuteTable(SQLChartAdapter.GetStore_EducationChart(departments)); int total = 0, max = 0, k = 0; foreach (DataRow item in table.Rows) { if (int.Parse(item["Count"].ToString()) > 0) { total += int.Parse(item["Count"].ToString()); max++; } } object[] data = new object[max]; for (int i = 0; i < table.Rows.Count; i++) { if (int.Parse(table.Rows[i]["Count"].ToString()) > 0) { var percentage = (float.Parse(table.Rows[i]["Count"].ToString()) / (float)total) * 100; if (displayPercentage) { data[k++] = new object[] { table.Rows[i]["EducationName"].ToString() + " (" + table.Rows[i]["Count"] + " người, chiếm " + percentage + " %)", percentage }; } else { data[k++] = new object[] { table.Rows[i]["EducationName"].ToString() + " (" + table.Rows[i]["Count"] + ")", percentage }; } } } BindData(data, @"Thống kê theo trình độ", height, size, true); }
/// <summary> /// Chức vụ đảng /// </summary> /// <param name="height"></param> /// <param name="size"></param> private void CpvPosition(int height, int size) { string departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var table = SQLHelper.ExecuteTable(SQLChartAdapter.GetStore_CPVPositionChart(departments)); int total = 0, tong = 0, k = 0; foreach (DataRow item in table.Rows) { if (int.Parse(item["Count"].ToString()) > 0) { total += int.Parse(item["Count"].ToString()); tong++; } } object[] data = new object[tong]; for (int i = 0; i < table.Rows.Count; i++) { var percentage = (float.Parse(table.Rows[i]["Count"].ToString()) / (float)total) * 100; if (displayPercentage) { data[k++] = new object[] { table.Rows[i]["CPVPositionName"].ToString() + " (" + table.Rows[i]["Count"] + " người, chiếm " + percentage + " %)", percentage }; } else { data[k++] = new object[] { table.Rows[i]["CPVPositionName"].ToString() + " (" + table.Rows[i]["Count"] + ")", percentage }; } } BindData(data, @"Thống kê theo chức vụ Đảng", height, size, true); }
/// <summary> /// /// </summary> /// <param name="male"></param> /// <param name="female"></param> /// <param name="departments"></param> private void GetGenderNumber(out int male, out int female, string departments) { var maleCount = SQLHelper.ExecuteScalar(SQLChartAdapter.GetStore_CountMaleRecordChart(departments)); male = (int)maleCount; var femaleCount = SQLHelper.ExecuteScalar(SQLChartAdapter.GetStore_CountFemaleRecordChart(departments)); female = (int)femaleCount; }
/// <summary> /// Tình trạng hôn nhân /// </summary> /// <param name="height"></param> /// <param name="size"></param> private void MarriageStatus(int height, int size) { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); //DataTable table = DataHandler.GetInstance().ExecuteDataTable("BieuDo_ThongKeNhanSuTheoTinhTrangHonNhan", "@MaDonVi", "@UserID", "@MenuID", maDV, userID, menuID); var table = SQLHelper.ExecuteTable(SQLChartAdapter.GetStore_MarriageStatusChart(departments)); int total = 0, tong = 0, k = 0; foreach (DataRow item in table.Rows) { if (int.Parse(item["Count"].ToString()) <= 0) { continue; } total += int.Parse(item["Count"].ToString()); tong++; } var data = new object[tong]; for (var i = 0; i < table.Rows.Count; i++) { if (int.Parse(table.Rows[i]["Count"].ToString()) <= 0) { continue; } var percentage = float.Parse(table.Rows[i]["Count"].ToString()) / total * 100; if (displayPercentage) { data[k++] = new object[] { table.Rows[i]["MaritalStatusName"] + " (" + table.Rows[i]["Count"] + " người, chiếm " + percentage + " %)", percentage }; } else { data[k++] = new object[] { table.Rows[i]["MaritalStatusName"] + " (" + table.Rows[i]["Count"] + ")", percentage }; } } BindData(data, @"Thống kê theo tình trạng hôn nhân", height, size, true); }
/// <summary> /// Thâm niên /// </summary> /// <param name="height"></param> /// <param name="size"></param> private void Seniority(int height, int size) { string departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var table = SQLHelper.ExecuteTable(SQLChartAdapter.GetStore_Seniority(departments)); int[] mocTn = { 0, 5, 10 }; int count = mocTn.Length; object[] tenMoc = new object[count + 1]; int[] data = new int[count + 1]; // create MocTN[] tenMoc[0] = "Dưới " + mocTn[1] + " năm"; data[0] = 0; for (int i = 1; i < count - 1; i++) { tenMoc[i] = mocTn[i] + "-" + mocTn[i + 1] + " năm"; data[i] = 0; } tenMoc[count - 1] = "Trên " + mocTn[count - 1] + " năm"; data[count - 1] = 0; tenMoc[count] = "Không xác định"; data[count] = 0; int total = 0; foreach (DataRow item in table.Rows) { int index = 0; for (int i = 0; i < count; i++) { if (int.Parse(item["years"].ToString()) == -1) { index = count; break; } if (int.Parse(item["years"].ToString()) >= mocTn[count - 1]) { index = count - 1; break; } if (int.Parse(item["years"].ToString()) < mocTn[i] && int.Parse(item["years"].ToString()) >= 0) { if (i > 0) { index = i - 1; } break; } } total++; data[index] = data[index] + 1; } int sz = 0; for (int j = 0; j < data.Count(); j++) { if (data[j] > 0) { sz++; } } object[] obj = new object[sz]; int k = 0; for (int i = 0; i <= count; i++) { if (data[i] > 0) { obj[k++] = new object[] { tenMoc[i] + " (" + data[i] + ")", ((float)data[i]) / ((float)total) * 100 } } ; } BindData(obj, @"Thống kê theo thâm niên", height, size, true); }
/// <summary> /// Độ tuổi /// </summary> /// <param name="height"></param> private void AgeChart(int height) { try { hcFrutas.Title = new Title(@"Thống kê theo độ tuổi"); string departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var table = SQLHelper.ExecuteTable(SQLChartAdapter.GetStore_AgeChart(departments)); int[] ageMileStone = { 0, 18, 30, 40, 50 }; int count = ageMileStone.Length; var nameMileStone = new object[count]; var ageData = new object[count]; //Create milestone nameMileStone[0] = "0 - 18"; ageData[0] = 0; for (var i = 1; i < count - 1; i++) { nameMileStone[i] = ageMileStone[i] + 1 + " - " + ageMileStone[i + 1]; ageData[i] = 0; } nameMileStone[count - 1] = "Trên " + ageMileStone[count - 1]; ageData[count - 1] = 0; foreach (DataRow item in table.Rows) { var index = 0; for (var i = 0; i < count; i++) { if (int.Parse(item["Age"].ToString()) >= ageMileStone[count - 1]) { index = count - 1; break; } if (int.Parse(item["Age"].ToString()) <= ageMileStone[i] && int.Parse(item["Age"].ToString()) >= 0) { if (i > 0) { index = i - 1; } break; } } ageData[index] = (int)ageData[index] + 1; } // ve bieu do hcFrutas.YAxis.Add(new YAxisItem { title = new Title(@"Số lượng") }); hcFrutas.XAxis.Add(new XAxisItem { categories = nameMileStone }); //dados var series = new Collection <Serie> { new Serie { name = "Cán bộ", data = ageData } }; hcFrutas.PlotOptions = new PlotOptionsColumn() { borderColor = "#dedede", borderRadius = 4, dataLabels = new DataLabels() { enabled = true, }, }; hcFrutas.Height = height; hcFrutas.Legend = new Legend() { layout = Highcharts.Core.Layout.horizontal, align = Align.left, verticalAlign = Highcharts.Core.VerticalAlign.top, x = 70, y = -5, floating = true, shadow = true, backgroundColor = "#FFF", enabled = false, }; hcFrutas.Exporting.enabled = true; hcFrutas.DataSource = series; hcFrutas.DataBind(); } catch { throw; } }
/// <summary> /// /// </summary> /// <param name="year"></param> /// <param name="height"></param> private void BieuDoBienDongNhanSuNew(int year, int height) { try { hcFrutas.Title = new Title("Biểu đồ biến động nhân sự {0}".FormatWith(year)); var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); int maxMonth = 12; if (DateTime.Now.Year == year) { maxMonth = DateTime.Now.Month; } // ve bieu do hcFrutas.YAxis.Add(new YAxisItem { title = new Title(@"Số lượng") }); hcFrutas.XAxis.Add(new XAxisItem { categories = new object[] { "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12" } }); //dados var series = new Collection <Serie>(); var statusParams = cat_WorkStatusServices.GetAll(); foreach (var item in statusParams) { var humanResources = SQLHelper.ExecuteTable( SQLChartAdapter.GetStore_HumanResourceChart(departments, year, item.Id)); var temp = GetHumanResourceData(humanResources, item.Id, year, maxMonth, out var temName); series.Add(new Serie { name = temName, data = temp }); } hcFrutas.PlotOptions = new PlotOptionsLine { dataLabels = new DataLabels { enabled = true } }; hcFrutas.Height = height; hcFrutas.Legend = new Legend { layout = Layout.vertical, align = Align.left, verticalAlign = VerticalAlign.top, x = 0, y = -5, floating = true, shadow = true, backgroundColor = "#FFF", enabled = true }; hcFrutas.Exporting.enabled = true; hcFrutas.DataSource = series; hcFrutas.DataBind(); } catch (Exception) { // ignored } }