示例#1
0
        private List <BaseDictory> ConvertStrToBaseList(string valuexml)
        {
            List <BaseDictory> baseValueList = new List <BaseDictory>();

            if (string.IsNullOrEmpty(valuexml))
            {
                return(baseValueList);
            }
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(valuexml);
                XmlNodeList xmlNodeList = xmldoc.SelectNodes("/Value/Item");
                if (xmlNodeList == null || xmlNodeList.Count == 0)
                {
                    return(baseValueList);
                }
                foreach (XmlNode item in xmlNodeList)
                {
                    BaseDictory baseOption = new BaseDictory();
                    baseOption.Id   = item.Attributes["Id"].Value;
                    baseOption.Name = item.InnerText;
                    baseValueList.Add(baseOption);
                }
                return(baseValueList);
            }
            catch (Exception ex)
            {
                return(baseValueList);
            }
        }
示例#2
0
        /// <summary>
        /// 将List化成valuecml
        /// </summary>
        /// <param name="basevalueList"></param>
        /// <returns></returns>
        public static string ConvertBaseToXml(BaseDictory basevalue)
        {
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml("<Value></Value>");
            XmlElement   xmlElement   = xmldoc.CreateElement("Item");
            XmlAttribute xmlAttribute = xmldoc.CreateAttribute("Id");

            xmlAttribute.Value = basevalue.Id;
            xmlElement.Attributes.Append(xmlAttribute);
            xmlElement.InnerText = basevalue.Name;
            xmldoc.DocumentElement.AppendChild(xmlElement as XmlNode);
            return(xmldoc.OuterXml);
        }
