示例#1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.SuccessInfo   successbll   = new Maticsoft.BLL.SuccessInfo();
     Maticsoft.Model.SuccessInfo successmodel = new Maticsoft.Model.SuccessInfo();
     if (txtsuccesstitle.Text.Trim() == "")
     {
         lbltitle.Text = "请填写案例名称";
         return;
     }
     successmodel.SuccessTitle = txtsuccesstitle.Text.Trim();
     lbltitle.Text             = "";
     if (txtwrite.Text.Trim() == "")
     {
         lblwrite.Text = "请填写发布人";
         return;
     }
     successmodel.Write = txtwrite.Text.Trim();
     lblwrite.Text      = "";
     if (txtfatime.Text.Trim() == "")
     {
         lblfatime.Text = "请填写您的发布时间";
     }
     successmodel.Fatime         = Convert.ToDateTime(txtfatime.Text.Trim());
     lblfatime.Text              = "";
     successmodel.ImageURL       = Image1.ImageUrl;
     successmodel.SuccessContent = txtcontent.Text.Trim();
     successbll.Add(successmodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
     txtsuccesstitle.Text = string.Empty;
     txtwrite.Text        = string.Empty;
     txtfatime.Text       = string.Empty;
     txtcontent.Text      = string.Empty;
 }
示例#2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtSuccessTitle.Text.Trim().Length == 0)
            {
                strErr += "SuccessTitle不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (this.txtWrite.Text.Trim().Length == 0)
            {
                strErr += "Write不能为空!\\n";
            }
            if (this.txtImageURL.Text.Trim().Length == 0)
            {
                strErr += "ImageURL不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtHitNum.Text))
            {
                strErr += "HitNum格式错误!\\n";
            }
            if (this.txtSuccessContent.Text.Trim().Length == 0)
            {
                strErr += "SuccessContent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      SuccessID      = int.Parse(this.lblSuccessID.Text);
            string   SuccessTitle   = this.txtSuccessTitle.Text;
            DateTime Fatime         = DateTime.Parse(this.txtFatime.Text);
            string   Write          = this.txtWrite.Text;
            string   ImageURL       = this.txtImageURL.Text;
            int      HitNum         = int.Parse(this.txtHitNum.Text);
            string   SuccessContent = this.txtSuccessContent.Text;


            Maticsoft.Model.SuccessInfo model = new Maticsoft.Model.SuccessInfo();
            model.SuccessID      = SuccessID;
            model.SuccessTitle   = SuccessTitle;
            model.Fatime         = Fatime;
            model.Write          = Write;
            model.ImageURL       = ImageURL;
            model.HitNum         = HitNum;
            model.SuccessContent = SuccessContent;

            Maticsoft.BLL.SuccessInfo bll = new Maticsoft.BLL.SuccessInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
示例#3
0
 private void ShowInfo(int SuccessID)
 {
     Maticsoft.BLL.SuccessInfo   bll   = new Maticsoft.BLL.SuccessInfo();
     Maticsoft.Model.SuccessInfo model = bll.GetModel(SuccessID);
     this.lblSuccessID.Text      = model.SuccessID.ToString();
     this.txtSuccessTitle.Text   = model.SuccessTitle;
     this.txtFatime.Text         = model.Fatime.ToString();
     this.txtWrite.Text          = model.Write;
     this.txtImageURL.Text       = model.ImageURL;
     this.txtHitNum.Text         = model.HitNum.ToString();
     this.txtSuccessContent.Text = model.SuccessContent;
 }
示例#4
0
        private void bind()
        {
            Maticsoft.BLL.SuccessInfo successbll = new Maticsoft.BLL.SuccessInfo();
            int index = int.Parse(Request.QueryString["SuccessID"].ToString());

            Maticsoft.Model.SuccessInfo successmodel = successbll.GetModel(index);
            lblfatime.Text  = Convert.ToDateTime(successmodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            lbltitle.Text   = successmodel.SuccessTitle;
            lblwrite.Text   = successmodel.Write;
            txtcontent.Text = successmodel.SuccessContent;
            Image1.ImageUrl = successmodel.ImageURL;
        }
示例#5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["SuccessID"] != null)
         {
             if (Request.QueryString["SuccessID"].ToString() != "")
             {
                 int successid = int.Parse(Request.QueryString["SuccessID"].ToString());
                 Maticsoft.BLL.SuccessInfo   success      = new Maticsoft.BLL.SuccessInfo();
                 Maticsoft.Model.SuccessInfo successmodel = success.GetModel(successid);
                 lblFatime.Text = Convert.ToDateTime(successmodel.Fatime.ToString()).ToString("yyyy-MM-dd");
                 int hitnum = 0;
                 if (successmodel.HitNum != null)
                 {
                     successmodel.HitNum = successmodel.HitNum + 1;
                     success.Update(successmodel);
                     lblHitNum.Text = successmodel.HitNum.ToString();
                 }
                 else
                 {
                     successmodel.HitNum = 1;
                     success.Update(successmodel);
                     lblHitNum.Text = successmodel.HitNum.ToString();
                 }
                 lbllblSuccessTitle1.Text = successmodel.SuccessTitle;
                 lblSuccessContent.Text   = successmodel.SuccessContent;
                 lblSuccessTitle.Text     = successmodel.SuccessTitle;
                 lblWrite.Text            = successmodel.Write;
                 ImgImageURL.ImageUrl     = successmodel.ImageURL;
             }
             else
             {
                 Response.Redirect("success.aspx");
             }
         }
         else
         {
             Response.Redirect("success.aspx");
         }
     }
 }
示例#6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SuccessInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SuccessInfo set ");
            strSql.Append("SuccessTitle=@SuccessTitle,");
            strSql.Append("Fatime=@Fatime,");
            strSql.Append("Write=@Write,");
            strSql.Append("ImageURL=@ImageURL,");
            strSql.Append("HitNum=@HitNum,");
            strSql.Append("SuccessContent=@SuccessContent");
            strSql.Append(" where SuccessID=@SuccessID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SuccessID",      SqlDbType.Int,         4),
                new SqlParameter("@SuccessTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@Fatime",         SqlDbType.DateTime),
                new SqlParameter("@Write",          SqlDbType.VarChar,   200),
                new SqlParameter("@ImageURL",       SqlDbType.Text),
                new SqlParameter("@HitNum",         SqlDbType.Int,         4),
                new SqlParameter("@SuccessContent", SqlDbType.Text)
            };
            parameters[0].Value = model.SuccessID;
            parameters[1].Value = model.SuccessTitle;
            parameters[2].Value = model.Fatime;
            parameters[3].Value = model.Write;
            parameters[4].Value = model.ImageURL;
            parameters[5].Value = model.HitNum;
            parameters[6].Value = model.SuccessContent;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SuccessInfo GetModel(int SuccessID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SuccessID,SuccessTitle,Fatime,Write,ImageURL,HitNum,SuccessContent from SuccessInfo ");
            strSql.Append(" where SuccessID=@SuccessID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SuccessID", SqlDbType.Int, 4)
            };
            parameters[0].Value = SuccessID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SuccessID"].ToString() != "")
                {
                    model.SuccessID = int.Parse(ds.Tables[0].Rows[0]["SuccessID"].ToString());
                }
                model.SuccessTitle = ds.Tables[0].Rows[0]["SuccessTitle"].ToString();
                if (ds.Tables[0].Rows[0]["Fatime"].ToString() != "")
                {
                    model.Fatime = DateTime.Parse(ds.Tables[0].Rows[0]["Fatime"].ToString());
                }
                model.Write    = ds.Tables[0].Rows[0]["Write"].ToString();
                model.ImageURL = ds.Tables[0].Rows[0]["ImageURL"].ToString();
                if (ds.Tables[0].Rows[0]["HitNum"].ToString() != "")
                {
                    model.HitNum = int.Parse(ds.Tables[0].Rows[0]["HitNum"].ToString());
                }
                model.SuccessContent = ds.Tables[0].Rows[0]["SuccessContent"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.SuccessInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SuccessInfo(");
            strSql.Append("SuccessTitle,Fatime,Write,ImageURL,HitNum,SuccessContent)");
            strSql.Append(" values (");
            strSql.Append("@SuccessTitle,@Fatime,@Write,@ImageURL,@HitNum,@SuccessContent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SuccessTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@Fatime",         SqlDbType.DateTime),
                new SqlParameter("@Write",          SqlDbType.VarChar,   200),
                new SqlParameter("@ImageURL",       SqlDbType.Text),
                new SqlParameter("@HitNum",         SqlDbType.Int,         4),
                new SqlParameter("@SuccessContent", SqlDbType.Text)
            };
            parameters[0].Value = model.SuccessTitle;
            parameters[1].Value = model.Fatime;
            parameters[2].Value = model.Write;
            parameters[3].Value = model.ImageURL;
            parameters[4].Value = model.HitNum;
            parameters[5].Value = model.SuccessContent;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }