Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(GSSModel.Menus model)
        {
            StringBuilder strSql = new StringBuilder();

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

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GSSModel.Menus GetModel(int F_MenuID)
        {
            StringBuilder strSql = new StringBuilder();

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

            GSSModel.Menus model = new GSSModel.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_FormName"] != null)
                {
                    model.F_FormName = ds.Tables[0].Rows[0]["F_FormName"].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;
                    }
                }
                if (ds.Tables[0].Rows[0]["F_Sort"].ToString() != "")
                {
                    model.F_Sort = int.Parse(ds.Tables[0].Rows[0]["F_Sort"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 初始化窗体
 /// </summary>
 private void InitForm()
 {
     if (_id != 0)
     {
         this.Text = "菜单修改";
         f_MenuIDTextBox.Enabled = false;
         GSSBLL.Menus   bll   = new GSSBLL.Menus();
         GSSModel.Menus model = bll.GetModel(_id);
         f_MenuIDTextBox.Text     = model.F_MenuID.ToString();
         f_ParentIDTextBox.Text   = model.F_ParentID.ToString();
         f_NameTextBox.Text       = model.F_Name;
         f_FormNameTextBox.Text   = model.F_FormName;
         f_SortTextBox.Text       = model.F_Sort.ToString();
         f_IsUsedCheckBox.Checked = model.F_IsUsed;
     }
 }
        /// <summary>
        /// 保存数据
        /// </summary>
        private void SaveData()
        {
            //验证数据项
            string msg = CheckData();

            if (msg.Length > 0)
            {
                MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //数据准备
            GSSModel.Menus model = new GSSModel.Menus();
            model.F_MenuID   = Convert.ToInt32(f_MenuIDTextBox.Text);
            model.F_ParentID = Convert.ToInt32(f_ParentIDTextBox.Text);
            model.F_Name     = f_NameTextBox.Text;
            model.F_FormName = f_FormNameTextBox.Text;
            model.F_Sort     = Convert.ToInt32(f_SortTextBox.Text);
            model.F_IsUsed   = f_IsUsedCheckBox.Checked;


            //数据提交
            GSSBLL.Menus bll  = new GSSBLL.Menus();
            bool         isok = false;

            if (_id != 0)
            {
                isok = bll.Update(model);
            }
            else
            {
                isok = bll.Add(model);
            }
            if (isok)
            {
                MessageBox.Show("数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(GSSModel.Menus model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }