Ejemplo n.º 1
0
        public string UpdateCategory(string nId, string name, string parentId)
        {
            if (string.IsNullOrEmpty(nId))
            {
                return("没有找到要编辑的数据,请检查");
            }
            Guid gId = Guid.Empty;

            if (!Guid.TryParse(nId, out gId))
            {
                return("当前编辑行的主键ID不合法,请检查");
            }
            if (string.IsNullOrEmpty(name))
            {
                return("类型名称不能为空");
            }
            if (string.IsNullOrEmpty(parentId))
            {
                return("所属名称对应值不正确,请检查");
            }
            Guid pId = Guid.Empty;

            if (!Guid.TryParse(parentId, out pId))
            {
                return("所属名称对应值格式不正确");
            }

            Model.Category model = new Model.Category();
            model.NumberID        = nId;
            model.CategoryName    = name;
            model.ParentID        = pId;
            model.Title           = "All";
            model.Sort            = 0;
            model.Remark          = string.Empty;
            model.LastUpdatedDate = DateTime.Now;

            BLL.Category cBll   = new BLL.Category();
            int          effect = cBll.Update(model);

            if (effect == 110)
            {
                return("已存在相同记录");
            }
            if (effect > 0)
            {
                return("操作成功");
            }
            else
            {
                return("操作失败");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (int.TryParse(Request.Params["id"], out id))
            {
                model = bll.GetModel(id);
            }


            model.ParentId  = int.Parse(ddlParentType.SelectedValue);
            model.Remark    = "";
            model.SortNum   = int.Parse(txtSortNum.Text);
            model.StateInfo = ckState.Checked ? 1 : 0;
            model.SubTitle  = txtSubTitle.Text;
            model.Title     = txtTitle.Text;

            if (int.Parse(ddlParentType.SelectedValue) == 0)
            {
                model.LevelNum = 0;
            }
            else
            {
                model.LevelNum = bll.GetModel(int.Parse(ddlParentType.SelectedValue)).LevelNum + 1;
            }

            if (string.IsNullOrEmpty(model.Id.ToString()) || string.Equals(model.Id.ToString(), "0"))
            {
                model.NumId   = bll.SetNumID();
                model.AddTime = DateTime.Now;

                if (bll.Add(model) > 0)
                {
                    JsMessage("类别添加成功", 2000, "true", "index.aspx");
                }
                else
                {
                    JsMessage("类别添加失败,请稍候重试", 2000, "false");
                }
            }
            else
            {
                if (bll.Update(model))
                {
                    JsMessage("类别信息修改成功", 2000, "true", "index.aspx" + Request.Url.Query);
                }
                else
                {
                    JsMessage("类别信息修改失败,请稍候重试", 2000, "false");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存数据
        /// </summary>
        private void OnSave()
        {
            hBackToN.Value = (int.Parse(hBackToN.Value) + 1).ToString();;

            #region 获取输入并验证

            string sName     = txtCategoryname.Value.Trim();
            string sParentID = "0";
            string sRemark   = txtCategoryname.Value.Trim();

            if (ddlCategory.SelectedIndex > -1)
            {
                sParentID = ddlCategory.SelectedValue;
            }

            if (string.IsNullOrEmpty(sName))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "分类名称不能为空", "操作错误", "error");
                return;
            }

            #endregion

            if (cBll == null)
            {
                cBll = new BLL.Category();
            }

            Model.Category model = new Model.Category();
            model.CategoryName = sName;
            model.ParentID     = sParentID;
            model.Remark       = sRemark;
            model.Sort         = 0;
            model.CreateDate   = DateTime.Now;
            model.Title        = title;

            int result = -1;
            if (!string.IsNullOrEmpty(cId))
            {
                model.NumberID = cId;
                result         = cBll.Update(model);
            }
            else
            {
                result = cBll.Insert(model);
            }

            if (result == 110)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "分类名称已存在,请换一个再重试!");
                return;
            }

            if (result > 0)
            {
                WebHelper.MessageBox.MessagerShow(this.Page, lbtnSave, "提交成功!");

                //重新加载所属分类
                InitCategoryList(ddlCategory);
            }
            else
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "提交失败,系统异常!", "系统提示");
            }
        }