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/Advertisement/");
            fileName = myFileUpload.FileName;
            try
            {
                upF.Upload(this.myFileUpload, allowExtensions, maxSize, savePath, fileName);
            }
            catch (Exception exp)
            {
                Cmn.Js.ShowAlert(exp.Message);
                return;
            }
        }

        DBEntity.Tab_Advertisement ent = new DBEntity.Tab_Advertisement();
        ent.Idx           = int.Parse(Request["Idx"]);
        ent.Links         = this.Links.Text;
        ent.AdPostion     = this.AdPostion.Text;
        ent.AdDescription = this.AdDescription.Text;
        ent.AdImg         = fileName;
        ent.OrderNumb     = int.Parse(this.OrderNumb.Text);
        ent.DateCreated   = DateTime.Now;

        ent.Update(ent);
        Cmn.Js.ShowAlert("操作成功!");
        Cmn.Js.ExeScript("location.href='AdvertisementManage.aspx'");
    }
Ejemplo n.º 2
0
 private void GetKol_ShareAd()
 {
     try
     {
         DBEntity.Tab_Advertisement ent = AdHelper.GetAd("Kol_ShareAd");
         string str = string.Format("  <a href='{0}'><img src='upload/Advertisement/{1}' width='108' height='147' alt='' /></a>", ent.Links, ent.AdImg);
         this.ltlKol_Share.Text = str.ToString();
     }
     catch
     { }
 }
Ejemplo n.º 3
0
        private static Tab_Advertisement ToModel(DataRow row)
        {
            Tab_Advertisement model = new Tab_Advertisement();

            model.Idx           = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.AdPostion     = row.IsNull("AdPostion")?null:(System.String)row["AdPostion"];
            model.AdImg         = row.IsNull("AdImg")?null:(System.String)row["AdImg"];
            model.Links         = row.IsNull("Links")?null:(System.String)row["Links"];
            model.AdDescription = row.IsNull("AdDescription")?null:(System.Object)row["AdDescription"];
            model.DateCreated   = row.IsNull("DateCreated") ? null : (System.DateTime?)row["DateCreated"];
            model.OrderNumb     = row.IsNull("OrderNumb")?null:(System.Int32?)row["OrderNumb"];
            return(model);
        }
Ejemplo n.º 4
0
        public int AddNew(Tab_Advertisement model)
        {
            string sql = "insert into Tab_Advertisement(AdPostion,AdImg,Links,AdDescription,OrderNumb)  values(@AdPostion,@AdImg,@Links,@AdDescription,@OrderNumb); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@AdPostion", model.AdPostion)
                                                                 , new SqlParameter("@AdImg", model.AdImg)
                                                                 , new SqlParameter("@Links", model.Links)
                                                                 , new SqlParameter("@AdDescription", model.AdDescription)

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

            return(Idx);
        }
Ejemplo n.º 5
0
        public bool Update(Tab_Advertisement model)
        {
            string sql  = "update Tab_Advertisement set AdPostion=@AdPostion,AdImg=@AdImg,Links=@Links,AdDescription=@AdDescription,DateCreated=@DateCreated,OrderNumb=@OrderNumb where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@AdPostion", model.AdPostion)
                                                    , new SqlParameter("@AdImg", model.AdImg)
                                                    , new SqlParameter("@Links", model.Links)
                                                    , new SqlParameter("@AdDescription", model.AdDescription)
                                                    , new SqlParameter("@DateCreated", model.DateCreated)
                                                    , new SqlParameter("@OrderNumb", model.OrderNumb)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         try
         {
             DBEntity.Tab_Advertisement ent  = AdHelper.GetAd("Ad_rule1");
             DBEntity.Tab_Advertisement ent2 = AdHelper.GetAd("Ad_rule2");
             this.Ad_rule1.Text = string.Format(" <a href='{0}' target='_blank'><img src='upload/Advertisement/{1}' width='448' height='254'   /></a>", ent.Links, ent.AdImg);
             this.Ad_rule2.Text = string.Format(" <a href='{0}' target='_blank'><img src='upload/Advertisement/{1}' width='448' height='254'  /></a>", ent2.Links, ent2.AdImg);
         }
         catch (Exception ex)
         {
             Cmn.Log.Write(ex.ToString());
         }
     }
 }
Ejemplo n.º 7
0
    protected void btnAddNew_Click(object sender, EventArgs e)
    {
        //string exts = ".jpg|.gif|.png|.bmp";
        //if (!Cmn.UploadNew.IsAllowedExtension(this.myFileUpload, exts))
        //{
        //    Cmn.Js.ShowAlert("文件格式不符,可以上传的文件格式为:" + exts);
        //    return;
        //}

        //decimal MaxSize = Convert.ToDecimal(Cmn.WebConfig.getApp("app_MaxSizeUpload"));
        //if (!Cmn.UploadNew.IsAllowedMaxSize(this.myFileUpload, MaxSize)) ;
        //{
        //    Cmn.Js.ShowAlert(string.Format("只能上传小于{0}M的文件!", MaxSize));
        //    return;
        //}


        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/Advertisement/");
        string         fileName        = myFileUpload.FileName;

        try
        {
            upF.Upload(this.myFileUpload, allowExtensions, maxSize, savePath, fileName);
        }
        catch (Exception exp)
        {
            Cmn.Js.ShowAlert(exp.Message);
            return;
        }


        DBEntity.Tab_Advertisement ent = new DBEntity.Tab_Advertisement();
        ent.AdPostion     = this.AdPostion.Text;
        ent.AdImg         = fileName;
        ent.AdDescription = this.AdDescription.Text;
        ent.Links         = this.Links.Text;
        ent.OrderNumb     = Convert.ToInt32(this.OrderNumb.Text);

        ent.AddNew(ent);
        Cmn.Js.ShowAlert("操作成功!");
        Cmn.Js.ExeScript("location.href='AdvertisementManage.aspx'");
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         string idx = Request["idx"];
         if (!String.IsNullOrEmpty(idx))
         {
             DBEntity.Tab_Advertisement ent = new DBEntity.Tab_Advertisement();
             ent = ent.Get(idx);
             this.AdPostion.Text       = ent.AdPostion;
             this.AdDescription.Text   = ent.AdDescription.ToString();
             this.Image1.ImageUrl      = string.Format("~/upload/Advertisement/{0}", ent.AdImg);
             this.OrderNumb.Text       = ent.OrderNumb.ToString();
             this.Links.Text           = ent.Links;
             this.hiddenFileName.Value = ent.AdImg;
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据 广告位 获取广告的实例
        /// </summary>
        /// <param name="AdPostion"></param>
        /// <returns></returns>
        public static Tab_Advertisement GetAdSingle(string AdPostion)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_Advertisement  where AdPostion=@AdPostion",
                                                    new SqlParameter("AdPostion", AdPostion)).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_Advertisement model = ToModel(row);

            return(model);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 根据广告位获取广告的信息
 /// </summary>
 /// <param name="adPostion"></param>
 /// <returns>实体</returns>
 public static DBEntity.Tab_Advertisement GetAd(string adPostion)
 {
     DBEntity.Tab_Advertisement ent = new DBEntity.Tab_Advertisement();
     ent = ent.GetByPostionName(adPostion);
     return(ent);
 }