private void Form_order_Click(object sender, RoutedEventArgs e) { Group group = Helper.OGroups.Where(k => k.groupe.Equals(combobox_groupe.SelectedItem)).ElementAt(0); int enroll = Convert.ToInt32(group.enroll_year); // Год поступления int end = Convert.ToInt32(group.end_year); // Год окончания int course = DateTime.Today.Year - enroll; int month = DateTime.Today.Month - 9; if (month >= 0) { course++; } Classes.Direction direction = Helper.ODirections.Where(k => k.name.Equals(group.direction)).ElementAt(0); string code = direction.code; this.dir = $"{Directory.GetCurrentDirectory()}\\documents\\orders\\Приказ {group.groupe} от {first_date.Text}\\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } CreateOrder(course, code, direction.name); }
private void CreateOrder(int course, string code, string direct) { string file = "order.docx"; // создаём документ DocX document = DocX.Create(dir + file); document.SetDefaultFont(new Font("Times New Roman"), fontSize: 12); // Устанавливаем стандартный для документа шрифт и размер шрифта document.MarginLeft = 42.5f; document.MarginTop = 34.1f; document.MarginRight = 34.1f; document.MarginBottom = 34.1f; document.InsertParagraph($"Проект приказа\n\n").Bold().Alignment = Alignment.center; document.InsertParagraph($"\tВ соответствии с календарным графиком учебного процесса допустить " + $"и направить для прохождения {form_pract.SelectedItem.ToString().ToLower()} практики {combobox_type.SelectedItem} " + $"следующих студентов {course} курса, очной формы, направление подготовки {code} «{direct}», " + $"профиль «Прикладная информатика в государственном и муниципальном управлении», факультета " + $"«Информационные системы в управлении» с {first_date.Text}г. по {second_date.Text}.\n"); document.InsertParagraph($"\tСпособ проведения практики: выездная и стационарная."); document.InsertParagraph($"\tСтационарная практика (без оплаты)\n").Bold(); document.InsertParagraph($"\tОбучающихся за счет бюджетных ассигнований федерального бюджета"); IEnumerable <Fill_data> studentsF = fill_data.Where(k => k.payable.Equals("Бюджет")); IEnumerable <Fill_data> studentsB = fill_data.Where(k => k.payable.Equals("Внебюджет")); Xceed.Document.NET.Table table = document.AddTable(studentsF.Count() + 1, 4); Xceed.Document.NET.Table tabpe_pay = document.AddTable(studentsB.Count() + 1, 4); table.Alignment = Alignment.center; table.AutoFit = AutoFit.Contents; tabpe_pay.Alignment = Alignment.center; tabpe_pay.AutoFit = AutoFit.Contents; table.Rows[0].Cells[0].Paragraphs[0].Append("ФИО студента").Alignment = Alignment.center; table.Rows[0].Cells[1].Paragraphs[0].Append("Группа").Alignment = Alignment.center; table.Rows[0].Cells[2].Paragraphs[0].Append("Место прохождения практики").Alignment = Alignment.center; table.Rows[0].Cells[3].Paragraphs[0].Append("Руководитель практики").Alignment = Alignment.center; tabpe_pay.Rows[0].Cells[0].Paragraphs[0].Append("ФИО студента").Alignment = Alignment.center; tabpe_pay.Rows[0].Cells[1].Paragraphs[0].Append("Группа").Alignment = Alignment.center; tabpe_pay.Rows[0].Cells[2].Paragraphs[0].Append("Место прохождения практики").Alignment = Alignment.center; tabpe_pay.Rows[0].Cells[3].Paragraphs[0].Append("Руководитель практики").Alignment = Alignment.center; for (int i = 0; i < studentsF.Count(); i++) { table.Rows[i + 1].Cells[0].Paragraphs[0].Append(studentsF.ElementAt(i).fio); table.Rows[i + 1].Cells[1].Paragraphs[0].Append(combobox_groupe.SelectedItem.ToString()); table.Rows[i + 1].Cells[2].Paragraphs[0].Append(studentsF.ElementAt(i).place); table.Rows[i + 1].Cells[3].Paragraphs[0].Append(combobox_otvetsven.SelectedItem.ToString()); } for (int i = 0; i < studentsB.Count(); i++) { tabpe_pay.Rows[i + 1].Cells[0].Paragraphs[0].Append(studentsB.ElementAt(i).fio); tabpe_pay.Rows[i + 1].Cells[1].Paragraphs[0].Append(combobox_groupe.SelectedItem.ToString()); tabpe_pay.Rows[i + 1].Cells[2].Paragraphs[0].Append(studentsB.ElementAt(i).place); tabpe_pay.Rows[i + 1].Cells[3].Paragraphs[0].Append(combobox_otvetsven.SelectedItem.ToString()); } document.InsertParagraph().InsertTableAfterSelf(table); if (studentsB.Count() > 0) { document.InsertParagraph($"\tОбучающихся на платной основе"); document.InsertParagraph().InsertTableAfterSelf(tabpe_pay); } document.InsertParagraph($"\tОтветственный по {form_pract.SelectedItem.ToString().ToLower()} практики по кафедре в период с {first_date.Text} г. по {second_date.Text} г. - {combobox_otvetsven.Text} ст. преподаватель кафедры ПИЭ."); Classes.Direction directions = Helper.ODirections.Where(k => k.name.Equals(direct)).ElementAt(0); Cathedra cathedra = Helper.OCathedras.Where(k => k.cathedra.Equals(directions.id_cathedra)).ElementAt(0); document.InsertParagraph($@" Проректор по УР ________«____» ________ {first_date.SelectedDate.Value.Year}г. С.В. Мельник Главный бухгалтер ________«____» ________ {first_date.SelectedDate.Value.Year} г. Г.И. Вилисова Начальник ПЭО ________«____» ________ {first_date.SelectedDate.Value.Year}г. Т.В. Грачева Начальник ООП и СТВ ________«____» ________{first_date.SelectedDate.Value.Year}г. Ю.С. Сачук Декан факультета «{directions.id_cathedra}» ________«____» ________ {first_date.SelectedDate.Value.Year}г. {cathedra.name.Remove(1)}.{cathedra.patronymic.Remove(1)}. {cathedra.surname} Ответственный за практику и содействие трудоустройству на факультете ________«____» __________ {first_date.SelectedDate.Value.Year}г. {cathedra.name.Remove(1)}.{cathedra.patronymic.Remove(1)}.{cathedra.surname} "); document.Save(); MessageBox.Show("Документ успешно сформирован!", "Документ", MessageBoxButton.OK, MessageBoxImage.Information); }
public Contracts_Edit(Classes.Contracts sel_items) { InitializeComponent(); this.sel_items = sel_items; contract_num.Text = sel_items.id; contract_org.Text = sel_items.contract_org; contract_empl.Text = sel_items.contract_empl; type_pract.Text = sel_items.type_pract; form_pract.ItemsSource = Helper.Practise_Forms; form_pract.SelectedItem = sel_items.form_pract; date.SelectedDate = Convert.ToDateTime(sel_items.date); dir = $"{Directory.GetCurrentDirectory()}\\documents\\contracts\\Договор №{contract_num.Text}\\"; List <List <string> > elements = SQLiteAdapter.GetValue("contracts INNER JOIN attach ON attach.id_contract = contracts.id " + "INNER JOIN students ON students.id = attach.id_student " + "INNER JOIN groups ON groups.id = students.groupe " + "INNER JOIN directions ON directions.id = groups.direction " + $"WHERE contracts.id = '{sel_items.id}'", "groups.groupe, students.surname, students.name, students.patronymic"); // TreeView fill this.TreeView = new ObservableCollection <Parent>(); for (int i = 0; i < elements.Count; i++) { if (elements[i].Count > 2) // Если присутствуют отдельные строки ФИО { elements[i][3] = $"{elements[i][1]} {elements[i][2]} {elements[i][3]}"; // Объединяем ФИО в одну строку elements[i].RemoveAt(1); // Удаляем Имя elements[i].RemoveAt(1); // Удаляем Отчестово, тоже id из за смещения на единицу после предыдущего удаления } } for (int j = 0; j < elements.Count; j++) { Group groups = Helper.OGroups.Where(k => k.groupe.Equals(elements[j][0])).Single(); Classes.Direction directions = Helper.ODirections.Where(k => k.name.Equals(groups.direction)).Single(); if (!this.selected_dir.Contains(directions.code)) { this.selected_dir.Add(directions.code); } for (int i = 0; i < elements.Count; i++) { if (elements[j][0].Equals(elements[i][0])) // Проверка на одинаковое имя { foreach (string tmp in elements[i]) { if (!elements[j].Contains(tmp)) { elements[j].Add(tmp); // Копируем все данные из совпадающей группы в одну } } if (i > j) { elements.RemoveAt(i); // Удаляем скопированную группу i--; // Корректировка смещения из за удаленного элемента } } } } List <List <string> > elements_new = new List <List <string> >(); for (int i = 0; i < elements.Count; i++) { elements_new.Add(new List <string>()); for (int j = 0; j < elements[i].Count; j++) { elements_new[i].Add(elements[i][j].ToString()); } } for (int i = 0; i < elements_new.Count; i++) { List <Student> student = Helper.OStudents.Where(k => k.groupe.Equals(elements_new[i][0])).ToList(); foreach (Student tmp in student) { if (!elements_new[i].Contains($"{tmp.surname} {tmp.name} {tmp.patronymic}")) { elements_new[i].Add($"{tmp.surname} {tmp.name} {tmp.patronymic}"); } } } foreach (List <string> element in elements_new) { List <Child> Member = new List <Child>(); for (int i = 1; i < element.Count; i++) // Начинаем с 1, чтобы не добавлять группы { if (!Member.Exists(k => k.Name.Equals(element[i]))) { Member.Add(new Child() { Name = element[i] }); } } if (Member.Count != 0) { this.TreeView.Add(new Parent() { Name = element[0], // Название группы Members = Member }); } } foreach (Parent parent in this.TreeView) { foreach (Child child in parent.Members) { child.SetValue(ItemHelper.ParentProperty, parent); // Отмечаем элементы полученые из БД foreach (List <string> tmp in elements) { if (tmp.Contains(child.Name)) { ItemHelper.SetIsChecked(child, true); } } } } }
private bool CreateContract_Attch2() { try { string file = $"Приложение 2.docx"; SQLiteAdapter.DeleteRowById("attach", $"[id_contract]='{sel_items.id}'"); // Удаляем существующие данные // создаём документ DocX document = DocX.Create(dir + file); document.SetDefaultFont(new Font("Times New Roman"), fontSize: 12); // Устанавливаем стандартный для документа шрифт и размер шрифта document.MarginLeft = 42.5f; document.MarginTop = 34.1f; document.MarginRight = 34.1f; document.MarginBottom = 34.1f; document.PageLayout.Orientation = Xceed.Document.NET.Orientation.Landscape; document.InsertParagraph("Приложение 2").Alignment = Alignment.right; document.InsertParagraph($"к договору № {contract_num.Text} от {date.Text} г.").Alignment = Alignment.right; document.InsertParagraph("Список студентов ФГБОУ ВО «СибАДИ», направляемых на производственные объекты").Alignment = Alignment.center; document.InsertParagraph($"\t\t{contract_org.Text}\t\t\t").UnderlineStyle(UnderlineStyle.singleLine).Alignment = Alignment.center; document.InsertParagraph("наименование предприятия, учреждения, организации").Script(Script.superscript).FontSize(12).Alignment = Alignment.center; document.InsertParagraph("для прохождения").Alignment = Alignment.center; Paragraph paragraph1 = document.InsertParagraph($"\t\t{form_pract.SelectedItem.ToString().Trim()}, {type_pract.Text}\t\t\t").UnderlineStyle(UnderlineStyle.singleLine); paragraph1.Append($"в {date.SelectedDate.Value.Year} г").Alignment = Alignment.center; document.InsertParagraph("вид и тип практики").Script(Script.superscript).FontSize(12).Alignment = Alignment.center; int _all_el = 0; foreach (List <string> tmp in selected_student) { _all_el += tmp.Count; } // создаём таблицу с N строками и 3 столбцами Table table = document.AddTable(_all_el + 2, 9); // располагаем таблицу по центру table.Alignment = Alignment.center; table.AutoFit = AutoFit.Contents; #region Стандартное заполнение table.Rows[0].Cells[0].Paragraphs[0].Append("№ п/п").Alignment = Alignment.center; table.Rows[0].Cells[1].Paragraphs[0].Append("Название факультета, кафедры, заявивших студентов на практику ").Alignment = Alignment.center; table.Rows[0].Cells[2].Paragraphs[0].Append("Направление/специальность").Alignment = Alignment.center; table.Rows[0].Cells[3].Paragraphs[0].Append("Сроки практики").Alignment = Alignment.center; table.Rows[0].Cells[4].Paragraphs[0].Append("Курс").Alignment = Alignment.center; table.Rows[0].Cells[5].Paragraphs[0].Append("Группа").Alignment = Alignment.center; table.Rows[0].Cells[6].Paragraphs[0].Append("Ф.И.О. студента").Alignment = Alignment.center; table.Rows[0].Cells[7].Paragraphs[0].Append("Ф.И.О. руководителя практики от кафедры").Alignment = Alignment.center; table.Rows[0].Cells[8].Paragraphs[0].Append("Контактные телефоны кафедры по вопросам практики ").Alignment = Alignment.center; table.Rows[1].Cells[0].Paragraphs[0].Append("1").Alignment = Alignment.center; table.Rows[1].Cells[1].Paragraphs[0].Append("2").Alignment = Alignment.center; table.Rows[1].Cells[2].Paragraphs[0].Append("3").Alignment = Alignment.center; table.Rows[1].Cells[3].Paragraphs[0].Append("4").Alignment = Alignment.center; table.Rows[1].Cells[4].Paragraphs[0].Append("5").Alignment = Alignment.center; table.Rows[1].Cells[5].Paragraphs[0].Append("6").Alignment = Alignment.center; table.Rows[1].Cells[6].Paragraphs[0].Append("7").Alignment = Alignment.center; table.Rows[1].Cells[7].Paragraphs[0].Append("8").Alignment = Alignment.center; table.Rows[1].Cells[8].Paragraphs[0].Append("9").Alignment = Alignment.center; #endregion int row = 2; for (int i = 0; i < selected_student.Count; i++) { foreach (string tmp_st in selected_student[i]) { table.Rows[row].Cells[0].Paragraphs[0].Append((i + 1).ToString()).Alignment = Alignment.center; Group group = Helper.OGroups.Where(k => k.groupe.Equals(selected_group[i])).ElementAt(0); Classes.Direction direction = Helper.ODirections.Where(k => k.name.Equals(group.direction)).ElementAt(0); Cathedra cathedra = Helper.OCathedras.Where(k => k.cathedra.Equals(direction.id_cathedra)).ElementAt(0); #region Вычисляем курс int enroll = Convert.ToInt32(group.enroll_year); // Год поступления int end = Convert.ToInt32(group.end_year); // Год окончания int course = DateTime.Today.Year - enroll; int month = DateTime.Today.Month - 9; if (month >= 0) { course++; } #endregion table.Rows[row].Cells[1].Paragraphs[0].Append(cathedra.cathedra).Alignment = Alignment.center; // Кафедра table.Rows[row].Cells[2].Paragraphs[0].Append(direction.code + " " + direction.name).Alignment = Alignment.center; // Направление table.Rows[row].Cells[3].Paragraphs[0].Append(" - ").Alignment = Alignment.center; // Сроки практики table.Rows[row].Cells[4].Paragraphs[0].Append(course.ToString()).Alignment = Alignment.center; // Курс table.Rows[row].Cells[5].Paragraphs[0].Append(group.groupe).Alignment = Alignment.center; // Группа table.Rows[row].Cells[6].Paragraphs[0].Append(tmp_st).Alignment = Alignment.center; // Ф.И.О. студента table.Rows[row].Cells[7].Paragraphs[0].Append(cathedra.surname + " " + cathedra.name + " " + cathedra.patronymic).Alignment = Alignment.center; // Ф.И.О. руководителя от кафедры table.Rows[row].Cells[8].Paragraphs[0].Append(cathedra.phone).Alignment = Alignment.center; // Телефон кафедры row++; // Добавляем студента в БД Attach // Разбиваем ФИО студента на состовляющие var fio = tmp_st.Split(); Student st_tmp = Helper.OStudents.Where(k => k.surname.Equals(fio[0]) && k.name.Equals(fio[1]) && k.patronymic.Equals(fio[2])).ElementAt(0); SQLiteAdapter.SetValue("attach", contract_num.Text, st_tmp.id); // и записываем новые } } document.InsertParagraph().InsertTableAfterSelf(table); document.InsertParagraph(); document.InsertParagraph("Согласовано:"); document.InsertParagraph("Заведующий выпускающей кафедрой"); document.InsertParagraph("«___________________________________» ______________ /______________________/"); document.InsertParagraph(" подпись расшифровка подписи").Script(Script.superscript).FontSize(10); document.InsertParagraph("Декан факультета / Директор института"); document.InsertParagraph("«___________________________________» ______________ /______________________/"); document.InsertParagraph(" подпись расшифровка подписи").Script(Script.superscript).FontSize(10); document.InsertParagraph("Начальник отдела организации практики"); document.InsertParagraph("и содействия трудоустройству выпускников ______________ / Ю.С.Сачук /"); document.InsertParagraph(" подпись расшифровка подписи").Script(Script.superscript).FontSize(10); // сохраняем документ document.Save(); } catch (Exception e) { MessageBox.Show($"Error: {e}", "Error", MessageBoxButton.OK); return(false); } return(true); }
private bool CreateContract_Attch1() { try { string file = $"Приложение 1.docx"; // создаём документ DocX document = DocX.Create(dir + file); document.SetDefaultFont(new Font("Times New Roman"), fontSize: 12); // Устанавливаем стандартный для документа шрифт и размер шрифта document.MarginLeft = 42.5f; document.MarginTop = 34.1f; document.MarginRight = 34.1f; document.MarginBottom = 34.1f; document.InsertParagraph("Приложение 1").Alignment = Alignment.right; document.InsertParagraph($"к договору № {contract_num.Text} от {date.Text} г.").Alignment = Alignment.right; // создаём таблицу с N строками и 3 столбцами Table table = document.AddTable(selected_dir.Count + 2, 3); // располагаем таблицу по центру table.Alignment = Alignment.center; table.AutoFit = AutoFit.Contents; #region Стандартное заполнение table.Rows[0].Cells[0].Paragraphs[0].Append("№ п/п").Alignment = Alignment.center; table.Rows[0].Cells[1].Paragraphs[0].Append("Направление /специальность").Alignment = Alignment.center; table.Rows[0].Cells[2].Paragraphs[0].Append("Курс").Alignment = Alignment.center; table.Rows[1].Cells[0].Paragraphs[0].Append("1").Alignment = Alignment.center; table.Rows[1].Cells[1].Paragraphs[0].Append("2").Alignment = Alignment.center; table.Rows[1].Cells[2].Paragraphs[0].Append("3").Alignment = Alignment.center; #endregion for (int i = 0; i < selected_dir.Count; i++) { Classes.Direction direction = Helper.ODirections.Where(k => k.code.Equals(selected_dir[i])).ElementAt(0); table.Rows[i + 2].Cells[0].Paragraphs[0].Append((i + 1).ToString()).Alignment = Alignment.center; table.Rows[i + 2].Cells[1].Paragraphs[0].Append(direction.code + " " + direction.name).Alignment = Alignment.both; string courses = ""; foreach (string course in selected_course[i]) { courses += Convert.ToInt32(course.Split()[0]) + ", "; } table.Rows[i + 2].Cells[2].Paragraphs[0].Append(courses.TrimEnd(new char[] { ',', ' ' })).Alignment = Alignment.center; } document.InsertParagraph().InsertTableAfterSelf(table); document.InsertParagraph(); document.InsertParagraph("Согласовано:"); document.InsertParagraph(); Paragraph paragraph1 = document.InsertParagraph("ФГБОУ ВО «СибАДИ» "); paragraph1.Append($"__{contract_org.Text}__").UnderlineStyle(UnderlineStyle.singleLine); Paragraph paragraph2 = document.InsertParagraph("Ректор А.П. Жигадло"); paragraph2.Append(" наименование предприятия, учреждения, организации").Script(Script.superscript).FontSize(10); document.InsertParagraph(" ____________________________________"); document.InsertParagraph(" подпись расшифровка подписи").Script(Script.superscript).FontSize(10); document.InsertParagraph("МП МП"); document.InsertParagraph("Имеет право подписи").Italic(); document.InsertParagraph("за руководителя(ректора)").Italic(); document.InsertParagraph("Проректор по учебной работе"); document.InsertParagraph("(доверенность № 61 от 29.10.2018)"); document.InsertParagraph("____________________ С.В. Мельник"); // сохраняем документ document.Save(); } catch (Exception e) { MessageBox.Show($"Error: {e}", "Error", MessageBoxButton.OK); return(false); } return(true); }