Beispiel #1
0
        /// <summary>
        /// 根据附件列表数据创建控件,设置样式,并添加至table
        /// </summary>
        /// <param name="objAttachList">附件列表</param>
        public void CreateAttachList(ObjAttachList[] objAttachList)
        {
            HtmlTable tb = CreateTable(0, 0, 0, "100%", null, null);
            int cols = 0;
            if (null != objAttachList && objAttachList.Length > 0)
            {
                foreach (ObjAttachList objAttach in objAttachList)
                {
                    { //创建显示标题
                        if (objAttach.AttachList != null && objAttach.AttachList.Length > 0)
                            TableCtrl.Controls.Add(CreateTop("附件"));
                    }
                    HtmlTableRow tr = new HtmlTableRow();
                    foreach (ObjAttach obj in objAttach.AttachList)
                    {
                        string name = obj.Name;
                        string url = obj.Url;
                        //三列自动换行
                        if ((cols % 3) == 0)
                        {
                            tr = new HtmlTableRow();
                            tr.Height = "20px";
                            tb.Controls.Add(tr);
                        }
                       
                        HtmlTableCell td = CreateTD(1, null, null, "billLink");

                        //创建链接
                        HtmlAnchor anchor = new HtmlAnchor();
                        anchor.HRef = url;
                        anchor.Target = "_bank";
                        anchor.InnerHtml = name;

                        td.Controls.Add(anchor);
                        tr.Controls.Add(td);
                        cols++;
                    }
                    
                }

            }

            TableCtrl.Rows.Add(AddTable(tb));
        }
