void LoadCustomers()
        {
            CustomerService customerService = new CustomerService();
            customers = customerService.GetCustomers().OrderBy(x => x.CustCode).ToList();
            customers.Insert(0, new Customer() { Id = 0, CustomerName = "Tất cả", CustCode = "Tất cả"});

            cbmCustomers.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cbmCustomers.AutoCompleteSource = AutoCompleteSource.ListItems;
            cbmCustomers.DataSource = customers;
            cbmCustomers.DisplayMember = "CustCode";
            cbmCustomers.ValueMember = "Id";
        }
Exemplo n.º 2
0
        public HttpResponseMessage Invoice(string date, string number, string total, string emails, string clientNumber, string matter, string description)
        {
            byte[] pdf = null;
            using (var ms = new MemoryStream())
            {
                using (var doc = new Document())
                {
                    doc.SetMargins(60, 60, 40, 40);
                    PdfWriter.GetInstance(doc, ms);
                    doc.Open();

                    #region Header
                    var table = new PdfPTable(4) { WidthPercentage = 100 };
                    var colSizes = new List<float> { 120f, 130f, 140f };
                    colSizes.Add(doc.PageSize.Width - colSizes.Sum());
                    table.SetWidths(colSizes.ToArray());
                    table.AddCell(new PdfPCell
                    {
                        Image = Image.GetInstance(HttpContext.Current.Request.MapPath("~\\App_Data\\Logo.jpg")),
                        BorderColorRight = BaseColor.WHITE,
                        Rowspan = 3
                    });

                    table.AddCell(new PdfPCell(CreatePhrase("950 E. State Hwy 114\nSuite 160\nSouthlake, TX 76092"))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER,
                        VerticalAlignment = Element.ALIGN_MIDDLE,
                        Rowspan = 3
                    });

                    table.AddCell(CreateCell("Invoice Date", Element.ALIGN_RIGHT));
                    table.AddCell(CreateCell(date, Element.ALIGN_CENTER));
                    table.AddCell(CreateCell("Invoice Number", Element.ALIGN_RIGHT));
                    table.AddCell(CreateCell(number, Element.ALIGN_CENTER));
                    table.AddCell(CreateCell("Invoice Total", Element.ALIGN_RIGHT));
                    table.AddCell(CreateCell(total, Element.ALIGN_CENTER));
                    doc.Add(table);
                    #endregion

                    #region Emails
                    doc.Add(CreatePhrase(" "));
                    table = new PdfPTable(1) { WidthPercentage = 100 };
                    table.AddCell(CreateCell($"Invoice for {emails}", Element.ALIGN_CENTER));
                    doc.Add(table);
                    #endregion

                    #region Matters
                    doc.Add(CreatePhrase(" "));
                    table = new PdfPTable(4) { WidthPercentage = 100 };
                    colSizes = new List<float> { 120f, 130f, 80f };
                    colSizes.Insert(2, doc.PageSize.Width - colSizes.Sum());
                    table.SetWidths(colSizes.ToArray());

                    var columns = new List<string> { "Client", "Matter", "Description", "Amount" };                    
                    columns.ForEach(c =>
                    {
                        var cell = new PdfPCell
                        {
                            Phrase = CreatePhrase(c, headerFont),
                            HorizontalAlignment = Element.ALIGN_CENTER                                                    
                        };
                        table.AddCell(cell);
                    });

                    columns = new List<string> { clientNumber, matter, description, total };
                    columns.ForEach(c =>
                    {
                        table.AddCell(CreateCell(c, Element.ALIGN_CENTER));
                    });
                    doc.Add(table);
                    #endregion

                    #region Footer
                    doc.Add(CreatePhrase("\nIf you have any questions, please contact us at [email protected].\n"));
                    doc.Add(CreatePhrase("\nThank you for using SyncIDS.com!"));
                    #endregion
                }
                pdf = ms.ToArray();
            }  

            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new ByteArrayContent(pdf);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
            return response;
        }
Exemplo n.º 3
0
        protected static string mergeDocuments(string sourcepath, string destinationPath, int leadID, int claimID)
        {
            List<LeadsDocument> documents = null;
            List<ClaimDocument> claimDocuments = null;
            List<string> pdfs = new List<string>();

            string mergedReportPath = null;

            documents = LeadsUploadManager.getLeadsDocumentForExportByLeadID(leadID);
            claimDocuments = ClaimDocumentManager.GetAll(claimID);

            // add original document to list
            pdfs.Insert(0, sourcepath);

            // lead documents
            if (documents != null && documents.Count > 0) {

                List<string> leadPDFs = (from x in documents
                                 where x.DocumentName.Contains(".pdf")
                                 select string.Format("{0}/LeadsDocument/{1}/{2}/{3}", appPath, x.LeadId, x.LeadDocumentId, x.DocumentName)
                              ).ToList();

                foreach(string pdf in leadPDFs) {
                    pdfs.Add(pdf);
                }
            }

            // claim documents
            if (claimDocuments != null && claimDocuments.Count > 0) {

                List<string> claimPDFs = (from x in claimDocuments
                                    where x.DocumentName.Contains(".pdf")
                                    select string.Format("{0}/ClaimDocuments/{1}/{2}/{3}", appPath, x.ClaimID, x.ClaimDocumentID, x.DocumentName)
                              ).ToList();

                foreach (string pdf in claimPDFs) {
                    pdfs.Add(pdf);
                }
            }

            // mergedReportPath = Path.GetDirectoryName(sourcepath) + "\\" + Guid.NewGuid().ToString() + ".pdf";
            // mergePDFFiles(mergedReportPath, pdfs.ToArray());

            mergePDFFiles(destinationPath, pdfs.ToArray());

            return destinationPath;
        }