示例#3
0
 private void SetChangedVaule(InCommonNoteItemEntity item, DataRow dtRow)
 {
     try
     {
         if (item == null || dtRow == null)
         {
             return;
         }
         if (item.DataElement == null && dataElementList.ContainsKey(item.CommonNote_Item_Flow))
         {
             item.DataElement = dataElementList[item.CommonNote_Item_Flow];
         }
         string elementType = item.DataElement.ElementType;
         if (elementType.ToUpper() == "S1" ||
             elementType.ToUpper() == "S4")
         {
             item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dtRow[item.CommonNote_Item_Flow].ToString());
         }
         else if (elementType.ToUpper() == "S2" ||
                  elementType.ToUpper() == "S3")
         {
             string dtrowcolvalue = dtRow[item.CommonNote_Item_Flow].ToString();
             if (string.IsNullOrEmpty(dtrowcolvalue))
             {
                 item.ValueXml = "";
             }
             else
             {
                 BaseDictory baseDictory = new BaseDictory();
                 bool        hasBase     = false;
                 foreach (var itembase in item.DataElement.BaseOptionList)
                 {
                     if (itembase.Name == dtrowcolvalue)
                     {
                         baseDictory.Id   = itembase.Id;
                         baseDictory.Name = itembase.Name;
                         hasBase          = true;
                         break;
                     }
                 }
                 if (hasBase == true)
                 {
                     item.ValueXml = InCommonNoteItemEntity.ConvertBaseToXml(baseDictory);
                 }
                 else
                 {
                     item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dtrowcolvalue);
                 }
             }
         }
         else if (elementType.ToUpper() == "S9")
         {
             string dtrowcolvalue = dtRow[item.CommonNote_Item_Flow].ToString();
             if (string.IsNullOrEmpty(dtrowcolvalue))
             {
                 item.ValueXml = "";
             }
             else
             {
                 string[]           strlist       = dtrowcolvalue.Split(',');
                 List <BaseDictory> baseValueList = new List <BaseDictory>();
                 foreach (string itemstr in strlist)
                 {
                     foreach (var itembase in item.DataElement.BaseOptionList)
                     {
                         if (itembase.Id.Trim() == itemstr.Trim())
                         {
                             BaseDictory baseDictory = new BaseDictory();
                             baseDictory.Id   = itembase.Id;
                             baseDictory.Name = itembase.Name;
                             baseValueList.Add(baseDictory);
                             break;
                         }
                     }
                 }
                 item.ValueXml = InCommonNoteItemEntity.ConvertBaseToXml(baseValueList);
             }
         }
         else if (elementType.ToUpper() == "DT" || elementType.ToUpper() == "D" || elementType.ToUpper() == "T")
         {
             string dtrowcolvalue = dtRow[item.CommonNote_Item_Flow].ToString();
             if (string.IsNullOrEmpty(dtrowcolvalue))
             {
                 item.ValueXml = "";
             }
             else
             {
                 if (elementType.ToUpper() == "DT")
                 {
                     item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(DateUtil.getDateTime(dtrowcolvalue, DateUtil.NORMAL_LONG));
                 }
                 else if (elementType.ToUpper() == "D")
                 {
                     item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(DateUtil.getDateTime(dtrowcolvalue, DateUtil.NORMAL_SHORT));
                 }
                 else if (elementType.ToUpper() == "T")
                 {
                     item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(DateUtil.getDateTime(dtrowcolvalue, DateUtil.NORMAL_LONG).Substring(11));
                 }
             }
         }
         else if (elementType.ToUpper() == "N")
         {
             item.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dtRow[item.CommonNote_Item_Flow].ToString());
         }
         else if (elementType.ToUpper() == "L")
         {
             string      dtrowcolvalue = dtRow[item.CommonNote_Item_Flow].ToString().ToUpper();
             BaseDictory basedic       = new BaseDictory();
             if (dtrowcolvalue == "TRUE")
             {
                 basedic.Id   = "1";
                 basedic.Name = "是";
             }
             else
             {
                 basedic.Id   = "0";
                 basedic.Name = "否";
             }
             item.ValueXml = InCommonNoteItemEntity.ConvertBaseToXml(basedic);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
        /// <summary>
        /// 保存项目 直接在对象的xml之中
        /// </summary>
        public bool GetInCommonNoteItemSave(ref string message)
        {
            if (this.inCommonNoteItemEntity.IsValidate == "否")
            {
                this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(txtValue.Text);
            }
            else
            {
                string elementType = this.inCommonNoteItemEntity.DataElement.ElementType;
                switch (elementType)
                {
                case "S1":
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(txtValue.Text);
                    break;

                case "S2":
                    string strText = cboS2S3.Text;
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(strText);
                    //选中时赋值的
                    break;

                case "S3":
                    string strTextS3 = cboS2S3.Text;
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(strTextS3);
                    //选中时赋值的
                    break;

                case "S4":
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(txtValue.Text);
                    break;

                case "S9":
                    List <BaseDictory> baseDictoryList = new List <BaseDictory>();
                    foreach (CheckedListBoxItem item in chkListValue.Items)
                    {
                        if (item.CheckState == CheckState.Checked)
                        {
                            baseDictoryList.Add(item.Value as BaseDictory);
                        }
                    }
                    this.inCommonNoteItemEntity.BaseValueList = baseDictoryList;
                    this.inCommonNoteItemEntity.ValueXml      = InCommonNoteItemEntity.ConvertBaseToXml(baseDictoryList);
                    //选中时赋值的
                    break;

                case "L":
                    BaseDictory basedicL = new BaseDictory();
                    basedicL.Id   = chboxValue.Checked == true ? "1" : "0";
                    basedicL.Name = chboxValue.Checked == true ? "是" : "否";
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertBaseToXml(basedicL);
                    break;

                case "N":
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(spinEditValue.Value.ToString());
                    break;

                case "D":
                    string dateV10 = DateUtil.getDateTime(dateEditValue.DateTime.ToString(), DateUtil.NORMAL_SHORT);
                    if (dateV10 == "0001-01-01")
                    {
                        dateV10 = "";
                    }
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dateV10);
                    break;

                case "DT":
                    string dateV19 = DateUtil.getDateTime(dateEditValue.DateTime.ToString(), DateUtil.NORMAL_LONG);
                    if (dateV19 == "0001-01-01 00:00:00")
                    {
                        dateV19 = "";
                    }
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dateV19);
                    break;

                case "T":
                    string dateV8 = DateUtil.getDateTime(timeEditValue.Time.ToString(), DateUtil.NORMAL_LONG).Substring(11, 8);
                    if (dateV8 == "00:00:00")
                    {
                        dateV8 = "";
                    }
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(dateV8);
                    break;

                default:
                    this.inCommonNoteItemEntity.ValueXml = InCommonNoteItemEntity.ConvertStrToXml(txtValue.Text);
                    break;
                }
            }
            return(true);
        }