示例#1
0
        /// <summary>
        /// 将DataRedar转换为List
        /// </summary>
        private List <Data.Model.Dictionary> DataReaderToList(SqlDataReader dataReader)
        {
            List <Data.Model.Dictionary> List = new List <Data.Model.Dictionary>();

            Data.Model.Dictionary model = null;
            while (dataReader.Read())
            {
                model          = new Data.Model.Dictionary();
                model.ID       = dataReader.GetGuid(0);
                model.ParentID = dataReader.GetGuid(1);
                model.Title    = dataReader.GetString(2);
                if (!dataReader.IsDBNull(3))
                {
                    model.Code = dataReader.GetString(3);
                }
                if (!dataReader.IsDBNull(4))
                {
                    model.Value = dataReader.GetString(4);
                }
                if (!dataReader.IsDBNull(5))
                {
                    model.Note = dataReader.GetString(5);
                }
                if (!dataReader.IsDBNull(6))
                {
                    model.Other = dataReader.GetString(6);
                }
                model.Sort = dataReader.GetInt32(7);
                List.Add(model);
            }
            return(List);
        }
示例#2
0
        private string getOptionsValue(OptionValueField valueField, Data.Model.Dictionary dict)
        {
            string value = string.Empty;

            switch (valueField)
            {
            case OptionValueField.Code:
                value = dict.Code;
                break;

            case OptionValueField.ID:
                value = dict.ID.ToString();
                break;

            case OptionValueField.Note:
                value = dict.Note;
                break;

            case OptionValueField.Other:
                value = dict.Other;
                break;

            case OptionValueField.Title:
                value = dict.Title;
                break;

            case OptionValueField.Value:
                value = dict.Value;
                break;
            }
            return(value);
        }
