protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string fileName = this.hiddenFileName.Value;

        if (myFileUpload.HasFile)
        {
            Cmn.uploadFile upF             = new Cmn.uploadFile();
            string[]       allowExtensions = { ".jpg", ".gif", ".png" };
            int            maxSize         = Convert.ToInt32(Cmn.WebConfig.getApp("app_MaxSizeUpload"));
            string         savePath        = Request.MapPath("~/upload/weiboHome/");
            fileName = myFileUpload.FileName;
            try
            {
                upF.Upload(this.myFileUpload, allowExtensions, maxSize, savePath, fileName);
            }
            catch (Exception exp)
            {
                Cmn.Js.ShowAlert(exp.Message);
                return;
            }
        }

        DBEntity.Tab_HomeWeibo ent = new DBEntity.Tab_HomeWeibo();
        ent.Idx          = int.Parse(Request["Idx"]);
        ent.EditName     = this.EditName.Text;
        ent.WeiboContent = this.WeiboContent.Text;
        ent.HeaderImg    = fileName;
        ent.SortNo       = int.Parse(this.SortNo.Text);
        ent.HomeShowBool = this.HomeShowBool.SelectedValue;
        ent.DateCreated  = DateTime.Now;

        ent.Update(ent);
        Cmn.Js.ShowAlert("操作成功!");
        Cmn.Js.ExeScript("location.href='weiboHomeManage.aspx'");
    }
Пример #2
0
        private static Tab_HomeWeibo ToModel(DataRow row)
        {
            Tab_HomeWeibo model = new Tab_HomeWeibo();

            model.Idx          = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.EditName     = row.IsNull("EditName")?null:(System.String)row["EditName"];
            model.HeaderImg    = row.IsNull("HeaderImg")?null:(System.String)row["HeaderImg"];
            model.WeiboContent = row.IsNull("WeiboContent")?null:(System.String)row["WeiboContent"];
            model.SortNo       = row.IsNull("SortNo")?null:(System.Int32?)row["SortNo"];
            model.DateCreated  = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            model.HomeShowBool = row.IsNull("HomeShowBool")?null:(System.String)row["HomeShowBool"];
            return(model);
        }
Пример #3
0
        public int AddNew(Tab_HomeWeibo model)
        {
            string sql = "insert into Tab_HomeWeibo(EditName,HeaderImg,WeiboContent,SortNo,HomeShowBool)  values(@EditName,@HeaderImg,@WeiboContent,@SortNo,@HomeShowBool); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@EditName", model.EditName)
                                                                 , new SqlParameter("@HeaderImg", model.HeaderImg)
                                                                 , new SqlParameter("@WeiboContent", model.WeiboContent)
                                                                 , new SqlParameter("@SortNo", model.SortNo)

                                                                 , new SqlParameter("@HomeShowBool", model.HomeShowBool)
                                                                 ));

            return(Idx);
        }
Пример #4
0
        public bool Update(Tab_HomeWeibo model)
        {
            string sql  = "update Tab_HomeWeibo set EditName=@EditName,HeaderImg=@HeaderImg,WeiboContent=@WeiboContent,SortNo=@SortNo,DateCreated=@DateCreated,HomeShowBool=@HomeShowBool where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@EditName", model.EditName)
                                                    , new SqlParameter("@HeaderImg", model.HeaderImg)
                                                    , new SqlParameter("@WeiboContent", model.WeiboContent)
                                                    , new SqlParameter("@SortNo", model.SortNo)
                                                    , new SqlParameter("@DateCreated", model.DateCreated)
                                                    , new SqlParameter("@HomeShowBool", model.HomeShowBool)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Пример #5
0
        public Tab_HomeWeibo Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_HomeWeibo  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow       row   = dt.Rows[0];
            Tab_HomeWeibo model = ToModel(row);

            return(model);
        }
Пример #6
0
    //首页微博
    private void ShowHomeWeibo()
    {
        string strSql = "select * from Tab_HomeWeibo where HomeShowBool='yes' order by SortNo";
        IEnumerable <DBEntity.Tab_HomeWeibo> ents = new DBEntity.Tab_HomeWeibo().ListAll(strSql);

        StringBuilder contentStr = new StringBuilder("");

        foreach (DBEntity.Tab_HomeWeibo ent in ents)
        {
            contentStr.AppendLine(" <li>");
            contentStr.AppendLine("   <dl>");
            contentStr.AppendLine(string.Format("     <dt><img src='upload/weiboHome/{0}' width='50' height='50' /></dt>", ent.HeaderImg));
            contentStr.AppendLine(string.Format("     <dd><span>{0}:</span>{1}</dd>", ent.EditName, Cmn.Str.GetStr(ent.WeiboContent, 100, false)));
            contentStr.AppendLine("       <br class='clr' />");
            contentStr.AppendLine("   </dl>");
            contentStr.AppendLine("</li>");
        }

        this.ltl_weiboHome.Text = contentStr.ToString();
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         string idx = Request["idx"];
         if (!String.IsNullOrEmpty(idx))
         {
             DBEntity.Tab_HomeWeibo ent = new DBEntity.Tab_HomeWeibo();
             ent = ent.Get(idx);
             this.EditName.Text     = ent.EditName;
             this.WeiboContent.Text = ent.WeiboContent;
             this.Image1.ImageUrl   = string.Format("~/upload/weiboHome/{0}", ent.HeaderImg);
             this.SortNo.Text       = ent.SortNo.ToString();
             for (int i = 0; i < this.HomeShowBool.Items.Count; i++)
             {
                 if (this.HomeShowBool.Items[i].Value == ent.HomeShowBool)
                 {
                     this.HomeShowBool.Items[i].Selected = true;
                 }
             }
             this.hiddenFileName.Value = ent.HeaderImg;
         }
     }
 }