示例#1
0
        /// <summary>
        /// 删
        /// </summary>
        /// <param name="model">empty model with key value</param>
        /// <returns></returns>
        public bool DeletePowers(PowersModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("delete from Powers where 1=1 ");
            sb.Append("and pcode=@pcode ");
            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("@pcode", model.pcode));
            int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray());

            return(res > 0);
        }
示例#2
0
        protected void OnBtnSaveClick(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session[SysConst.S_LOGIN_USER] == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(btnSave.CommandName))
            {
                return;
            }
            PowersModel model = new PowersModel();

            if (btnSave.CommandName == CMD_MOD)
            {
                model = FGA_BLL.Cache.PowersCache.Powers.Find(p => p.pcode == btnSave.CommandArgument);
            }
            else
            {
                model.pcode = btnSave.CommandArgument;//添加时放入父节点编码,逻辑层替换
            }
            model.pname        = FGA_NUtility.SqlCheck.CheckStr(txtName.Text.Trim());
            model.purl         = FGA_NUtility.SqlCheck.CheckStr(txtUrl.Text.Trim());
            model.pdescription = FGA_NUtility.SqlCheck.CheckStr(txtDescription.Text.Trim());
            model.bz           = 1;
            if (rdoYes.Checked)
            {
                model.bz = 0;
            }
            //save


            bool res = false;

            if (btnSave.CommandName == CMD_ADD)
            {
                res = FGA_BLL.PowersBLL.AddPowers(model);
            }
            else
            {
                res = FGA_BLL.PowersBLL.UpdatePowers(model);
            }

            if (res)
            {
                FGA_BLL.Cache.PowersCache.InitCache();//刷新缓存
                base.DoYmpromptBack(string.Format("{0}{1}{2}", model.pcode, SysConst.SPLIT, model.pname));
            }
        }
示例#3
0
        /// <summary>
        /// 查
        /// </summary>
        /// <param name="model">empty model with key value</param>
        /// <returns></returns>
        public PowersModel GetPowersInfo(PowersModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select * from Powers where 1=1 ");
            sb.Append("and pcode=@pcode ");
            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("@pcode", model.pcode));
            DataSet ds = Base.SQLServerHelper.Query(sb.ToString(), pms.ToArray());

            if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            return(new PowersModel(ds.Tables[0].Rows[0]));
        }
示例#4
0
        /// <summary>
        /// 改
        /// </summary>
        /// <param name="model">model to be updated</param>
        /// <returns></returns>
        public bool UpdatePowers(PowersModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("update Powers set ");
            sb.Append("pname=@pname, pdescription=@pdescription, purl=@purl,bz=@bz ");
            sb.Append("where 1=1 ");
            sb.Append("and pcode=@pcode ");
            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("@pcode", model.pcode));
            pms.Add(new SqlParameter("@pname", model.pname));
            pms.Add(new SqlParameter("@pdescription", model.pdescription));
            pms.Add(new SqlParameter("@purl", model.purl));
            pms.Add(new SqlParameter("@bz", model.bz));
            int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray());

            return(res > 0);
        }
示例#5
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="model">new model</param>
        /// <returns></returns>
        public bool AddPowers(PowersModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("insert into Powers ( ");
            sb.Append("pcode,pname,pdescription,purl,bz");
            sb.Append(") values ( ");
            sb.Append("@pcode,@pname,@pdescription,@purl,@bz");
            sb.Append(") ");
            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("@pcode", model.pcode));
            pms.Add(new SqlParameter("@pname", model.pname));
            pms.Add(new SqlParameter("@pdescription", model.pdescription));
            pms.Add(new SqlParameter("@purl", model.purl));
            pms.Add(new SqlParameter("@bz", model.bz));
            int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray());

            return(res > 0);
        }
示例#6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (HttpContext.Current.Session[SysConst.S_LOGIN_USER] == null)
         {
             return;
         }
         string parentCode = Request.QueryString["pcode"];
         string departCode = Request.QueryString["code"];
         if (!string.IsNullOrEmpty(parentCode))
         {
             //传入父编码时为添加
             btnSave.CommandName     = CMD_ADD;
             btnSave.CommandArgument = parentCode;
         }
         if (!string.IsNullOrEmpty(departCode))
         {
             //传入编码为修改,加载旧数据
             btnSave.CommandName     = CMD_MOD;
             btnSave.CommandArgument = departCode;
             PowersModel model = FGA_BLL.Cache.PowersCache.Powers.Find(p => p.pcode == btnSave.CommandArgument);
             if (model != null)
             {
                 txtName.Text        = model.pname;
                 txtUrl.Text         = model.purl;
                 txtDescription.Text = model.pdescription;
                 if (model.bz == 0)
                 {
                     rdoYes.Checked = true;
                     rdoNo.Checked  = false;
                 }
                 else
                 {
                     rdoNo.Checked  = true;
                     rdoYes.Checked = false;
                 }
             }
         }
     }
 }
示例#7
0
 /// <summary>
 /// 查
 /// </summary>
 /// <param name="model">empty model with key value</param>
 /// <returns></returns>
 public static PowersModel GetPowersInfo(PowersModel model)
 {
     return(Common.Instance._Powers.GetPowersInfo(model));
 }
示例#8
0
 /// <summary>
 /// 删
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool DeletePowers(PowersModel model)
 {
     return(Common.Instance._Powers.DeletePowers(model));
 }
示例#9
0
 /// <summary>
 /// 增
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddPowers(PowersModel model)
 {
     model.pcode = Common.Instance._Powers.GetMaxPowerCode(model.pcode);
     return(Common.Instance._Powers.AddPowers(model));
 }