示例#3
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model">Data.Model.Dictionary实体类</param>
        public int Update(Data.Model.Dictionary model)
        {
            string sql = @"UPDATE Dictionary SET 
				ParentID=@ParentID,Title=@Title,Code=@Code,Value=@Value,Note=@Note,Other=@Other,Sort=@Sort,UseCache=@UseCache
				WHERE ID=@ID"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@ParentID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ParentID
                },
                new SqlParameter("@Title", SqlDbType.NVarChar, -1)
                {
                    Value = model.Title
                },
                model.Code == null ? new SqlParameter("@Code", SqlDbType.VarChar, 500)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Code", SqlDbType.VarChar, 500)
                {
                    Value = model.Code
                },
                model.Value == null ? new SqlParameter("@Value", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Value", SqlDbType.VarChar, -1)
                {
                    Value = model.Value
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = model.Note
                },
                model.Other == null ? new SqlParameter("@Other", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Other", SqlDbType.VarChar, -1)
                {
                    Value = model.Other
                },
                new SqlParameter("@Sort", SqlDbType.Int, -1)
                {
                    Value = model.Sort
                },
                new SqlParameter("@UseCache", SqlDbType.Bit, -1)
                {
                    Value = model.UseCache
                },
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
示例#4
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">Data.Model.Dictionary实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(Data.Model.Dictionary model)
        {
            string sql = @"INSERT INTO Dictionary
				(ID,ParentID,Title,Code,Value,Note,Other,Sort,UseCache) 
				VALUES(@ID,@ParentID,@Title,@Code,@Value,@Note,@Other,@Sort,@UseCache)"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                },
                new SqlParameter("@ParentID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ParentID
                },
                new SqlParameter("@Title", SqlDbType.NVarChar, -1)
                {
                    Value = model.Title
                },
                model.Code == null ? new SqlParameter("@Code", SqlDbType.VarChar, 500)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Code", SqlDbType.VarChar, 500)
                {
                    Value = model.Code
                },
                model.Value == null ? new SqlParameter("@Value", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Value", SqlDbType.VarChar, -1)
                {
                    Value = model.Value
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = model.Note
                },
                model.Other == null ? new SqlParameter("@Other", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Other", SqlDbType.VarChar, -1)
                {
                    Value = model.Other
                },
                new SqlParameter("@Sort", SqlDbType.Int, -1)
                {
                    Value = model.Sort
                },
                new SqlParameter("@UseCache", SqlDbType.Bit, -1)
                {
                    Value = model.UseCache
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
示例#5
0
        /// <summary>
        /// 得到一个字典项的上级节点数
        /// </summary>
        /// <param name="dictList"></param>
        /// <param name="dict"></param>
        /// <returns></returns>
        private int getParentCount(List <Data.Model.Dictionary> dictList, Data.Model.Dictionary dict)
        {
            int parent = 0;

            Data.Model.Dictionary parentDict = dictList.Find(p => p.ID == dict.ParentID);
            while (parentDict != null)
            {
                parentDict = dictList.Find(p => p.ID == parentDict.ParentID);
                parent++;
            }
            return(parent);
        }
示例#6
0
        public ActionResult Body(FormCollection collection)
        {
            Business.Platform.Dictionary bdict = new Business.Platform.Dictionary();
            Data.Model.Dictionary        dict  = null;
            string id = Request.QueryString["id"];

            if (id.IsGuid())
            {
                dict = bdict.Get(id.ToGuid());
            }
            if (dict == null)
            {
                dict = bdict.GetRoot();
            }

            if (collection != null)
            {
                string refreshID = dict.ParentID == Guid.Empty ? dict.ID.ToString() : dict.ParentID.ToString();
                //删除
                if (!Request.Form["Delete"].IsNullOrEmpty())
                {
                    int i = bdict.DeleteAndAllChilds(dict.ID);
                    bdict.RefreshCache();
                    Business.Platform.Log.Add("删除了数据字典及其下级共" + i.ToString() + "项", dict.Serialize(), Business.Platform.Log.Types.数据字典);
                    ViewBag.Script = "alert('删除成功!');parent.frames[0].reLoad('" + refreshID + "');window.location='Body?id=" + dict.ParentID.ToString() + "&appid=" + Request.QueryString["appid"] + "';";
                    return(View(dict));
                }

                string title  = Request.Form["Title"];
                string code   = Request.Form["Code"];
                string values = Request.Form["Values"];
                string note   = Request.Form["Note"];
                string other  = Request.Form["Other"];
                string oldXML = dict.Serialize();

                dict.Code  = code.IsNullOrEmpty() ? null : code.Trim();
                dict.Note  = note.IsNullOrEmpty() ? null : note.Trim();
                dict.Other = other.IsNullOrEmpty() ? null : other.Trim();
                dict.Title = title.Trim();
                dict.Value = values.IsNullOrEmpty() ? null : values.Trim();

                bdict.Update(dict);
                bdict.RefreshCache();
                Business.Platform.Log.Add("修改了数据字典项", "", Business.Platform.Log.Types.数据字典, oldXML, dict.Serialize());
                ViewBag.Script = "alert('保存成功!');parent.frames[0].reLoad('" + refreshID + "');";
            }

            return(View(dict));
        }
示例#7
0
        public ActionResult add1(FormCollection collection)
        {
            Data.Model.Dictionary        dict  = new Data.Model.Dictionary();
            Business.Platform.Dictionary bdict = new Business.Platform.Dictionary();
            string id = Request.QueryString["id"];

            if (!id.IsGuid())
            {
                var dictRoot = bdict.GetRoot();
                id = dictRoot != null?dictRoot.ID.ToString() : "";
            }
            if (!id.IsGuid())
            {
                throw new Exception("未找到父级");
            }

            if (collection != null)
            {
                string title  = Request.Form["Title"];
                string code   = Request.Form["Code"];
                string values = Request.Form["Values"];
                string note   = Request.Form["Note"];
                string other  = Request.Form["Other"];

                dict.ID       = Guid.NewGuid();
                dict.Code     = code.IsNullOrEmpty() ? null : code.Trim();
                dict.Note     = note.IsNullOrEmpty() ? null : note.Trim();
                dict.Other    = other.IsNullOrEmpty() ? null : other.Trim();
                dict.ParentID = id.ToGuid();
                dict.Sort     = bdict.GetMaxSort(id.ToGuid());
                dict.Title    = title.Trim();
                dict.Value    = values.IsNullOrEmpty() ? null : values.Trim();

                bdict.Add(dict);
                bdict.RefreshCache();
                Business.Platform.Log.Add("添加了数据字典项", dict.Serialize(), Business.Platform.Log.Types.数据字典);
                ViewBag.Script = "alert('添加成功!');parent.frames[0].reLoad('" + id + "');";
            }

            return(View(dict));
        }
示例#8
0
 /// <summary>
 /// 更新
 /// </summary>
 public int Update(Data.Model.Dictionary model)
 {
     return(dataDictionary.Update(model));
 }
示例#9
0
 /// <summary>
 /// 新增
 /// </summary>
 public int Add(Data.Model.Dictionary model)
 {
     return(dataDictionary.Add(model));
 }