/// <summary>
        /// 生成图纸封面并插入到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void requestbtn_Click(object sender, EventArgs e)
        {
            string comText = string.Empty;
            string btntext = this.requestbtn.Text.ToString();
            string pid     = this.pidtb.Text.ToString();
            object drawno  = this.DRAWINGNOcomboBox.SelectedItem;

            if (drawno == null)
            {
                return;
            }
            else
            {
                switch (btntext)
                {
                case "生成封面":
                    string sqlstr = "SELECT count(*) FROM SP_CREATEPDFDRAWING T WHERE T.PROJECTID = '" + pid + "' AND T.DRAWINGNO = '" + drawno + "'";
                    object count  = User.GetScalar1(sqlstr, DataAccess.OIDSConnStr);
                    if (Convert.ToInt16(count) == 0)
                    {
                        comText = "INSERT INTO SP_CREATEPDFDRAWING (PROJECTID, DRAWINGNO, FRONTPAGE) VALUES ('" + pid + "', '" + drawno + "', :dfd)";
                        InsertFrontPage.GenerateFrontPage(comText);
                    }
                    else
                    {
                        DialogResult result = MessageBox.Show("该图纸封面已存在,确定要重新生成?", "WARNNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                        if (result == DialogResult.OK)
                        {
                            comText = "UPDATE SP_CREATEPDFDRAWING SET FRONTPAGE = :dfd WHERE PROJECTID = '" + pid + "' AND DRAWINGNO = '" + drawno + "'";
                            InsertFrontPage.GenerateFrontPage(comText);
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }
        private void Startbtn_Click(object sender, EventArgs e)
        {
            this.Startbtn.Enabled = false;
            this.Quitbtn.Enabled  = false;
            ArrayList imagelist = new ArrayList();

            object A = this.AttachFiledgv.Rows[0].Cells["StartPage"].Value;

            if (A != null)
            {
                traystart = A.ToString();
            }

            object B = this.AttachFiledgv.Rows[0].Cells["EndPage"].Value;

            if (B != null)
            {
                trayend = B.ToString();
            }

            object C = this.AttachFiledgv.Rows[1].Cells["StartPage"].Value;

            if (C != null)
            {
                partstart = C.ToString();
            }
            object D = this.AttachFiledgv.Rows[1].Cells["EndPage"].Value;

            if (D != null)
            {
                partend = D.ToString();
            }

            object E = this.AttachFiledgv.Rows[2].Cells["StartPage"].Value;

            if (E != null)
            {
                materialstart = E.ToString();
            }
            object F = this.AttachFiledgv.Rows[2].Cells["EndPage"].Value;

            if (F != null)
            {
                materialend = F.ToString();
            }

            object G = this.AttachFiledgv.Rows[3].Cells["StartPage"].Value;

            if (G != null)
            {
                weightstart = G.ToString();
            }
            object H = this.AttachFiledgv.Rows[3].Cells["EndPage"].Value;

            if (H != null)
            {
                weightend = H.ToString();
            }

            object J = this.AttachFiledgv.Rows[4].Cells["StartPage"].Value;

            if (J != null)
            {
                flangestart = J.ToString();
            }
            object K = this.AttachFiledgv.Rows[4].Cells["EndPage"].Value;

            if (K != null)
            {
                flangend = K.ToString();
            }

            DownLoadFrontPage();

            string pdfTemplate = User.rootpath + "\\" + drawing + ".pdf";

            if (string.IsNullOrEmpty(pdfTemplate))
            {
                return;
            }
            string     pdfnewfile    = pdfTemplate.Substring(0, pdfTemplate.LastIndexOf('.'));
            string     newFile       = pdfnewfile + "new.pdf";
            PdfReader  pdfReader     = new PdfReader(pdfTemplate);
            PdfStamper pdfStamper    = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
            AcroFields pdfFormFields = pdfStamper.AcroFields;
            string     cardstr       = GetImageName();

            string[] cardno = cardstr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i <= cardno.Length - 1; i++)
            {
                string chartLoc = string.Format(@"\\ecdms\sign$\jpg\{0}.jpg", cardno[i]);
                imagelist.Add(chartLoc);
            }
            Single X = 0, Y = 43;

            if (imagelist.Count == 0)
            {
                MessageBox.Show("系统没有查询到相关电子签名,请与管理员联系");
                return;
            }
            else if (imagelist.Count == 4)
            {
                foreach (string item in imagelist)
                {
                    iTextSharp.text.Image chartImg = iTextSharp.text.Image.GetInstance(item);
                    iTextSharp.text.pdf.PdfContentByte underContent;
                    iTextSharp.text.Rectangle          rect;

                    try
                    {
                        rect = pdfReader.GetPageSizeWithRotation(1);
                        X    = 190;
                        Y   += 13;
                        chartImg.ScalePercent(20);
                        chartImg.SetAbsolutePosition(X, Y);
                        underContent = pdfStamper.GetOverContent(1);
                        underContent.AddImage(chartImg);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }

            else if (imagelist.Count == 5)
            {
                for (int i = 0; i < imagelist.Count; i++)
                {
                    iTextSharp.text.Image chartImg = iTextSharp.text.Image.GetInstance(imagelist[i].ToString());
                    iTextSharp.text.pdf.PdfContentByte underContent;
                    iTextSharp.text.Rectangle          rect;
                    rect = pdfReader.GetPageSizeWithRotation(1);
                    chartImg.ScalePercent(20);
                    if (i == 0)
                    {
                        X = 190; Y = 56;
                    }
                    else if (i == 1)
                    {
                        X = 190; Y = 69;
                    }
                    else if (i == 2)
                    {
                        X = 180; Y = 82;
                    }
                    else if (i == 3)
                    {
                        X = 205; Y = 82;
                    }
                    else if (i == 4)
                    {
                        X = 190; Y = 95;
                    }
                    chartImg.SetAbsolutePosition(X, Y);
                    underContent = pdfStamper.GetOverContent(1);
                    underContent.AddImage(chartImg);
                }
            }

            else if (imagelist.Count == 6)
            {
                for (int i = 0; i < imagelist.Count; i++)
                {
                    iTextSharp.text.Image chartImg = iTextSharp.text.Image.GetInstance(imagelist[i].ToString());
                    iTextSharp.text.pdf.PdfContentByte underContent;
                    iTextSharp.text.Rectangle          rect;
                    rect = pdfReader.GetPageSizeWithRotation(1);
                    chartImg.ScalePercent(20);
                    if (i == 0)
                    {
                        X = 190; Y = 56;
                    }
                    else if (i == 1)
                    {
                        X = 180; Y = 69;
                    }
                    else if (i == 2)
                    {
                        X = 205; Y = 69;
                    }
                    else if (i == 3)
                    {
                        X = 180; Y = 82;
                    }
                    else if (i == 4)
                    {
                        X = 205; Y = 82;
                    }
                    else if (i == 5)
                    {
                        X = 190; Y = 95;
                    }
                    chartImg.SetAbsolutePosition(X, Y);
                    underContent = pdfStamper.GetOverContent(1);
                    underContent.AddImage(chartImg);
                }
            }

            InsertCharacteristics(pdfStamper, traystart, 340, 394);
            InsertCharacteristics(pdfStamper, trayend, 395, 394);

            InsertCharacteristics(pdfStamper, partstart, 340, 383);
            InsertCharacteristics(pdfStamper, partend, 395, 383);

            InsertCharacteristics(pdfStamper, materialstart, 340, 371);
            InsertCharacteristics(pdfStamper, materialend, 395, 371);

            InsertCharacteristics(pdfStamper, weightstart, 340, 360);
            InsertCharacteristics(pdfStamper, weightend, 395, 360);

            InsertCharacteristics(pdfStamper, flangestart, 340, 348);
            InsertCharacteristics(pdfStamper, flangend, 395, 348);

            pdfStamper.Close();
            pdfReader.Close();
            FileInfo fi = new FileInfo(pdfTemplate);

            fi.Delete();
            File.Move(newFile, pdfTemplate);

            Thread.Sleep(2000);
            string comText = "UPDATE SP_CREATEPDFDRAWING SET UPDATEDFRONTPAGE = :dfd WHERE PROJECTID = '" + projectid + "' AND DRAWINGNO = '" + drawing + "' and flag = 'Y'";

            InsertFrontPage.UpdateFrontPage(comText, User.rootpath + "\\" + drawing + ".pdf");
            FileInfo file = new FileInfo(pdfTemplate);

            file.Delete();

            this.Quitbtn.Enabled = true;
            this.Quitbtn.Text    = "完成";
        }