public void FilterData(StringBuilder res = null) { if (DisableBaseFilterData) { return; } if (res == null) { res = GetAutoPropertyFilterString(); } if (res.Length == 0 && vloader.NavigationExpression.Count != 0) { res.Append("&& All"); } if (res.Length > 0) { vloader.FilterExpression = res.ToString().Trim().Substring(2).Trim(); } else { if (vloader.FilterExpression != "All") { vloader.FilterExpression = null; } } Document_Type.Refresh(); NotifyPropertyChanged(x => this.Document_Type); }
public IHttpActionResult PutDocument_Type(int id, Document_Type document_Type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != document_Type.document_type_id) { return(BadRequest()); } db.Entry(document_Type).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Document_TypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(Document_Type d) { var data = db.Document_Type.Where(a => a.document_type_name == d.document_type_name && a.document_type_isDeleted != true && a.document_type_id != d.document_type_id).SingleOrDefault(); if (data != null) { if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.errMsg = d.document_type_name + " " + Servicely.Languages.Language.document_type_already_exist; return(View(d)); } } ViewBag.errMsg = d.document_type_name + " " + Servicely.Languages.Language.document_type_already_exist; return(View(d)); } var old = db.Document_Type.Find(d.document_type_id); old.document_type_name = d.document_type_name; old.document_type_name_arabic = d.document_type_name_arabic; old.document_type_description = d.document_type_description; old.document_type_description_arabic = d.document_type_description_arabic; db.SaveChanges(); return(RedirectToAction("Index")); }
private void IncompOpsIntializeCdoc(DocumentCT cdoc, Document_Type dt, AsycudaDocumentSet ads) { BaseDataModel.Instance.IntCdoc(cdoc, dt, ads); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.AutoUpdate = false; cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Description = "Incomplete Allocations Opening Stock Entries"; cdoc.Document.xcuda_Declarant.Number = cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.Declarant_Reference_Number + "-INCOPS" + "-F" + cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.FileNumber.ToString(); }
public void OPSIntializeCdoc(DocumentCT cdoc, Document_Type dt, AsycudaDocumentSet ads) { BaseDataModel.Instance.IntCdoc(cdoc, dt, ads); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.AutoUpdate = false; cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Description = "Existing Opening Stock Entries"; cdoc.Document.xcuda_Declarant.Number = cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.Declarant_Reference_Number + "-OPS" + "-F" + cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.FileNumber.ToString(); }
public ActionResult DeleteConfirmed(int id) { Document_Type document_Type = db.Document_Type.Find(id); db.Document_Type.Remove(document_Type); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Ex9InitializeCdoc(Document_Type dt, string dfp, DocumentCT cdoc, AsycudaDocumentSet ads) { try { cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.AutoUpdate = false; BaseDataModel.Instance.IntCdoc(cdoc, dt, ads); switch (dfp) { case "Duty Free": var Exp = BaseDataModel.Instance.ExportTemplates.FirstOrDefault(y => y.Description.ToUpper() == "EX9".ToUpper()); if (Exp.Customs_Procedure == null || string.IsNullOrEmpty(Exp.Customs_Procedure)) { throw new ApplicationException("Export Template default Customs Procedures not Configured!"); } cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Description = "Duty Free Entries"; var df = BaseDataModel.Instance.Customs_Procedures.AsEnumerable() .FirstOrDefault( x => x.DisplayName == ((Exp == null || string.IsNullOrEmpty(Exp.Customs_Procedure)) ? "9070-000" : Exp.Customs_Procedure)); AttachCustomProcedure(cdoc, df); break; case "Duty Paid": var Exp1 = BaseDataModel.Instance.ExportTemplates.FirstOrDefault(y => y.Description == "IM4"); if (Exp1.Customs_Procedure == null || string.IsNullOrEmpty(Exp1.Customs_Procedure)) { throw new ApplicationException("Export Template default Customs Procedures not Configured!"); } cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Description = "Duty Paid Entries"; var dp = BaseDataModel.Instance.Customs_Procedures.AsEnumerable() .FirstOrDefault( x => x.DisplayName == ((Exp1 == null || string.IsNullOrEmpty(Exp1.Customs_Procedure)) ? "4070-000" : Exp1.Customs_Procedure)); AttachCustomProcedure(cdoc, dp); break; default: break; } AllocationsModel.Instance.AddDutyFreePaidtoRef(cdoc, dfp, ads); } catch (Exception) { throw; } }
public ActionResult Edit([Bind(Include = "DocumentTypeId,Description,Code")] Document_Type document_Type) { if (ModelState.IsValid) { db.Entry(document_Type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(document_Type)); }
public ActionResult Create([Bind(Include = "DocumentTypeId,Description,Code")] Document_Type document_Type) { if (ModelState.IsValid) { db.Document_Type.Add(document_Type); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(document_Type)); }
public IHttpActionResult GetDocument_Type(int id) { Document_Type document_Type = db.Document_Type.Find(id); if (document_Type == null) { return(NotFound()); } return(Ok(document_Type)); }
public async Task SaveDocument_Type(Document_Type i) { if (i == null) { return; } using (var ctx = new Document_TypeService()) { await ctx.UpdateDocument_Type(i).ConfigureAwait(false); } }
public IHttpActionResult Post(Document_Type applyAt) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _Document_TypeService.Create (applyAt); return Created(applyAt); }
public IHttpActionResult PostDocument_Type(Document_Type document_Type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Document_Type.Add(document_Type); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = document_Type.document_type_id }, document_Type)); }
public IHttpActionResult DeleteDocument_Type(int id) { Document_Type document_Type = db.Document_Type.Find(id); if (document_Type == null) { return(NotFound()); } db.Document_Type.Remove(document_Type); db.SaveChanges(); return(Ok(document_Type)); }
// GET: DocumentType/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Document_Type document_Type = db.Document_Type.Find(id); if (document_Type == null) { return(HttpNotFound()); } return(View(document_Type)); }
public ActionResult Create(Document_Type document_Type) { var data = db.Document_Type.Where(a => a.document_type_name == document_Type.document_type_name && a.document_type_isDeleted != true).SingleOrDefault(); if (data != null) { ViewBag.errMsg = Languages.Language.document_type_already_exist; return(View(document_Type)); } db.Document_Type.Add(document_Type); db.SaveChanges(); return(RedirectToAction("Index")); }
private bool GetDocumentType(out Document_Type dt) { dt = BaseDataModel.Instance.Document_Types.AsEnumerable().FirstOrDefault(x => x.DisplayName == "IM7"); if (dt == null) { throw new ApplicationException(string.Format("Null Document Type for '{0}' Contact your Network Administrator", "IM7")); } var docTypeId = dt.Document_TypeId; dt.DefaultCustoms_Procedure = BaseDataModel.Instance.Customs_Procedures.AsEnumerable() .FirstOrDefault(x => x.DisplayName.Contains("OPS") && x.Document_TypeId == docTypeId); if (dt.DefaultCustoms_Procedure == null) { throw new ApplicationException(string.Format("Null Customs Procedure for '{0}' Contact your Network Administrator", "OPS")); } return(false); }
private Document_Type CreateDocumentType() { Document_Type dt = BaseDataModel.Instance.Document_Types.FirstOrDefault(x => x.DisplayName == "EX9"); if (dt == null) { throw new ApplicationException(string.Format("Null Document Type for '{0}' Contact your Network Administrator", "EX9")); } dt.DefaultCustoms_Procedure = BaseDataModel.Instance.Customs_Procedures .FirstOrDefault(x => x.DisplayName.Contains("EXW") && x.Document_TypeId == dt.Document_TypeId); if (dt.DefaultCustoms_Procedure == null) { throw new ApplicationException(string.Format("Null Customs Procedure for '{0}' Contact your Network Administrator", "EXW")); } return(dt); }
public ActionResult AddFileType(AddFileTypeModel model) { if (ModelState.IsValid) { Document_Type a = new Document_Type { Document_Type_Name = model.Type_Name, Description = model.Description, }; db.Document_Type.Add(a); db.SaveChanges(); //record action global.addAudit("Repository", "Repository: Add File Type", "Create", User.Identity.Name); TempData["classStyle"] = "success"; TempData["Message"] = "File type successfully added"; return(RedirectToAction("ViewFileType")); } else { return(View(model)); } }
public void Document_Create(Document_Type type, Document_Format format, string name, DataTable table) { Configuration_class configuration_Class = new Configuration_class(); configuration_Class.Document_Configuration_Get(); switch (name != "" || name != null) { case true: switch (format) { case Document_Format.Word: word.Application application = new word.Application(); word.Document document = application.Documents.Add(Visible: true); try { word.Range range = document.Range(0, 0); document.Sections.PageSetup.LeftMargin = application.CentimetersToPoints((float)Configuration_class.doc_Left_Merge); document.Sections.PageSetup.RightMargin = application.CentimetersToPoints((float)Configuration_class.doc_Right_Merge); document.Sections.PageSetup.TopMargin = application.CentimetersToPoints((float)Configuration_class.doc_Top_Merge); document.Sections.PageSetup.BottomMargin = application.CentimetersToPoints((float)Configuration_class.doc_Bottom_Merge); range.Text = Configuration_class.Organiztion_Name; range.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; range.ParagraphFormat.SpaceAfter = 1; range.ParagraphFormat.SpaceBefore = 1; range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; range.Font.Name = "Times New Roman"; range.Font.Size = 12; document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph Document_Name = document.Paragraphs.Add(); Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; switch (type) { case Document_Type.Report: Document_Name.Range.Text = "ОТЧЁТ"; break; case Document_Type Statistic: Document_Name.Range.Text = "СТАТИСТИЧЕСКИЙ ОТЧЁТ"; break; } document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph statparg = document.Paragraphs.Add(); word.Table stat_table = document.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 12; stat_table.Range.Font.Name = "Times New Roman"; for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph Footparg = document.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString("dd.MM.yyyy")); } catch { } finally { switch (format) { case Document_Format.Word: document.SaveAs2(name, word.WdSaveFormat.wdFormatDocument); break; case Document_Format.PDF: document.SaveAs2(name, word.WdSaveFormat.wdFormatPDF); break; } document.Close(); application.Quit(); } break; case Document_Format.Excel: excel.Application application_ex = new excel.Application(); excel.Workbook workbook = application_ex.Workbooks.Add(); excel.Worksheet worksheet = (excel.Worksheet)workbook.ActiveSheet(); try { switch (type) { case Document_Type.Report: worksheet.Name = "Отчет"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); } } excel.Range border = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[worksheet.Rows.Count + 1][table.Columns.Count + 1]]; border.Borders.LineStyle = excel.XlLineStyle.xlContinuous; border.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; border.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 2, table.Columns.Count + 2]].Merge(); break; case Document_Type.Statistic: worksheet.Name = "Статистический отчет"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); } } excel.Range border1 = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[worksheet.Rows.Count + 1][table.Columns.Count + 1]]; border1.Borders.LineStyle = excel.XlLineStyle.xlContinuous; border1.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; border1.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); excel.ChartObjects chartObjects = (excel.ChartObjects)worksheet.ChartObjects(Type.Missing); excel.ChartObject chartObject = chartObjects.Add(300, 50, 250, 250); excel.Chart chart = chartObject.Chart; excel.SeriesCollection seriesCollection = (excel.SeriesCollection)chart.SeriesCollection(Type.Missing); excel.Series series = seriesCollection.NewSeries(); chart.ChartType = excel.XlChartType.xl3DColumn; series.XValues = worksheet.get_Range("B2", "B" + table.Rows.Count + 1); series.Values = worksheet.get_Range("C2", "C" + table.Rows.Count + 1); break; } } catch { } finally { workbook.SaveAs(name, application_ex.DefaultSaveFormat); workbook.Close(); application_ex.Quit(); } break; } break; case false: System.Windows.Forms.MessageBox.Show("Введите название документа"); break; } }
private async Task <int> InitializeDocumentCT(int itmcount, string prevEntryId, AllocationsModel.MyPodData mypod, DocumentCT cdoc, AsycudaDocumentSet docSet, string prevIM7, AllocationsModel.AllocationDataBlock monthyear, Document_Type dt, string dfp) { try { if (MaxLineCount(itmcount) || InvoicePerEntry(prevEntryId, mypod) || (cdoc.Document == null || itmcount == 0) || IsPerIM7(prevIM7, monthyear)) { if (itmcount != 0) { if (cdoc.Document != null) { await SaveDocumentCT(cdoc).ConfigureAwait(false); //} //else //{ cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(true); } } Ex9InitializeCdoc(dt, dfp, cdoc, docSet); if (PerIM7 == true) { cdoc.Document.xcuda_Declarant.Number = cdoc.Document.xcuda_Declarant.Number.Replace( docSet.Declarant_Reference_Number, docSet.Declarant_Reference_Number + "-" + monthyear.CNumber); } InsertEntryIdintoRefNum(cdoc, mypod.EntlnData.EntryDataDetails[0].EntryDataId); itmcount = 0; } return(itmcount); } catch (Exception) { throw; } }
public async Task CreateOversOps(IEnumerable <OversShortEX> selOS, AsycudaDocumentSet docSet) { if (docSet == null) { throw new ApplicationException("Please Select a Asycuda Document Set before proceding"); } if (selOS.Any() == false) { throw new ApplicationException("Please Select Overs/Shorts before proceding"); } StatusModel.Timer("Getting Data..."); var slstSource = selOS.SelectMany(x => x.OverShortDetailsEXes.Where(y => y.Type == "Over")).ToList(); if (!slstSource.Any()) { StatusModel.StopStatusUpdate(); return; } var slst = (from s in slstSource group s by new { s.ItemNumber, s.ItemDescription, s.InventoryItem.TariffCode, s.Cost, s.InventoryItem } into g select new { EntlnData = new BaseDataModel.EntryLineData() { ItemNumber = g.Key.ItemNumber, ItemDescription = g.Key.ItemDescription, TariffCode = g.Key.TariffCode, Cost = Convert.ToDouble(g.Key.Cost), InventoryItem = g.Key.InventoryItem, Quantity = Convert.ToDouble(g.Sum(x => x.OversQuantity)), EntryDataDetails = new List <IEntryDataDetail>() } }).ToList(); if (!slst.Any()) { StatusModel.StopStatusUpdate(); throw new ApplicationException( "No OPS Allocations found! If you just deleted Entries, Please Allocate Sales then continue Else Contact your Network Administrator"); } DocumentCT cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(false); int itmcount = 0; Document_Type dt = BaseDataModel.Instance.Document_Types.FirstOrDefault(x => x.DisplayName == "IM7"); if (dt == null) { StatusModel.StopStatusUpdate(); throw new ApplicationException(string.Format("Null Document Type for '{0}' Contact your Network Administrator", "IM7")); } dt.DefaultCustoms_Procedure = BaseDataModel.Instance.Customs_Procedures .FirstOrDefault(x => x.DisplayName.Contains("OPP") && x.Document_TypeId == dt.Document_TypeId); if (dt.DefaultCustoms_Procedure == null) { StatusModel.StopStatusUpdate(); throw new ApplicationException(string.Format("Null Customs Procedure for '{0}' Contact your Network Administrator", "OPP")); } CreateOPSClass.Instance.OPSIntializeCdoc(cdoc, dt, docSet); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Customs_Procedure = dt.DefaultCustoms_Procedure; StatusModel.StartStatusUpdate("Creating Opening Stock Entries", slst.Count()); foreach (var pod in slst) { StatusModel.StatusUpdate(); xcuda_Item itm = BaseDataModel.Instance.CreateItemFromEntryDataDetail(pod.EntlnData, cdoc); if (itm != null) { itmcount += 1; } if (itmcount % BaseDataModel.Instance.CurrentApplicationSettings.MaxEntryLines == 0) { await BaseDataModel.Instance.SaveDocumentCT(cdoc).ConfigureAwait(false); cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(false); CreateOPSClass.Instance.OPSIntializeCdoc(cdoc, dt, docSet); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Customs_Procedure = dt.DefaultCustoms_Procedure; } } if (cdoc.DocumentItems.Count == 0) { await BaseDataModel.Instance.DeleteAsycudaDocument(cdoc.Document).ConfigureAwait(false); } }
public void Document_Create(Document_Type type, Document_format format, string name, DataTable table) { Configuration_Class configuration_Class = new Configuration_Class(); configuration_Class.Document_configuration_Get(); switch (name != "" || name != null) { case true: switch (format) { case Document_format.Word: word.Application application = new word.Application(); word.Document document = application.Documents.Add(Visible: true); try { word.Range range = document.Range(0, 0); document.Sections.PageSetup.LeftMargin = application.CentimetersToPoints((float)Configuration_Class.doc_Left_Merge); document.Sections.PageSetup.TopMargin = application.CentimetersToPoints((float)Configuration_Class.doc_Top_Merge); document.Sections.PageSetup.RightMargin = application.CentimetersToPoints((float)Configuration_Class.doc_Right_Merge); range.Text = Configuration_Class.Organization_Name; //Выравнивание range.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; //Интревал range.ParagraphFormat.SpaceAfter = 1; range.ParagraphFormat.SpaceBefore = 1; range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; range.Font.Name = "Times New Roman"; range.Font.Size = 12; document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph Document_Name = document.Paragraphs.Add(); Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph statparg = document.Paragraphs.Add(); //Создание области таблицы в документе word.Table stat_table //ие таблицы в области документа //указывается параграф в котором документ создан //Количество строк и столбцов = document.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); //Настройка границ таблицы внутренние stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Настройка границ таблицы внешние stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Выравнивание текста внутри ячеек по ширине stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; //Выравнивание текста внутри ячеек по высоте stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 11; stat_table.Range.Font.Name = "Times New Romman"; //Индексикация столбцов и строк в Word начинается с 1,1 for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } document.Paragraphs.Add(); document.Paragraphs.Add(); //Параграф с фиксацией даты слздания документа word.Paragraph Footparg = document.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString("dd.MM.yyyy")); } catch { } finally { switch (format) { case Document_format.Word: //Сохранение документа с названием из метода и формата doc document.SaveAs2(name, word.WdSaveFormat.wdFormatDocument); break; case Document_format.PDF: //Сохранение документа в формате PDF document.SaveAs2(name, word.WdSaveFormat.wdFormatPDF); break; } //Закрываем документ document.Close(); //Выходим из процесса с его закрытием application.Quit(); } break; case Document_format.Excel: //Создание процесса Excel excel.Application application_ex = new excel.Application(); //Создание книги excel.Workbook workbook = application_ex.Workbooks.Add(); //Создание страницы excel.Worksheet worksheet = (excel.Worksheet)workbook.ActiveSheet; try { switch (type) { case Document_Type.Report: //Название страницы worksheet.Name = "Отчёт"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); //Указание диапазона работы с ячееками листа excel.Range border //Начало диапазона = worksheet.Range[worksheet.Cells[1, 1], //Динамический конец диапазона в зависимости от выходимых данных worksheet.Cells[table.Rows.Count + 1] [table.Columns.Count + 1]]; //Стиль линий границ ячеек border.Borders.LineStyle = excel.XlLineStyle.xlContinuous; //Выравнивание во высоте border.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; //Выравнивание по ширине border.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; //Внесение даты создания документа worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); //Объединение ячеек worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 2, table.Columns.Count + 2]].Merge(); } } break; case Document_Type.Statistic: worksheet.Name = "Статический отчёт"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); } } excel.Range border1 = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[table.Rows.Count + 1][table.Columns.Count + 1]]; border1.Borders.LineStyle = excel.XlLineStyle.xlContinuous; border1.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; border1.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 2, table.Columns.Count + 2]].Merge(); //Класс области графики excel.ChartObjects chartObjects = (excel.ChartObjects)worksheet.ChartObjects(Type.Missing); //Область размещения графиков: отступы слева сверху, размер ширина и высота excel.ChartObject chartObject = chartObjects.Add(300, 50, 250, 250); //Объявление области графики excel.Chart chart = chartObject.Chart; //Объявление коллекции построений графиков excel.SeriesCollection seriesCollection = (excel.SeriesCollection)chart.SeriesCollection(Type.Missing); //Объявление построения графиков excel.Series series = seriesCollection.NewSeries(); //Тип графика chart.ChartType = excel.XlChartType.xl3DColumn; //Диапазон значений по оси Х series.XValues = worksheet.get_Range("B2", "B" + table.Rows.Count + 1); //Диапазон значений по оси У series.Values = worksheet.get_Range("C2", "C" + table.Rows.Count + 1); break; } } catch { } finally { //Сохранение книги worksheet.SaveAs(name, application_ex.DefaultSaveFormat); //Закрытие книги workbook.Close(); //Завершение процесса application_ex.Quit(); } break; } break; case false: System.Windows.Forms.MessageBox.Show("Введите название документа"); break; } }
/// <summary> /// Метод создания и сохранения документов /// в форматах Microsoft Word (doc, PDF), /// Excel (exls) /// </summary> /// <param name="type">Тип создаваемого документа /// отчёт или статистика</param> /// <param name="format">Формат сохранения /// документ или таблица</param> /// <param name="name">Название документа</param> /// <param name="table">Входная таблица с данными</param> public void Document_Create(Document_Type type, Document_Format format, string name, DataTable table) { string filename = ""; if (format == Document_Format.Word) { System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog(); saveFileDialog.Filter = "Word документ (*.doc)|*.doc|Все файлы (*.*)|*.*"; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } filename = saveFileDialog.FileName; } //Получение данных о конфигурации документа Configuration_class configuration_Class = new Configuration_class(); configuration_Class.Document_Configuration_Get(); //Проверка на пустоту названия switch (name != "" || name != null) { case true: //Выбор формата либо Word либо PDF //Запуск процесса в дистпечере задач word.Application application = new word.Application(); //создание документа в процессе word.Document document //Присвоение документа процессу, Visible: true //возможность редактирования документа = application.Documents.Add(Visible: true); try { //Объявление дипапазона для формирования текста word.Range range = document.Range(0, 0); //Настройка отступов в документе document.Sections.PageSetup.LeftMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Left_Merge); document.Sections.PageSetup.TopMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Top_Merge); document.Sections.PageSetup.RightMargin = application. CentimetersToPoints((float) Configuration_class.doc_Right_Merg); document.Sections.PageSetup.BottomMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Bottom_Merge); //Присвоение текстового знеачения в дипазон range.Text = Configuration_class.Organization_Name; //Настройка выравнивания текста range.ParagraphFormat.Alignment = word.WdParagraphAlignment. wdAlignParagraphCenter; //Настройка интервала после абзаца range.ParagraphFormat.SpaceAfter = 1; //Настройка интервала перед абзаца range.ParagraphFormat.SpaceBefore = 1; //Настройка межстрочного интервала range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; //Настройка названия шрифта range.Font.Name = "Times New Roman"; //Настройка размера шрифта range.Font.Size = 12; //Добавление параграфов document.Paragraphs.Add(); //В конце текста document.Paragraphs.Add(); //Свободный document.Paragraphs.Add(); //Для будущего текста //Параграф для названия документа word.Paragraph Document_Name = document.Paragraphs.Add(); //Настройка параграфа через свойство диапазона Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; //Проверка на тип документа, отчёт или статистика switch (type) { case Document_Type.Report: Document_Name.Range.Text = "ОТЧЁТ"; break; case Document_Type.Statistic: Document_Name.Range.Text = "СТАТИСТИЧЕСКИЙ ОТЧЁТ"; break; case Document_Type.List: Document_Name.Range.Text = "СПИСОК СОТРУДНИКОВ"; break; case Document_Type.Check: Document_Name.Range.Text = "ЧЕК"; break; } document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph statparg = document.Paragraphs.Add(); //Создание области таблицы в документе if (type == Document_Type.Check) { word.Table stat_table2 = document.Tables.Add(statparg.Range, 2, 5); stat_table2.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Настройка границ таблицы внешние stat_table2.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Выравнивание текста внутри ячеек по ширине stat_table2.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; //Выравнивание текста внутри ячеек по высоте stat_table2.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table2.Range.Font.Size = 11; stat_table2.Range.Font.Name = "Times New Roman"; stat_table2.Cell(1, 1).Range.Text = "Цена"; stat_table2.Cell(1, 2).Range.Text = "Дата"; stat_table2.Cell(1, 3).Range.Text = "Фамилия"; stat_table2.Cell(1, 4).Range.Text = "Имя"; stat_table2.Cell(1, 5).Range.Text = "Отчество"; stat_table2.Cell(2, 1).Range.Text = table.Rows[0][0].ToString(); stat_table2.Cell(2, 2).Range.Text = table.Rows[0][1].ToString(); stat_table2.Cell(2, 3).Range.Text = table.Rows[0][2].ToString(); stat_table2.Cell(2, 4).Range.Text = table.Rows[0][3].ToString(); stat_table2.Cell(2, 5).Range.Text = table.Rows[0][4].ToString(); } if (type != Document_Type.Check) { word.Table stat_table //Добавление таблицы в область документа //Указывается параграф в котором документ создан //Количество строк и столбцов = document.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); //Настройка границ таблицы внутренние stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Настройка границ таблицы внешние stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Выравнивание текста внутри ячеек по ширине stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; //Выравнивание текста внутри ячеек по высоте stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 11; stat_table.Range.Font.Name = "Times New Roman"; //Индексация столбцов и строк в Word начинается с 1,1 for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } } document.Paragraphs.Add(); document.Paragraphs.Add(); //Парадграф с фиксациейц даты создания документа word.Paragraph Footparg = document.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString("dd.MM.yyyy")); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } finally { switch (format) { case Document_Format.Word: //Сохранение документа с названием из метода, //и в формате doc document.SaveAs2(filename, word.WdSaveFormat.wdFormatDocument); //document.SaveAs2(string.Format("{0}\\{1}",Environment.CurrentDirectory, name) , // word.WdSaveFormat.wdFormatDocument); filename document.Close(); break; case Document_Format.PDF: //Сохранение документа в формате PDF document.SaveAs2(string.Format("{0}\\{1}", Environment.CurrentDirectory, name), word.WdSaveFormat.wdFormatPDF); break; } //Закрываем документ //Выходим из процесса с его закрытием application.Quit(); } break; } }
public fmComment(Document_Type DocType, String OrderNo) { InitializeComponent(); orderno = OrderNo; doctype = DocType; }
public async Task CreateShortsEx9(IEnumerable <OversShortEX> selos, AsycudaDocumentSet docSet, bool BreakOnMonthYear, bool ApplyEX9Bucket) { if (docSet == null) { throw new ApplicationException("Please Select a Asycuda Document Set before proceding"); } if (selos.Any() == false) { throw new ApplicationException("Please Select Overs/Shorts before proceding"); } StatusModel.Timer("Getting Data..."); var slstSource = selos.SelectMany(x => x.OverShortDetailsEXes.Where(y => y.Type == "Short")).ToList(); if (!slstSource.Any()) { return; } IEnumerable <EXWDataBlock> slst; if (BreakOnMonthYear) { slst = (from s in slstSource group s by new { MonthYear = s.OversShortEX.InvoiceDate.ToString("MMM-yy") } into g select new EXWDataBlock() { MonthYear = g.Key.MonthYear, DutyFreePaid = "DutyFree", OverShortDetailsEX = g.ToList(), }).ToList(); } else { slst = (from s in slstSource group s by new { MonthYear = "NoMTY" } into g select new EXWDataBlock { MonthYear = g.Key.MonthYear, DutyFreePaid = "DutyFree", OverShortDetailsEX = g.ToList(), }).ToList(); } if (!slst.Any()) { StatusModel.StopStatusUpdate(); throw new ApplicationException( "No OPS Allocations found! If you just deleted Entries, Please Allocate Sales then continue Else Contact your Network Administrator"); } var dfp = "Duty Free"; Document_Type dt = CreateDocumentType(); if (dt == null) { return; } DocumentCT cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(false); CreateEx9Class.Instance.Ex9InitializeCdoc(dt, dfp, cdoc, docSet); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Customs_Procedure = dt.DefaultCustoms_Procedure; int itmcount = 0; StatusModel.StartStatusUpdate("Creating Shorts EXW Entries", slst.Count()); foreach (EXWDataBlock monthyear in slst) { var elst = PrepareShortsEXWData(monthyear); foreach (var pod in elst) { StatusModel.StatusUpdate(); if (CreateEx9Class.Instance.CreateEx9EntryAsync(pod, cdoc, itmcount, dfp, ApplyEX9Bucket)) { StatusModel.StatusUpdate(); itmcount += 1; } if (itmcount % BaseDataModel.Instance.CurrentApplicationSettings.MaxEntryLines == 0) { await BaseDataModel.Instance.SaveDocumentCT(cdoc).ConfigureAwait(false); } //dup new file cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(false); CreateEx9Class.Instance.Ex9InitializeCdoc(dt, dfp, cdoc, docSet); cdoc.Document.xcuda_ASYCUDA_ExtendedProperties.Customs_Procedure = dt.DefaultCustoms_Procedure; if (cdoc.Document != null) { cdoc.Document.xcuda_Valuation = new xcuda_Valuation(); cdoc.Document.xcuda_Valuation.xcuda_Weight = new xcuda_Weight(); cdoc.Document.xcuda_Valuation.xcuda_Weight.Gross_weight = cdoc.Document.xcuda_PreviousItem.Sum(x => x.Net_weight); } } } if (cdoc.DocumentItems.Count == 0) { await BaseDataModel.Instance.DeleteAsycudaDocument(cdoc.Document).ConfigureAwait(false); } }
/// <summary> /// Метод создания и сохранения документов /// в форматах Microsoft Word (doc, PDF), /// Excel (exls) /// </summary> /// <param name="type">Тип создаваемого документа /// отчёт или статистика</param> /// <param name="format">Формат сохранения /// документ или таблица</param> /// <param name="name">Название документа</param> /// <param name="table">Входная таблица с данными</param> public void Document_Create(Document_Type type, Document_Format format, string name, DataTable table) { //Получение данных о конфигурации документа Configuration_class configuration_Class = new Configuration_class(); configuration_Class.Document_Configuration_Get(); //Проверка на пустоту названия switch (name != "" || name != null) { case true: //Выбор формата либо Word либо Excel switch (format) { case Document_Format.Word: //Запуск процесса в дистпечере задач word.Application application = new word.Application(); //создание документа в процессе word.Document document //Присвоение документа процессу, Visible: true //возможность редактирования документа = application.Documents.Add(Visible: true); try { //Объявление дипапазона для формирования текста word.Range range = document.Range(0, 0); //89Настройка отступов в документе document.Sections.PageSetup.LeftMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Left_Merge); document.Sections.PageSetup.TopMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Top_Merge); document.Sections.PageSetup.RightMargin = application. CentimetersToPoints((float) Configuration_class.doc_Right_Merg); document.Sections.PageSetup.BottomMargin = application.CentimetersToPoints( (float)Configuration_class. doc_Bottom_Merge); //Присвоение текстового знеачения в дипазон range.Text = "Мвидео"; //Настройка выравнивания текста range.ParagraphFormat.Alignment = word.WdParagraphAlignment. wdAlignParagraphCenter; //Настройка интервала после абзаца range.ParagraphFormat.SpaceAfter = 1; //Настройка интервала перед абзаца range.ParagraphFormat.SpaceBefore = 1; //Настройка межстрочного интервала range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; //Настройка названия шрифта range.Font.Name = "Times New Roman"; //Настройка размера шрифта range.Font.Size = 12; //Добавление параграфов document.Paragraphs.Add(); //В конце текста document.Paragraphs.Add(); //Свободный document.Paragraphs.Add(); //Для будущего текста //Параграф для названия документа word.Paragraph Document_Name = document.Paragraphs.Add(); //Настройка параграфа через свойство диапазона Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; //Проверка на тип документа, отчёт или статистика switch (type) { case Document_Type.Report: Document_Name.Range.Text = "ОТЧЁТ"; break; case Document_Type.Statistic: Document_Name.Range.Text = "СТАТИСТИЧЕСКИЙ ОТЧЁТ"; break; } document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); word.Paragraph statparg = document.Paragraphs.Add(); //Создание области таблицы в документе word.Table stat_table //Добавление таблицы в область документа //Указывается параграф в котором документ создан //Количество строк и столбцов = document.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); //Настройка границ таблицы внутренние stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Настройка границ таблицы внешние stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; //Выравнивание текста внутри ячеек по ширине stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; //Выравнивание текста внутри ячеек по высоте stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 11; stat_table.Range.Font.Name = "Times New Roman"; //Индексация столбцов и строк в Word начинается с 1,1 for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } document.Paragraphs.Add(); document.Paragraphs.Add(); //Парадграф с фиксациейц даты создания документа word.Paragraph Footparg = document.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString("dd.MM.yyyy")); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } finally { switch (format) { case Document_Format.Word: //Сохранение документа с названием из метода, //и в формате doc document.SaveAs2(string.Format("{0}\\{1}", Environment.CurrentDirectory, name), word.WdSaveFormat.wdFormatDocument); break; case Document_Format.PDF: //Сохранение документа в формате PDF document.SaveAs2(string.Format("{0}\\{1}", Environment.CurrentDirectory, name), word.WdSaveFormat.wdFormatPDF); break; } //Закрываем документ document.Close(); //Выходим из процесса с его закрытием application.Quit(); } break; case Document_Format.Excel: //Создание процесса Excel excel.Application application_ex = new excel.Application(); //Создание книги excel.Workbook workbook = application_ex.Workbooks.Add(); //Создание страницы excel.Worksheet worksheet = (excel.Worksheet)workbook.ActiveSheet; try { switch (type) { case Document_Type.Report: //Название страницы worksheet.Name = "Отчёт"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { //ЗАнесение данных в ячейку worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); } } //Указание диапазона работы с ячеёками листа excel.Range border //Начало диапазона = worksheet.Range[worksheet.Cells[1, 1], //Динамический конец диапазона в зависимости от //выдодимых данных worksheet.Cells[table.Rows.Count + 1] [table.Columns.Count + 1]]; //Стиль линий границ ячеек border.Borders.LineStyle = excel.XlLineStyle.xlContinuous; //Выравнивание во высоте border.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; //Выравнивание по ширине border.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; //Внесение даты создания документа worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); //Объединение ячеек worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 2, table.Columns.Count + 2]].Merge(); break; case Document_Type.Statistic: worksheet.Name = "Статистический отчёт"; for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 1][col + 1] = table.Rows[row][col].ToString(); } } excel.Range border1 = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[table.Rows.Count + 1] [table.Columns.Count + 1]]; border1.Borders.LineStyle = excel.XlLineStyle.xlContinuous; border1.VerticalAlignment = excel.XlHAlign.xlHAlignCenter; border1.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; worksheet.Cells[table.Rows.Count + 3][2] = string.Format("Дата создания {0}", DateTime.Now.ToString()); worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 2, table.Columns.Count + 2]].Merge(); //Класс области графиков excel.ChartObjects chartObjects = (excel.ChartObjects)worksheet.ChartObjects( Type.Missing); //Область размещения графиков: отступы слева сверху, //размер ширина и высота excel.ChartObject chartObject = chartObjects.Add(300, 50, 250, 250); //Объявление области графика excel.Chart chart = chartObject.Chart; //Объявление колекции построений графиков excel.SeriesCollection seriesCollection = (excel.SeriesCollection)chart.SeriesCollection( Type.Missing); //Объявление посторения графика excel.Series series = seriesCollection.NewSeries(); //Тип графика chart.ChartType = excel.XlChartType.xl3DColumn; //Диапазон значений по оси X series.XValues = worksheet.get_Range("B2", "B" + table.Rows.Count + 1); //Диапазон значений по оси Y series.Values = worksheet.get_Range("C2", "C" + table.Rows.Count + 1); break; } } catch { } finally { //Сохранение книги workbook.SaveAs(string.Format("{0}\\{1}", Environment.CurrentDirectory, name), application_ex.DefaultSaveFormat); //Закрытие книги workbook.Close(); //Завершение процесса application_ex.Quit(); } break; } break; case false: System.Windows.Forms.MessageBox.Show ("Введите название документа"); break; } }
public async Task <Document_Type> CreateDocument_Type(Document_Type entity) { return(await Channel.CreateDocument_Type(entity).ConfigureAwait(false)); }
///<summary> ///Процедура формирования документа ///</summary> ///<param name="type">Тип документа</param> ///<param name="name">Название документа</param> ///<param name="table">результирующая таблица</param> public void Document_Create(Document_Type type, string name, DataTable table) { //Получение данных о документе Configuration_class configuration_Class = new Configuration_class(); configuration_Class.Document_Configuration_Get(); switch (name != "" || name != null) { case (true): switch (type) { case (Document_Type.Check): //Открытие приложения и документа в нём word.Application application = new word.Application(); word.Document document = application.Documents.Add(Visible: true); //Формирование документа try { //Начало word.Range range = document.Range(0, 0); //Поля document.Sections.PageSetup.LeftMargin = application.CentimetersToPoints((float)Configuration_class.doc_Left_Merge); document.Sections.PageSetup.RightMargin = application.CentimetersToPoints((float)Configuration_class.doc_Right_Merge); document.Sections.PageSetup.TopMargin = application.CentimetersToPoints((float)Configuration_class.doc_Top_Merge); document.Sections.PageSetup.BottomMargin = application.CentimetersToPoints((float)Configuration_class.doc_Bottom_Merge); //Присвоение текстового значения в абзац range.Text = Configuration_class.Organization_Name; //Выравнивание range.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; //Интервалы в абзаце range.ParagraphFormat.SpaceAfter = 1; range.ParagraphFormat.SpaceBefore = 1; range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; //Шрифт range.Font.Name = "Times New Roman"; range.Font.Size = 12; //Параграф (один Enter) document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); //Название документа word.Paragraph Document_Name = document.Paragraphs.Add(); //Настройка параграфа Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; Document_Name.Range.Text = "Выгрузка чека"; document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); //Создание таблицы word.Paragraph statparg = document.Paragraphs.Add(); word.Table stat_table = document.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); //Настройка таблицы stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 11; stat_table.Range.Font.Name = "Times New Roman"; //Заполнение таблицы for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } document.Paragraphs.Add(); document.Paragraphs.Add(); document.Paragraphs.Add(); //Строка даты создания word.Paragraph Footparg = document.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString()); } catch { } finally { try { //Сохранение документа document.SaveAs2(name + "DOC", word.WdSaveFormat.wdFormatDocument); //Закрытие документа document.Close(SaveChanges: false); } catch (Exception ex) { MessageBox.Show(ex.Message); } application.Quit(); } break; case (Document_Type.MarkSchemes): //Открытие приложения, создание документа (книги) и листа в нём. excel.Application application_ex = new excel.Application(); excel.Workbook workbook = application_ex.Workbooks.Add(); //excel.Worksheet worksheet = (excel.Worksheet)workbook.ActiveSheet; excel.Worksheet worksheet = workbook.ActiveSheet; try { worksheet.Name = "MarketerDoc"; worksheet.Cells[1][1] = "Отчёт о работе отдела маркетинга"; worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[1, table.Columns.Count + 1]].Merge(); //Заполнение таблицы for (int row = 0; row < table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { worksheet.Cells[row + 3, col + 1] = table.Rows[row][col].ToString(); } } //Работа со стилем таблицы excel.Range border1 = worksheet.Range[worksheet.Cells[3, 1], worksheet.Cells[table.Rows.Count + 3][table.Columns.Count]]; border1.Borders.LineStyle = excel.XlLineStyle.xlContinuous; border1.VerticalAlignment = excel.XlVAlign.xlVAlignCenter; border1.HorizontalAlignment = excel.XlHAlign.xlHAlignCenter; //Дата документа worksheet.Cells[2][table.Rows.Count + 3] = string.Format("Дата создания {0}", DateTime.Now.ToString()); //Объединение ячеек worksheet.Range[worksheet.Cells[table.Rows.Count + 3, 2], worksheet.Cells[table.Rows.Count + 3, table.Columns.Count + 2]].Merge(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Сохранение и выход workbook.SaveAs(name, application_ex.DefaultSaveFormat); workbook.Close(); application_ex.Quit(); } break; case (Document_Type.Order): //Открытие приложения и документа в нём word.Application application_or = new word.Application(); word.Document document_or = application_or.Documents.Add(Visible: true); //Формирование документа try { //Начало word.Range range = document_or.Range(0, 0); //Поля document_or.Sections.PageSetup.LeftMargin = application_or.CentimetersToPoints((float)Configuration_class.doc_Left_Merge); document_or.Sections.PageSetup.RightMargin = application_or.CentimetersToPoints((float)Configuration_class.doc_Right_Merge); document_or.Sections.PageSetup.TopMargin = application_or.CentimetersToPoints((float)Configuration_class.doc_Top_Merge); document_or.Sections.PageSetup.BottomMargin = application_or.CentimetersToPoints((float)Configuration_class.doc_Bottom_Merge); //Присвоение текстового значения в абзац range.Text = Configuration_class.Organization_Name; //Выравнивание range.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; //Интервалы в абзаце range.ParagraphFormat.SpaceAfter = 1; range.ParagraphFormat.SpaceBefore = 1; range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; //Шрифт range.Font.Name = "Times New Roman"; range.Font.Size = 12; //Параграф (один Enter) document_or.Paragraphs.Add(); document_or.Paragraphs.Add(); document_or.Paragraphs.Add(); //Название документа word.Paragraph Document_Name = document_or.Paragraphs.Add(); //Настройка параграфа Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; Document_Name.Range.Text = table.Rows[0][0].ToString(); document_or.Paragraphs.Add(); document_or.Paragraphs.Add(); document_or.Paragraphs.Add(); //Создание таблицы word.Paragraph statparg = document_or.Paragraphs.Add(); word.Paragraph Document_Text = document_or.Paragraphs.Add(); //Настройка параграфа Document_Text.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphLeft; Document_Text.Format.LeftIndent = (float)1.25; Document_Text.Range.Font.Name = "Times New Roman"; Document_Text.Range.Font.Size = 14; Document_Text.Range.Text = table.Rows[0][1].ToString(); } catch { } finally { try { //Сохранение документа document_or.SaveAs2(name + "PDF", word.WdSaveFormat.wdFormatPDF); //Закрытие документа document_or.Close(SaveChanges: false); } catch (Exception ex) { MessageBox.Show(ex.Message); } application_or.Quit(); } break; case (Document_Type.Storage): //Открытие приложения и документа в нём word.Application application_St = new word.Application(); word.Document document_St = application_St.Documents.Add(Visible: true); //Формирование документа try { //Начало word.Range range = document_St.Range(0, 0); //Поля document_St.Sections.PageSetup.LeftMargin = application_St.CentimetersToPoints((float)Configuration_class.doc_Left_Merge); document_St.Sections.PageSetup.RightMargin = application_St.CentimetersToPoints((float)Configuration_class.doc_Right_Merge); document_St.Sections.PageSetup.TopMargin = application_St.CentimetersToPoints((float)Configuration_class.doc_Top_Merge); document_St.Sections.PageSetup.BottomMargin = application_St.CentimetersToPoints((float)Configuration_class.doc_Bottom_Merge); //Присвоение текстового значения в абзац range.Text = Configuration_class.Organization_Name; //Выравнивание range.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; //Интервалы в абзаце range.ParagraphFormat.SpaceAfter = 1; range.ParagraphFormat.SpaceBefore = 1; range.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceSingle; //Шрифт range.Font.Name = "Times New Roman"; range.Font.Size = 12; //Параграф (один Enter) document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); //Название документа word.Paragraph Document_Name = document_St.Paragraphs.Add(); //Настройка параграфа Document_Name.Format.Alignment = word.WdParagraphAlignment.wdAlignParagraphCenter; Document_Name.Range.Font.Name = "Times New Roman"; Document_Name.Range.Font.Size = 16; Document_Name.Range.Text = "Выгрузка чека"; document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); //Создание таблицы word.Paragraph statparg = document_St.Paragraphs.Add(); word.Table stat_table = document_St.Tables.Add(statparg.Range, table.Rows.Count, table.Columns.Count); //Настройка таблицы stat_table.Borders.InsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Borders.OutsideLineStyle = word.WdLineStyle.wdLineStyleSingle; stat_table.Rows.Alignment = word.WdRowAlignment.wdAlignRowCenter; stat_table.Range.Cells.VerticalAlignment = word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; stat_table.Range.Font.Size = 11; stat_table.Range.Font.Name = "Times New Roman"; //Заполнение таблицы for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 1; col <= table.Columns.Count; col++) { stat_table.Cell(row, col).Range.Text = table.Rows[row - 1][col - 1].ToString(); } } document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); document_St.Paragraphs.Add(); //Строка даты создания word.Paragraph Footparg = document_St.Paragraphs.Add(); Footparg.Range.Text = string.Format("Дата создания \t\t\t{0}", DateTime.Now.ToString()); } catch { } finally { try { //Сохранение документа document_St.SaveAs2(name + "DOC", word.WdSaveFormat.wdFormatDocument); //Закрытие документа document_St.Close(SaveChanges: false); } catch (Exception ex) { MessageBox.Show(ex.Message); } application_St.Quit(); } break; } break; case (false): MessageBox.Show("Введите название документа"); break; } }
// GET: Document_Type/Delete/5 public ActionResult Delete(int id) { Document_Type document_Type = db.Document_Type.Find(id); return(View(document_Type)); }