Exemplo n.º 1
0
        private void AddNewIndustryProcess(IndustryInfo peer)
        {
            peer.Id = _industryService.AddIndustryInfo(peer);

            var source = this.tlIndustry.DataSource as List <IndustryInfo>;

            source.Add(peer);
            this.tlIndustry.RefreshDataSource();
            this.tlIndustry.SetFocusedNode(this.tlIndustry.FocusedNode.ParentNode.LastNode);
        }
Exemplo n.º 2
0
        public virtual int AddIndustryInfo(IndustryInfo entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            _industryInfoRepository.Insert(entity);

            return(entity.Id);
        }
Exemplo n.º 3
0
        //
        // GET: /Category/Industry/

        public ActionResult List()
        {
            var list = IndustryService.List();

            ViewBag.List = list;
            int          id           = Controleng.Common.CECRequest.GetQueryInt("id", 0);
            IndustryInfo industryInfo = null;

            if (id > 0)
            {
                industryInfo = IndustryService.GetById(id);
            }
            return(View(industryInfo));
        }
Exemplo n.º 4
0
 public static IndustryInfo Create(IndustryInfo model)
 {
     if (model.Id == 0)
     {
         //Add
         int id = CategoryManage.AddIndustryInfo(model);
         model.Id = id;
     }
     else
     {
         CategoryManage.UpdateIndustryInfo(model);
     }
     return(model);
 }
Exemplo n.º 5
0
        public static IndustryInfo GetIndustryInfoById(int id)
        {
            string       strSQL = "SELECT * FROM Categories WITH(NOLOCK) WHERE Id = @Id AND [Type] = 'industry'";
            SqlParameter parm   = new SqlParameter("Id", id);
            DataRow      dr     = SQLPlus.ExecuteDataRow(CommandType.Text, strSQL, parm);
            IndustryInfo model  = new IndustryInfo();

            if (dr != null)
            {
                model.Alias     = dr.Field <string>("Alias");
                model.Id        = dr.Field <int>("Id");
                model.IsDeleted = dr.Field <bool>("IsDeleted");
                model.Name      = dr.Field <string>("Name");
                model.Sort      = dr.Field <int>("Sort");
            }
            return(model);
        }
Exemplo n.º 6
0
        public ActionResult List(IndustryInfo model)
        {
            //检查
            //如果添加,判断别名是否存在
            bool isAdd = true;
            var  list  = IndustryService.List();

            if (model.Id > 0)
            {
                isAdd = false;
            }
            if (isAdd)
            {
                //判断是否别名存在
                if (!string.IsNullOrEmpty(model.Alias))
                {
                    if (list.Where(m => m.Alias == model.Alias).Count() > 0)
                    {
                        ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名");
                    }
                }
            }
            else
            {
                //编辑,除了自身之外,判断是否存在
                if (!string.IsNullOrEmpty(model.Alias))
                {
                    if (list.Where(m => (m.Alias == model.Alias && m.Id != model.Id)).Count() > 0)
                    {
                        ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名");
                    }
                }
            }

            if (ModelState.IsValid)
            {
                IndustryService.Create(model);
                ViewBag.Msg = "保存成功";
            }

            list         = IndustryService.List();
            ViewBag.List = list;


            return(View());
        }
Exemplo n.º 7
0
        private void BindIndustryTree()
        {
            var industryInfos = _industryService.GetAllIndustry();

            var all = new IndustryInfo
            {
                Id       = 0,
                ParentId = -1,
                Name     = "全部",
                Level    = 0,
            };

            industryInfos.Add(all);

            this.tlIndustry.Initialize(industryInfos, "Id", "ParentId", editable: true, showColumns: false, autoWidth: true, showHorzLines: false, showVertLines: false, expandAll: true);
            this.tlIndustry.AllowDrop = false;
            this.tlIndustry.OptionsDragAndDrop.DragNodesMode = DevExpress.XtraTreeList.DragNodesMode.Single;
            this.tlIndustry.SetDefaultFocusedNode(0);
        }
Exemplo n.º 8
0
        public static int UpdateIndustryInfo(IndustryInfo model)
        {
            string strSQL = "UPDATE Categories SET Name = @Name,Alias = @Alias,Sort = @Sort,IsDeleted = @IsDeleted WHERE Id = @Id AND [Type] = 'industry'";

            SqlParameter[] parms =
            {
                new SqlParameter("Id",        SqlDbType.Int),
                new SqlParameter("Name",      SqlDbType.NVarChar),
                new SqlParameter("Alias",     SqlDbType.NVarChar),
                new SqlParameter("Sort",      SqlDbType.Int),
                new SqlParameter("IsDeleted", SqlDbType.Bit),
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.Name;
            parms[2].Value = model.Alias;
            parms[3].Value = model.Sort;
            parms[4].Value = model.IsDeleted;

            return(SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 添加行业分类
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddIndustryInfo(IndustryInfo model)
        {
            string strSQL = "INSERT INTO Categories(ParentId,RootId,ParentIds,Name,Alias,Sort,IsDeleted,[Type],CreateDateTime) VALUES(0,0,'0',@Name,@Alias,@Sort,@IsDeleted,@Type,GETDATE());SELECT @@IDENTITY;";

            SqlParameter[] param =
            {
                new SqlParameter("Name",      SqlDbType.NVarChar),
                new SqlParameter("Alias",     SqlDbType.VarChar),
                new SqlParameter("Sort",      SqlDbType.Int),
                new SqlParameter("IsDeleted", SqlDbType.Bit),
                new SqlParameter("Type",      SqlDbType.VarChar)
            };
            param[0].Value = model.Name;
            param[1].Value = model.Alias.ToLower();
            param[2].Value = model.Sort;
            param[3].Value = model.IsDeleted;
            param[4].Value = CatType.Industry.ToString().ToLower();

            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, param)));
        }
Exemplo n.º 10
0
        private void barBtnAddChild_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                TreeListNode currentNode = this.tlIndustry.FocusedNode;
                if (currentNode == null)
                {
                    return;
                }
                var peer = new IndustryInfo
                {
                    Name     = "新建主体",
                    ParentId = Convert.ToInt32(currentNode.GetValue(tcId)),
                    Remarks  = null,
                };

                AddNewIndustryProcess(peer);
            }
            catch (Exception ex)
            {
                DXMessage.ShowError(ex.Message);
            }
        }