Exemplo n.º 1
0
        public HRContractBLL(SqlConnection conn)
        {
            this.conn = conn;
            this.fontpath = Functions.GetAppConfigString("FontPath", "") + "\\simsun.ttc";
            this._templetbase = Functions.GetAppConfigString("TempletFileRootPath", "");
            this._fieldsInfo = PDFTemplet.LoadFromJSONFile(_templetbase+"\\TempletFields.json");

            ;
        }
Exemplo n.º 2
0
        private void GenerateFieldRow(PDFTemplet fieldsInfo,KeyValuePair<string, string> de)
        {
            string fieldKey = de.Value.ToString();//value!!!
            //string fieldValue = pdfReader.AcroFields.GetField(fieldKey);

            bool editable = fieldsInfo.GetItem(fieldKey).Editable;//该字段是否可以被编辑
            if (!editable) return;

            string showtitle = fieldsInfo.GetItem(fieldKey).FieldTitle;
            string note = fieldsInfo.GetItem(fieldKey).Note;

            TableRow row = new TableRow();

            TableCell cell_1 = new TableCell();
            TableCell cell_2 = new TableCell();

            Literal lt = new Literal();
            TextBox tb = new TextBox();
            Literal ltnote = new Literal();
            if (showtitle.Equals("")) showtitle = fieldKey;

            lt.Text = "<span title='" + fieldKey + "'>" + showtitle + "&nbsp;</span>:";
            tb.Text = "";// fieldValue;
            tb.ID = "txt_" + fieldKey; //textbox的命名为txt_fieldkey
            ltnote.Text = note;

            //this.Controls.Add(tb);

            cell_1.Controls.Add(lt);
            cell_2.Controls.Add(tb);
            cell_2.Controls.Add(ltnote);

            row.Cells.Add(cell_1);
            row.Cells.Add(cell_2);

            FieldsHolderTable.Rows.Add(row);
        }
Exemplo n.º 3
0
        private void CreateUI()
        {
            //获取字段模板配置信息(位于模板目录)
            if (!File.Exists(this._templetbase + "\\TempletFields.json")) {
                Response.Write("CreateUI.字段模板json文件不存在");
                return;
            }
               _fieldsInfo = PDFTemplet.LoadFromJSONFile(this._templetbase+"\\TempletFields.json");

               string docpath = Functions.ParseStr(ViewState["templetdocpath"]);
            if (docpath.Equals("")) return;

            //创建控件 from templetfile
            string templefile = this._templetbase + "\\" + this.CorpID + "\\" + docpath;
            if (!docpath.Equals(""))
                CreateFieldControls(_fieldsInfo, templefile);

            ////绑定数据db-->ui
            //string personid = Functions.ParseStr(ViewState["personid"]);
            //if (personid.Equals("")) return;
            //DataFromDBToUI(_fieldsInfo);
        }
Exemplo n.º 4
0
        //创建pdf中field对应的输入控件,依赖fieldsInfo中的字段属性
        private void CreateFieldControls(PDFTemplet fieldsInfo ,string templetefileserverpath)
        {
            this.FieldsHolderTable.Rows.Clear();

            PdfReader pdfReader = new PdfReader(templetefileserverpath);
            //将pdf中的字段,存在于fieldInfo中的,放入到sl中,其他放到dictionary中
            SortedList<string, string> sortedkeys = new SortedList<string, string>();
            Dictionary<string, string> unsortedkeys = new Dictionary<string, string>();
            foreach (DictionaryEntry de in pdfReader.AcroFields.Fields)
            {
                string fieldKey = de.Key.ToString();
                string ordervalue = fieldsInfo.GetItem(fieldKey).Order;
                if (ordervalue.Equals("-1")) { unsortedkeys.Add(fieldKey, fieldKey); }//key与value相同!!!
                else { sortedkeys.Add(ordervalue, fieldKey); }

            }
            //循环sorted list
            foreach (KeyValuePair<string, string> de in sortedkeys)
            {
                GenerateFieldRow(fieldsInfo, de);
            }
            //循环unsorted list
            foreach (KeyValuePair<string, string> de in unsortedkeys)
            {
                GenerateFieldRow(fieldsInfo, de);
            }
        }