//获取节点信息
        public ActionResult GetNode(string nodeCode, string nodeKey)
        {
            Bse_Dict dict = new Bse_Dict();

            if (nodeCode.Contains("temp_"))
            {
                //var tmp = TempDictList.Where(o => o.Dict_Code == nodeCode.Split('_')[1]);
                //if (tmp.Count() > 0)
                //{
                //    dict = tmp.First();
                //}
                //else
                //{

                //}
                var newNodeCode = nodeCode.Split('_')[1];
                dict = dictInstance.GetModelByCode(newNodeCode, nodeKey);
            }
            else
            {
                dict = dictInstance.GetModelByCode(nodeCode, nodeKey);
            }

            var result = new JsonResult()
            {
                Data = new { result = "success", data = dict }
            };

            return(result);
        }
        //public ActionResult DeleteNode(string code,string type)
        //{
        //    if (code.Contains("temp"))
        //    {
        //        code = code.Split('_')[1];
        //        TempDictList.Remove(TempDictList.Where(o => o.Dict_Code == code).First());
        //        return Json(new { result = "success" });
        //    }
        //    else
        //    {
        //        if (type == SPECDICT.MMTYPE.ToString())
        //        {
        //            var dictList=dictInstance.GetListByCode(" AND Dict_Key='"+type+"'");
        //            List<Bse_Dict> list = commInstance.DictTreeNoDepth(dictList, code);
        //            if (list.Count>1)
        //            {
        //                return Json(new { result = "fail", msg = "存在子类别,不能删除" });
        //            }

        //            var strCheck = "";
        //            foreach (var item in list)
        //            {
        //                strCheck += "'"+item.Dict_Code + "',";
        //            }
        //            strCheck = strCheck.TrimEnd(',');
        //            var CheckResult = materialInstance.GetListByCode(" AND MD_Group in (" + strCheck + ") ");
        //            if (CheckResult.Count>0)
        //            {
        //                return Json(new { result = "fail",msg="类别下存在物料,不能删除" });
        //            }
        //        }

        //        var Re=dictInstance.Delete(string.Format(" AND Dict_Code='{0}'", code));

        //        //添加日志
        //        this.OpLog(type, "删除:字典" + type + "中编码:" + code + "的数据", Re.ToString());

        //        if (Re)
        //        {
        //            return Json(new { result = "success" });
        //        }
        //        else
        //        {
        //            return Json(new { result = "fail" });
        //        }
        //    }

        //}

        /// <summary>
        /// 添加和更新操作
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        public ActionResult DictOperation(Bse_Dict dict)
        {
            var flag = false;

            //如果Dict_ID 为0,则表示为添加
            if (dict.Dict_ID == 0)
            {
                //Bse_Dict PNode = dictInstance.GetModel(" AND Dict_Code='" + dict.Dict_PCode + "' AND Dict_Key='" + dict.Dict_Key + "'");
                var order = 0;
                //dict.Dict_Code = dictInstance.CreateDictNode(PNode, false, ref order);
                flag         = dictInstance.Add(dict);
                TempDictList = new List <Bse_Dict>();
                //添加日志
                this.OpLog(dict.Dict_Key, "添加:编码:" + dict.Dict_Name + "数据", flag.ToString());
            }
            else
            {
                flag = dictInstance.Update(dict);
                //添加日志
                this.OpLog(dict.Dict_Key, "修改:编码:" + dict.Dict_Name + "数据", flag.ToString());
            }

            if (flag)
            {
                return(Json(new { result = "success", target = dict }));
            }
            else
            {
                return(Json(new { result = "fail" }));
            }

            //return View();
        }
