Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtF_Name.Text.Trim().Length == 0)
            {
                strErr += "菜单名称不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtF_ParentID.Text))
            {
                strErr += "父编号格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string F_Name     = this.txtF_Name.Text;
            int    F_ParentID = int.Parse(this.txtF_ParentID.Text);
            bool   F_IsUsed   = this.chkF_IsUsed.Checked;

            WSS.Model.Menus model = new WSS.Model.Menus();
            model.F_Name     = F_Name;
            model.F_ParentID = F_ParentID;
            model.F_IsUsed   = F_IsUsed;

            WSS.BLL.Menus bll = new WSS.BLL.Menus();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WSS.Model.Menus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Menus set ");
            strSql.Append("F_Name=@F_Name,");
            strSql.Append("F_ParentID=@F_ParentID,");
            strSql.Append("F_IsUsed=@F_IsUsed");
            strSql.Append(" where F_MenuID=@F_MenuID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@F_ParentID", SqlDbType.Int,       4),
                new SqlParameter("@F_IsUsed",   SqlDbType.Bit,       1),
                new SqlParameter("@F_MenuID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_Name;
            parameters[1].Value = model.F_ParentID;
            parameters[2].Value = model.F_IsUsed;
            parameters[3].Value = model.F_MenuID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WSS.Model.Menus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Menus(");
            strSql.Append("F_Name,F_ParentID,F_IsUsed)");
            strSql.Append(" values (");
            strSql.Append("@F_Name,@F_ParentID,@F_IsUsed)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@F_ParentID", SqlDbType.Int,       4),
                new SqlParameter("@F_IsUsed",   SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.F_Name;
            parameters[1].Value = model.F_ParentID;
            parameters[2].Value = model.F_IsUsed;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 private void ShowInfo(int F_MenuID)
 {
     WSS.BLL.Menus   bll   = new WSS.BLL.Menus();
     WSS.Model.Menus model = bll.GetModel(F_MenuID);
     this.lblF_MenuID.Text    = model.F_MenuID.ToString();
     this.txtF_Name.Text      = model.F_Name;
     this.txtF_ParentID.Text  = model.F_ParentID.ToString();
     this.chkF_IsUsed.Checked = model.F_IsUsed;
 }
Ejemplo n.º 5
0
 private void ShowInfo(int F_MenuID)
 {
     WSS.BLL.Menus   bll   = new WSS.BLL.Menus();
     WSS.Model.Menus model = bll.GetModel(F_MenuID);
     this.lblF_MenuID.Text   = model.F_MenuID.ToString();
     this.lblF_Name.Text     = model.F_Name;
     this.lblF_ParentID.Text = model.F_ParentID.ToString();
     this.lblF_IsUsed.Text   = model.F_IsUsed?"ÊÇ":"·ñ";
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WSS.Model.Menus GetModel(int F_MenuID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_MenuID,F_Name,F_ParentID,F_IsUsed from T_Menus ");
            strSql.Append(" where F_MenuID=@F_MenuID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_MenuID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_MenuID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_MenuID"].ToString() != "")
                {
                    model.F_MenuID = int.Parse(ds.Tables[0].Rows[0]["F_MenuID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_Name"] != null)
                {
                    model.F_Name = ds.Tables[0].Rows[0]["F_Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_ParentID"].ToString() != "")
                {
                    model.F_ParentID = int.Parse(ds.Tables[0].Rows[0]["F_ParentID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_IsUsed"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_IsUsed"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_IsUsed"].ToString().ToLower() == "true"))
                    {
                        model.F_IsUsed = true;
                    }
                    else
                    {
                        model.F_IsUsed = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }