protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         btnClose.OnClientClick = ActiveWindow.GetHideReference();
         BindGrid();
         Calendar1.SelectedDate = DateTime.Now;
         if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
         {
             ddlfatherId.SelectedValue = Request.QueryString["tyId"];
             ddlfatherId.Enabled       = false;
         }
         if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
         {
             ddlfatherId.Enabled = true;
             Maticsoft.BLL.tArticle   bll   = new Maticsoft.BLL.tArticle();
             Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"]));
             imgPhoto.ImageUrl         = model.FengMian;
             txtTile.Text              = model.Title;
             txtRemark.Text            = model.Remark;
             txtEdit.Text              = model.Editor;
             Calendar1.SelectedDate    = model.UpdateTime;
             ddlfatherId.SelectedValue = model.ArtTyID.ToString();
             txtSort.Text              = model.Sort.ToString();
             hfEditorInitValue.Text    = model.ArticleContent;
         }
     }
 }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["tId"] == null && Request.QueryString["Id"] == null)
            {
                Response.Redirect("index.aspx");
                return;
            }
            int tId = 0;

            try
            {
                tId = int.Parse(Request.QueryString["tId"].ToString());
            }
            catch
            {
                Response.Redirect("index.aspx");
                return;
            }
            if (!IsPostBack)
            {
                getNav(tId);
            }
            Maticsoft.Model.tArticle model = null;
            Maticsoft.BLL.tArticle   BLL   = new Maticsoft.BLL.tArticle();
            model       = BLL.GetModel(int.Parse(Request.QueryString["Id"]));
            model.Click = (model.Click + 1);
            BLL.Update(model);
            lit_title.Text   = model.Title;
            this.Title      += "-" + model.Title;
            lit_content.Text = model.ArticleContent;
            lit_edit.Text    = model.Editor;
            lit_click.Text   = model.Click.ToString();
            lit_time.Text    = Convert.ToDateTime(model.UpdateTime).ToString("yyyy-MM-dd");
        }
