コード例 #1
0
ファイル: BillView.cs プロジェクト: JuRogn/OA
        /// <summary>
        /// 根据主表数据创建控件,设置样式,并添加至table
        /// </summary>
        /// <param name="objDetailList">主表数据数组</param>
        public void CreateDetails(ObjDetailList[] objDetailList)
        {
            //创建table
            HtmlTable tb = CreateTable(0, 0, 0, "100%", null, "MobileTabTable grid");

            if (null != objDetailList && objDetailList.Length > 0)
            {
                foreach (ObjDetailList detailList in objDetailList)
                {
                    //判断pad或者phone,确定在页面显示几列
                    int column = int.Parse(this.Viewmode.Name == "Pad" ?
                        detailList.PadRepeatCount : detailList.PhoneRepeatCount);

                    int count = 0;
                    HtmlTableRow tr = null;
                    int m = 0;
                    int visibleCount = 0;
                    int tdcount = 100;
                    ListBase<Field> fieldDict = detailList.GetFieldDict();
                    if (null != fieldDict && fieldDict.Count > 0)
                    {

                        foreach (Field field in fieldDict)
                        {
                            if (field.ControlType == Constant.CtrlType.Rtf)
                            {

                            }

                            if (field.IsVisible && field.ControlType != Constant.CtrlType.Rtf)
                            {
                                if (count == visibleCount - 1)
                                {
                                    field.Colspan = (column - 1 - m % column) + 1;
                                }

                                if (tdcount >= column)
                                {
                                    tr = CreateTR(null, "16px", null);
                                    tdcount = 0;
                                }
                                tdcount = tdcount + field.Colspan;
                                {
                                    string cssName = "billField";
                                    if (!string.IsNullOrEmpty(field.CssName))
                                    {
                                        cssName = field.CssName;
                                    }

                                    if (field.IsShowCaption)    //是否显示标题
                                    {
                                        HtmlTableCell td1 = CreateTD(1, null, null, "billFormIdText");
                                        td1.Controls.Add((Control)field.CaptionControl);
                                        td1.Width = (100 / (column * 4)) + "%";
                                        ((Label)field.CaptionControl).ToolTip = field.FieldName;
                                        tr.Controls.Add(td1);

                                        HtmlTableCell td3 = CreateTD(1, null, null, cssName);
                                        td3.ColSpan = (field.Colspan - 1) * 2 + 1;
                                        td3.Width = (((100 / (column * 4)) * 3) + (100 / (column * 4)) * (field.Colspan - 1)) + "%";

                                        if (field.ControlType == Constant.CtrlType.Rtf)
                                        {

                                            //Panel panel = new Panel();
                                            //panel.ID = "divContext";

                                            //Label lab = new Label();
                                            //lab.Text = "Load...";

                                            //HtmlImage img = new HtmlImage();
                                            //img.Src = Template.ImageUrl + "loading.gif";

                                            //panel.Controls.Add(lab);
                                            //panel.Controls.Add(img);
                                            //td3.Controls.Add(panel);
                                        }
                                        else
                                        {
                                            td3.Controls.Add((Control)field.MainControl[0]);
                                        }


                                        tr.Controls.Add(td3);
                                    }
                                    else
                                    {
                                        HtmlTableCell td3 = CreateTD(1, null, null, cssName);
                                        td3.ColSpan = (field.Colspan - 1) * 2 + 1 + 1;
                                        td3.Width = ((((100 / (column * 4)) * 3) + (100 / (column * 4)) * (field.Colspan - 1)) + (100 / (column * 4))) + "%"; ;
                                        Literal li = new Literal();
                                        li.Text = field.CaptionName;
                                        td3.Controls.Add(li);

                                        td3.Controls.Add((Control)field.MainControl[0]);
                                        tr.Controls.Add(td3);
                                    }

                                    tb.Controls.Add(tr);
                                }
                            }

                            count++;
                            m = m + field.Colspan;
                        }
                    }
                }


                TableCtrl.Rows.Add(AddTable(tb));
            }
        }
コード例 #2
0
ファイル: BillData.cs プロジェクト: JuRogn/OA
        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;

        }