Exemplo n.º 4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string pdfPathSql = string.Empty;
            pathstr = User.rootpath + "\\" + drawing;
            if (!Directory.Exists(pathstr))//若文件夹不存在则新建文件夹
            {
                Directory.CreateDirectory(pathstr); //新建文件夹
            }
            DataSet ds = new DataSet();
            if (indicator == 0)
            {
                pdfPathSql = @"select t.pdfpath,t.spoolname
              from sp_pdf_tab t
             where t.spoolname in
               (select s.spoolname
              from sp_spool_tab s
             where s.flag = 'Y'
               and s.drawingno = '" + drawing + "' and s.projectid = '" + pid + "' ) and t.flag = 'Y' order by t.spoolname";
                User.DataBaseConnect(pdfPathSql, ds);
            }
            if (indicator == 1)
            {
                pdfPathSql = @"select t.pdfpath
              from sp_pdf_tab t
             where t.spoolname in
               (select s.spoolname
              from sp_spool_tab s
             where s.flag = 'Y'
               and s.MODIFYDRAWINGNO = '" + drawing + "' and s.projectid = '" + pid + "' ) and t.flag = 'Y' order by t.spoolname";
                User.DataBaseConnect(pdfPathSql, ds);
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string pdfpath = ds.Tables[0].Rows[i][0].ToString();
                if (string.IsNullOrEmpty(pdfpath))
                {
                    MessageBox.Show("该小票缺少目标存储地址,请与管理员联系!");
                    continue;
                }
                if (System.IO.File.Exists(@pdfpath))
                {
                    string filenamestr = pdfpath.Substring(pdfpath.LastIndexOf("\\"));
                    if (filenamestr.Contains("_"))
                    {
                        filenamestr = filenamestr.Substring(filenamestr.IndexOf("_") + 1);
                        System.IO.File.Copy(pdfpath, pathstr + "\\" + filenamestr, true);
                        //this.backgroundWorker1.ReportProgress(progressStr, String.Format("当前值是 {0} ", progressStr));
                        this.backgroundWorker1.ReportProgress(i + 1, String.Format("当前值是 {0} ", i + 1));
                    }
                    else
                    {
                        System.IO.File.Copy(pdfpath, pathstr + "\\" + filenamestr, true);
                        //this.backgroundWorker1.ReportProgress(progressStr, String.Format("当前值是 {0} ", progressStr));
                        this.backgroundWorker1.ReportProgress(i + 1, String.Format("当前值是 {0} ", i + 1));
                    }
                }
                else
                {
                    //MessageBox.Show("目标地址未能查找到该管路小票,请与管理员联系!");
                    continue;
                }
            }
            if (indicator == 0)
            {
                string drawingstatus = DBConnection.GetDrawingStatus("SP_GETDRAWINGSTATUS", drawing, version);
                if (drawingstatus == "1")
                {
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        string spoolstr = ds.Tables[0].Rows[j][1].ToString();
                        int page_no = j + 3;
                        DBConnection.InsertSpoolPageNo("SP_InsertSpoolPageNo", pid, drawing, spoolstr, page_no);
                    }
                }
            }
            ds.Dispose();

            pathstr = User.rootpath + "\\" + drawing;
            if (!Directory.Exists(pathstr))//若文件夹不存在则新建文件夹
            {
                MessageBox.Show("请确认小票是否已上传");
                return;
            }

            OracleDataReader dr = null;
            OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);
            conn.Open();
            OracleCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.Text;
            if (indicator == 0)
            {
                cmd.CommandText = "select UPDATEDFRONTPAGE from SP_CREATEPDFDRAWING where PROJECTID = '" + pid + "' AND DRAWINGNO = '" + drawing + "' and FLAG = 'Y'";
            }
            else
            {
                cmd.CommandText = "select MODIFYDRAWINGFRONTPAGE from SP_CREATEPDFDRAWING where PROJECTID = '" + pid + "' AND DRAWINGNO = '" + drawing + "' and FLAG = 'Y'";
            }
            dr = cmd.ExecuteReader();
            byte[] File = null;
            if (dr.Read())
            {
                File = (byte[])dr[0];
            }
            string filestr = User.rootpath + "\\" + drawing + "_frontpage" + ".pdf";
            FileStream fs = new FileStream(filestr, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(File, 0, File.Length);
            bw.Close();
            fs.Close();
            conn.Close();

            filename = PdfFiles();

            if (System.IO.File.Exists(pathstr + "\\" + drawing + "_frontpage" + ".pdf"))
            {
                filename.Insert(0, drawing + "_frontpage" + ".pdf");
                System.IO.File.Delete(filestr);
            }
            else
            {
                System.IO.File.Move(filestr, pathstr + "\\" + drawing + "_frontpage" + ".pdf");
                filename.Insert(0, drawing + "_frontpage" + ".pdf");
            }
            if (pid == "COSL H256")
            {
                if (indicator == 0)
                {
                    if (System.IO.File.Exists(pathstr + "\\" + drawing + "CSL4附图.pdf"))
                    {
                        filename.Insert(1, drawing + "CSL4附图.pdf");
                    }
                    else
                    {
                        System.IO.File.Copy(Application.StartupPath + "\\Resources\\CSL4附图.pdf", pathstr + "\\" + drawing + "CSL4附图.pdf");
                        filename.Insert(1, drawing + "CSL4附图.pdf");
                    }
                }
            }
            else
            {
                if (System.IO.File.Exists(pathstr + "\\" + drawing + "附图1.pdf"))
                {
                    filename.Insert(1, drawing + "附图1.pdf");
                }
                else
                {
                    System.IO.File.Copy(Application.StartupPath + "\\Resources\\附图1.pdf", pathstr + "\\" + drawing + "附图1.pdf");
                    filename.Insert(1, drawing + "附图1.pdf");
                }
            }
            if (pid == "COSL H256")
            {
                if (System.IO.File.Exists(pathstr + "\\" + drawing + "CSL4附图1.pdf"))
                {
                    filename.Add(drawing + "CSL4附图1.pdf");
                }
                else
                {
                    System.IO.File.Copy(Application.StartupPath + "\\Resources\\CSL4附图1.pdf", pathstr + "\\" + drawing + "CSL4附图1.pdf");
                    filename.Add(drawing + "CSL4附图1.pdf");
                }
            }
            else
            {
                if (System.IO.File.Exists(pathstr + "\\" + drawing + "附图2.pdf"))
                {
                    filename.Add(drawing + "附图2.pdf");
                }
                else
                {
                    System.IO.File.Copy(Application.StartupPath + "\\Resources\\附图2.pdf", pathstr + "\\" + drawing + "附图2.pdf");
                    filename.Add(drawing + "附图2.pdf");
                }
            }

            int totalpages = filename.Count;
            NoCount = totalpages + 1;
            if (pid == "COSL H256" && indicator == 1)
            {
                pageNoStr = "共" + NoCount.ToString() + "页";
            }
            else
            {
                pageNoStr = "共" + totalpages.ToString() + "页";
            }

            DirectoryInfo mydir = new DirectoryInfo(pathstr);
            FileInfo[] files = mydir.GetFiles();
            if (files.Length <= 1)
            {
                MessageBox.Show("数据库中暂没有查询到相关数据");
                this.Close();
                Directory.Delete(pathstr, true);
                return;
            }

            Thread.Sleep(1000);
            StartMerge(filename.ToArray(), pathstr + "\\" + drawing + ".pdf");
        }