Beispiel #2
0
        public static ObjBill CreateBill(string xml, ref string error)
        {
            ObjBill bill = new ObjBill();

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            //读取Form中的数据
            XmlNode nodeResult = doc.SelectSingleNode("//Result");
            if (nodeResult != null)
            {
                if (((XmlElement)nodeResult).GetAttribute("Code") != "0")
                {
                    error = ((XmlElement)nodeResult).InnerText.ToString();
                    throw new SmtException(((XmlElement)nodeResult).InnerText);
                }
                else
                {
                    XmlNode nodeForm = doc.SelectSingleNode("//Form");
                    bill.ModelCode = ((XmlElement)nodeForm).GetAttribute("ModelCode");
                    bill.OrderType = ((XmlElement)nodeForm).GetAttribute("OrderType");
                    bill.Text = ((XmlElement)nodeForm).GetAttribute("Text");
                    bill.FormID = ((XmlElement)nodeForm).GetAttribute("FormID");
                    bill.MessageStatus = ((XmlElement)nodeForm).GetAttribute("MESSAGESTATUS");
                    ObjBill schemaBill = DataManager<ObjBill>.Get(HttpContext.Current.Server.MapPath("BillSchema/" + bill.ModelCode + ".xml"));

                    XmlNode nodeObject = doc.SelectSingleNode("//Object");

                    { //读取主表数据

                        XmlNodeList list = nodeObject.SelectNodes("Attribute");
                        ObjDetailList detailList = new ObjDetailList();
                        detailList.ObjFieldList = new ObjField[list.Count];
                        foreach (var item in schemaBill.DetailLists)
                        {
                            item.Load();
                        }
                        for (int i = 0; i < list.Count; i++)
                        {
                            XmlElement node = list[i] as XmlElement;
                            string Name = ((XmlElement)node).GetAttribute("Name");
                            string Text = ((XmlElement)node).GetAttribute("Text");
                            string DataType = ((XmlElement)node).GetAttribute("DataType");
                            string DataValue = ((XmlElement)node).GetAttribute("DataValue");
                            string fgColor = string.Empty;
                            string Tooltip = string.Empty;
                            if (node.HasAttribute("Color"))
                            {
                                fgColor = node.GetAttribute("Color");
                            }
                            if (node.HasAttribute("Tooltip"))
                            {
                                Tooltip = node.GetAttribute("Tooltip");
                            }

                            ObjField dataField = new ObjField();
                            dataField.Name = Name;
                            dataField.Text = Text;
                            dataField.DataType = DataType;
                            dataField.DataValue = DataValue.Replace("\n","<br />");
                            dataField.Color = fgColor;
                            dataField.Tooltip = Tooltip;

                            //将数据样式应用于字段
                            if (schemaBill.DetailLists.Length > 0 &&
                                schemaBill.DetailLists[0].ObjFieldList.Length > 0 && schemaBill.DetailLists[0].GetObjFieldDict()[Name] != null)
                            {

                                ObjField schemaField = schemaBill.DetailLists[0].GetObjFieldDict()[Name];
                                dataField.Colspan = schemaField.Colspan;
                                dataField.IsVisible = schemaField.IsVisible;
                                dataField.CssName = schemaField.CssName;
                                dataField.Orderno = schemaField.Orderno;
                                dataField.ColumnOrder = schemaField.ColumnOrder;
                                dataField.Text = schemaField.Text;
                                dataField.IsShowCaption = schemaField.IsShowCaption;
                                dataField.IsLink = schemaField.IsLink;
                                if (dataField.DataType.ToLower() == "rtf")
                                {
                                    bill.RtfData = dataField.DataValue;
                                }
                                //因业务编号的问题,需要重新获取编号(目前出差报销)
                                if (dataField.DataValue == "")
                                {
                                    //TODO:需要重新获取编号
                                    //UNDONE:需要重新获取编号

                                }
                            }
                            else //在配置文件中没找到的字段,都不显示 
                            {
                                dataField.IsVisible = false;
                            }
                            detailList.ObjFieldList[i] = dataField;
                            detailList.PadRepeatCount = schemaBill.DetailLists[0].PadRepeatCount;
                            detailList.PhoneRepeatCount = schemaBill.DetailLists[0].PhoneRepeatCount;
                        }
                        bill.DetailLists = new ObjDetailList[] { detailList };

                    }


                    bill.SubLists = CreateSubList(nodeObject, "", schemaBill, false);

                    XmlNode ConsultationList = doc.SelectSingleNode("//ConsultationList");
                    if (ConsultationList != null)
                    {
                        bill.ConsultationLists = CreateConsultationList(ConsultationList);
                    }
                    XmlNode nodeApproval = doc.SelectSingleNode("//ApprovalList");

                    if (nodeApproval != null)
                    {//读取审核列表数据

                        XmlNodeList list = nodeApproval.SelectNodes("Atrribute");
                        ObjApprovalList approvalList = new ObjApprovalList();
                        approvalList.Text = "审核信息";
                        approvalList.ApprovalList = new ObjApproval[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            XmlNode node = list[i];
                            string Approver = ((XmlElement)node).GetAttribute("Approver");
                            string ApprovalTime = ((XmlElement)node).GetAttribute("ApprovalTime");
                            string ApprovalState = ((XmlElement)node).GetAttribute("ApprovalState");
                            string ApprovalRemark = ((XmlElement)node).GetAttribute("ApprovalRemark");
                            string FlowType = ((XmlElement)node).GetAttribute("FlowType");
                            string Flag = ((XmlElement)node).GetAttribute("Flag");
                            ObjApproval dataField = new ObjApproval();
                            dataField.Approver = Approver;
                            dataField.ApprovalTime = Convert.ToDateTime(ApprovalTime);
                            dataField.ApprovalState = ApprovalState;
                            dataField.ApprovalRemark = ApprovalRemark;
                            dataField.Flag = Flag;
                            dataField.FlowType = FlowType;

                            //应用样式于字段
                            if (null != schemaBill.ApprovalLists && schemaBill.ApprovalLists.Length > 0 && null != schemaBill.ApprovalLists[0].ApprovalList &&
                                schemaBill.ApprovalLists[0].ApprovalList.Length > 0 && schemaBill.ApprovalLists[0].GetApprovalDict()[Approver] != null)
                            {
                                ObjApproval schemaField = schemaBill.ApprovalLists[0].GetApprovalDict()[Approver];

                                //dataField.Colspan = schemaField.Colspan;
                            }
                            approvalList.ApprovalList[i] = dataField;
                        }
                        bill.ApprovalLists = new ObjApprovalList[] { approvalList };
                    }


                    XmlNode nodeAttach = doc.SelectSingleNode("//AttachList");
                    if (nodeAttach != null)
                    {//读取附件列表数据

                        XmlNodeList list = nodeAttach.SelectNodes("Atrribute");
                        ObjAttachList approvalList = new ObjAttachList();
                        approvalList.AttachList = new ObjAttach[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            XmlNode node = list[i];
                            string Name = ((XmlElement)node).GetAttribute("Name");
                            string Url = ((XmlElement)node).GetAttribute("Url");

                            ObjAttach dataField = new ObjAttach();
                            dataField.Name = Name;
                            dataField.Url = Url;

                            //将样式应用于字段
                            if (null != schemaBill && null != schemaBill.AttachLists && schemaBill.AttachLists.Length > 0 &&
                                schemaBill.AttachLists[0].AttachList != null &&
                                schemaBill.AttachLists[0].AttachList.Length > 0 && schemaBill.AttachLists[0].GetAttachDict()[Name] != null)
                            {
                                ObjAttach schemaField = schemaBill.AttachLists[0].GetAttachDict()[Name];
                                //dataField.Colspan = schemaField.Colspan;
                            }
                            approvalList.AttachList[i] = dataField;
                        }
                        bill.AttachLists = new ObjAttachList[] { approvalList };
                    }


                }



            }

            return bill;

        }