} // тип занятости 0 - совместитель 1 - штатный public DataTable DataProcessing(DBManagement DBM, DataTable temp) { DataTable staffTable = new DataTable(); DataTable positions = DBM.GetPositions(); char[] delimer = { ' ', '\n' }; // Разделитель Boolean match = false; Employment = 1; staffTable.Columns.Add("ФИО"); for (int i = 0; i < temp.Rows.Count; i++) { String[] substring = temp.Rows[i][0].ToString().Split(delimer); // блок анализа документа на штатность сотрудников в списке if (!match) { foreach (var str in substring) { if (str.Equals("совместителей")) { match = true; Employment = 0; } else if (str.Equals("ФИО")) { match = true; } } continue; } if (substring[0].Equals("ФИО") || substring[0].Equals("Кафедра") || substring[0].Equals("Табель") || substring[0].Equals("кафедра") || substring[0].Equals("Руководитель") || substring[0].Equals("Ответственный") || substring[0].Equals("") || substring[0].Equals("Приложение")) { continue; } else { for (int j = 0; j < positions.Rows.Count; j++) { if (positions.Rows[j][1].ToString() == temp.Rows[i][1].ToString()) { staffTable.Rows.Add(temp.Rows[i][0]); break; } } } } return(staffTable); }
public void DrawGraphMember(DBManagement DBM, ZedGraphControl ZGC, String initials, Int32 employment, Int32 limit) { Int32 member_id = DBM.GetMemberId(initials); DataTable memberData = DBM.GetMemeberStatistics(member_id, employment, limit); Double[] premiumValue = new Double[memberData.Rows.Count]; String[] date = new String[memberData.Rows.Count]; if (memberData.Rows.Count != 0) { if (!memberData.Rows[0][1].Equals(DBNull.Value)) { for (int i = 0; i < memberData.Rows.Count; i++) { premiumValue[i] = Convert.ToDouble(memberData.Rows[i][1]); date[i] = DBM.GetDate(Convert.ToInt32(memberData.Rows[i][0])).ToString("dd.MM.yyyy"); } Array.Reverse(date); Array.Reverse(premiumValue); } } GraphPane pane = ZGC.GraphPane; pane.CurveList.Clear(); pane.GraphItemList.Clear(); BarItem curve = pane.AddBar("", null, premiumValue, Color.CornflowerBlue); curve.Bar.Fill.Type = FillType.Solid; curve.Bar.Border.IsVisible = false; for (int i = 0; i < curve.Points.Count; i++) { TextItem ti = new TextItem(curve.Points[i].Y.ToString(), (float)curve.Points[i].X, (float)curve.Points[i].Y / 2); ti.FontSpec.Border.IsVisible = false; ti.FontSpec.Fill.Type = FillType.None; ti.FontSpec.Size = 16; ti.FontSpec.IsBold = true; pane.GraphItemList.Add(ti); } pane.MinBarGap = 0.0f; pane.XAxis.Type = AxisType.Text; pane.XAxis.TextLabels = date; pane.Title = "Статистика премии сотрудника " + initials; ZGC.AxisChange(); ZGC.Invalidate(); }
public MainWindow() { InitializeComponent(); DBM = new DBManagement(); Op = new Settings("settings.fw"); IS = new ImportStaff(); IWT = new ImportWorkTime(); COHF = new CreatingReportFile(); Stat = new Staticstics(); InitTable(); InitDataGridView(); AddInTable(); InitZedGraphControls(); membersDataGridView.SelectionChanged += MembersDataGridView_SelectionChanged; Stat.DrawGraphPremium(DBM, PremiumZedGraphControl, Op.Period); }
} // тип занятости 0 - совместитель 1 - штатный public DataTable CountingWorkTime(DBManagement DBM, DataTable temp) { DataTable positions = DBM.GetPositions(); DataTable e = DBM.GetEmployment(); char[] delimer = { ' ', '\n', ':' }; // Разделитель DataTable staffTable = new DataTable(); staffTable.Columns.Add("ФИО"); staffTable.Columns.Add("Должность"); staffTable.Columns.Add("Ставка"); staffTable.Columns[2].DataType = Type.GetType("System.Double"); staffTable.Columns.Add("Штатность"); staffTable.Columns.Add("Часов работы"); staffTable.Columns[4].DataType = Type.GetType("System.Double"); staffTable.Columns.Add("Выходных дней"); staffTable.Columns[5].DataType = Type.GetType("System.Int32"); staffTable.Columns.Add("Дней в командировке"); staffTable.Columns[6].DataType = Type.GetType("System.Int32"); staffTable.Columns.Add("Дней на больничном"); staffTable.Columns[7].DataType = Type.GetType("System.Int32"); staffTable.Columns.Add("Тар.коэфф"); staffTable.Columns[8].DataType = Type.GetType("System.Double"); Int32 daysOff = 0, sickDays = 0, tripDays = 0; Double workTime = 0, conv = 0; Boolean match = false; Employment = 1; for (int i = 0; i < temp.Rows.Count; i++) { String[] substring = temp.Rows[i][0].ToString().Split(delimer); // блок анализа документа на штатность сотрудников в списке if (!match) { foreach (var str in substring) { if (str.Equals("совместителей")) { match = true; Employment = 0; } else if (str.Equals("ФИО")) { match = true; } } continue; } if (substring[0].Equals("ФИО") || substring[0].Equals("Кафедра") || substring[0].Equals("Табель") || substring[0].Equals("кафедра") || substring[0].Equals("Руководитель") || substring[0].Equals("Ответственный") || substring[0].Equals("") || substring[0].Equals("Приложение")) { continue; } else { for (int j = 0; j < positions.Rows.Count; j++) { if (positions.Rows[j][1].ToString() == temp.Rows[i][1].ToString()) { for (int k = 3; k < temp.Columns.Count; k++) { if (temp.Rows[i][k].ToString().Equals("в") || temp.Rows[i][k].ToString().Equals("В")) { daysOff++; } else if (temp.Rows[i][k].ToString().Equals("к") || temp.Rows[i][k].ToString().Equals("К")) { tripDays++; } else if (temp.Rows[i][k].ToString().Equals("б") || temp.Rows[i][k].ToString().Equals("Б")) { sickDays++; } else if (temp.Rows[i][k].ToString().Contains(",")) { workTime += Convert.ToDouble(temp.Rows[i][k].ToString()); } else if (temp.Rows[i][k].ToString().Contains(":")) { String[] nums = temp.Rows[i][k].ToString().Split(delimer); workTime += Convert.ToDouble(nums[0]); workTime += Convert.ToDouble(nums[1]) / 60.0; } else if (Double.TryParse(temp.Rows[i][k].ToString(), out conv)) { workTime += conv; } } staffTable.Rows.Add(temp.Rows[i][0], temp.Rows[i][1], temp.Rows[i][2], e.Rows[Employment][1], workTime, daysOff, tripDays, sickDays, positions.Rows[j][2]); workTime = 0; daysOff = 0; tripDays = 0; sickDays = 0; } } } } return(staffTable); }
public void DrawGraphPremium(DBManagement DBM, ZedGraphControl ZGC, Int32 limit) { DataTable premiumData = DBM.GetPremiumsStatistics(limit); Double[] budgetValue = new Double[premiumData.Rows.Count]; Double[] paidValue = new Double[premiumData.Rows.Count]; Double[] paragraphValue = new Double[premiumData.Rows.Count]; String[] date = new String[premiumData.Rows.Count]; if (premiumData.Rows.Count != 0) { if (!premiumData.Rows[0][1].Equals(DBNull.Value)) { for (int i = 0; i < premiumData.Rows.Count; i++) { budgetValue[i] = Convert.ToDouble(premiumData.Rows[i][1]); paidValue[i] = Convert.ToDouble(premiumData.Rows[i][2]); paragraphValue[i] = Convert.ToDouble(premiumData.Rows[i][3]); DateTime dt = Convert.ToDateTime(premiumData.Rows[i][4]); date[i] = dt.ToString("dd.MM.yyyy"); } } Array.Reverse(budgetValue); Array.Reverse(paidValue); Array.Reverse(paragraphValue); Array.Reverse(date); GraphPane pane = ZGC.GraphPane; pane.CurveList.Clear(); pane.GraphItemList.Clear(); BarItem budget = pane.AddBar("Бюджет", null, budgetValue, Color.OrangeRed); BarItem paid = pane.AddBar("Платное", null, paidValue, Color.LightBlue); BarItem paragraph = pane.AddBar("§54", null, paragraphValue, Color.LightGreen); budget.Bar.Fill.Type = FillType.Solid; paid.Bar.Fill.Type = FillType.Solid; paragraph.Bar.Fill.Type = FillType.Solid; for (int i = 0; i < budget.Points.Count; i++) { TextItem tiB = new TextItem(budget.Points[i].Y.ToString(), (float)budget.Points[i].X - 0.25f, (float)budget.Points[i].Y / 5); tiB.FontSpec.Border.IsVisible = false; tiB.FontSpec.Fill.Type = FillType.None; tiB.FontSpec.Size = 16; tiB.FontSpec.IsBold = true; tiB.FontSpec.Angle = -90; pane.GraphItemList.Add(tiB); TextItem tiPaid = new TextItem(paid.Points[i].Y.ToString(), (float)paid.Points[i].X, (float)paid.Points[i].Y / 5); tiPaid.FontSpec.Border.IsVisible = false; tiPaid.FontSpec.Fill.Type = FillType.None; tiPaid.FontSpec.Size = 16; tiPaid.FontSpec.IsBold = true; tiPaid.FontSpec.Angle = -90; pane.GraphItemList.Add(tiPaid); TextItem tiPara = new TextItem(paragraph.Points[i].Y.ToString(), (float)paragraph.Points[i].X + 0.25f, (float)paragraph.Points[i].Y / 5); tiPara.FontSpec.Border.IsVisible = false; tiPara.FontSpec.Fill.Type = FillType.None; tiPara.FontSpec.Size = 16; tiPara.FontSpec.IsBold = true; tiPara.FontSpec.Angle = -90; pane.GraphItemList.Add(tiPara); } pane.XAxis.Type = AxisType.Text; pane.XAxis.TextLabels = date; pane.MinBarGap = 0.0f; pane.MinClusterGap = 1.0f; pane.YAxis.Type = AxisType.Log; pane.YAxis.Min = 1.0f; pane.Legend.FontSpec.Size = 14; ZGC.AxisChange(); ZGC.Invalidate(); } }