Пример #1
0
        /// <summary>
        /// 将DataRedar转换为List
        /// </summary>
        private List <FoWoSoft.Data.Model.Dictionary> DataReaderToList(SqlDataReader dataReader)
        {
            List <FoWoSoft.Data.Model.Dictionary> List = new List <FoWoSoft.Data.Model.Dictionary>();

            FoWoSoft.Data.Model.Dictionary model = null;
            while (dataReader.Read())
            {
                model          = new FoWoSoft.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, FoWoSoft.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
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];

            this.Code.Attributes.Add("validate_url", "CheckCode.ashx?id=" + id);
            if (id.IsGuid())
            {
                dict = bdict.Get(id.ToGuid());
            }
            if (dict == null)
            {
                dict = bdict.GetRoot();
            }
            if (IsPostBack && dict != 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();
                    FoWoSoft.Platform.Log.Add("删除了数据字典及其下级共" + i.ToString() + "项", dict.Serialize(), FoWoSoft.Platform.Log.Types.数据字典);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('删除成功!');parent.frames[0].reLoad('" + refreshID + "');window.location='Body.aspx?id=" + dict.ParentID.ToString() + "&appid=" + Request.QueryString["appid"] + "';", true);
                }
                //保存
                if (!Request.Form["Save"].IsNullOrEmpty())
                {
                    string title  = Request.Form["Title1"];
                    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();
                    FoWoSoft.Platform.Log.Add("修改了数据字典项", "", FoWoSoft.Platform.Log.Types.数据字典, oldXML, dict.Serialize());
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');parent.frames[0].reLoad('" + refreshID + "');", true);
                }
            }
            if (dict != null)
            {
                this.Title1.Value = dict.Title;
                this.Code.Value   = dict.Code;
                this.Values.Value = dict.Value;
                this.Note.Value   = dict.Note;
                this.Other.Value  = dict.Other;
            }
        }
Пример #4
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model">FoWoSoft.Data.Model.Dictionary实体类</param>
        public int Update(FoWoSoft.Data.Model.Dictionary model)
        {
            string sql = @"UPDATE Dictionary SET 
				ParentID=@ParentID,Title=@Title,Code=@Code,Value=@Value,Note=@Note,Other=@Other,Sort=@Sort
				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("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
Пример #5
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">FoWoSoft.Data.Model.Dictionary实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(FoWoSoft.Data.Model.Dictionary model)
        {
            string sql = @"INSERT INTO Dictionary
				(ID,ParentID,Title,Code,Value,Note,Other,Sort) 
				VALUES(@ID,@ParentID,@Title,@Code,@Value,@Note,@Other,@Sort)"                ;

            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
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
Пример #6
0
        /// <summary>
        /// 得到一个字典项的上级节点数
        /// </summary>
        /// <param name="dictList"></param>
        /// <param name="dict"></param>
        /// <returns></returns>
        private int getParentCount(List <FoWoSoft.Data.Model.Dictionary> dictList, FoWoSoft.Data.Model.Dictionary dict)
        {
            int parent = 0;

            FoWoSoft.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);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                FoWoSoft.Data.Model.Dictionary dict  = new FoWoSoft.Data.Model.Dictionary();
                FoWoSoft.Platform.Dictionary   bdict = new FoWoSoft.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("未找到父级");
                }


                string title  = Request.Form["Title1"];
                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();
                FoWoSoft.Platform.Log.Add("添加了数据字典项", dict.Serialize(), FoWoSoft.Platform.Log.Types.数据字典);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');", true);
            }
        }
Пример #8
0
 /// <summary>
 /// 更新
 /// </summary>
 public int Update(FoWoSoft.Data.Model.Dictionary model)
 {
     return(dataDictionary.Update(model));
 }
Пример #9
0
 /// <summary>
 /// 新增
 /// </summary>
 public int Add(FoWoSoft.Data.Model.Dictionary model)
 {
     return(dataDictionary.Add(model));
 }