Exemplo n.º 5
0
 private void LoadInitializeValues(Table pTable)
 {
     gComeMainForm = true;
     var vGroups = ProductGroup.GetAllProductGroups();
     var ucProductGroups = new ucProductGroups();
     ucProductGroups.SetGroups(vGroups, GroupClick);
     gbGroups.Controls.Add(ucProductGroups);
     cmbTables.ValueMember = "Id";
     cmbTables.DisplayMember = "TableName";
     tables = Table.GetAllTables();
     tables.Insert(0, new Table { Id = -1, TableName = "Seçiniz" });
     cmbTables.DataSource = tables;
     if (pTable != null)
     {
         cmbTables.SelectedValue = pTable.Id;
         gTable = pTable;
         if (pTable.Active)
         {
             LoadGrid(pTable.Id);
         }
     }
     gComeMainForm = false;
 }
Exemplo n.º 6
0
        /// <summary>
        /// 獲取賣場列表
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetChannel()
        {
            string json = String.Empty;
            List<Channel> store = new List<Channel>();

            try
            {
                Channel channel = new Channel();
                _channelMgr = new ChannelMgr(mySqlConnectionString);
                store = _channelMgr.QueryList(0);
                channel.channel_id = 0;
                channel.channel_name_simple = "全部";
                store.Insert(0, channel);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 7
0
        // 廠商下拉列表
        public HttpResponseBase GetVendorName()
        {
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            List<Vendor> stores = new List<Vendor>();
            string json = string.Empty;
            try
            {
                Vendor query = new Vendor();
                stores = _IiplasMgr.VendorQueryAll(query);

                query.vendor_name_simple = "所有廠商名稱";
                stores.Insert(0, query);
                json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 8
0
        public static bool Merge(List<PDFFiles> InFiles, string OutFile)
        {
            try
            {

                for(int i=0; i<InFiles.Count; i++)
                {
                    PdfReader reader = null;

                    reader = new PdfReader(InFiles[i].filePath);
                    if (!reader.IsOpenedWithFullPermissions)
                    {
                        string newUnlockedFile = unlockPDF(InFiles[i].filePath); //throw new System.IO.FileLoadException("Cannot merge because \"" + file.fileName + "\" is Locked for editing");
                        InFiles.Remove(InFiles[i]);
                        InFiles.Insert(i, new PDFFiles(newUnlockedFile));
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                throw ex;
            }
            catch (System.IO.FileLoadException)
            {
                throw;
            }
            catch
            {
                return false;
            }

            try
            {
                using (FileStream stream = new FileStream(OutFile, FileMode.Create))
                using (Document doc = new Document(PageSize.A4))
                using (PdfCopy pdf = new PdfCopy(doc, stream))
                {
                    doc.Open();

                    PdfReader reader = null;
                    PdfImportedPage page = null;

                    //fixed typo
                    InFiles.ForEach(file =>
                    {
                        reader = new PdfReader(file.filePath);                        

                        for (int i = 0; i < reader.NumberOfPages; i++)
                        {
                            page = pdf.GetImportedPage(reader, i + 1);
                            //doc.SetPageSize(page.Width <= page.Height ? PageSize.A4 : PageSize.A4.Rotate());
                            pdf.AddPage(page);
                        }

                        pdf.FreeReader(reader);
                        reader.Close();
                    });
                }
            }
            catch
            {
                return false;
            }


            ScaleToA4(OutFile, OutFile);
            return true;
        }