private void Client_EditCriterionCompleted(object sender, ServiceReference1.EditCriterionCompletedEventArgs e) { Loading.stop(); if (e.Result != -1) { id_criterion = e.Result; MessageBox.Show("Критерий изменен"); } else { MessageBox.Show("Не удалось сохранить изменения"); } }
private void Client_EditProjectCompleted(object sender, ServiceReference1.EditProjectCompletedEventArgs e) { Loading.stop(); if (e.Result != -1) { id_project = e.Result; MessageBox.Show("Проект изменен"); } else { MessageBox.Show("Не удалось сохранить изменения"); } }
private void Client_AddExperisePospelovCompleted(object sender, ServiceReference1.AddExperisePospelovCompletedEventArgs e) { Loading.stop(); if (e.Result != -1) { SaveExperise.Content = "Изменить"; MessageBox.Show("Экспертиза добавлена"); } else { MessageBox.Show(e.Error.Message); } }
private void Client_GetListCurrentExpertisesCompleted(object sender, ServiceReference1.GetListCurrentExpertisesCompletedEventArgs e) { cLoading.stop(); if (e.Error == null) { dgCurrentExpertises.ItemsSource = e.Result.ToList(); } else { MessageBox.Show(e.Error.Message); } }
private void Client_GetListCriterionsCompleted(object sender, ServiceReference1.GetListCriterionsCompletedEventArgs e) { Loading.stop(); if (e.Error == null) { dgCriteries.ItemsSource = e.Result.ToList(); //MessageBox.Show("Критерий добавлен"); } else { MessageBox.Show(e.Error.Message); } }
private void Client_GetListExpertisesCriterionsCompleted(object sender, ServiceReference1.GetListExpertisesCriterionsCompletedEventArgs e) { Loading.stop(); if (e.Error == null) { dt = new DataTable(); v.id_expertise = e.Result.id_expertise; v.list_ex_cr = e.Result.list_ex_cr; v.list_pr_ex = e.Result.list_pr_ex; v.list_marks = e.Result.list_marks; //MessageBox.Show(v.list_pr_ex[0].projects.name); dt.Columns.Add("критерии"); for (int i = 0; i < v.list_pr_ex.Count(); i++) { dt.Columns.Add(v.list_pr_ex[i].projects.name); } //dt.Columns.Add("id_pr" + v.list_pr_ex[i].id_project); for (int i = 0; i < v.list_ex_cr.Count(); i++) { DataRow r = dt.NewRow(); r[0] = v.list_ex_cr[i].criterions.name; for (int j = 1; j < v.list_pr_ex.Count() + 1; j++) { var value = v.list_marks.Where(o => o.id_project == v.list_pr_ex[j - 1].id_project && o.id_criterion == v.list_ex_cr[i].id_criterion).FirstOrDefault(); if (value != null) { r[j] = Math.Round(value.value * 100); } else { r[j] = 0; } } dt.Rows.Add(r); } dgExpertises.ItemsSource = dt.DefaultView; } else { MessageBox.Show(e.Error.Message); } }
private void Client_GetIdExpertCompleted(object sender, ServiceReference1.GetIdExpertCompletedEventArgs e) { cLoading.stop(); if (e.Error == null) { if (e.Result.id_expert != -1) { ((MainWindow)Application.Current.MainWindow).id_expert = e.Result.id_expert; ((MainWindow)Application.Current.MainWindow).temp_experts = e.Result; MessageBox.Show("Вы успешно авторизовались"); this.DialogResult = true; } else { MessageBox.Show("Такой учетной записи не существует"); } } else { MessageBox.Show(e.Error.Message); } }
//формируем отчет в ексель по методу поспелова private void Client_GetListExpertiseReportPospelovCompleted(object sender, ServiceReference1.GetListExpertiseReportPospelovCompletedEventArgs e) { if (e.Error == null) { Excel.Application xlApp = new Excel.Application(); if (xlApp == null) { MessageBox.Show("Excel is not properly installed!!"); return; } Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet = null; object misValue = System.Reflection.Missing.Value; xlWorkBook = xlApp.Workbooks.Add(); var experts = e.Result.list_marks_factors.GroupBy(o => o.id_expert).ToList(); for (int i = 0; i < experts.Count(); i++) { int id_expert = experts[i].Key; if (i == 0) { xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Name = "Отчет эксперта " + e.Result.list_marks_factors.Where(o => o.id_expert == id_expert).FirstOrDefault().experts.first_name; //e.Result.list_marks.Where(o => o.id_expert == id_expert).FirstOrDefault().experts.first_name + " " + e.Result.list_marks.Where(o => o.id_expert == id_expert).FirstOrDefault().experts.second_name + " " + e.Result.list_marks.Where(o => o.id_expert == id_expert).FirstOrDefault().experts.patronymic; } else { xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.Add(Type.Missing, xlWorkSheet, Type.Missing, Type.Missing); xlWorkSheet.Name = "Отчет эксперта " + e.Result.list_marks_factors.Where(o => o.id_expert == id_expert).FirstOrDefault().experts.first_name; } var ls_marks_factors_expert = e.Result.list_marks_factors.Where(o => o.id_expert == id_expert).OrderBy(o => o.factors.priority).ToList(); var ls_marks_ribs_expert = e.Result.list_marks_ribs.Where(o => o.id_expert == id_expert).OrderBy(o => o.ribs.factors.priority).ToList(); var list_priority = e.Result.list_marks_factors.Select(o => o.factors.priority).GroupBy(o => o).OrderBy(o => o.Key).ToList(); int number_row = 0; for (int j = 0; j < list_priority.Count() - 1; j++) { int number_col = 1; number_row++; int count_pr_row = ls_marks_factors_expert.Where(o => o.factors.priority == list_priority[j].Key + 1).Count(); for (int t = 0; t < ls_marks_factors_expert.Count(); t++) { //if (ls_marks_factors_expert[t].factors.priority == 0) //{ // number_col++; // xlWorkSheet.Cells[1,number_col] = ls_marks_factors_expert[t].factors.name //} if (ls_marks_factors_expert[t].factors.priority == list_priority[j].Key) { number_col++; xlWorkSheet.Cells[number_row, number_col] = ls_marks_factors_expert[t].factors.name + "\n" + " " + Math.Round(ls_marks_factors_expert[t].value * 100); //number_row++; } else if (ls_marks_factors_expert[t].factors.priority == list_priority[j].Key + 1) { number_row++; //xlWorkSheet.Cells.Style.WrapText = true; xlWorkSheet.Cells[number_row, 1] = ls_marks_factors_expert[t].factors.name + "\n" + Math.Round(ls_marks_factors_expert[t].value * 100); var values = ls_marks_ribs_expert.Where(o => o.ribs.id_factor_in == ls_marks_factors_expert[t].factors.id_factor).ToList(); for (int l = 0; l < values.Count(); l++) { xlWorkSheet.Cells[number_row, 2 + l] = Math.Round(values[l].value * 100); } //var mark_rib = ls_marks_ribs_expert.Where(o=>o.ribs.factors.name == ) } } number_row++; } //Постройка диаграммы int last_priority2 = list_priority.Max(o => o.Key); var ls_res_fact_last2 = e.Result.list_marks_factors.Where(o => o.factors.priority == last_priority2 && o.id_expert == id_expert).OrderBy(o => o.factors.priority).ToList(); List <double> masY2 = new List <double>(); List <string> masX2 = new List <string>(); for (int t = 0; t < ls_res_fact_last2.Count(); t++) { masX2.Add(ls_res_fact_last2[t].factors.name); masY2.Add(Math.Round(ls_res_fact_last2[t].value * 100)); } //строим диаграмму Excel.ChartObjects _xlCharts2 = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing); Excel.ChartObject _myChart2 = (Excel.ChartObject)_xlCharts2.Add(10 * last_priority2, 80, 300, 250); Excel.Chart _chartPage2 = _myChart2.Chart; SeriesCollection _seriesCollection2 = (SeriesCollection)_chartPage2.SeriesCollection(Type.Missing); Series _series2 = _seriesCollection2.NewSeries(); _series2.XValues = masX2.ToArray(); _series2.Values = masY2.ToArray(); _chartPage2.ApplyLayout(2, _chartPage2.ChartType); _chartPage2.Legend.LegendEntries(_chartPage2.Legend.LegendEntries().Count).Delete(); _chartPage2.ChartTitle.Text = "Результат"; } //Строим итоговую таблицу var ls_results_factors = e.Result.list_results_factors.OrderBy(o => o.factors.priority).ToList(); var ls_results_ribs_expert = e.Result.list_results_ribs.OrderBy(o => o.ribs.factors.priority).ToList(); var list_priority_result = e.Result.list_results_factors.Select(o => o.factors.priority).GroupBy(o => o).OrderBy(o => o.Key).ToList(); int number_row2 = 0; xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.Add(Type.Missing, xlWorkSheet, Type.Missing, Type.Missing); xlWorkSheet.Name = "Отчет общий "; for (int j = 0; j < list_priority_result.Count() - 1; j++) { int number_col = 1; number_row2++; int count_pr_row = ls_results_factors.Where(o => o.factors.priority == list_priority_result[j].Key + 1).Count(); for (int t = 0; t < ls_results_factors.Count(); t++) { if (ls_results_factors[t].factors.priority == list_priority_result[j].Key) { number_col++; xlWorkSheet.Cells[number_row2, number_col] = ls_results_factors[t].factors.name + "\n" + Math.Round(ls_results_factors[t].value * 100); //number_row++; } else if (ls_results_factors[t].factors.priority == list_priority_result[j].Key + 1) { number_row2++; //xlWorkSheet.Cells.Style.WrapText = true; xlWorkSheet.Cells[number_row2, 1] = ls_results_factors[t].factors.name + "\n" + Math.Round(ls_results_factors[t].value * 100); var values = ls_results_ribs_expert.Where(o => o.ribs.id_factor_in == ls_results_factors[t].factors.id_factor).ToList(); for (int l = 0; l < values.Count(); l++) { xlWorkSheet.Cells[number_row2, 2 + l] = Math.Round(values[l].value * 100); } //var mark_rib = ls_marks_ribs_expert.Where(o=>o.ribs.factors.name == ) } } number_row2++; } int last_priority = list_priority_result.Max(o => o.Key); var ls_res_fact_last = e.Result.list_results_factors.Where(o => o.factors.priority == last_priority).OrderBy(o => o.factors.priority).ToList(); List <double> masY = new List <double>(); List <string> masX = new List <string>(); for (int i = 0; i < ls_res_fact_last.Count(); i++) { masX.Add(ls_res_fact_last[i].factors.name); masY.Add(Math.Round(ls_res_fact_last[i].value * 100)); } //строим диаграмму Excel.ChartObjects _xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing); Excel.ChartObject _myChart = (Excel.ChartObject)_xlCharts.Add(10 * last_priority, 80, 300, 250); Excel.Chart _chartPage = _myChart.Chart; SeriesCollection _seriesCollection = (SeriesCollection)_chartPage.SeriesCollection(Type.Missing); Series _series = _seriesCollection.NewSeries(); _series.XValues = masX.ToArray(); _series.Values = masY.ToArray(); _chartPage.ApplyLayout(2, _chartPage.ChartType); _chartPage.Legend.LegendEntries(_chartPage.Legend.LegendEntries().Count).Delete(); _chartPage.ChartTitle.Text = "Результат"; //chartPage.ApplyDataLabels(XlDataLabelsType.xlDataLabelsShowValue, false, true, false, false, false, false, true, false, false); //_chartPage.ChartType = Excel.XlChartType.xlPie; //Excel.Range cellRange = (Excel.Range)xlWorkSheet.Cells[1, 1]; //Excel.Range rowRange = cellRange.EntireRow; //rowRange.Insert(Excel.XlInsertShiftDirection.xlShiftDown, false); //xlWorkSheet.Cells[1,1] = "awdwad"; //xlWorkSheet.Columns.AutoFit(); xlWorkSheet.Cells.Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; xlWorkSheet.Cells.Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; SaveFileDialog sFile = new SaveFileDialog(); sFile.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"; try { if (sFile.ShowDialog() == true) { string path = sFile.FileName; xlWorkBook.Application.DisplayAlerts = false; //MessageBox.Show(path); xlWorkBook.SaveAs(path, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); //xlApp.Visible = true; xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); MessageBox.Show("Ексель файл создан. Вы можете найти его по пути " + path); } Marshal.ReleaseComObject(xlWorkSheet); Marshal.ReleaseComObject(xlWorkBook); Marshal.ReleaseComObject(xlApp); GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception ex) { MessageBox.Show("Error", ex.Message); } } else { MessageBox.Show(e.Error.Message); } cLoading.stop(); }
private void Client_GetListExpertisePospelovCompleted(object sender, ServiceReference1.GetListExpertisePospelovCompletedEventArgs e) { Loading.stop(); if (e.Error == null) { v.id_expertise = e.Result.id_expertise; v.list_factors = e.Result.list_factors; v.list_ribs = e.Result.list_ribs; v.list_marks_ribs = e.Result.list_marks_ribs; v.list_marks_factors = e.Result.list_marks_factors; var list_priority = v.list_factors.Select(o => o.priority).GroupBy(o => o).OrderBy(o => o.Key).ToList(); for (int i = 0; i < list_priority.Count() - 1; i++) { DataGrid dataGrid = new DataGrid(); dataGrid.CanUserAddRows = false; dataGrid.IsReadOnly = false; dataGrid.AutoGenerateColumns = true; dataGrid.ColumnWidth = new DataGridLength(1, DataGridLengthUnitType.Star); DataTable dt = new DataTable(); dt.Columns.Add("факторы"); int number_row = 0; for (int j = 0; j < v.list_factors.Count(); j++) { if (v.list_factors[j].priority == list_priority[i].Key) { dt.Columns.Add(v.list_factors[j].name); } else if (v.list_factors[j].priority == list_priority[i].Key + 1) { DataRow r = dt.NewRow(); dt.Rows.Add(r); dt.Rows[number_row][0] = v.list_factors[j].name; for (int k = 1; k < dt.Columns.Count; k++) { int id_fact_col = v.list_factors.Where(o => o.name == dt.Columns[k].ColumnName).FirstOrDefault().id_factor; int id_rib = v.list_ribs.Where(o => o.id_factor_from == id_fact_col && o.id_factor_in == v.list_factors[j].id_factor).FirstOrDefault().id_rib; if (v.list_marks_ribs.Count != 0) { var value_rib = v.list_marks_ribs.Where(o => o.id_rib == id_rib).FirstOrDefault().value; if (value_rib != -1) { dt.Rows[number_row][k] = Math.Round(value_rib * 100); } } } number_row++; } } ls_dt.Add(dt); dataGrid.ItemsSource = dt.DefaultView; splMain.Children.Add(dataGrid); } Button button = new Button(); button.Content = "сохранить"; button.Click += btnSave_click; splMain.Children.Add(button); } else { MessageBox.Show(e.Error.Message); } }