Beispiel #1
0
 /// <summary>
 /// 得到一个实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ShowShop.Model.Accessories.Hailhellowlink GetModelByID(int id)
 {
     ShowShop.Model.Accessories.Hailhellowlink model = new ShowShop.Model.Accessories.Hailhellowlink();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 [id],[sitename],[siteurl],[sitelogo],[sitelevel],[sitecontent],[sitelinktype],[sitestate],[siteclickcount],[createdate],[updatedate],[putoutid],[putouttyid],[aread] from yxs_hailhellowlink ");
     strSql.Append(" where [id]=@id ");
     SqlParameter[] parameters = (SqlParameter[])this.ValueIDPara(id);
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters))
     {
         if (reader.Read())
         {
             model.ID = reader.GetInt32(0);
             model.SiteName = reader.GetString(1);
             model.SiteUrl = reader.GetString(2);
             model.SiteLogo = reader.GetString(3);
             model.SiteLevel = reader.GetInt32(4);
             model.SiteContent = reader.GetString(5);
             model.SiteLinkType = reader.GetInt32(6);
             model.SiteState = reader.GetInt32(7);
             model.SiteClickCount = reader.GetInt32(8);
             model.CreateDate = reader.GetDateTime(9);
             model.UpdateDate = reader.GetDateTime(10);
             model.PutoutID = reader.GetInt32(11);
             model.PutoutTyID = reader.GetInt32(12);
             model.Aread = reader.GetString(13);
             //model.SiteImages = reader.GetString(14);//
         }
     }
     return model;
 }
        /// <summary>
        /// 保存
        /// </summary>
        protected void Save()
        {
            ShowShop.BLL.Accessories.Hailhellowlink bll = new ShowShop.BLL.Accessories.Hailhellowlink();
            ShowShop.Model.Accessories.Hailhellowlink model = new ShowShop.Model.Accessories.Hailhellowlink();
            ShowShop.Common.SysParameter sp = new ShowShop.Common.SysParameter();
            model.SiteName = this.txtSiteName.Text.Trim();
            model.SiteUrl = this.txtSiteUrl.Text.Trim();
            if (this.txtSiteLogo.Text.Trim() != null && this.txtSiteLogo.Text.Trim() != "" && !this.fuSmallImages.HasFile)
            {
                model.SiteLogo = this.txtSiteLogo.Text.Trim();
            }
            else
            {
                //获取图片
                ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                uf.ExtensionLim = ".gif,.jpg,.jpeg,.dmp";
                uf.FileLengthLim = sp.ImageSize;
                uf.PostedFile = this.fuSmallImages;
                uf.SavePath = "/yxuploadfile/brand";
                if (uf.Upload())
                {
                    if (uf.HaveLoad)
                    {
                        model.SiteLogo = uf.FilePath;
                    }
                    else
                    {
                        if (ViewState["SiteImages"] != null)
                        {
                            model.SiteLogo = ViewState["SiteImages"].ToString();
                        }
                        else
                        {
                            model.SiteLogo = string.Empty;
                        }
                    }
                }
                else
                {
                    this.ltlMsg.Text = "操作失败," + uf.Message + "";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
            }
            //model.SiteLogo = this.txtSiteLogo.Text.Trim();
            model.SiteLevel = Convert.ToInt32(this.txtSiteLevel.Text.Trim());
            model.SiteContent = this.txtSiteContent.Text.Trim();
            model.SiteLinkType = Convert.ToInt32(this.rablistLinkType.SelectedValue);
            model.SiteState = Convert.ToInt32(this.rablistSiteState.SelectedValue);
            model.SiteClickCount = this.txtSiteClickCount.Text == string.Empty ? 0 : Convert.ToInt32(this.txtSiteClickCount.Text.Trim());
            model.Aread = this.hfAread.Value != string.Empty ? this.hfAread.Value : "0";

            if (ViewState["ID"] != null)
            {
                model.ID = Convert.ToInt32(ViewState["ID"].ToString());
                model.PutoutID = Convert.ToInt32(ViewState["PutoutID"]);
                model.PutoutTyID = Convert.ToInt32(ViewState["PutoutTyID"]);
                model.UpdateDate = DateTime.Now;
                model.CreateDate = Convert.ToDateTime(ViewState["CreateDate"].ToString());
                bll.Amend(model);
                this.ltlMsg.Text = "操作成功,已保存该信息";
                this.BandInfo(model.ID);//刷新
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";
            }
            else
            {
                //添加时的类型
                model.PutoutTyID = 0;
                ShowShop.Model.Admin.AdminInfo adminModel = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
                //管理员ID
                model.PutoutID = adminModel.AdminId;
                model.CreateDate = DateTime.Now;
                model.UpdateDate = DateTime.Now;
                bll.Add(model);
                this.ltlMsg.Text = "操作成功,已添加该信息";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";
            }
        }
Beispiel #3
0
 /// <summary>
 /// 所有数据集合
 /// </summary>
 /// <returns></returns>
 public List<ShowShop.Model.Accessories.Hailhellowlink> GetAll()
 {
     List<ShowShop.Model.Accessories.Hailhellowlink> list = new List<ShowShop.Model.Accessories.Hailhellowlink>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  [id],[sitename],[siteurl],[sitelogo],[sitelevel],[sitecontent],[sitelinktype],[sitestate],[siteclickcount],[createdate],[updatedate],[putoutid],[putouttyid],[aread] from yxs_hailhellowlink ");
     strSql.Append(" where 1=1");
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.Accessories.Hailhellowlink model = new ShowShop.Model.Accessories.Hailhellowlink();
             model.ID = reader.GetInt32(0);
             model.SiteName = reader.GetString(1);
             model.SiteUrl = reader.GetString(2);
             model.SiteLogo = reader.GetString(3);
             model.SiteLevel = reader.GetInt32(4);
             model.SiteContent = reader.GetString(5);
             model.SiteLinkType = reader.GetInt32(6);
             model.SiteState = reader.GetInt32(7);
             model.SiteClickCount = reader.GetInt32(8);
             model.CreateDate = reader.GetDateTime(9);
             model.UpdateDate = reader.GetDateTime(10);
             model.PutoutID = reader.GetInt32(11);
             model.PutoutTyID = reader.GetInt32(12);
             model.Aread = reader.GetString(13);
             list.Add(model);
         }
     }
     return list;
 }