Exemple #3
0
        public bool Add(Bse_Dict model)
        {
            if (instance.Add(model) > 0)
            {
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public bool Update(Bse_Dict model)
        {
            if (instance.Update(model) > 0)
            {
                return(true);
            }

            return(false);
        }
Exemple #5
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        //public Bse_Dict GetModel(int id)
        //{
        //    Bse_Dict model = instance.GetByKey(id);
        //    return model;
        //}

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Update(Bse_Dict model)
        {
            bool result  = false;
            var  e       = new ModelExceptions();
            int  _rseult = instance.Update(model);

            if (_rseult > 0)
            {
                result = true;
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 后续遍历树-->得到根节点
        /// </summary>
        /// <param name="current"></param>
        /// <param name="allData"></param>
        /// <param name="sb"></param>
        public void GeneratePath(Bse_Dict current, List <Bse_Dict> allData, StringBuilder sb)
        {
            var temp = allData.FirstOrDefault(o => o.Dict_Code == current.Dict_PCode);

            if (temp != null)
            {
                GeneratePath(temp, allData, sb);
                sb.AppendFormat("\\{0}", temp.Dict_Name);
            }
            else
            {
                return;
            }
        }
Exemple #7
0
        private void FindDictChild(Bse_Dict model, List <Bse_Dict> all, ref List <Bse_Dict> ResultList)
        {
            var child = all.Where(o => o.Dict_PCode == model.Dict_Code);

            if (child.Count() == 0)
            {
                return;
            }
            foreach (var item in child)
            {
                ResultList.Add(item);
                FindDictChild(item, all, ref ResultList);
            }
        }
Exemple #8
0
        private void GenerateChild(Bse_Dict dict, List <Bse_Dict> allData)
        {
            dict.ChildDictList = allData.Where(o => o.Dict_PCode.ToUpper() == dict.Dict_Code.ToUpper());

            if (dict.ChildDictList.Count() == 0)
            {
                return;
            }

            foreach (var d in dict.ChildDictList)
            {
                GenerateChild(d, allData);
            }
        }
Exemple #9
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public Bse_Dict GetModel(string strCondition)
        {
            List <Bse_Dict> list  = instance.GetListByWhere(strCondition);
            Bse_Dict        model = new Bse_Dict();

            if (list != null && list.Count > 0)
            {
                model = list[0];
            }
            else
            {
                model = null;
            }
            return(model);
        }
        /// <summary>
        /// 生成节点
        /// </summary>
        /// <param name="parentCode"></param>
        /// <returns></returns>
        public ActionResult CreateNode(string parentCode, string itype)
        {
            int order = 0;

            if (parentCode.Contains("temp"))
            {
                parentCode = parentCode.Split('_')[1];
            }
            var dictNode = dictInstance.GetModelByCode(parentCode, itype);

            string newCode = string.Empty;

            bool IsChildNode = false;

            //如果是根节点则可以添加
            if (dictNode.Dict_Order == 0)
            {
                IsChildNode = false;
                newCode     = dictInstance.CreateDictNode(dictNode, IsChildNode, ref order);
            }//不是根节点则判断是否允许层级
            else
            {
                bool isLevel = dictInstance.IsAllowLevel(dictNode.Dict_Key);
                if (isLevel)
                {
                    IsChildNode = true;
                    newCode     = dictInstance.CreateDictNode(dictNode, IsChildNode, ref order);
                }
            }

            if (!string.IsNullOrEmpty(newCode))
            {
                var model = new Bse_Dict()
                {
                    Dict_Code  = newCode,
                    Dict_Key   = dictNode.Dict_Key,
                    Dict_Order = order,
                    Dict_PCode = parentCode.ToUpper()
                };

                TempDictList.Add(model);
                return(Json(new { Dict_Code = newCode, Dict_Key = dictNode.Dict_Key, Dict_Order = order, Dict_PCode = parentCode.ToUpper(), result = "success" }));
            }
            else
            {
                return(Json(new { result = "fail" }));
            }
        }
Exemple #11
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <param name='model'>是否完成验证</param>
        /// <returns>bool</returns>
        public bool Insert(Bse_Dict model, bool IsValid)
        {
            var  e      = new ModelExceptions();
            bool result = false;

            if (e.IsValid && IsValid)
            {
                //完成了验证,开始更新数据库了
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemple #12
0
        /// <summary>
        /// 逻辑删除数据
        /// </summary>
        /// <param name='model'>model</param>
        /// <returns>bool</returns>
        public bool Delete(string Condition)
        {
            bool            result = false;
            List <Bse_Dict> list   = instance.GetListByWhere(Condition);

            if (list.Count > 0)
            {
                Bse_Dict model = list[0];
                model.Stat = 1;
                int _rseult = instance.Update(model);
                if (_rseult > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemple #13
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Insert(Bse_Dict model)
        {
            bool result = false;

            try
            {
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Exemple #14
0
        public string CreateDictNode(Bse_Dict Node, bool IsChildNode, ref int order)
        {
            //获取关键字
            string codeKey = Node.Dict_Key;

            //获取父编码
            string parentCode = Node.Dict_Code;

            if (codeKey == parentCode)//如果是最顶级,即其父编码为空
            {
                parentCode = "";
            }

            //throw new NotImplementedException();
            //var dict = GetModelByCode(parentCode,);
            order = 0;
            //var newCode = GenerateDictCode(dict.Dict_Key,IsChildNode, ref order);
            string Code    = "";
            var    newCode = Bll_Comm.GetTableKey("", codeKey, parentCode, Code);

            return(newCode);
        }
Exemple #15
0
        /// <summary>
        /// 添加字典信息
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        public int AddDict(Bse_Dict dict, DictKeyEnum key)
        {
            //默认添加为有效状态
            dict.Stat = 0;

            //string dDepth = Instance.GetMaxByWhere("Dict_Level", key.ToString(), "").ToString();

            //if (!string.IsNullOrEmpty(dDepth))
            //{
            //    int depth = Convert.ToInt32(dDepth) + 1;

            //    //dict.Dict_Code = key.ToString() + "_" + depth.ToString();
            dict.Dict_Code = GenerateDictCode(key.ToString());
            dict.Dict_Key = key.ToString();
            //dict.Dict_Level = depth;
            //}

            return Instance.Add(dict);
        }
Exemple #16
0
        public DataTable GetPagedTable(DataTable dt, int PageIndex, int PageSize, string moduleCode)
        {
            if (PageIndex == 0)
            {
                return(null);
            }
            DataTable newdt = dt.Clone();

            #region 获取字典相关信息
            //获取列表字段的配置信息
            Bll_Sys_Config_Fieled    filedInstance = new Bll_Sys_Config_Fieled();
            Bll_Bse_Dict             DictInstance  = new Bll_Bse_Dict();
            List <Sys_Config_Fieled> listField     = filedInstance.GetListByCode(" AND D_ModuleCode='" + moduleCode + "'");
            string dictKeyList = "''";
            foreach (var field in listField)
            {
                if (!string.IsNullOrEmpty(field.D_DictKey))
                {
                    dictKeyList += ",'" + field.D_DictKey + "'";
                }
            }
            //获取配置信息中所有的字典表关键字里拥有的字典信息
            List <Bse_Dict> listDictionary = DictInstance.GetListByCode("  and (dict_key in (" + dictKeyList + "))");

            #endregion

            //newdt.Clear();
            int rowbegin = (PageIndex - 1) * PageSize;
            int rowend   = PageIndex * PageSize;

            if (rowbegin >= dt.Rows.Count)//如果开始列数大于所拥有的列数
            {
                rowbegin = 0;
            }

            if (rowend > dt.Rows.Count)
            {
                rowend = dt.Rows.Count;
            }
            for (int i = rowbegin; i <= rowend - 1; i++)
            {
                DataRow newdr = newdt.NewRow();
                DataRow dr    = dt.Rows[i];
                foreach (DataColumn column in dt.Columns)
                {
                    newdr[column.ColumnName] = dr[column.ColumnName];
                    //更新字典信息
                    var field = listField.Where(o => o.D_Index == column.ColumnName).FirstOrDefault();
                    if (field != null && !string.IsNullOrEmpty(field.D_DictKey))
                    {
                        Bse_Dict dict = listDictionary.Where(o => o.Dict_Code == dr[column.ColumnName].ToString()).FirstOrDefault();
                        if (dict != null)
                        {
                            newdr[column.ColumnName] = dict.Dict_Name;
                        }
                    }

                    //对编码进行转换
                    //if (field!=null && !string.IsNullOrEmpty(field.D_UDEF1))
                    //{
                    //    string[] Converts = field.D_UDEF1.Split(',');
                    //    if (Converts.Count()==3)
                    //    {
                    //        if (dr[column.ColumnName]!=null && !string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                    //        {
                    //            var data = instance.ListDataByCode(Converts[0], Converts[1] + "='" + dr[column.ColumnName].ToString() + "'");
                    //            if (data.Rows.Count>0)
                    //            {
                    //                newdr[column.ColumnName] = data.Rows[0][Converts[2]].ToString();
                    //            }
                    //        }
                    //    }
                    //}
                }
                newdt.Rows.Add(newdr);
            }
            return(newdt);
        }
Exemple #17
0
        /// <summary>
        /// 添加对应处理方法
        /// </summary>
        /// <param name="parentNode"></param>
        /// <param name="dict"></param>
        public void AddTreeNode(TreeNode parentNode, Bse_Dict dict)
        {
            TreeNode tmpNd = new TreeNode();

            tmpNd.Tag = dict.Dict_Code;
            tmpNd.Text = dict.Dict_Name;

            parentNode.Nodes.Add(tmpNd);
        }
Exemple #18
0
        private void btnTvAdd_Click(object sender, EventArgs e)
        {
            //如果是层级字典则无限级;不是层级则无论点击任何节点添加均是针对根节点添加
            if (IsLevel)
            {

                if (SelectedNode != null)
                {
                    //MessageBox.Show(this.SelectedNode.Text);

                    //Dict = fcInstance.GetFailureCatInfoByKey(this.SelectedNode.Tag.ToString());

                    //if (this.SelectedNode.Level != 0 && !IsLevel)
                    //{
                    //    Alert.Show("不能添加叶子节点!");
                    //}
                    //else
                    //{

                    Dict = new Bse_Dict();

                    //设置当前添加状态的字典实体关键字
                    Dict.Dict_Key = DictKey.ToString();

                    Dict.Dict_PCode = SelectedNode.Tag.ToString();
                    Dict.Dict_PName = SelectedNode.Text;

                    //SetlblMessage("添加"+Dict.Dict_PName+"子结点信息");

                    SetMode(OperationTypeEnum.OperationType.Add);
                    //}
                    //bmHelper.BindModelToControl<Bse_Dict>(Dict, gbFailurenList.Controls);
                }
                else
                {
                    Alert.Show("请先选择要操作的节点!");
                }
            }
            else
            {

                if (this.treeView1.Nodes.Count > 0)
                {
                    //this.treeView1.Nodes[0];

                    //if (SelectedNode == null)
                    //{
                    SelectedNode = this.treeView1.Nodes[0];
                    //}

                    Dict = new Bse_Dict();

                    //设置当前添加状态的字典实体关键字
                    Dict.Dict_Key = DictKey.ToString();
                    Dict.Dict_PCode = this.treeView1.Nodes[0].Tag.ToString();
                    Dict.Dict_PName = this.treeView1.Nodes[0].Text;

                    //SetlblMessage("添加"+Dict.Dict_PName+"子结点信息");

                    SetMode(OperationTypeEnum.OperationType.Add);
                }

            }
        }
Exemple #19
0
        /// <summary>
        /// 添加数据字典 Bse_Dict对象(即:一条记录)
        /// </summary>
        public int Add(Bse_Dict bse_Dict)
        {
            string sql = "INSERT INTO Bse_Dict (Dict_Key,Dict_Code,Dict_Name,Dict_PCode,Dict_PName,Dict_Desp,Dict_SCode,Dict_Bak,Dict_UDef1,Dict_UDef2,Dict_UDef3,Dict_UDef4,Dict_UDef5,Dict_Level,Dict_IsEditable,Stat,Dict_Order) VALUES (@Dict_Key,@Dict_Code,@Dict_Name,@Dict_PCode,@Dict_PName,@Dict_Desp,@Dict_SCode,@Dict_Bak,@Dict_UDef1,@Dict_UDef2,@Dict_UDef3,@Dict_UDef4,@Dict_UDef5,@Dict_Level,@Dict_IsEditable,@Stat,@Dict_Order)";

            if (string.IsNullOrEmpty(bse_Dict.Dict_Key))
            {
                idb.AddParameter("@Dict_Key", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Key", bse_Dict.Dict_Key);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Code))
            {
                idb.AddParameter("@Dict_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Code", bse_Dict.Dict_Code);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Name))
            {
                idb.AddParameter("@Dict_Name", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Name", bse_Dict.Dict_Name);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_PCode))
            {
                idb.AddParameter("@Dict_PCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_PCode", bse_Dict.Dict_PCode);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_PName))
            {
                idb.AddParameter("@Dict_PName", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_PName", bse_Dict.Dict_PName);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Desp))
            {
                idb.AddParameter("@Dict_Desp", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Desp", bse_Dict.Dict_Desp);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_SCode))
            {
                idb.AddParameter("@Dict_SCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_SCode", bse_Dict.Dict_SCode);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Bak))
            {
                idb.AddParameter("@Dict_Bak", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Bak", bse_Dict.Dict_Bak);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef1))
            {
                idb.AddParameter("@Dict_UDef1", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef1", bse_Dict.Dict_UDef1);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef2))
            {
                idb.AddParameter("@Dict_UDef2", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef2", bse_Dict.Dict_UDef2);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef3))
            {
                idb.AddParameter("@Dict_UDef3", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef3", bse_Dict.Dict_UDef3);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef4))
            {
                idb.AddParameter("@Dict_UDef4", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef4", bse_Dict.Dict_UDef4);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef5))
            {
                idb.AddParameter("@Dict_UDef5", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef5", bse_Dict.Dict_UDef5);
            }
            if (bse_Dict.Dict_Level == 0)
            {
                idb.AddParameter("@Dict_Level", 0);
            }
            else
            {
                idb.AddParameter("@Dict_Level", bse_Dict.Dict_Level);
            }
            if (bse_Dict.Dict_IsEditable == 0)
            {
                idb.AddParameter("@Dict_IsEditable", 0);
            }
            else
            {
                idb.AddParameter("@Dict_IsEditable", bse_Dict.Dict_IsEditable);
            }
            if (bse_Dict.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", bse_Dict.Stat);
            }
            if (bse_Dict.Dict_Order == 0)
            {
                idb.AddParameter("@Dict_Order", 0);
            }
            else
            {
                idb.AddParameter("@Dict_Order", bse_Dict.Dict_Order);
            }

            return(idb.ExeCmd(sql));
        }
Exemple #20
0
        /// <summary>
        /// 更新数据字典 Bse_Dict对象(即:一条记录
        /// </summary>
        public int Update(Bse_Dict bse_Dict)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       Bse_Dict       SET ");
            if (bse_Dict.Dict_Key_IsChanged)
            {
                sbParameter.Append("Dict_Key=@Dict_Key, ");
            }
            if (bse_Dict.Dict_Code_IsChanged)
            {
                sbParameter.Append("Dict_Code=@Dict_Code, ");
            }
            if (bse_Dict.Dict_Name_IsChanged)
            {
                sbParameter.Append("Dict_Name=@Dict_Name, ");
            }
            if (bse_Dict.Dict_PCode_IsChanged)
            {
                sbParameter.Append("Dict_PCode=@Dict_PCode, ");
            }
            if (bse_Dict.Dict_PName_IsChanged)
            {
                sbParameter.Append("Dict_PName=@Dict_PName, ");
            }
            if (bse_Dict.Dict_Desp_IsChanged)
            {
                sbParameter.Append("Dict_Desp=@Dict_Desp, ");
            }
            if (bse_Dict.Dict_SCode_IsChanged)
            {
                sbParameter.Append("Dict_SCode=@Dict_SCode, ");
            }
            if (bse_Dict.Dict_Bak_IsChanged)
            {
                sbParameter.Append("Dict_Bak=@Dict_Bak, ");
            }
            if (bse_Dict.Dict_UDef1_IsChanged)
            {
                sbParameter.Append("Dict_UDef1=@Dict_UDef1, ");
            }
            if (bse_Dict.Dict_UDef2_IsChanged)
            {
                sbParameter.Append("Dict_UDef2=@Dict_UDef2, ");
            }
            if (bse_Dict.Dict_UDef3_IsChanged)
            {
                sbParameter.Append("Dict_UDef3=@Dict_UDef3, ");
            }
            if (bse_Dict.Dict_UDef4_IsChanged)
            {
                sbParameter.Append("Dict_UDef4=@Dict_UDef4, ");
            }
            if (bse_Dict.Dict_UDef5_IsChanged)
            {
                sbParameter.Append("Dict_UDef5=@Dict_UDef5, ");
            }
            if (bse_Dict.Dict_Level_IsChanged)
            {
                sbParameter.Append("Dict_Level=@Dict_Level, ");
            }
            if (bse_Dict.Dict_IsEditable_IsChanged)
            {
                sbParameter.Append("Dict_IsEditable=@Dict_IsEditable, ");
            }
            if (bse_Dict.Stat_IsChanged)
            {
                sbParameter.Append("Stat=@Stat, ");
            }
            if (bse_Dict.Dict_Order_IsChanged)
            {
                sbParameter.Append("Dict_Order=@Dict_Order ");
            }
            sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
            sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0))   and Dict_ID=@Dict_ID; ");
            string sql = sb.ToString();

            if (bse_Dict.Dict_Key_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Key))
                {
                    idb.AddParameter("@Dict_Key", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Key", bse_Dict.Dict_Key);
                }
            }
            if (bse_Dict.Dict_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Code))
                {
                    idb.AddParameter("@Dict_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Code", bse_Dict.Dict_Code);
                }
            }
            if (bse_Dict.Dict_Name_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Name))
                {
                    idb.AddParameter("@Dict_Name", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Name", bse_Dict.Dict_Name);
                }
            }
            if (bse_Dict.Dict_PCode_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_PCode))
                {
                    idb.AddParameter("@Dict_PCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_PCode", bse_Dict.Dict_PCode);
                }
            }
            if (bse_Dict.Dict_PName_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_PName))
                {
                    idb.AddParameter("@Dict_PName", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_PName", bse_Dict.Dict_PName);
                }
            }
            if (bse_Dict.Dict_Desp_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Desp))
                {
                    idb.AddParameter("@Dict_Desp", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Desp", bse_Dict.Dict_Desp);
                }
            }
            if (bse_Dict.Dict_SCode_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_SCode))
                {
                    idb.AddParameter("@Dict_SCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_SCode", bse_Dict.Dict_SCode);
                }
            }
            if (bse_Dict.Dict_Bak_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Bak))
                {
                    idb.AddParameter("@Dict_Bak", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Bak", bse_Dict.Dict_Bak);
                }
            }
            if (bse_Dict.Dict_UDef1_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef1))
                {
                    idb.AddParameter("@Dict_UDef1", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef1", bse_Dict.Dict_UDef1);
                }
            }
            if (bse_Dict.Dict_UDef2_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef2))
                {
                    idb.AddParameter("@Dict_UDef2", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef2", bse_Dict.Dict_UDef2);
                }
            }
            if (bse_Dict.Dict_UDef3_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef3))
                {
                    idb.AddParameter("@Dict_UDef3", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef3", bse_Dict.Dict_UDef3);
                }
            }
            if (bse_Dict.Dict_UDef4_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef4))
                {
                    idb.AddParameter("@Dict_UDef4", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef4", bse_Dict.Dict_UDef4);
                }
            }
            if (bse_Dict.Dict_UDef5_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef5))
                {
                    idb.AddParameter("@Dict_UDef5", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef5", bse_Dict.Dict_UDef5);
                }
            }
            if (bse_Dict.Dict_Level_IsChanged)
            {
                if (bse_Dict.Dict_Level == 0)
                {
                    idb.AddParameter("@Dict_Level", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_Level", bse_Dict.Dict_Level);
                }
            }
            if (bse_Dict.Dict_IsEditable_IsChanged)
            {
                if (bse_Dict.Dict_IsEditable == 0)
                {
                    idb.AddParameter("@Dict_IsEditable", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_IsEditable", bse_Dict.Dict_IsEditable);
                }
            }
            if (bse_Dict.Stat_IsChanged)
            {
                if (bse_Dict.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", bse_Dict.Stat);
                }
            }
            if (bse_Dict.Dict_Order_IsChanged)
            {
                if (bse_Dict.Dict_Order == 0)
                {
                    idb.AddParameter("@Dict_Order", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_Order", bse_Dict.Dict_Order);
                }
            }

            idb.AddParameter("@Dict_ID", bse_Dict.Dict_ID);

            return(idb.ExeCmd(sql));
        }
Exemple #21
0
 /// <summary>
 /// 更新字典
 /// </summary>
 /// <param name="dict"></param>
 /// <returns></returns>
 public int UpdateDict(Bse_Dict dict)
 {
     return Instance.Update(dict);
 }
Exemple #22
0
        /// <summary>
        /// 字典更新
        /// </summary>
        /// <param name="key"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool AddOrUpdateDict(string key, List<Bse_Dict> list)
        {
            List<Bse_Dict> oldlist = GetListByDictKey(key);

            foreach (Bse_Dict item in oldlist)
            {
                var temp = list.FirstOrDefault(o => o.Dict_Code == item.Dict_Code);
                if (temp != null)
                {
                    temp.Dict_ID = item.Dict_ID;

                    UpdateDict(temp);

                    list.Remove(temp);

                }
                else
                {
                    DeleteDict(item);
                }
            }

            foreach (var it in list)
            {
                Bse_Dict bs = new Bse_Dict();
                bs = it;
                int order = 0;

                bs.Dict_Key = key;

                bs.Dict_Code = GenerateDictCode(key, ref order);
                bs.Dict_Order = order;
                bs.Dict_PCode = key;

                AddDict(bs);
            }

            return true;
        }
Exemple #23
0
        /// <summary>
        /// 更新数据字典 Bse_Dict对象(即:一条记录
        /// </summary>
        public int Update(Bse_Dict bse_Dict)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       Bse_Dict       SET ");
            if (bse_Dict.Dict_Key_IsChanged)
            {
                sbParameter.Append("Dict_Key=@Dict_Key, ");
            }
            if (bse_Dict.Dict_Code_IsChanged)
            {
                sbParameter.Append("Dict_Code=@Dict_Code, ");
            }
            if (bse_Dict.Dict_Name_IsChanged)
            {
                sbParameter.Append("Dict_Name=@Dict_Name, ");
            }
            if (bse_Dict.Dict_Order_IsChanged)
            {
                sbParameter.Append("Dict_Order=@Dict_Order, ");
            }
            if (bse_Dict.Dict_PCode_IsChanged)
            {
                sbParameter.Append("Dict_PCode=@Dict_PCode, ");
            }
            if (bse_Dict.Dict_PName_IsChanged)
            {
                sbParameter.Append("Dict_PName=@Dict_PName, ");
            }
            if (bse_Dict.Dict_Desp_IsChanged)
            {
                sbParameter.Append("Dict_Desp=@Dict_Desp, ");
            }
            if (bse_Dict.Dict_SCode_IsChanged)
            {
                sbParameter.Append("Dict_SCode=@Dict_SCode, ");
            }
            if (bse_Dict.Dict_Bak_IsChanged)
            {
                sbParameter.Append("Dict_Bak=@Dict_Bak, ");
            }
            if (bse_Dict.Dict_UDef1_IsChanged)
            {
                sbParameter.Append("Dict_UDef1=@Dict_UDef1, ");
            }
            if (bse_Dict.Dict_UDef2_IsChanged)
            {
                sbParameter.Append("Dict_UDef2=@Dict_UDef2, ");
            }
            if (bse_Dict.Dict_UDef3_IsChanged)
            {
                sbParameter.Append("Dict_UDef3=@Dict_UDef3, ");
            }
            if (bse_Dict.Dict_UDef4_IsChanged)
            {
                sbParameter.Append("Dict_UDef4=@Dict_UDef4, ");
            }
            if (bse_Dict.Dict_UDef5_IsChanged)
            {
                sbParameter.Append("Dict_UDef5=@Dict_UDef5, ");
            }
            if (bse_Dict.Dict_Level_IsChanged)
            {
                sbParameter.Append("Dict_Level=@Dict_Level, ");
            }
            if (bse_Dict.Dict_IsEditable_IsChanged)
            {
                sbParameter.Append("Dict_IsEditable=@Dict_IsEditable, ");
            }
            if (bse_Dict.Stat_IsChanged)
            {
                sbParameter.Append("Stat=@Stat ");
            }
            sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
            sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0))   and Dict_ID=@Dict_ID; ");
            string sql = sb.ToString();

            if (bse_Dict.Dict_Key_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Key))
                {
                    idb.AddParameter("@Dict_Key", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Key", bse_Dict.Dict_Key);
                }
            }
            if (bse_Dict.Dict_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Code))
                {
                    idb.AddParameter("@Dict_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Code", bse_Dict.Dict_Code);
                }
            }
            if (bse_Dict.Dict_Name_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Name))
                {
                    idb.AddParameter("@Dict_Name", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Name", bse_Dict.Dict_Name);
                }
            }
            if (bse_Dict.Dict_Order_IsChanged)
            {
                if (bse_Dict.Dict_Order == 0)
                {
                    idb.AddParameter("@Dict_Order", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_Order", bse_Dict.Dict_Order);
                }
            }
            if (bse_Dict.Dict_PCode_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_PCode))
                {
                    idb.AddParameter("@Dict_PCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_PCode", bse_Dict.Dict_PCode);
                }
            }
            if (bse_Dict.Dict_PName_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_PName))
                {
                    idb.AddParameter("@Dict_PName", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_PName", bse_Dict.Dict_PName);
                }
            }
            if (bse_Dict.Dict_Desp_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Desp))
                {
                    idb.AddParameter("@Dict_Desp", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Desp", bse_Dict.Dict_Desp);
                }
            }
            if (bse_Dict.Dict_SCode_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_SCode))
                {
                    idb.AddParameter("@Dict_SCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_SCode", bse_Dict.Dict_SCode);
                }
            }
            if (bse_Dict.Dict_Bak_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_Bak))
                {
                    idb.AddParameter("@Dict_Bak", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_Bak", bse_Dict.Dict_Bak);
                }
            }
            if (bse_Dict.Dict_UDef1_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef1))
                {
                    idb.AddParameter("@Dict_UDef1", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef1", bse_Dict.Dict_UDef1);
                }
            }
            if (bse_Dict.Dict_UDef2_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef2))
                {
                    idb.AddParameter("@Dict_UDef2", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef2", bse_Dict.Dict_UDef2);
                }
            }
            if (bse_Dict.Dict_UDef3_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef3))
                {
                    idb.AddParameter("@Dict_UDef3", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef3", bse_Dict.Dict_UDef3);
                }
            }
            if (bse_Dict.Dict_UDef4_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef4))
                {
                    idb.AddParameter("@Dict_UDef4", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef4", bse_Dict.Dict_UDef4);
                }
            }
            if (bse_Dict.Dict_UDef5_IsChanged)
            {
                if (string.IsNullOrEmpty(bse_Dict.Dict_UDef5))
                {
                    idb.AddParameter("@Dict_UDef5", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dict_UDef5", bse_Dict.Dict_UDef5);
                }
            }
            if (bse_Dict.Dict_Level_IsChanged)
            {
                if (bse_Dict.Dict_Level == 0)
                {
                    idb.AddParameter("@Dict_Level", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_Level", bse_Dict.Dict_Level);
                }
            }
            if (bse_Dict.Dict_IsEditable_IsChanged)
            {
                if (bse_Dict.Dict_IsEditable == 0)
                {
                    idb.AddParameter("@Dict_IsEditable", 0);
                }
                else
                {
                    idb.AddParameter("@Dict_IsEditable", bse_Dict.Dict_IsEditable);
                }
            }
            if (bse_Dict.Stat_IsChanged)
            {
                if (bse_Dict.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", bse_Dict.Stat);
                }
            }

            idb.AddParameter("@Dict_ID", bse_Dict.Dict_ID);


            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();

            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = "0";

            foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
            {
                param.Add(item.Key, item.Value);
            }
            try
            {
                Re = idb.ExeCmd(sql);
                Ex = Re.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

            SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);

            return(Re);
        }
Exemple #24
0
 /// <summary>
 /// 是否拥有子节点
 /// </summary>
 /// <param name="dict"></param>
 /// <returns></returns>
 public bool IsHaveChild(Bse_Dict dict, DictKeyEnum key)
 {
     List<Bse_Dict> list = this.GetByParent(dict.Dict_Code, key)
      ;
     if (list != null && list.Count > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #25
0
        /// <summary>
        /// 获取指定的数据字典 Bse_Dict对象集合
        /// </summary>
        public List <Bse_Dict> GetListByWhere(string strCondition)
        {
            List <Bse_Dict> ret = new List <Bse_Dict>();
            string          sql = "SELECT  Dict_ID,Dict_Key,Dict_Code,Dict_Name,Dict_PCode,Dict_PName,Dict_Desp,Dict_SCode,Dict_Bak,Dict_UDef1,Dict_UDef2,Dict_UDef3,Dict_UDef4,Dict_UDef5,Dict_Level,Dict_IsEditable,Stat,Dict_Order FROM Bse_Dict WHERE 1=1 AND ((Stat is null) or (Stat=0) ) ";

            if (!string.IsNullOrEmpty(strCondition))
            {
                strCondition.Replace('\'', '"'); //防sql注入
                sql += strCondition;
            }
            sql += " ORDER BY Dict_ID DESC ";
            SqlDataReader dr = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    Bse_Dict bse_Dict = new Bse_Dict();
                    if (dr["Dict_ID"] != DBNull.Value)
                    {
                        bse_Dict.Dict_ID = Convert.ToInt64(dr["Dict_ID"]);
                    }
                    if (dr["Dict_Key"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Key = Convert.ToString(dr["Dict_Key"]);
                    }
                    if (dr["Dict_Code"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Code = Convert.ToString(dr["Dict_Code"]);
                    }
                    if (dr["Dict_Name"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Name = Convert.ToString(dr["Dict_Name"]);
                    }
                    if (dr["Dict_PCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PCode = Convert.ToString(dr["Dict_PCode"]);
                    }
                    if (dr["Dict_PName"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PName = Convert.ToString(dr["Dict_PName"]);
                    }
                    if (dr["Dict_Desp"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Desp = Convert.ToString(dr["Dict_Desp"]);
                    }
                    if (dr["Dict_SCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_SCode = Convert.ToString(dr["Dict_SCode"]);
                    }
                    if (dr["Dict_Bak"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Bak = Convert.ToString(dr["Dict_Bak"]);
                    }
                    if (dr["Dict_UDef1"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef1 = Convert.ToString(dr["Dict_UDef1"]);
                    }
                    if (dr["Dict_UDef2"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef2 = Convert.ToString(dr["Dict_UDef2"]);
                    }
                    if (dr["Dict_UDef3"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef3 = Convert.ToString(dr["Dict_UDef3"]);
                    }
                    if (dr["Dict_UDef4"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef4 = Convert.ToString(dr["Dict_UDef4"]);
                    }
                    if (dr["Dict_UDef5"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef5 = Convert.ToString(dr["Dict_UDef5"]);
                    }
                    if (dr["Dict_Level"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Level = Convert.ToInt32(dr["Dict_Level"]);
                    }
                    if (dr["Dict_IsEditable"] != DBNull.Value)
                    {
                        bse_Dict.Dict_IsEditable = Convert.ToInt32(dr["Dict_IsEditable"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        bse_Dict.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    if (dr["Dict_Order"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Order = Convert.ToInt32(dr["Dict_Order"]);
                    }
                    ret.Add(bse_Dict);
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(ret);
        }
Exemple #26
0
        /// <summary>
        /// 获取指定的数据字典 Bse_Dict对象(即:一条记录
        /// </summary>
        public Bse_Dict GetByKey(Int64 dict_ID)
        {
            Bse_Dict bse_Dict = new Bse_Dict();
            string   sql      = "SELECT  Dict_ID,Dict_Key,Dict_Code,Dict_Name,Dict_PCode,Dict_PName,Dict_Desp,Dict_SCode,Dict_Bak,Dict_UDef1,Dict_UDef2,Dict_UDef3,Dict_UDef4,Dict_UDef5,Dict_Level,Dict_IsEditable,Stat,Dict_Order FROM Bse_Dict WHERE 1=1 AND ((Stat is null) or (Stat=0) )  AND Dict_ID=@Dict_ID ";

            idb.AddParameter("@Dict_ID", dict_ID);

            SqlDataReader dr = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    if (dr["Dict_ID"] != DBNull.Value)
                    {
                        bse_Dict.Dict_ID = Convert.ToInt64(dr["Dict_ID"]);
                    }
                    if (dr["Dict_Key"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Key = Convert.ToString(dr["Dict_Key"]);
                    }
                    if (dr["Dict_Code"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Code = Convert.ToString(dr["Dict_Code"]);
                    }
                    if (dr["Dict_Name"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Name = Convert.ToString(dr["Dict_Name"]);
                    }
                    if (dr["Dict_PCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PCode = Convert.ToString(dr["Dict_PCode"]);
                    }
                    if (dr["Dict_PName"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PName = Convert.ToString(dr["Dict_PName"]);
                    }
                    if (dr["Dict_Desp"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Desp = Convert.ToString(dr["Dict_Desp"]);
                    }
                    if (dr["Dict_SCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_SCode = Convert.ToString(dr["Dict_SCode"]);
                    }
                    if (dr["Dict_Bak"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Bak = Convert.ToString(dr["Dict_Bak"]);
                    }
                    if (dr["Dict_UDef1"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef1 = Convert.ToString(dr["Dict_UDef1"]);
                    }
                    if (dr["Dict_UDef2"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef2 = Convert.ToString(dr["Dict_UDef2"]);
                    }
                    if (dr["Dict_UDef3"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef3 = Convert.ToString(dr["Dict_UDef3"]);
                    }
                    if (dr["Dict_UDef4"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef4 = Convert.ToString(dr["Dict_UDef4"]);
                    }
                    if (dr["Dict_UDef5"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef5 = Convert.ToString(dr["Dict_UDef5"]);
                    }
                    if (dr["Dict_Level"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Level = Convert.ToInt32(dr["Dict_Level"]);
                    }
                    if (dr["Dict_IsEditable"] != DBNull.Value)
                    {
                        bse_Dict.Dict_IsEditable = Convert.ToInt32(dr["Dict_IsEditable"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        bse_Dict.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    if (dr["Dict_Order"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Order = Convert.ToInt32(dr["Dict_Order"]);
                    }
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(bse_Dict);
        }
Exemple #27
0
        /// <summary>
        /// 添加字典信息
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        public object AddDictForReturn(Bse_Dict dict, DictKeyEnum key)
        {
            //默认添加为有效状态
            dict.Stat = 0;

            string dDepth = Instance.GetMaxByWhere("Dict_Level", key.ToString(), "").ToString();

            if (!string.IsNullOrEmpty(dDepth))
            {
                int depth = Convert.ToInt32(dDepth) + 1;
                dict.Dict_Code = key.ToString() + "_" + depth.ToString();
                dict.Dict_Level = depth;
            }
            object re = Instance.AddForReturn(dict);
            return re;
        }
Exemple #28
0
 public int DeleteDict(Bse_Dict dict)
 {
     //Instance.Delete(dict.Dict_ID);
     dict.Stat = 1;
     return Instance.Update(dict);
     //return 0;
 }
Exemple #29
0
        /// <summary>
        /// 添加数据字典 Bse_Dict对象(即:一条记录)
        /// </summary>
        public int Add(Bse_Dict bse_Dict)
        {
            string sql = "INSERT INTO Bse_Dict (Dict_Key,Dict_Code,Dict_Name,Dict_Order,Dict_PCode,Dict_PName,Dict_Desp,Dict_SCode,Dict_Bak,Dict_UDef1,Dict_UDef2,Dict_UDef3,Dict_UDef4,Dict_UDef5,Dict_Level,Dict_IsEditable,Stat) VALUES (@Dict_Key,@Dict_Code,@Dict_Name,@Dict_Order,@Dict_PCode,@Dict_PName,@Dict_Desp,@Dict_SCode,@Dict_Bak,@Dict_UDef1,@Dict_UDef2,@Dict_UDef3,@Dict_UDef4,@Dict_UDef5,@Dict_Level,@Dict_IsEditable,@Stat)";

            if (string.IsNullOrEmpty(bse_Dict.Dict_Key))
            {
                idb.AddParameter("@Dict_Key", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Key", bse_Dict.Dict_Key);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Code))
            {
                idb.AddParameter("@Dict_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Code", bse_Dict.Dict_Code);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Name))
            {
                idb.AddParameter("@Dict_Name", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Name", bse_Dict.Dict_Name);
            }
            if (bse_Dict.Dict_Order == 0)
            {
                idb.AddParameter("@Dict_Order", 0);
            }
            else
            {
                idb.AddParameter("@Dict_Order", bse_Dict.Dict_Order);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_PCode))
            {
                idb.AddParameter("@Dict_PCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_PCode", bse_Dict.Dict_PCode);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_PName))
            {
                idb.AddParameter("@Dict_PName", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_PName", bse_Dict.Dict_PName);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Desp))
            {
                idb.AddParameter("@Dict_Desp", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Desp", bse_Dict.Dict_Desp);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_SCode))
            {
                idb.AddParameter("@Dict_SCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_SCode", bse_Dict.Dict_SCode);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_Bak))
            {
                idb.AddParameter("@Dict_Bak", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_Bak", bse_Dict.Dict_Bak);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef1))
            {
                idb.AddParameter("@Dict_UDef1", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef1", bse_Dict.Dict_UDef1);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef2))
            {
                idb.AddParameter("@Dict_UDef2", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef2", bse_Dict.Dict_UDef2);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef3))
            {
                idb.AddParameter("@Dict_UDef3", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef3", bse_Dict.Dict_UDef3);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef4))
            {
                idb.AddParameter("@Dict_UDef4", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef4", bse_Dict.Dict_UDef4);
            }
            if (string.IsNullOrEmpty(bse_Dict.Dict_UDef5))
            {
                idb.AddParameter("@Dict_UDef5", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dict_UDef5", bse_Dict.Dict_UDef5);
            }
            if (bse_Dict.Dict_Level == 0)
            {
                idb.AddParameter("@Dict_Level", 0);
            }
            else
            {
                idb.AddParameter("@Dict_Level", bse_Dict.Dict_Level);
            }
            if (bse_Dict.Dict_IsEditable == 0)
            {
                idb.AddParameter("@Dict_IsEditable", 0);
            }
            else
            {
                idb.AddParameter("@Dict_IsEditable", bse_Dict.Dict_IsEditable);
            }
            if (bse_Dict.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", bse_Dict.Stat);
            }


            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();

            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = "0";

            foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
            {
                param.Add(item.Key, item.Value);
            }
            try
            {
                Re = idb.ExeCmd(sql);
                Ex = Re.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

            SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);

            return(Re);
        }
Exemple #30
0
 /// <summary>
 /// 是否重复编码
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public bool IsRepeatCode(Bse_Dict dict)
 {
     Bse_Dict dic = this.GetDictByKey(dict.Dict_Key, dict.Dict_Code);
     if (dic != null)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #31
0
        /// <summary>
        /// 获取所有的数据字典 Bse_Dict对象(即:一条记录
        /// </summary>
        public List <Bse_Dict> GetAll()
        {
            List <Bse_Dict> ret = new List <Bse_Dict>();
            string          sql = "SELECT  Dict_ID,Dict_Key,Dict_Code,Dict_Name,Dict_Order,Dict_PCode,Dict_PName,Dict_Desp,Dict_SCode,Dict_Bak,Dict_UDef1,Dict_UDef2,Dict_UDef3,Dict_UDef4,Dict_UDef5,Dict_Level,Dict_IsEditable,Stat FROM Bse_Dict where 1=1 AND ((Stat is null) or (Stat=0) ) order by Dict_ID desc ";
            SqlDataReader   dr  = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    Bse_Dict bse_Dict = new Bse_Dict();
                    if (dr["Dict_ID"] != DBNull.Value)
                    {
                        bse_Dict.Dict_ID = Convert.ToDecimal(dr["Dict_ID"]);
                    }
                    if (dr["Dict_Key"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Key = Convert.ToString(dr["Dict_Key"]);
                    }
                    if (dr["Dict_Code"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Code = Convert.ToString(dr["Dict_Code"]);
                    }
                    if (dr["Dict_Name"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Name = Convert.ToString(dr["Dict_Name"]);
                    }
                    if (dr["Dict_Order"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Order = Convert.ToInt32(dr["Dict_Order"]);
                    }
                    if (dr["Dict_PCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PCode = Convert.ToString(dr["Dict_PCode"]);
                    }
                    if (dr["Dict_PName"] != DBNull.Value)
                    {
                        bse_Dict.Dict_PName = Convert.ToString(dr["Dict_PName"]);
                    }
                    if (dr["Dict_Desp"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Desp = Convert.ToString(dr["Dict_Desp"]);
                    }
                    if (dr["Dict_SCode"] != DBNull.Value)
                    {
                        bse_Dict.Dict_SCode = Convert.ToString(dr["Dict_SCode"]);
                    }
                    if (dr["Dict_Bak"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Bak = Convert.ToString(dr["Dict_Bak"]);
                    }
                    if (dr["Dict_UDef1"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef1 = Convert.ToString(dr["Dict_UDef1"]);
                    }
                    if (dr["Dict_UDef2"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef2 = Convert.ToString(dr["Dict_UDef2"]);
                    }
                    if (dr["Dict_UDef3"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef3 = Convert.ToString(dr["Dict_UDef3"]);
                    }
                    if (dr["Dict_UDef4"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef4 = Convert.ToString(dr["Dict_UDef4"]);
                    }
                    if (dr["Dict_UDef5"] != DBNull.Value)
                    {
                        bse_Dict.Dict_UDef5 = Convert.ToString(dr["Dict_UDef5"]);
                    }
                    if (dr["Dict_Level"] != DBNull.Value)
                    {
                        bse_Dict.Dict_Level = Convert.ToInt32(dr["Dict_Level"]);
                    }
                    if (dr["Dict_IsEditable"] != DBNull.Value)
                    {
                        bse_Dict.Dict_IsEditable = Convert.ToInt32(dr["Dict_IsEditable"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        bse_Dict.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    ret.Add(bse_Dict);
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(ret);
        }
Exemple #32
0
 /// <summary>
 /// 添加字典信息
 /// </summary>
 /// <param name="dict"></param>
 /// <returns></returns>
 public int AddDict(Bse_Dict dict)
 {
     return Instance.Add(dict);
 }