|
@@ -0,0 +1,3097 @@
|
|
|
|
|
+using System;
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
+//using System.Drawing;
|
|
|
|
|
+using System.Linq;
|
|
|
|
|
+using System.Text;
|
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
+using System.Xml.Linq;
|
|
|
|
|
+using Aspose.Words;
|
|
|
|
|
+using Aspose.Words.Saving;
|
|
|
|
|
+using DocumentFormat.OpenXml.Packaging;
|
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
+using Spire.Doc;
|
|
|
|
|
+using SuperCms.Models;
|
|
|
|
|
+using Syncfusion.DocIO;
|
|
|
|
|
+using Syncfusion.DocIO.DLS;
|
|
|
|
|
+using Syncfusion.Drawing;
|
|
|
|
|
+using OutlineLevel = Syncfusion.DocIO.OutlineLevel;
|
|
|
|
|
+using System.IO;
|
|
|
|
|
+using System.Globalization;
|
|
|
|
|
+using Syncfusion.XlsIO;
|
|
|
|
|
+using System.Net.Http;
|
|
|
|
|
+using System.Net;
|
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
|
|
+
|
|
|
|
|
+namespace SuperCms.Controllers
|
|
|
|
|
+{
|
|
|
|
|
+ public class UtilsController
|
|
|
|
|
+ {
|
|
|
|
|
+ private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
|
|
|
|
|
+
|
|
|
|
|
+ public static string[] validformats = new[] {
|
|
|
|
|
+ "MM/dd/yyyy",
|
|
|
|
|
+ "yyyy/MM/dd",
|
|
|
|
|
+ "dd/MM/yyyy HH:mm:ss",
|
|
|
|
|
+ "MM/dd/yyyy HH:mm:ss",
|
|
|
|
|
+ "MM/dd/yyyy hh:mm tt",
|
|
|
|
|
+ "yyyy-MM-dd HH:mm:ss, fff",
|
|
|
|
|
+ "yyyy-MM-ddTHH:mm:ss",
|
|
|
|
|
+ "yyyy-MM-ddTHH:mm",
|
|
|
|
|
+ "yyyy-MM-ddTHH:mm:ss.fff",
|
|
|
|
|
+ "yyyy-MM-dd",
|
|
|
|
|
+ "HH:mm:ss","HH:mm"};
|
|
|
|
|
+ public static String convertLargeNumberToString(int remain, String resString)
|
|
|
|
|
+ {
|
|
|
|
|
+ int result, phanDu;
|
|
|
|
|
+ if (remain > 1000)
|
|
|
|
|
+ {
|
|
|
|
|
+ result = remain / 1000;
|
|
|
|
|
+ phanDu = remain - result * 1000;
|
|
|
|
|
+ if (resString == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ return convertLargeNumberToString(phanDu, resString + "." + phanDu);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return convertLargeNumberToString(phanDu, resString + ".");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ return resString + "." + remain.ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static string RandomString(int size, bool lowerCase)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
|
|
+ Random random = new Random();
|
|
|
|
|
+ char ch;
|
|
|
|
|
+ for (int i = 0; i < size; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
|
|
|
|
|
+ builder.Append(ch);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (lowerCase)
|
|
|
|
|
+ return builder.ToString().ToLower();
|
|
|
|
|
+ return builder.ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public class Constant
|
|
|
|
|
+ {
|
|
|
|
|
+ public const String SERVICE_ID = "3";
|
|
|
|
|
+ public const String PARENT_ID = "-1";
|
|
|
|
|
+
|
|
|
|
|
+ public const String NUMBER_ROW_ON_PAGE = "10";
|
|
|
|
|
+ public const String GET_ALL = "-1";
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+ public const String SUCCESS = "0";
|
|
|
|
|
+ public const String ERROR = "-1";
|
|
|
|
|
+
|
|
|
|
|
+ public const String BOTS = "1";
|
|
|
|
|
+ public const String GROUPS = "2";
|
|
|
|
|
+ public const String SCHEDULES = "3";
|
|
|
|
|
+ public const String CONFIGS = "4";
|
|
|
|
|
+ public const String SENDMAIL = "5";
|
|
|
|
|
+ public const String SERVICE_CONFIG = "6";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public const int MAX_SCHEDULE_STATUS = 5;
|
|
|
|
|
+ public const int MAX_GROUP_STATUS = 2;
|
|
|
|
|
+ public const int MAX_BOT_STATUS = 1;
|
|
|
|
|
+ public const int MAX_WARNING_STATUS = 2;
|
|
|
|
|
+
|
|
|
|
|
+ public const String DISABLE = "0";
|
|
|
|
|
+ public const String ENABLE = "1";
|
|
|
|
|
+
|
|
|
|
|
+ public const String MONEY_GET = "0";
|
|
|
|
|
+ public const String SUBS_GET = "1";
|
|
|
|
|
+ public const int MAX_GET = 2;
|
|
|
|
|
+ public const int MAX_TABLE = 5;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public const String ONLY_REVEUNUE = "0";
|
|
|
|
|
+ public const String ALL_REVEUNUE = "1";
|
|
|
|
|
+ public const int MAX_FILE = 2;
|
|
|
|
|
+ public const String PAYMENT_FILE = "0";
|
|
|
|
|
+ public const String INVOICE_FILE = "1";
|
|
|
|
|
+
|
|
|
|
|
+ public const String SHOW_FILE = "1";
|
|
|
|
|
+ public const String SAVE_FILE = "2";
|
|
|
|
|
+
|
|
|
|
|
+ public const String DISABLE_GET_DATA = "0";
|
|
|
|
|
+ public const String ENABLE_GET_DATA_AND_WARNING = "1";
|
|
|
|
|
+ public const String ENABLE_GET_DATA_AND_NOT_WARNING = "2";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertNameTable(String tableType)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (tableType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "1": return "Cấu hình người gửi";
|
|
|
|
|
+ case "2": return "Cấu hình người nhận";
|
|
|
|
|
+ case "3": return "Cấu hình lập lịch gửi";
|
|
|
|
|
+ case "4": return "Cấu hình configuration";
|
|
|
|
|
+ case "5": return "Cấu hình gửi email";
|
|
|
|
|
+ case "6": return "Cấu hình thêm mới dịch vụ";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ public static String convertNameTypeGet(String typeGet)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (typeGet)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "0": return "Money Report";
|
|
|
|
|
+ case "1": return "Subscribers Report";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertScheduleStatus(int status)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (status)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0: return "Disable";
|
|
|
|
|
+ case 1: return "Reminder one time";
|
|
|
|
|
+ case 2: return "Reminder hour by hour";
|
|
|
|
|
+ case 3: return "Reminder day by day";
|
|
|
|
|
+ case 4: return "Reminder week by week";
|
|
|
|
|
+ case 5: return "Reminder month by month";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertBotStatus(int status)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (status)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0: return "Disable";
|
|
|
|
|
+ case 1: return "Get and warning";
|
|
|
|
|
+ case 2: return "Get and not warning";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertServiceState(int state)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (state)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0: return "Không";
|
|
|
|
|
+ case 1: return "Có";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertGroupStatus(int status)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (status)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0: return "Disable";
|
|
|
|
|
+ case 1: return "Communication";
|
|
|
|
|
+ case 2: return "Alarm";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertSendMailStatus(int status)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (status)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0: return "Disable";
|
|
|
|
|
+ case 1: return "Enable";
|
|
|
|
|
+ default: return "NULL";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static string ConvertListType(String type)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (type)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "0": return "Payment file";
|
|
|
|
|
+ case "1": return "Invoice file";
|
|
|
|
|
+ default: return type + " Unknown";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String ReadDocFileToHtml()
|
|
|
|
|
+ {
|
|
|
|
|
+ String html = System.IO.File.ReadAllText("./resources/payment_code_all.html");
|
|
|
|
|
+ return html;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static bool InvoiceNatcomInterlandDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
|
|
|
|
|
+ "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ // Creating a new document.
|
|
|
|
|
+ WordDocument document = new WordDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // Setting document page margins.
|
|
|
|
|
+ MarginsF pagemargins = new MarginsF();
|
|
|
|
|
+ pagemargins.Bottom = 20;
|
|
|
|
|
+ pagemargins.Top = 20;
|
|
|
|
|
+ pagemargins.Left = 75;
|
|
|
|
|
+ pagemargins.Right = 75;
|
|
|
|
|
+ // Assigning document page margins to the current section.
|
|
|
|
|
+
|
|
|
|
|
+ IWSection section = document.AddSection();
|
|
|
|
|
+ section.PageSetup.Margins = pagemargins;
|
|
|
|
|
+ section.AddParagraph();
|
|
|
|
|
+ IWTable table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ int rowNum = 7, columnNum = 2;
|
|
|
|
|
+ RowFormat format = new RowFormat();
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ float tableWidth = table.Width;
|
|
|
|
|
+
|
|
|
|
|
+ //table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
|
|
|
|
|
+ table.Rows[0].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[0].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[2].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[2].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[4].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[4].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ if (i == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (j == 6)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (j == 1 || j == 2 || j == 5 || j == 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (j == 6)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (j == 1 || j == 2 || j == 5 || j == 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ table.ApplyHorizontalMerge(0, 0, 1);
|
|
|
|
|
+ IWParagraph para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ IWTextRange textRange = para.AppendText("COMMERCIAL INVOICE");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 16;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //para = table[0, 0].AddParagraph();
|
|
|
|
|
+ //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ //textRange = para.AppendText("No: " + convertTime.ToString("ddMMyyyy") + "-" + contract.id);
|
|
|
|
|
+ //textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ //textRange.CharacterFormat.FontSize = 13;
|
|
|
|
|
+ //textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("DATE OF EXPORT");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(convertTime.ToString("MMMM/yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("INVOICE NUMBER: " + convertTime.ToString("MM") + contract.id + "/" + convertTime.ToString("yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //para = table[1, 1].AddParagraph();
|
|
|
|
|
+ //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ //String d1 = (int.Parse(contract.id) < 10 ? "0" + contract.id : contract.id) + "/VTL-" + contract.syntaxConpany + "/VAS/" + convertTime.ToString("yyyy");
|
|
|
|
|
+ //textRange = para.AppendText(convertTime.ToString("MM") + contract.id + "/" + convertTime.ToString("yyyy"));
|
|
|
|
|
+ //textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ //textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ //textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("PROVIDER");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("BUYER");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("NAME: " + contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Address: " + contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ //para = table[3, 0].AddParagraph();
|
|
|
|
|
+ //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ //textRange = para.AppendText("Tax code: " + "0108453894");
|
|
|
|
|
+ //textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ //textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ //textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("NAME: " + contract.telco);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Address: " + contract.addressTelco);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ //para = table[3, 1].AddParagraph();
|
|
|
|
|
+ //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ //textRange = para.AppendText("Tax code: " + "1150150");
|
|
|
|
|
+ //textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ //textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ //textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("DEFINITION OF PAYMENT");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ IWTable table2 = table[4, 1].AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 3;
|
|
|
|
|
+ table2.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table2.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table2.Rows[j].Cells[i];
|
|
|
|
|
+ if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ IWParagraph para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("QUANTITY");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("UNIT PRICE (USD)");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("TOTAL (USD)");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+ para = table[5, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(contract.service + " SHARING REVENUE OF " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para = table[5, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table2 = table[5, 1].AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 3;
|
|
|
|
|
+ table2.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table2.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table2.Rows[j].Cells[i];
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("1");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("TOTAL");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("By word:");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
|
|
|
|
|
+ textRange = para.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(ConvertAmount(double.Parse(contract.money)) + " Dollars.");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 0].AddParagraph();
|
|
|
|
|
+ para = table[6, 1].AddParagraph();
|
|
|
|
|
+ // content
|
|
|
|
|
+ //Appends paragraph.
|
|
|
|
|
+
|
|
|
|
|
+ IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Please remit payment to:") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 5; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Name of Beneficiary");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.beneficiary);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Address");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Name of Beneficiary’s bank");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.bank);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Account number");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.account);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("SWIFT Code");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.swiftCode);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ table.TableFormat.Borders.Color = Color.White;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.6 : tableWidth * 0.4);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("SIGNATURE");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Saves the Word document to MemoryStream
|
|
|
|
|
+ MemoryStream stream = new MemoryStream();
|
|
|
|
|
+ document.Save(stream, FormatType.Docx);
|
|
|
|
|
+ stream.Position = 0;
|
|
|
|
|
+
|
|
|
|
|
+ bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool PaymentNatcomAllDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "dd/MM/yyyy", "dd-MMM-yyyy" };
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ // Creating a new document.
|
|
|
|
|
+ WordDocument document = new WordDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // Setting document page margins.
|
|
|
|
|
+ MarginsF pagemargins = new MarginsF();
|
|
|
|
|
+ pagemargins.Bottom = 20;
|
|
|
|
|
+ pagemargins.Top = 20;
|
|
|
|
|
+ pagemargins.Left = 75;
|
|
|
|
|
+ pagemargins.Right = 75;
|
|
|
|
|
+ // Assigning document page margins to the current section.
|
|
|
|
|
+
|
|
|
|
|
+ IWSection section = document.AddSection();
|
|
|
|
|
+ section.PageSetup.Margins = pagemargins;
|
|
|
|
|
+ section.AddParagraph();
|
|
|
|
|
+ IWTable table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ int rowNum = 1, columnNum = 2;
|
|
|
|
|
+ RowFormat format = new RowFormat();
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? table.Width * 0.5 : table.Width * 0.5);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IWParagraph para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ IWTextRange textRange = para.AppendText(contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //textRange = table[0, 0].AddParagraph().AppendText("");
|
|
|
|
|
+
|
|
|
|
|
+ String d1 = "NO: " + "07/2019" + "/" + "MTV " + contract.syntaxConpany + "NV - " + contract.syntaxTelco + " - " + contract.service;
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText(d1);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("SOCIALIST REPUBLIC OF VIETNAM");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Freedom - Equality - Fraternity");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = table[0, 1].AddParagraph().AppendText("");
|
|
|
|
|
+
|
|
|
|
|
+ String d2 = "Hanoi, " + convertTime.ToString("dd-MMMM, yyyy");
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText(d2);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
|
|
+ //Appends paragraph.
|
|
|
|
|
+ IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = paragraph.AppendText("PAYMENT REQUEST") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 15;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = paragraph.AppendText("To " + contract.telco) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 15;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "According to the contract No ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.contractCode) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(" service provision contract and if there is content of contract") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(" regarding to providing service on " + contract.syntaxTelco + " Mobile network between " + contract.syntaxTelco + " and ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.company + ".") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "According to COMMERCIAL INVOICE No: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ String d3 = convertTime.ToString("ddMMyyyy") + "-" + contract.id + " " + contract.service;
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(d3) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "According to Form of Yield Confirmation – Income of ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.service) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" Service between " + contract.telco + " and ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.company) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" for month ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(convertTime.AddMonths(-1).ToString("MMMM yyyy") + ".") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + contract.syntaxTelco + " must make payment to " + contract.company + " for " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + " : ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.company) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" for ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(convertTime.ToString("MMMM yyyy") + " : ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "$ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Total : $ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("In words : " + ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Thus, you are requested to transfer the payment above and fax us the T/T remittance once available ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Payment method and currency : Telegraphic in USD") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ rowNum = 5; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ float tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
|
|
|
|
|
+
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Beneficiary");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Address");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Account No.");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Bank");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Swift Code");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ /////--------------
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.beneficiary);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.account);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.bank);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.swiftCode);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Best Regards, ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ table.TableFormat.Borders.Color = Color.White;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.2 : tableWidth * 0.8);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Director");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Saves the Word document to MemoryStream
|
|
|
|
|
+ MemoryStream stream = new MemoryStream();
|
|
|
|
|
+ document.Save(stream, FormatType.Docx);
|
|
|
|
|
+ stream.Position = 0;
|
|
|
|
|
+
|
|
|
|
|
+ bool exists = Directory.Exists("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ Directory.CreateDirectory("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream outputStream = new FileStream("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_payment_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool PaymentDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "dd/MM/yyyy", "dd-MMM-yyyy" };
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ int coChu = 12;
|
|
|
|
|
+
|
|
|
|
|
+ // Creating a new document.
|
|
|
|
|
+ WordDocument document = new WordDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // Setting document page margins.
|
|
|
|
|
+ MarginsF pagemargins = new MarginsF();
|
|
|
|
|
+ pagemargins.Bottom = 20;
|
|
|
|
|
+ pagemargins.Top = 20;
|
|
|
|
|
+ pagemargins.Left = 75;
|
|
|
|
|
+ pagemargins.Right = 75;
|
|
|
|
|
+ // Assigning document page margins to the current section.
|
|
|
|
|
+
|
|
|
|
|
+ IWSection section = document.AddSection();
|
|
|
|
|
+ section.PageSetup.Margins = pagemargins;
|
|
|
|
|
+ section.AddParagraph();
|
|
|
|
|
+ IWTable table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ int rowNum = 1, columnNum = 2;
|
|
|
|
|
+ RowFormat format = new RowFormat();
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? table.Width * 0.5 : table.Width * 0.5);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IWParagraph para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ IWTextRange textRange = para.AppendText(contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //textRange = table[0, 0].AddParagraph().AppendText("");
|
|
|
|
|
+
|
|
|
|
|
+ String d1 = "NO: " + convertTime.ToString(contract.syntaxConpany == "GTS" ? "ddMM/yyyy" : "MM/yyyy") + "/" + contract.syntaxConpany + " - " + contract.syntaxTelco + " - " + contract.service;
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText(d1);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("SOCIALIST REPUBLIC OF VIETNAM");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Freedom - Equality - Fraternity");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = table[0, 1].AddParagraph().AppendText("");
|
|
|
|
|
+
|
|
|
|
|
+ String d2 = "Hanoi, " + convertTime.ToString("dd-MMMM, yyyy");
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText(d2);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
|
|
+ //Appends paragraph.
|
|
|
|
|
+ IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = paragraph.AppendText("PAYMENT REQUEST") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 15;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("To: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.telco) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Taxtcode: 1150150") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("According to the contract " + contract.contractCode) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(" service provision contract and content of contract") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(" regarding to providing " + contract.service + " service on " + contract.syntaxTelco + " Mobile network between " + contract.syntaxTelco + " and " + contract.company + ".") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ String d3 = convertTime.ToString(contract.syntaxConpany == "ITL" || contract.syntaxConpany == "INTERLAND" ? "yyyyMMdd" : "ddMMyyyy") + "-" + contract.id;
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "According to COMMERCIAL INVOICE No: " + d3) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "According to Form of Yield Confirmation – Income of " + contract.service + " Service between " + contract.syntaxTelco + " and " + contract.company + " for month " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + ".") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + contract.syntaxTelco + " must make payment to " + contract.company + " for " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + " : ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("$ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Total : $ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("In words : ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ if (contract.contractCode == "VIETTECH")
|
|
|
|
|
+ {
|
|
|
|
|
+ textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " United States Dollars.") as WTextRange;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (contract.contractCode == "ITL" || contract.contractCode == "INTERLAND")
|
|
|
|
|
+ {
|
|
|
|
|
+ textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " USD.") as WTextRange;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
|
|
|
|
|
+ }
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ textRange.CharacterFormat.Italic = true;
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Thus, you are requested to transfer the payment above and fax us the T/T remittance once available ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(" " + "Payment method and currency : Telegraphic in USD") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ rowNum = 5; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ float tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
|
|
|
|
|
+
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Name of Beneficiary" : "Beneficiary");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Address");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Bank account:" : "Account No.");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Bank Name" : "Bank");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Swift Code:");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ /////--------------
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.beneficiary);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.account);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.bank);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.swiftCode);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Best Regards, ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ table.TableFormat.Borders.Color = Color.White;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.2 : tableWidth * 0.8);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Director");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = coChu;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Saves the Word document to MemoryStream
|
|
|
|
|
+ MemoryStream stream = new MemoryStream();
|
|
|
|
|
+ document.Save(stream, FormatType.Docx);
|
|
|
|
|
+ stream.Position = 0;
|
|
|
|
|
+
|
|
|
|
|
+ bool exists = Directory.Exists("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ Directory.CreateDirectory("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream outputStream = new FileStream("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_payment_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool InvoiceGTSDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
|
|
|
|
|
+ "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ // Creating a new document.
|
|
|
|
|
+ WordDocument document = new WordDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // Setting document page margins.
|
|
|
|
|
+ MarginsF pagemargins = new MarginsF();
|
|
|
|
|
+ pagemargins.Bottom = 20;
|
|
|
|
|
+ pagemargins.Top = 20;
|
|
|
|
|
+ pagemargins.Left = 75;
|
|
|
|
|
+ pagemargins.Right = 75;
|
|
|
|
|
+ // Assigning document page margins to the current section.
|
|
|
|
|
+
|
|
|
|
|
+ IWSection section = document.AddSection();
|
|
|
|
|
+ section.PageSetup.Margins = pagemargins;
|
|
|
|
|
+ section.AddParagraph();
|
|
|
|
|
+ IWTable table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ int rowNum = 1, columnNum = 2;
|
|
|
|
|
+ RowFormat format = new RowFormat();
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? table.Width * 0.65 : table.Width * 0.35);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IWParagraph para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ IWTextRange textRange = para.AppendText(contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Add: " + contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Registration Number: ");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("0108079693");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ // Gets the image stream.
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ FileStream imageStream = new FileStream("./resources/gts.jpg", FileMode.Open, FileAccess.Read);
|
|
|
|
|
+ IWPicture picture = para.AppendPicture(imageStream);
|
|
|
|
|
+ picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
|
|
|
|
|
+ picture.VerticalOrigin = VerticalOrigin.Margin;
|
|
|
|
|
+ //picture.VerticalPosition = -45;
|
|
|
|
|
+ //picture.HorizontalOrigin = HorizontalOrigin.Column;
|
|
|
|
|
+ //picture.HorizontalPosition = 263.5f;
|
|
|
|
|
+ //picture.WidthScale = 20;
|
|
|
|
|
+ //picture.HeightScale = 15;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
|
|
+ //Appends paragraph.
|
|
|
|
|
+ IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = paragraph.AppendText("INVOICE") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 25;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+ textRange.CharacterFormat.TextColor = Color.Orange;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ float tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Dot;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("No: ");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 15;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(convertTime.ToString("ddMMyyyy") + "-" + contract.id);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 13;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Date: ");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 15;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(convertTime.ToString("dd/MM/yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 13;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.telco) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Address: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText("CBD 4 Timor Plaza, Comoro, Dili, Timor Leste") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Tax Registration No : ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText("1150150") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Attention: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText("Mr. Tran Van Bang") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Contract: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.contractCode) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 2; columnNum = 3;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.1 : i == 1 ? tableWidth * 0.6 : tableWidth * 0.3);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Dot;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("No");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 14;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Description");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 14;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("Amount");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 14;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("1");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 14;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("USD " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 14;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("In writing: " + ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Following is the Payment reference:") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("- Name of Bank: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.bank) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("- Address: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.address) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("- Swift Code: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.swiftCode) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("- Account No: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.account) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("- Account holdere: ") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ textRange = paragraph.AppendText(contract.beneficiary) as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ table.TableFormat.Borders.Color = Color.White;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("DIRECTOR");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 17;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Saves the Word document to MemoryStream
|
|
|
|
|
+ MemoryStream stream = new MemoryStream();
|
|
|
|
|
+ document.Save(stream, FormatType.Docx);
|
|
|
|
|
+ stream.Position = 0;
|
|
|
|
|
+
|
|
|
|
|
+ bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool InvoiceVTECHDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
|
|
|
|
|
+ "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ // Creating a new document.
|
|
|
|
|
+ WordDocument document = new WordDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // Setting document page margins.
|
|
|
|
|
+ MarginsF pagemargins = new MarginsF();
|
|
|
|
|
+ pagemargins.Bottom = 20;
|
|
|
|
|
+ pagemargins.Top = 20;
|
|
|
|
|
+ pagemargins.Left = 75;
|
|
|
|
|
+ pagemargins.Right = 75;
|
|
|
|
|
+ // Assigning document page margins to the current section.
|
|
|
|
|
+
|
|
|
|
|
+ IWSection section = document.AddSection();
|
|
|
|
|
+ section.PageSetup.Margins = pagemargins;
|
|
|
|
|
+ section.AddParagraph();
|
|
|
|
|
+ IWTable table = section.AddTable();
|
|
|
|
|
+
|
|
|
|
|
+ int rowNum = 7, columnNum = 2;
|
|
|
|
|
+ RowFormat format = new RowFormat();
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ float tableWidth = table.Width;
|
|
|
|
|
+
|
|
|
|
|
+ //table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
|
|
|
|
|
+ table.Rows[0].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[0].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[2].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[2].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[4].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+ table.Rows[4].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ if (i == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (j == 6)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (j == 1 || j == 2 || j == 5 || j == 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (j == 6)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (j == 1 || j == 2 || j == 5 || j == 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ table.ApplyHorizontalMerge(0, 0, 1);
|
|
|
|
|
+ IWParagraph para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+
|
|
|
|
|
+ IWTextRange textRange = para.AppendText("COMMERCIAL INVOICE");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 16;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("No: " + convertTime.ToString("ddMMyyyy") + "-" + contract.id);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 13;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("DATE OF EXPORT");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(convertTime.ToString("dd/MM/yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("CONTRACT");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ //String d1 = (int.Parse(contract.id) < 10 ? "0" + contract.id : contract.id) + "/VTL-" + contract.syntaxConpany + "/VAS/" + convertTime.ToString("yyyy");
|
|
|
|
|
+ String d1 = contract.contractCode;
|
|
|
|
|
+ textRange = para.AppendText(d1);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("PROVIDER");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("BUYER");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("NAME: " + contract.company);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Address: " + contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Tax code: " + "0108453894");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("NAME: " + contract.telco);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Address: " + contract.addressTelco + ".");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("Tax code: " + "1150150");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("DEFINITION OF PAYMENT");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ IWTable table2 = table[4, 1].AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 3;
|
|
|
|
|
+ table2.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table2.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table2.Rows[j].Cells[i];
|
|
|
|
|
+ if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ IWParagraph para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("QUANTITY");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("UNIT PRICE (USD)");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("TOTAL (USD)");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 10;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+ para = table[5, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para = table[5, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+ table2 = table[5, 1].AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 3;
|
|
|
|
|
+ table2.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table2.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table2.Rows[j].Cells[i];
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText("1");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 0].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 1].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+ para2 = table2[0, 2].AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("TOTAL");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 12;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText("By word:");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
|
|
|
|
|
+ textRange = para.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[6, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = para.AppendText(ConvertAmount(double.Parse(contract.money)) + " Dollars.");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
|
|
+ //Appends paragraph.
|
|
|
|
|
+
|
|
|
|
|
+ IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+ textRange = paragraph.AppendText("Please remit payment to:") as WTextRange;
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 5; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
|
|
|
|
|
+ cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
|
|
|
|
|
+ cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Name of Beneficiary");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.beneficiary);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Address");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[1, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.address);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Name of Beneficiary’s bank");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[2, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.bank);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("Account number");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[3, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.account);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 0].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText("SWIFT Code");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ para = table[4, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
|
|
|
|
|
+
|
|
|
|
|
+ textRange = para.AppendText(contract.swiftCode);
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = false;
|
|
|
|
|
+
|
|
|
|
|
+ paragraph = section.AddParagraph();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ table = section.AddTable();
|
|
|
|
|
+ rowNum = 1; columnNum = 2;
|
|
|
|
|
+ table.ResetCells(rowNum, columnNum);
|
|
|
|
|
+ table.TableFormat.HorizontalAlignment = RowAlignment.Center;
|
|
|
|
|
+ tableWidth = table.Width;
|
|
|
|
|
+ table.TableFormat.Borders.Color = Color.White;
|
|
|
|
|
+ for (int i = 0; i < columnNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < rowNum; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ WTableCell cell = table.Rows[j].Cells[i];
|
|
|
|
|
+ cell.Width = (float)(i == 0 ? tableWidth * 0.6 : tableWidth * 0.4);
|
|
|
|
|
+ cell.CellFormat.Paddings.Top = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Bottom = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Left = 5;
|
|
|
|
|
+ cell.CellFormat.Paddings.Right = 5;
|
|
|
|
|
+ cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ para = table[0, 1].AddParagraph();
|
|
|
|
|
+ para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
|
|
+ textRange = para.AppendText("SIGNATURE");
|
|
|
|
|
+ textRange.CharacterFormat.FontName = "Times New Roman";
|
|
|
|
|
+ textRange.CharacterFormat.FontSize = 11;
|
|
|
|
|
+ textRange.CharacterFormat.Bold = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Saves the Word document to MemoryStream
|
|
|
|
|
+ MemoryStream stream = new MemoryStream();
|
|
|
|
|
+ document.Save(stream, FormatType.Docx);
|
|
|
|
|
+ stream.Position = 0;
|
|
|
|
|
+
|
|
|
|
|
+ bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool InvoiceITLDumpt(Contract contract)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
|
|
|
|
|
+ "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
|
|
|
|
|
+
|
|
|
|
|
+ DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
|
|
|
|
|
+ CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
|
|
|
|
+
|
|
|
|
|
+ ExcelEngine excelEngine = new ExcelEngine();
|
|
|
|
|
+ int rowCount = 1;
|
|
|
|
|
+ IApplication application = excelEngine.Excel;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ application.DefaultVersion = ExcelVersion.Excel2013;
|
|
|
|
|
+ IWorkbook workbook = application.Workbooks.Create(1);
|
|
|
|
|
+ IWorksheet worksheet = workbook.Worksheets[0];
|
|
|
|
|
+
|
|
|
|
|
+ List<RowAttributed> rowAttributedList = new List<RowAttributed>();
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range["A1"].ColumnWidth = 3;
|
|
|
|
|
+ worksheet.Range["B1"].ColumnWidth = 50;
|
|
|
|
|
+ worksheet.Range["C1"].ColumnWidth = 8;
|
|
|
|
|
+ worksheet.Range["D1"].ColumnWidth = 14;
|
|
|
|
|
+ worksheet.Range["E1"].ColumnWidth = 18;
|
|
|
|
|
+ worksheet.Range["F1"].ColumnWidth = 30;
|
|
|
|
|
+
|
|
|
|
|
+ //Defining body style
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle bodyStyle = workbook.Styles.Add("BodyStyle");
|
|
|
|
|
+ bodyStyle.BeginUpdate();
|
|
|
|
|
+ bodyStyle.Color = Color.FromArgb(255, 255, 255);
|
|
|
|
|
+ bodyStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.None;
|
|
|
|
|
+ bodyStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.None;
|
|
|
|
|
+ bodyStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.None;
|
|
|
|
|
+ bodyStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.None;
|
|
|
|
|
+ bodyStyle.EndUpdate();
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range["A1:F39"].CellStyle = bodyStyle;
|
|
|
|
|
+
|
|
|
|
|
+ // style
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTableCenterBold = workbook.Styles.Add("table-center-bold");
|
|
|
|
|
+ cellStyleTableCenterBold.Font.Size = 12;
|
|
|
|
|
+ cellStyleTableCenterBold.Font.Bold = true;
|
|
|
|
|
+ cellStyleTableCenterBold.Font.FontName = "Roboto";
|
|
|
|
|
+ cellStyleTableCenterBold.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
|
|
+ cellStyleTableCenterBold.VerticalAlignment = ExcelVAlign.VAlignCenter;
|
|
|
|
|
+ cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTableCenterNormal = workbook.Styles.Add("table-center-normal");
|
|
|
|
|
+ cellStyleTableCenterNormal.Font.Size = 12;
|
|
|
|
|
+ cellStyleTableCenterNormal.Font.Bold = false;
|
|
|
|
|
+ cellStyleTableCenterNormal.Font.FontName = "Roboto";
|
|
|
|
|
+ cellStyleTableCenterNormal.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
|
|
+ cellStyleTableCenterNormal.VerticalAlignment = ExcelVAlign.VAlignCenter;
|
|
|
|
|
+ cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTextBold = workbook.Styles.Add("text-bold");
|
|
|
|
|
+ cellStyleTextBold.Font.Size = 12;
|
|
|
|
|
+ cellStyleTextBold.Font.Bold = true;
|
|
|
|
|
+ cellStyleTextBold.Font.FontName = "Roboto";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTextBoldCenter = workbook.Styles.Add("text-bold-center");
|
|
|
|
|
+ cellStyleTextBoldCenter.Font.Size = 12;
|
|
|
|
|
+ cellStyleTextBoldCenter.Font.Bold = true;
|
|
|
|
|
+ cellStyleTextBoldCenter.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
|
|
+ cellStyleTextBoldCenter.Font.FontName = "Roboto";
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTextNormal = workbook.Styles.Add("text-normal");
|
|
|
|
|
+ cellStyleTextNormal.Font.Size = 12;
|
|
|
|
|
+ cellStyleTextNormal.Font.Bold = false;
|
|
|
|
|
+ cellStyleTextNormal.Font.FontName = "Roboto";
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyleTextNormalCenter = workbook.Styles.Add("text-normal-center");
|
|
|
|
|
+ cellStyleTextNormalCenter.Font.Size = 12;
|
|
|
|
|
+ cellStyleTextNormalCenter.Font.Bold = false;
|
|
|
|
|
+ cellStyleTextNormalCenter.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
|
|
+ cellStyleTextNormalCenter.Font.FontName = "Roboto";
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
|
|
|
|
|
+
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle rowStyle = workbook.Styles.Add("style1");
|
|
|
|
|
+ rowStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.None;
|
|
|
|
|
+ rowStyle.Color = Color.FromArgb(255, 174, 33);
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = rowStyle;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
|
|
|
|
|
+ rowStyle = workbook.Styles.Add("style2");
|
|
|
|
|
+ rowStyle.Color = Color.FromArgb(255, 0, 0);
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = rowStyle;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(1) + 39.ToString() + ":" + GetExcelColumnName(6) + 39.ToString()].CellStyle = rowStyle;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "INVOICE";
|
|
|
|
|
+ Syncfusion.XlsIO.IStyle cellStyle = workbook.Styles.Add("style3");
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].RowHeight = 120;
|
|
|
|
|
+ cellStyle.Font.Size = 24;
|
|
|
|
|
+ cellStyle.Font.Bold = true;
|
|
|
|
|
+ cellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyle;
|
|
|
|
|
+
|
|
|
|
|
+ //Adding a picture
|
|
|
|
|
+ FileStream imageStream = new FileStream("./resources/ITL.jpg", FileMode.Open, FileAccess.Read);
|
|
|
|
|
+ IPictureShape shape = worksheet.Pictures.AddPicture(6, 3, imageStream);
|
|
|
|
|
+
|
|
|
|
|
+ //Positioning a Picture
|
|
|
|
|
+ shape.Top = 60;
|
|
|
|
|
+ shape.Left = 700;
|
|
|
|
|
+
|
|
|
|
|
+ //Re-sizing a Picture
|
|
|
|
|
+ shape.Height = 160;
|
|
|
|
|
+ shape.Width = 180;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.company;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = convertTime.ToString("dd/MM/yyyy");
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.address;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].RowHeight = 40;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].WrapText = true;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = "INVOICE No." + convertTime.ToString("yyyyMMdd") + "-" + contract.id;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tax Code: 0107836502";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Email: vninterland@gmail.com";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ rowCount += 3;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "BILL TO";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].ColorRGB = Color.FromArgb(215, 215, 215);
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount += 3;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.telco;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.addressTelco;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tel: +670 76900005";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tax code: 1150150";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ rowCount ++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.contractCode;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
|
|
|
|
|
+ rowCount += 2;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "DESCRIPTION";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "QTY";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].Text = "UNIT PRICE (USD)";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = "TOTAL (USD)";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(2) + (rowCount + 1).ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy");
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(2) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(3) + rowCount.ToString() + ":" + GetExcelColumnName(3) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "1";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(4) + (rowCount + 1).ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString() + ":" + GetExcelColumnName(5) + (rowCount + 1).ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].Text = int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture);
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(5) + rowCount.ToString() + ":" + GetExcelColumnName(5) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString() + ":" + GetExcelColumnName(6) + (rowCount + 1).ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture);
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(6) + rowCount.ToString() + ":" + GetExcelColumnName(6) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterBold;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount += 2;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "By word: " + ConvertAmount(double.Parse(contract.money)) + " USD.";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount += 2;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = contract.company;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "DIRECTOR";
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
|
|
|
|
|
+ worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
|
|
|
|
|
+
|
|
|
|
|
+ rowCount++;
|
|
|
|
|
+
|
|
|
|
|
+ //Saving the workbook as stream
|
|
|
|
|
+ bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ if (!exists)
|
|
|
|
|
+ System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
|
|
|
|
|
+ FileStream stream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".xlsx", FileMode.Create, FileAccess.ReadWrite);
|
|
|
|
|
+ workbook.SaveAs(stream);
|
|
|
|
|
+ stream.Dispose();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exp: " + ex);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String[] units = { "Zero", "One", "Two", "Three",
|
|
|
|
|
+ "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
|
|
|
|
|
+ "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen",
|
|
|
|
|
+ "Seventeen", "Eighteen", "Nineteen" };
|
|
|
|
|
+
|
|
|
|
|
+ private static String[] unitsNormal = { "zero", "one", "two", "three",
|
|
|
|
|
+ "four", "five", "six", "seven", "eight", "nine", "ten", "eleven",
|
|
|
|
|
+ "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
|
|
|
|
|
+ "seventeen", "eighteen", "nineteen" };
|
|
|
|
|
+
|
|
|
|
|
+ private static String[] tens = { "", "", "Twenty", "Thirty", "Forty",
|
|
|
|
|
+ "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
|
|
|
|
|
+
|
|
|
|
|
+ private static String[] tensNormal = { "", "", "twenty", "thirty", "forty",
|
|
|
|
|
+ "fifty", "sixty", "seventy", "eighty", "ninety" };
|
|
|
|
|
+
|
|
|
|
|
+ public static String ConvertAmount(double amount)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ Int64 amount_int = (Int64)amount;
|
|
|
|
|
+ Int64 amount_dec = (Int64)Math.Round((amount - (double)(amount_int)) * 100);
|
|
|
|
|
+ if (amount_dec == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ return FirstLetterToUpperCase(ConvertEnglish(amount_int));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ return FirstLetterToUpperCase(ConvertEnglish(amount_int)) + " Point " + ConvertEnglish(amount_dec);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e)
|
|
|
|
|
+ {
|
|
|
|
|
+ // TODO: handle exception
|
|
|
|
|
+ }
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String ConvertEnglish(Int64 i)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i < 20)
|
|
|
|
|
+ {
|
|
|
|
|
+ return unitsNormal[i];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i < 100)
|
|
|
|
|
+ {
|
|
|
|
|
+ return tensNormal[i / 10] + ((i % 10 > 0) ? " " + ConvertEnglish(i % 10) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i < 1000)
|
|
|
|
|
+ {
|
|
|
|
|
+ return unitsNormal[i / 100] + " hundred"
|
|
|
|
|
+ + ((i % 100 > 0) ? " and " + ConvertEnglish(i % 100) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i < 100000)
|
|
|
|
|
+ {
|
|
|
|
|
+ return ConvertEnglish(i / 1000) + " thousand "
|
|
|
|
|
+ + ((i % 1000 > 0) ? " " + ConvertEnglish(i % 1000) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i < 10000000)
|
|
|
|
|
+ {
|
|
|
|
|
+ return ConvertEnglish(i / 100000) + " lakh "
|
|
|
|
|
+ + ((i % 100000 > 0) ? " " + ConvertEnglish(i % 100000) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i < 1000000000)
|
|
|
|
|
+ {
|
|
|
|
|
+ return ConvertEnglish(i / 10000000) + " crore "
|
|
|
|
|
+ + ((i % 10000000 > 0) ? " " + ConvertEnglish(i % 10000000) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ return ConvertEnglish(i / 1000000000) + " arab "
|
|
|
|
|
+ + ((i % 1000000000 > 0) ? " " + ConvertEnglish(i % 1000000000) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static List<String> StringSeprate(String input, int numCharacter)
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] words = input.Split(' ');
|
|
|
|
|
+ int counter = 0;
|
|
|
|
|
+ int countWord = 0;
|
|
|
|
|
+ String result = "";
|
|
|
|
|
+ String result2 = "";
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < words.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ int nextCounter = counter + words[i].Length;
|
|
|
|
|
+ if (nextCounter < numCharacter)
|
|
|
|
|
+ {
|
|
|
|
|
+ countWord++;
|
|
|
|
|
+ if (counter == 0)
|
|
|
|
|
+ result += words[i];
|
|
|
|
|
+ else
|
|
|
|
|
+ result += (" " + words[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ counter = nextCounter;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = countWord; i < words.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i == countWord)
|
|
|
|
|
+ result2 += words[i];
|
|
|
|
|
+ else
|
|
|
|
|
+ result2 += (" " + words[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> res = new List<string>();
|
|
|
|
|
+ res.Add(result);
|
|
|
|
|
+ res.Add(result2);
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static string FirstLetterToUpperCase(string s)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrEmpty(s))
|
|
|
|
|
+ throw new ArgumentException("There is no first letter");
|
|
|
|
|
+
|
|
|
|
|
+ char[] a = s.ToCharArray();
|
|
|
|
|
+ a[0] = char.ToUpper(a[0]);
|
|
|
|
|
+ return new string(a);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void SaveDocFile(String inputFileName)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Open an existing WordDocument
|
|
|
|
|
+ FileStream inputStream = new FileStream(inputFileName, FileMode.Open);
|
|
|
|
|
+ WordDocument document = new WordDocument(inputStream, FormatType.Docx);
|
|
|
|
|
+ //To-Do some manipulation
|
|
|
|
|
+ //To-Do some manipulation
|
|
|
|
|
+ //Saving the Word document
|
|
|
|
|
+ FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
|
|
|
|
+ document.Save(outputStream, FormatType.Docx);
|
|
|
|
|
+ document.Close();
|
|
|
|
|
+ outputStream.Flush();
|
|
|
|
|
+ outputStream.Dispose();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static void IterateTextBody(WTextBody textBody)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Iterates through each of the child items of WTextBody
|
|
|
|
|
+ for (int i = 0; i < textBody.ChildEntities.Count; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ //IEntity is the basic unit in DocIO DOM.
|
|
|
|
|
+ //Accesses the body items (should be either paragraph, table or block content control) as IEntity
|
|
|
|
|
+ IEntity bodyItemEntity = textBody.ChildEntities[i];
|
|
|
|
|
+ //A Text body has 3 types of elements - Paragraph, Table and Block Content Control
|
|
|
|
|
+ //Decides the element type by using EntityType
|
|
|
|
|
+ switch (bodyItemEntity.EntityType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case EntityType.Paragraph:
|
|
|
|
|
+ WParagraph paragraph = bodyItemEntity as WParagraph;
|
|
|
|
|
+ //Checks for particular style name and removes the paragraph from DOM
|
|
|
|
|
+ if (paragraph.StyleName == "MyStyle")
|
|
|
|
|
+ {
|
|
|
|
|
+ int index = textBody.ChildEntities.IndexOf(paragraph);
|
|
|
|
|
+ textBody.ChildEntities.RemoveAt(index);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EntityType.Table:
|
|
|
|
|
+ //Table is a collection of rows and cells
|
|
|
|
|
+ //Iterates through table's DOM
|
|
|
|
|
+ IterateTable(bodyItemEntity as WTable);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EntityType.BlockContentControl:
|
|
|
|
|
+ BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
|
|
|
|
|
+ //Iterates to the body items of Block Content Control.
|
|
|
|
|
+ IterateTextBody(blockContentControl.TextBody);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static string GetExcelColumnName(int columnNumber)
|
|
|
|
|
+ {
|
|
|
|
|
+ int dividend = columnNumber;
|
|
|
|
|
+ string columnName = String.Empty;
|
|
|
|
|
+ int modulo;
|
|
|
|
|
+
|
|
|
|
|
+ while (dividend > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ modulo = (dividend - 1) % 26;
|
|
|
|
|
+ columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
|
|
|
|
+ dividend = (int)((dividend - modulo) / 26);
|
|
|
|
|
+ }
|
|
|
|
|
+ return columnName;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static void IterateTable(WTable table)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Iterates the row collection in a table
|
|
|
|
|
+ foreach (WTableRow row in table.Rows)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Iterates the cell collection in a table row
|
|
|
|
|
+ foreach (WTableCell cell in row.Cells)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Table cell is derived from (also a) TextBody
|
|
|
|
|
+ //Reusing the code meant for iterating TextBody
|
|
|
|
|
+ IterateTextBody(cell);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static bool CheckFile(String path)
|
|
|
|
|
+ {
|
|
|
|
|
+ return File.Exists(path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void DeleteFile(String path)
|
|
|
|
|
+ {
|
|
|
|
|
+ File.Delete(path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static Byte[] GetFileByte(String path)
|
|
|
|
|
+ {
|
|
|
|
|
+ var dataBytes = File.ReadAllBytes(path);
|
|
|
|
|
+ return dataBytes;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static Dictionary<String, String> GetAttribute(String data)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Dictionary<String, String> attributes = new Dictionary<String, String>();
|
|
|
|
|
+ string[] seprateSpace = data.Split(" ");
|
|
|
|
|
+ for (int i = 0; i < seprateSpace.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ string[] seprateEqual = seprateSpace[i].Split("=\"");
|
|
|
|
|
+ if (seprateEqual.Length >= 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (seprateEqual[0] == "\"__VIEWSTATEGENERATOR\"")
|
|
|
|
|
+ {
|
|
|
|
|
+ attributes.Add(seprateEqual[0], seprateEqual[1].Remove(seprateEqual[1].Length - 1, 1));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Regex regex = new Regex("value=(['\"])(?:\\/.+?)\\1", RegexOptions.IgnoreCase);
|
|
|
|
|
+ Match match;
|
|
|
|
|
+ string value = seprateEqual[1];
|
|
|
|
|
+ for (match = regex.Match(seprateSpace[i]); match.Success; match = match.NextMatch())
|
|
|
|
|
+ {
|
|
|
|
|
+ string d = match.Groups[0].Value.Substring(7);
|
|
|
|
|
+ value = d.Remove(d.Length - 1, 1);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ attributes.Add(seprateEqual[0], value);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return attributes;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static List<KeyValuePair<string, string>> ParseDataRequest(String responseText)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ List<KeyValuePair<string, string>> data;
|
|
|
|
|
+ data = new List<KeyValuePair<string, string>>();
|
|
|
|
|
+
|
|
|
|
|
+ Regex regex = new Regex("<input.*?(?:name=\"*\".*?value=\"([^\"]+)| value =\"([^\"]+).*? name =\"*\")\"[^>]*>", RegexOptions.IgnoreCase);
|
|
|
|
|
+ Match match;
|
|
|
|
|
+ for (match = regex.Match(responseText); match.Success; match = match.NextMatch())
|
|
|
|
|
+ {
|
|
|
|
|
+ Dictionary<String, String> attrs = UtilsController.GetAttribute(match.Groups[0].Value);
|
|
|
|
|
+ String key = "";
|
|
|
|
|
+ String value = "";
|
|
|
|
|
+ foreach (KeyValuePair<string, string> item in attrs)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (item.Key == "name")
|
|
|
|
|
+ {
|
|
|
|
|
+ key = item.Value;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.Key == "value")
|
|
|
|
|
+ {
|
|
|
|
|
+ value = item.Value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!key.Contains("cmdTraCuu") && !key.Contains("__EVENTTARGET") && !key.Contains("__EVENTARGUMENT"))
|
|
|
|
|
+ {
|
|
|
|
|
+ string resultKey = Regex.Replace(key, @"[^\w\d]", "");
|
|
|
|
|
+ data.Add(new KeyValuePair<string, string>(resultKey, value));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|