Example #1
0
 private void ShowInfo(int MenuID)
 {
     WebDemo.BLL.WebDemo.MenusSub   bll   = new WebDemo.BLL.WebDemo.MenusSub();
     WebDemo.Model.WebDemo.MenusSub model = bll.GetModel(MenuID);
     this.lblMenuID.Text    = model.MenuID.ToString();
     this.lblUpperID.Text   = model.UpperID.ToString();
     this.lblMenuName.Text  = model.MenuName;
     this.lblUrlAddr.Text   = model.UrlAddr;
     this.lblUrlTarget.Text = model.UrlTarget;
     this.lblImageUrl.Text  = model.ImageUrl;
     this.lblFlag.Text      = model.Flag.ToString();
     this.lblOrdernum.Text  = model.Ordernum.ToString();
     this.lblSystemNum.Text = model.SystemNum.ToString();
 }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.MenusSub model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update MenusSub set ");
            strSql.Append("UpperID=@UpperID,");
            strSql.Append("MenuName=@MenuName,");
            strSql.Append("UrlAddr=@UrlAddr,");
            strSql.Append("UrlTarget=@UrlTarget,");
            strSql.Append("ImageUrl=@ImageUrl,");
            strSql.Append("Flag=@Flag,");
            strSql.Append("Ordernum=@Ordernum,");
            strSql.Append("SystemNum=@SystemNum");
            strSql.Append(" where MenuID=@MenuID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UpperID",   SqlDbType.Int,       4),
                new SqlParameter("@MenuName",  SqlDbType.VarChar,  50),
                new SqlParameter("@UrlAddr",   SqlDbType.VarChar, 200),
                new SqlParameter("@UrlTarget", SqlDbType.VarChar,  50),
                new SqlParameter("@ImageUrl",  SqlDbType.VarChar,  50),
                new SqlParameter("@Flag",      SqlDbType.Int,       4),
                new SqlParameter("@Ordernum",  SqlDbType.Int,       4),
                new SqlParameter("@SystemNum", SqlDbType.Int,       4),
                new SqlParameter("@MenuID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UpperID;
            parameters[1].Value = model.MenuName;
            parameters[2].Value = model.UrlAddr;
            parameters[3].Value = model.UrlTarget;
            parameters[4].Value = model.ImageUrl;
            parameters[5].Value = model.Flag;
            parameters[6].Value = model.Ordernum;
            parameters[7].Value = model.SystemNum;
            parameters[8].Value = model.MenuID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.MenusSub DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.MenusSub model = new WebDemo.Model.WebDemo.MenusSub();
     if (row != null)
     {
         if (row["MenuID"] != null && row["MenuID"].ToString() != "")
         {
             model.MenuID = int.Parse(row["MenuID"].ToString());
         }
         if (row["UpperID"] != null && row["UpperID"].ToString() != "")
         {
             model.UpperID = int.Parse(row["UpperID"].ToString());
         }
         if (row["MenuName"] != null)
         {
             model.MenuName = row["MenuName"].ToString();
         }
         if (row["UrlAddr"] != null)
         {
             model.UrlAddr = row["UrlAddr"].ToString();
         }
         if (row["UrlTarget"] != null)
         {
             model.UrlTarget = row["UrlTarget"].ToString();
         }
         if (row["ImageUrl"] != null)
         {
             model.ImageUrl = row["ImageUrl"].ToString();
         }
         if (row["Flag"] != null && row["Flag"].ToString() != "")
         {
             model.Flag = int.Parse(row["Flag"].ToString());
         }
         if (row["Ordernum"] != null && row["Ordernum"].ToString() != "")
         {
             model.Ordernum = int.Parse(row["Ordernum"].ToString());
         }
         if (row["SystemNum"] != null && row["SystemNum"].ToString() != "")
         {
             model.SystemNum = int.Parse(row["SystemNum"].ToString());
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.MenusSub model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MenusSub(");
            strSql.Append("MenuID,UpperID,MenuName,UrlAddr,UrlTarget,ImageUrl,Flag,Ordernum,SystemNum)");
            strSql.Append(" values (");
            strSql.Append("@MenuID,@UpperID,@MenuName,@UrlAddr,@UrlTarget,@ImageUrl,@Flag,@Ordernum,@SystemNum)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MenuID",    SqlDbType.Int,       4),
                new SqlParameter("@UpperID",   SqlDbType.Int,       4),
                new SqlParameter("@MenuName",  SqlDbType.VarChar,  50),
                new SqlParameter("@UrlAddr",   SqlDbType.VarChar, 200),
                new SqlParameter("@UrlTarget", SqlDbType.VarChar,  50),
                new SqlParameter("@ImageUrl",  SqlDbType.VarChar,  50),
                new SqlParameter("@Flag",      SqlDbType.Int,       4),
                new SqlParameter("@Ordernum",  SqlDbType.Int,       4),
                new SqlParameter("@SystemNum", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.MenuID;
            parameters[1].Value = model.UpperID;
            parameters[2].Value = model.MenuName;
            parameters[3].Value = model.UrlAddr;
            parameters[4].Value = model.UrlTarget;
            parameters[5].Value = model.ImageUrl;
            parameters[6].Value = model.Flag;
            parameters[7].Value = model.Ordernum;
            parameters[8].Value = model.SystemNum;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.MenusSub GetModel(int MenuID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 MenuID,UpperID,MenuName,UrlAddr,UrlTarget,ImageUrl,Flag,Ordernum,SystemNum from MenusSub ");
            strSql.Append(" where MenuID=@MenuID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MenuID", SqlDbType.Int, 4)
            };
            parameters[0].Value = MenuID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUpperID.Text))
            {
                strErr += "UpperID格式错误!\\n";
            }
            if (this.txtMenuName.Text.Trim().Length == 0)
            {
                strErr += "MenuName不能为空!\\n";
            }
            if (this.txtUrlAddr.Text.Trim().Length == 0)
            {
                strErr += "UrlAddr不能为空!\\n";
            }
            if (this.txtUrlTarget.Text.Trim().Length == 0)
            {
                strErr += "UrlTarget不能为空!\\n";
            }
            if (this.txtImageUrl.Text.Trim().Length == 0)
            {
                strErr += "ImageUrl不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtFlag.Text))
            {
                strErr += "Flag格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtOrdernum.Text))
            {
                strErr += "Ordernum格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtSystemNum.Text))
            {
                strErr += "SystemNum格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    MenuID    = int.Parse(this.lblMenuID.Text);
            int    UpperID   = int.Parse(this.txtUpperID.Text);
            string MenuName  = this.txtMenuName.Text;
            string UrlAddr   = this.txtUrlAddr.Text;
            string UrlTarget = this.txtUrlTarget.Text;
            string ImageUrl  = this.txtImageUrl.Text;
            int    Flag      = int.Parse(this.txtFlag.Text);
            int    Ordernum  = int.Parse(this.txtOrdernum.Text);
            int    SystemNum = int.Parse(this.txtSystemNum.Text);


            WebDemo.Model.WebDemo.MenusSub model = new WebDemo.Model.WebDemo.MenusSub();
            model.MenuID    = MenuID;
            model.UpperID   = UpperID;
            model.MenuName  = MenuName;
            model.UrlAddr   = UrlAddr;
            model.UrlTarget = UrlTarget;
            model.ImageUrl  = ImageUrl;
            model.Flag      = Flag;
            model.Ordernum  = Ordernum;
            model.SystemNum = SystemNum;

            WebDemo.BLL.WebDemo.MenusSub bll = new WebDemo.BLL.WebDemo.MenusSub();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }