Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (CurrAdmin == null)
         {
             RedirectToLogin();
         }
         else
         {
             if (Request.QueryString["t"] != null && Request.QueryString["t"] == "edit")
             {
                 //修改
                 XNotice nobj = bllXNotice.GetOneByID(Request.QueryString["id"]);
                 if (nobj != null)
                 {
                     txtTitle.Text        = nobj.Title;
                     txtInfo.Text         = nobj.Info;
                     txtIndex.Text        = nobj.SortIndex.ToString();
                     ViewState["hid"]     = nobj.NID;
                     ViewState["backurl"] = Request.UrlReferrer.ToString();
                 }
             }
             else
             {
                 //新增
                 ViewState["hid"]     = "";
                 ViewState["backurl"] = Request.UrlReferrer.ToString();
             }
         }
     }
 }
Esempio n. 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string tmpID   = "";
            string backUrl = "";

            if (ViewState["hid"] != null)
            {
                tmpID = ViewState["hid"].ToString();
            }
            if (ViewState["backurl"] != null)
            {
                backUrl = ViewState["backurl"].ToString();
            }
            if (tmpID.Length > 0)
            {
                //修改
                XNotice nobj = bllXNotice.GetOneByID(tmpID);
                if (nobj != null)
                {
                    nobj.Title      = txtTitle.Text;
                    nobj.Info       = txtInfo.Text;
                    nobj.UpdateTime = DateTime.Now;
                    if (bllXNotice.Update(nobj))
                    {
                        JscriptMsg("已成功提交保存!", backUrl);
                    }
                    else
                    {
                        JscriptMsg("提交保存失败,请重新提交!", "");
                    }
                }
            }
            else
            {
                //新增
                XNotice nobj = new XNotice()
                {
                    NID        = CreateID(),
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now,
                    Info       = txtInfo.Text,
                    IsDeleted  = 0,
                    IsPublish  = 1,
                    NType      = "公告通知",
                    SortIndex  = Convert.ToInt32(txtIndex.Text),
                    Title      = txtTitle.Text
                };
                if (bllXNotice.Add(nobj))
                {
                    JscriptMsg("已成功提交保存!", backUrl);
                }
                else
                {
                    JscriptMsg("提交保存失败,请重新提交!", "");
                }
            }
        }
Esempio n. 3
0
        public bool Update(XNotice model)
        {
            string sql = string.Format(@"update XNotice
                set NType=@NType,Info=@Info,IsPublish=@IsPublish,Title=@Title,
                    SortIndex=@SortIndex,IsDeleted=@IsDeleted,CreateTime=@CreateTime,
                    UpdateTime=@UpdateTime
                where NID=@NID");

            DbParameter[] parms =
            {
                new SqlParameter("@NID",        SqlDbType.VarChar, 50)
                {
                    Value = model.NID
                },
                new SqlParameter("@NType",      SqlDbType.VarChar, 50)
                {
                    Value = model.NType
                },
                new SqlParameter("@Info",       SqlDbType.Text)
                {
                    Value = model.Info
                },
                new SqlParameter("@IsPublish",  SqlDbType.Int)
                {
                    Value = model.IsPublish
                },
                new SqlParameter("@Title",      SqlDbType.VarChar, 500)
                {
                    Value = model.Title
                },
                new SqlParameter("@SortIndex",  SqlDbType.Int)
                {
                    Value = model.SortIndex
                },
                new SqlParameter("@IsDeleted",  SqlDbType.Int)
                {
                    Value = model.IsDeleted
                },
                new SqlParameter("@CreateTime", SqlDbType.DateTime)
                {
                    Value = model.CreateTime
                },
                new SqlParameter("@UpdateTime", SqlDbType.DateTime)
                {
                    Value = model.UpdateTime
                }
            };
            return(dbHelper.ExecuteNonQuery(sql, parms));
        }
Esempio n. 4
0
        public bool Add(XNotice model)
        {
            string sql = string.Format(@"insert into XNotice
                (NID,NType,Info,IsPublish,Title,SortIndex,IsDeleted,CreateTime,UpdateTime) 
                values(@NID,@NType,@Info,@IsPublish,@Title,@SortIndex,@IsDeleted,@CreateTime,@UpdateTime) ");

            DbParameter[] parms =
            {
                new SqlParameter("@NID",        SqlDbType.VarChar, 50)
                {
                    Value = model.NID
                },
                new SqlParameter("@NType",      SqlDbType.VarChar, 50)
                {
                    Value = model.NType
                },
                new SqlParameter("@Info",       SqlDbType.Text)
                {
                    Value = model.Info
                },
                new SqlParameter("@IsPublish",  SqlDbType.Int)
                {
                    Value = model.IsPublish
                },
                new SqlParameter("@Title",      SqlDbType.VarChar, 500)
                {
                    Value = model.Title
                },
                new SqlParameter("@SortIndex",  SqlDbType.Int)
                {
                    Value = model.SortIndex
                },
                new SqlParameter("@IsDeleted",  SqlDbType.Int)
                {
                    Value = model.IsDeleted
                },
                new SqlParameter("@CreateTime", SqlDbType.DateTime)
                {
                    Value = model.CreateTime
                },
                new SqlParameter("@UpdateTime", SqlDbType.DateTime)
                {
                    Value = model.UpdateTime
                }
            };
            return(dbHelper.ExecuteNonQuery(sql, parms));
        }
Esempio n. 5
0
        public bool Delete(XNotice model)
        {
            string sql = string.Format(@"update XNotice
                set IsDeleted=@IsDeleted,UpdateTime=@UpdateTime
                where NID=@NID");

            DbParameter[] parms =
            {
                new SqlParameter("@NID",        SqlDbType.VarChar, 50)
                {
                    Value = model.NID
                },
                new SqlParameter("@IsDeleted",  SqlDbType.Int)
                {
                    Value = model.IsDeleted
                },
                new SqlParameter("@UpdateTime", SqlDbType.DateTime)
                {
                    Value = model.UpdateTime
                }
            };
            return(dbHelper.ExecuteNonQuery(sql, parms));
        }
Esempio n. 6
0
 public bool Delete(XNotice model)
 {
     return(dal.Delete(model));
 }
Esempio n. 7
0
 public bool Update(XNotice model)
 {
     return(dal.Update(model));
 }
Esempio n. 8
0
 public bool Add(XNotice model)
 {
     return(dal.Add(model));
 }