/// <summary> /// Констурктор формы редактирования графика технического обслуживания. /// </summary> /// <param name="BaseCard">Родительская карточка.</param> /// <param name="Type">Тип проверки (техническое обслуживание)</param> /// <param name="DateOfEvent">Дата проведения.</param> /// <param name="NextDateOfEvent">Дата следующего проведения.</param> /// <param name="EmployeeId">Идентификатор сотрудника.</param> /// <param name="Document">Идентификатор карточки документа.</param> /// <param name="Interval">Периодичность проверки.</param> /// <param name="Unit">Единица измерения времени.</param> public MaintenanceForm(MyBaseCard BaseCard, RefEquipmentCard.Enums.TypeOfInspection Type, DateTime DateOfEvent, DateTime NextDateOfEvent, Guid EmployeeId, Guid Document, Decimal Interval, RefEquipmentCard.Enums.Units Unit) { InitializeComponent(); this.Location = ComputeLocation(this.Size); this.BaseCard = BaseCard; Context = BaseCard.Context; this.Type = Type; this.Interval = Interval; this.Unit = Unit; this.Text = "Данные о проведении технического обслуживания:"; if (DateOfEvent != DateTime.MinValue) { this.DateOfEvent.EditValue = DateOfEvent; } if (NextDateOfEvent != DateTime.MinValue) { this.NextDateOfEvent.EditValue = NextDateOfEvent; } RespEmployee = EmployeeId == Guid.Empty ? null : Context.GetObject <DocsVision.BackOffice.ObjectModel.StaffEmployee>(EmployeeId); DocumentCard = Document == Guid.Empty ? null : Context.GetObject <DocsVision.BackOffice.ObjectModel.Document>(Document); this.Employee.Text = RespEmployee == null ? "" : RespEmployee.DisplayName; this.Position.Text = RespEmployee == null || RespEmployee.Position == null ? "" : RespEmployee.Position.Name; this.Document.Text = DocumentCard == null ? "" : DocumentCard.MainInfo.FileName; }
/// <summary> /// Обработчик кнопки "Добавить документ". /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Add_Click(object sender, EventArgs e) { OpenFileDialog MyFileDialog = new OpenFileDialog(); MyFileDialog.Multiselect = false; switch (Type) { case RefEquipmentCard.Enums.TypeOfInspection.Verification: MyFileDialog.Title = "Выберите файл, подтверждающий проведение поверки..."; break; case RefEquipmentCard.Enums.TypeOfInspection.Calibration: MyFileDialog.Title = "Выберите файл, подтверждающий проведение калибровки..."; break; case RefEquipmentCard.Enums.TypeOfInspection.Attestation: MyFileDialog.Title = "Выберите файл, подтверждающий проведение аттестации..."; break; } if (MyFileDialog.ShowDialog() == DialogResult.OK) { if (DocumentCard != null) { Context.DeleteObject(DocumentCard); } DocumentCard = Context.GetObject <DocsVision.BackOffice.ObjectModel.Document>(SKB.Base.MyHelper.CreateDocument(Context, MyFileDialog.FileName)); this.Document.Text = DocumentCard.Description; } }
/// <summary> /// Обработчик кнопки "Удалить документ". /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Remove_Click(object sender, EventArgs e) { if (DocumentCard != null) { Context.DeleteObject(DocumentCard); DocumentCard = null; this.Document.Text = ""; } }
private void printApproval_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DocsVision.BackOffice.ObjectModel.Document FileCardDocument = this.Context.GetObject <DocsVision.BackOffice.ObjectModel.Document>(new System.Guid("224D391A-B7ED-E511-9414-E4115BB03AEA")); //MessageBox.Show("Документ нашли"); string oTempPath = System.IO.Path.GetTempPath(); string oFilePath = oTempPath + FileCardDocument.MainInfo.MainFileName; this.DocumentService.DownloadMainFile(FileCardDocument, oFilePath); //MessageBox.Show("Документ скачали"); //получаем объект word Microsoft.Office.Interop.Word.ApplicationClass oApplication = new Microsoft.Office.Interop.Word.ApplicationClass(); oApplication.Visible = true; object oMissing = Type.Missing; object oFileNameMain = (object)oFilePath; object oFalse = false; object oTrue = true; try{ Microsoft.Office.Interop.Word.Document oMainFileWord = oApplication.Documents.Open(ref oFileNameMain, ref oMissing, ref oFalse, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref oTrue, ref oMissing); //MessageBox.Show("Открыли"); object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; string temp = String.Empty; BaseCardSectionRow row = (BaseCardSectionRow)Document.GetSection(new System.Guid("30EB9B87-822B-4753-9A50-A1825DCA1B74"))[0]; Guid tempId = new System.Guid(row["ResponsDepartment"].ToString()); StaffUnit unit = Context.GetObject <StaffUnit>(tempId); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Организация."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = unit.Name; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Состояние."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = Document.SystemInfo.State.LocalizedName; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); BaseCardSectionRow docPartnerRow = (BaseCardSectionRow)Document.GetSection(new System.Guid("6E976D72-3EA7-4708-A2C2-2A1499141301"))[0]; CardData PartnerDictionary = Session.CardManager.GetCardData(new System.Guid("65FF9382-17DC-4E9F-8E93-84D6D3D8FE8C")); //Справочник контрагентов RowData PartnerRow = PartnerDictionary.Sections[new System.Guid("C78ABDED-DB1C-4217-AE0D-51A400546923")].GetRow(new System.Guid(docPartnerRow["SenderOrg"].ToString())); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Контрагент."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = PartnerRow.GetString("Name"); oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); if (row["StatusId"] != null) { CardData dictionaryCard = this.Session.CardManager.GetCardData(new System.Guid("4538149D-1FC7-4D41-A104-890342C6B4F8")); SectionData dictionarySection = dictionaryCard.Sections[new System.Guid("A1DCE6C1-DB96-4666-B418-5A075CDB02C9")]; RowData rdItemTypesNuno = dictionarySection.GetRow(new System.Guid("10630364-D63F-4249-83E8-5DE95B2CD385")); //виды бухгалтерских документов foreach (RowData rdItems in rdItemTypesNuno.ChildSections[new System.Guid("1B1A44FB-1FB1-4876-83AA-95AD38907E24")].Rows) { if (row["StatusId"].ToString().ToUpper() == "{" + rdItems.Id.ToString().ToUpper() + "}") { temp = rdItems.GetString("Name"); } } } else { temp = String.Empty; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Вид документа."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); BaseCardSectionRow contractRow = (BaseCardSectionRow)Document.GetSection(new System.Guid("3997861D-4FF5-496A-B8A2-D16617DE91D7"))[0]; temp = contractRow["AddAgreementNumber"] + ""; oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Номер."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Дата."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = Convert.ToDateTime(contractRow["AttachmentDate"] + "").ToShortDateString(); oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Сумма."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = contractRow["MySum"] + ""; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); string partially; if (row["WasSent"] + "" == "False") { temp = contractRow["MySum"] + ""; partially = "Нет"; } else { temp = row["Sum"] + ""; partially = "Да"; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&К оплате."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); if (row["SLA"] != null) { //MessageBox.Show("якобы условия оплаты заполнены"+row["SLA"]); CardData dictionaryCard = this.Session.CardManager.GetCardData(new System.Guid("4538149D-1FC7-4D41-A104-890342C6B4F8")); SectionData dictionarySection = dictionaryCard.Sections[new System.Guid("A1DCE6C1-DB96-4666-B418-5A075CDB02C9")]; RowData rdItemTypesNuno = dictionarySection.GetRow(new System.Guid("305EF160-0CBA-41B7-8187-E6383A471849")); //условия оплаты foreach (RowData rdItems in rdItemTypesNuno.ChildSections[new System.Guid("1B1A44FB-1FB1-4876-83AA-95AD38907E24")].Rows) { if (row["StatusId"].ToString().ToUpper() == "{" + rdItems.Id.ToString().ToUpper() + "}") { temp = rdItems.GetString("Name"); } } } else { //MessageBox.Show("условия оплаты не заполнены"); temp = String.Empty; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Условия."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Валюта."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = contractRow["ContractCurrency"] + ""; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Частично."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = partially; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); Microsoft.Office.Interop.Word.Table newTable; Microsoft.Office.Interop.Word.Range myRange = oMainFileWord.Range(); //object startOfRange = myRange.Text.IndexOf("&Таблица."); //object endOfRange = myRange.Text.IndexOf("&Таблица.") + 9; //Microsoft.Office.Interop.Word.Range wrdRng = oMainFileWord.Range(ref startOfRange, ref endOfRange); object oEndOfDoc = "\\endofdoc"; Microsoft.Office.Interop.Word.Range wrdRng = oMainFileWord.Bookmarks.get_Item(ref oEndOfDoc).Range; //MessageBox.Show("range is determined"); newTable = oMainFileWord.Tables.Add(wrdRng, 1, 4, ref oMissing, ref oMissing); //MessageBox.Show("table added"); newTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle; newTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle; newTable.AllowAutoFit = true; newTable.Cell(1, 1).Range.Text = "Сотрудник"; newTable.Cell(1, 1).Range.Font.Bold = 1; newTable.Cell(1, 2).Range.Text = "Дата согласования"; newTable.Cell(1, 2).Range.Bold = 1; newTable.Cell(1, 3).Range.Text = "Результат"; newTable.Cell(1, 3).Range.Bold = 1; newTable.Cell(1, 4).Range.Text = "Комментарий"; newTable.Cell(1, 4).Range.Bold = 1; int i = 1; while (i <= Document.GetSection(new System.Guid("AACEF937-EAD2-4AFD-A64C-DC42D7846B80")).Count) { newTable.Rows.Add(); BaseCardSectionRow commentTable = (BaseCardSectionRow)Document.GetSection(new System.Guid("AACEF937-EAD2-4AFD-A64C-DC42D7846B80"))[i - 1]; string employeeId = commentTable["Employee"].ToString(); StaffEmployee employee = Context.GetObject <StaffEmployee>(new System.Guid(employeeId)); newTable.Cell(i + 1, 1).Range.Text = employee.DisplayString; newTable.Cell(i + 1, 1).Range.Bold = 0; newTable.Cell(i + 1, 2).Range.Text = Convert.ToDateTime(commentTable["Date"] + "").ToShortDateString(); if (commentTable["Result"] + "" == "0") { temp = "Согласовано"; } else { temp = "Не согласовано"; } newTable.Cell(i + 1, 2).Range.Bold = 0; newTable.Cell(i + 1, 3).Range.Text = temp; newTable.Cell(i + 1, 3).Range.Bold = 0; newTable.Cell(i + 1, 4).Range.Text = commentTable["Comment"] + ""; newTable.Cell(i + 1, 4).Range.Bold = 0; i++; } } catch (Exception ex) { UIService.ShowError(ex, "Во время создания файла произошла ошибка"); } /*удал¤ем временный файл * if (System.IO.File.Exists(oFilePath)) * System.IO.File.Delete(oFilePath);*/ //закрываем ворд //oApplication.Quit(ref oMissing, ref oMissing, ref oMissing); }