Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.tLinkType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tLinkType set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Sort=@Sort,");
            strSql.Append("FatherID=@FatherID");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",     SqlDbType.NVarChar, 30),
                new SqlParameter("@Sort",     SqlDbType.Int,       4),
                new SqlParameter("@FatherID", SqlDbType.Int,       4),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Sort;
            parameters[2].Value = model.FatherID;
            parameters[3].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.tLinkType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tLinkType(");
            strSql.Append("Name,Sort,FatherID)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Sort,@FatherID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",     SqlDbType.NVarChar, 30),
                new SqlParameter("@Sort",     SqlDbType.Int,       4),
                new SqlParameter("@FatherID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Sort;
            parameters[2].Value = model.FatherID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
        /// <summary>
        /// 根据ArtGuid 来给控件赋值
        /// </summary>
        /// <param name="ArtGuid"></param>
        public void UpMenuModel(string ArtGuid)
        {
            Maticsoft.BLL.tLinkType   BLL = new Maticsoft.BLL.tLinkType();
            Maticsoft.Model.tLinkType m   = BLL.GetModel(int.Parse(ArtGuid));

            txtName.Text = m.Name;
            ddlfatherId.SelectedValue = m.FatherID.ToString();
            txtSort.Text = m.Sort.ToString();
        }
Exemple #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["ArtGuid"]))
            {
                Maticsoft.BLL.tLinkType BLL = new Maticsoft.BLL.tLinkType();
                int ArtGuid = int.Parse(Request.QueryString["ArtGuid"]);
                Maticsoft.Model.tLinkType menu = BLL.GetModel(ArtGuid);
                if (BLL.GetList(string.Format(" Name='{0}' and Id<>{1} ", txtName.Text, ArtGuid)).Tables[0].Rows.Count >= 1)
                {
                    Alert.ShowInTop("该分类名称已经存在!"); return;
                }
                if (ddlfatherId.SelectedValue == menu.Id.ToString())
                {
                    Alert.ShowInTop("上级分类不可选择!"); return;
                }
                menu.Id       = ArtGuid;
                menu.Name     = txtName.Text.ToString().Trim();
                menu.FatherID = int.Parse(ddlfatherId.SelectedValue);
                menu.Sort     = Convert.ToInt32(txtSort.Text.ToString().Trim());

                if (BLL.Update(menu) == true)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("操作失败!");
                }
            }
            else
            {
                Maticsoft.BLL.tLinkType   BLL  = new Maticsoft.BLL.tLinkType();
                Maticsoft.Model.tLinkType menu = new Maticsoft.Model.tLinkType();
                if (BLL.GetList(string.Format(" Name='{0}' ", txtName.Text)).Tables[0].Rows.Count >= 1)
                {
                    Alert.ShowInTop("该分类名称已经存在!"); return;
                }

                menu.Name     = txtName.Text.ToString().Trim();
                menu.FatherID = int.Parse(ddlfatherId.SelectedValue);
                menu.Sort     = Convert.ToInt32(txtSort.Text.ToString().Trim());

                if (BLL.Add(menu) >= 1)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("操作失败!");
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tLinkType DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tLinkType model = new Maticsoft.Model.tLinkType();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Sort"] != null && row["Sort"].ToString() != "")
         {
             model.Sort = int.Parse(row["Sort"].ToString());
         }
         if (row["FatherID"] != null && row["FatherID"].ToString() != "")
         {
             model.FatherID = int.Parse(row["FatherID"].ToString());
         }
     }
     return(model);
 }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tLinkType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,Sort,FatherID from tLinkType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Maticsoft.Model.tLinkType model = new Maticsoft.Model.tLinkType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }