示例#1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public bool UpdateTableData(string FromValues, string ItemID)
        {
            var TableModel = this.GetTableModel();

            BLL.ObjectData ModelData = new BLL.ObjectData(TableModel.TableName);
            ModelData.SetValues(FromValues); //表单数据
            if (TableModel.TableType == 1)   //表格数据
            {
                return(BaseClass.UpdateModel(ModelData, TableModel.PrimaryKey, ItemID));
            }
            else if (TableModel.TableType == 2)//XML数据
            {
                return(BaseClass.XmlUpdateTableModel(ModelData, TableModel.PrimaryKey, ItemID));
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <returns></returns>
        public string InsertTableData(string FromValues)
        {
            var TableModel = this.GetTableModel();

            BLL.ObjectData ModelData = new BLL.ObjectData(TableModel.TableName);
            ModelData.SetValues(FromValues); //表单数据
            if (TableModel.TableType == 1)   //表格数据
            {
                return(BaseClass.InsertModel(ModelData, TableModel.PrimaryKey));
            }
            else if (TableModel.TableType == 2)//XML数据
            {
                return(BaseClass.XmlInsertTableModel(ModelData, TableModel.PrimaryKey));
            }
            else
            {
                return("");
            }
        }
示例#3
0
 /// <summary>
 /// 修改xml表格信息
 /// </summary>
 /// <param name="ModelData"></param>
 /// <param name="PrimaryKey"></param>
 /// <param name="ItemID"></param>
 /// <returns></returns>
 public static bool XmlUpdateTableModel(BLL.ObjectData ModelData, string PrimaryKey, string ItemID)
 {
     try
     {
         string      xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\DataXML\\" + ModelData.TableName;
         XmlDocument xml     = new XmlDocument();
         xml.Load(xmlPath);                                                                         //读取文件
         XmlElement root     = xml.DocumentElement;                                                 //获取根节点
         XmlNode    rootChil = root.SelectSingleNode("OPTION[@" + PrimaryKey + "=" + ItemID + "]"); //获取指定子节点
         if (rootChil != null)
         {
             var pros = ModelData.GetValues().Keys;//所有字段名称
             List <SqlParameter> paramlist = new List <SqlParameter>();
             foreach (var fieldName in pros)
             {
                 if (!fieldName.ToUpper().Equals(PrimaryKey == null ? "" : PrimaryKey.ToUpper()))
                 {
                     if (ModelData.IsSet(fieldName))//是否赋值了
                     {
                         var fieldValue = ModelData.GetValue(fieldName);
                         rootChil.Attributes[fieldName].Value = fieldValue.ToString();
                     }
                 }
             }
             xml.Save(xmlPath);
             if (ModelData.TableName == "Table.xml")
             {
                 XmlToUpdateTableFielModel(Convert.ToInt32(ItemID));
             }
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#4
0
        void LoadBind(string GetType)
        {
            int    PageIndex   = Convert.ToInt32(Request.QueryString["page"]);
            int    PageSize    = Convert.ToInt32(Request.QueryString["limit"]);
            int    PageStart   = Convert.ToInt32(Request.QueryString["start"]);
            string Order       = Request.QueryString["order"];
            string OSrderDir   = Request.QueryString["orderDir"];
            var    WhereValues = Request.QueryString["WhereValues"];

            if (GetType == "GetDataList")
            {
                System.Data.DataTable dt = (WhereValues == null ? null : BLL.JsonHelper.DeserializeJsonToObject <System.Data.DataTable>(WhereValues));//条件数据
                Response.Write(tableModel.GetDataListJson(dt, PageStart, PageIndex, PageSize, " " + Order + " " + OSrderDir));
                Response.End();
            }
            else if (GetType == "SaveFromData")
            {
                var            ChoiceValue = Request.QueryString["ChoiceValue"];
                var            FromValues  = Server.UrlDecode(Request.QueryString["FromValues"]);
                BLL.ObjectData ModelData   = new BLL.ObjectData(tableModel.TableModel.TableName);
                ModelData.SetValues(FromValues);//表单数据
                var RowNum   = true;
                var CodeJson = "";
                if (ChoiceValue != null && ChoiceValue != "")//修改
                {
                    RowNum = tableModel.UpdateModel(ModelData, ChoiceValue);
                    if (RowNum)
                    {
                        CodeJson = "[{\"code\":100}]";
                    }
                    else
                    {
                        CodeJson = "[{\"code\":105}]";
                    }
                }
                else//添加
                {
                    var ItemID = tableModel.InsertModel(ModelData);
                    if (string.IsNullOrWhiteSpace(ItemID))
                    {
                        CodeJson = "[{\"code\":100}]";
                    }
                    else
                    {
                        CodeJson = "[{\"code\":105}]";
                    }
                }
                Response.Write(CodeJson);
                Response.End();
            }
            else if (GetType == "GetDataView")
            {
                var ChoiceValue = Request.QueryString["ChoiceValue"];
                Response.Write(tableModel.GetDataViewJson(ChoiceValue));
                Response.End();
            }
            else if (GetType == "BntOperation")
            {
                var ChoiceValue = Request["ChoiceValue"];
                if (!string.IsNullOrWhiteSpace(ChoiceValue))
                {
                    Response.Write(tableModel.DeleteData(ChoiceValue));
                }
                else
                {
                    Response.Write("False");
                }
                Response.End();
            }
            else if (GetType == "GetFieldKeyValue")
            {
                Dictionary <string, string> data = new Dictionary <string, string> {
                };
                for (int i = 0; i < Request.QueryString.Count; i++)
                {
                    data.Add(Request.QueryString.Keys[i].ToString(), Request.QueryString[i].ToString());
                }
                if (data.Count > 0)
                {
                    Response.Write(tableModel.GetFieldKeyValue(data));
                }
                else
                {
                    Response.Write("False");
                }
                Response.End();
            }
        }
示例#5
0
        /// <summary>
        /// 新增xml表格信息
        /// </summary>
        /// <param name="ModelData"></param>
        /// <returns></returns>
        public static string XmlInsertTableModel(BLL.ObjectData ModelData, string PrimaryKey)
        {
            try
            {
                string      xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\DataXML\\" + ModelData.TableName;
                XmlDocument xml     = new XmlDocument();
                xml.Load(xmlPath);                                               //读取文件
                XmlElement          root = xml.DocumentElement;                  //获取根节点
                XmlElement          xmlElemDeptChildId = xml.CreateElement("OPTION");
                var                 pros           = ModelData.GetValues().Keys; //所有字段名称
                List <SqlParameter> paramlist      = new List <SqlParameter>();
                XmlNode             XmlColumnsNode = root.SelectSingleNode("MAXID");
                var                 MaxID          = Convert.ToInt32(XmlColumnsNode.InnerText) + 1;
                foreach (var fieldName in pros)
                {
                    if (!fieldName.ToUpper().Equals(PrimaryKey == null ? "" : PrimaryKey.ToUpper()))
                    {
                        if (ModelData.IsSet(fieldName))//是否赋值了
                        {
                            var fieldValue = ModelData.GetValue(fieldName);
                            xmlElemDeptChildId.SetAttribute(fieldName, fieldValue.ToString());
                        }
                    }
                    else
                    {
                        xmlElemDeptChildId.SetAttribute(fieldName, MaxID.ToString());
                    }
                }
                if (ModelData.TableName == "Table.xml")
                {
                    xmlElemDeptChildId.SetAttribute("TableID", MaxID.ToString());
                    xmlElemDeptChildId.SetAttribute("IsPlus", "0");
                    xmlElemDeptChildId.SetAttribute("IsWhere", "0");
                    xmlElemDeptChildId.SetAttribute("IsChoice", "0");
                    xmlElemDeptChildId.SetAttribute("IsInsert", "0");
                    xmlElemDeptChildId.SetAttribute("IsUpdate", "0");
                    xmlElemDeptChildId.SetAttribute("IsDelete", "0");
                    xmlElemDeptChildId.SetAttribute("PredefinedSQL", "");
                    xmlElemDeptChildId.SetAttribute("PrimaryKey", "TableID");
                }
                xmlElemDeptChildId.InnerText = "";
                if (ModelData.TableName == "Table.xml")
                {
                    XmlElement xmlCOLUMNSChildId = xml.CreateElement("COLUMNS");
                    xmlCOLUMNSChildId.InnerText = "";
                    xmlElemDeptChildId.AppendChild(xmlCOLUMNSChildId);

                    XmlElement xmlMoreButtonChildId = xml.CreateElement("MoreButton");
                    xmlMoreButtonChildId.InnerText = "";
                    xmlElemDeptChildId.AppendChild(xmlMoreButtonChildId);

                    XmlElement xmlTopHeadChildId = xml.CreateElement("TopHead");
                    xmlTopHeadChildId.InnerText = "";
                    xmlElemDeptChildId.AppendChild(xmlTopHeadChildId);

                    XmlElement xmlBottomHtmlChildId = xml.CreateElement("BottomHtml");
                    xmlBottomHtmlChildId.InnerText = "";
                    xmlElemDeptChildId.AppendChild(xmlBottomHtmlChildId);

                    XmlElement xmlBottomScriptChildId = xml.CreateElement("BottomScript");
                    xmlBottomScriptChildId.InnerText = "";
                    xmlElemDeptChildId.AppendChild(xmlBottomScriptChildId);
                }
                root.AppendChild(xmlElemDeptChildId);
                XmlColumnsNode.InnerText = MaxID.ToString();
                xml.Save(xmlPath);
                if (ModelData.TableName == "Table.xml")
                {
                    XmlToUpdateTableFielModel(MaxID);
                }
                return(MaxID.ToString());
            }
            catch (Exception)
            {
                return("");
            }
        }