Exemple #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.tArticle model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tArticle set ");
            strSql.Append("Title=@Title,");
            strSql.Append("ArticleContent=@ArticleContent,");
            strSql.Append("Sort=@Sort,");
            strSql.Append("Editor=@Editor,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("ArtTyID=@ArtTyID,");
            strSql.Append("Click=@Click,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("FengMian=@FengMian,");
            strSql.Append("IsEnable=@IsEnable");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",          SqlDbType.NVarChar,  100),
                new SqlParameter("@ArticleContent", SqlDbType.NVarChar,   -1),
                new SqlParameter("@Sort",           SqlDbType.Int,         4),
                new SqlParameter("@Editor",         SqlDbType.NVarChar,   50),
                new SqlParameter("@UpdateTime",     SqlDbType.DateTime),
                new SqlParameter("@ArtTyID",        SqlDbType.Int,         4),
                new SqlParameter("@Click",          SqlDbType.Int,         4),
                new SqlParameter("@Remark",         SqlDbType.NVarChar,  200),
                new SqlParameter("@FengMian",       SqlDbType.NVarChar,  250),
                new SqlParameter("@IsEnable",       SqlDbType.Int,         4),
                new SqlParameter("@Id",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.ArticleContent;
            parameters[2].Value  = model.Sort;
            parameters[3].Value  = model.Editor;
            parameters[4].Value  = model.UpdateTime;
            parameters[5].Value  = model.ArtTyID;
            parameters[6].Value  = model.Click;
            parameters[7].Value  = model.Remark;
            parameters[8].Value  = model.FengMian;
            parameters[9].Value  = model.IsEnable;
            parameters[10].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tArticle DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tArticle model = new Maticsoft.Model.tArticle();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["ArticleContent"] != null)
         {
             model.ArticleContent = row["ArticleContent"].ToString();
         }
         if (row["Sort"] != null && row["Sort"].ToString() != "")
         {
             model.Sort = int.Parse(row["Sort"].ToString());
         }
         if (row["Editor"] != null)
         {
             model.Editor = row["Editor"].ToString();
         }
         if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
         {
             model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
         }
         if (row["ArtTyID"] != null && row["ArtTyID"].ToString() != "")
         {
             model.ArtTyID = int.Parse(row["ArtTyID"].ToString());
         }
         if (row["Click"] != null && row["Click"].ToString() != "")
         {
             model.Click = int.Parse(row["Click"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["FengMian"] != null)
         {
             model.FengMian = row["FengMian"].ToString();
         }
         if (row["IsEnable"] != null && row["IsEnable"].ToString() != "")
         {
             model.IsEnable = int.Parse(row["IsEnable"].ToString());
         }
     }
     return(model);
 }
Exemple #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.tArticle model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tArticle(");
            strSql.Append("Title,ArticleContent,Sort,Editor,UpdateTime,ArtTyID,Click,Remark,FengMian,IsEnable)");
            strSql.Append(" values (");
            strSql.Append("@Title,@ArticleContent,@Sort,@Editor,@UpdateTime,@ArtTyID,@Click,@Remark,@FengMian,@IsEnable)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",          SqlDbType.NVarChar,  100),
                new SqlParameter("@ArticleContent", SqlDbType.NVarChar,   -1),
                new SqlParameter("@Sort",           SqlDbType.Int,         4),
                new SqlParameter("@Editor",         SqlDbType.NVarChar,   50),
                new SqlParameter("@UpdateTime",     SqlDbType.DateTime),
                new SqlParameter("@ArtTyID",        SqlDbType.Int,         4),
                new SqlParameter("@Click",          SqlDbType.Int,         4),
                new SqlParameter("@Remark",         SqlDbType.NVarChar,  200),
                new SqlParameter("@FengMian",       SqlDbType.NVarChar,  250),
                new SqlParameter("@IsEnable",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.ArticleContent;
            parameters[2].Value = model.Sort;
            parameters[3].Value = model.Editor;
            parameters[4].Value = model.UpdateTime;
            parameters[5].Value = model.ArtTyID;
            parameters[6].Value = model.Click;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.FengMian;
            parameters[9].Value = model.IsEnable;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tArticle GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Title,ArticleContent,Sort,Editor,UpdateTime,ArtTyID,Click,Remark,FengMian,IsEnable from tArticle ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        protected void Grid_RowCommand(object sender, GridCommandEventArgs e)
        {
            int artId = GetSelectedDataKeyID(Grid);


            if (e.CommandName == "Delete")
            {
                Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();

                Maticsoft.Model.tArticle model = BLL.GetModel(artId);
                if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png"))
                {
                    string directoryPath = Server.MapPath(model.FengMian);
                    File.Delete(directoryPath);
                    //删除掉原来的图片
                }
                BLL.Delete(artId);
                GetView();
            }
            if (e.CommandName == "Edit")
            {
                PageContext.RegisterStartupScript(Window1.GetShowReference("ArticlesEdit.aspx?Id=" + artId));
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.tArticle bll = new Maticsoft.BLL.tArticle();
            if (imgPhoto.ImageUrl == "")
            {
                filePhoto.MarkInvalid("请先上传封面图片!");

                Alert.ShowInTop("请先上传封面图片!");
                return;
            }
            if (Calendar1.SelectedDate == null)
            {
                Calendar1.SelectedDate = DateTime.Now;
            }
            string content = Request.Form["editor1"] == null ? "" : Request.Form["editor1"];

            if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
            {
                Maticsoft.Model.tArticle model = new Maticsoft.Model.tArticle();
                model.FengMian       = imgPhoto.ImageUrl;
                model.Title          = txtTile.Text;
                model.Remark         = txtRemark.Text;
                model.Editor         = txtEdit.Text;
                model.UpdateTime     = Calendar1.SelectedDate;
                model.ArtTyID        = int.Parse(ddlfatherId.SelectedValue);
                model.Sort           = int.Parse(txtSort.Text);
                model.ArticleContent = content;
                model.IsEnable       = 1;
                int k = bll.Add(model);



                if (k > 0)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"]));
                if (imgPhoto.ImageUrl != model.FengMian)
                {
                    if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png"))
                    {
                        string directoryPath = Server.MapPath(model.FengMian);
                        File.Delete(directoryPath);
                        //删除掉原来的图片
                    }
                }
                model.FengMian       = imgPhoto.ImageUrl;
                model.Title          = txtTile.Text;
                model.Remark         = txtRemark.Text;
                model.Editor         = txtEdit.Text;
                model.UpdateTime     = Calendar1.SelectedDate;
                model.ArtTyID        = int.Parse(ddlfatherId.SelectedValue);
                model.Sort           = int.Parse(txtSort.Text);
                model.ArticleContent = content;
                model.IsEnable       = 1;
                bll.Update(model);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
        }