コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string idx = Request["Idx"];
            if (!String.IsNullOrEmpty(idx))
            {
                DBEntity.Tab_Activity ent = new DBEntity.Tab_Activity();
                ent = ent.Get(idx);
                this.ActiveTitle.Text       = ent.ActiveTitle;
                this.Rules.Text             = ent.Rules;
                this.Platform.Text          = ent.Platform;
                this.Prizes.Text            = ent.Prizes;
                this.Image1.ImageUrl        = string.Format("~/upload/Activity/{0}", ent.PreviewImg);
                this.Image2.ImageUrl        = string.Format("~/upload/Activity/{0}", ent.DisplayHomePreview);
                this.ActivityStartDate.Text = ent.ActivityStartDate.ToString();
                this.ActivityEndDate.Text   = ent.ActivityEndDate.ToString();
                for (int i = 0; i < this.DisplayHomeBool.Items.Count; i++)
                {
                    if (this.DisplayHomeBool.Items[i].Value == ent.DisplayHomeBool)
                    {
                        this.DisplayHomeBool.Items[i].Selected = true;
                    }
                }

                this.HiddenField1.Value = ent.PreviewImg;
                this.HiddenField2.Value = ent.DisplayHomePreview;
            }
        }
    }
コード例 #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string fileName = this.HiddenField1.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/Activity/");
            fileName = Cmn.Rand.GetGuid().Replace("-", "") + "_" + myFileUpload.FileName;
            try
            {
                upF.Upload(this.myFileUpload, allowExtensions, maxSize, savePath, fileName);
            }
            catch (Exception exp)
            {
                Cmn.Js.ShowAlert(exp.Message);
                return;
            }
        }

        //===========
        string fileName2 = this.HiddenField2.Value;

        if (myFileUpload2.HasFile)
        {
            Cmn.uploadFile upF2             = new Cmn.uploadFile();
            string[]       allowExtensions2 = { ".jpg", ".gif", ".png" };
            int            maxSize2         = Convert.ToInt32(Cmn.WebConfig.getApp("app_MaxSizeUpload"));
            string         savePath2        = Request.MapPath("~/upload/Activity/");
            fileName2 = Cmn.Rand.GetGuid().Replace("-", "") + "_" + myFileUpload2.FileName;
            try
            {
                upF2.Upload(this.myFileUpload2, allowExtensions2, maxSize2, savePath2, fileName2);
            }
            catch (Exception exp)
            {
                Cmn.Js.ShowAlert(exp.Message);
                return;
            }
        }
        //====================================
        DBEntity.Tab_Activity ent = new DBEntity.Tab_Activity();
        ent.Idx = int.Parse(Request["Idx"]);

        ent.ActiveTitle        = this.ActiveTitle.Text;
        ent.PreviewImg         = fileName;
        ent.ActivityStartDate  = DateTime.Parse(this.ActivityStartDate.Text);
        ent.ActivityEndDate    = DateTime.Parse(this.ActivityEndDate.Text);
        ent.Rules              = this.Rules.Text;
        ent.Platform           = this.Platform.Text;
        ent.Prizes             = this.Prizes.Text;
        ent.DisplayHomeBool    = this.DisplayHomeBool.SelectedValue;
        ent.DisplayHomePreview = fileName2;

        ent.Update(ent);
        Cmn.Js.ShowAlert("操作成功!");
        Cmn.Js.ExeScript("location.href='ActivityManage.aspx'");
    }
コード例 #3
0
    //首页活动列表
    private void ActivityList()
    {
        string strSql = "select top 10 * from Tab_Activity where DisplayHomeBool ='yes' "; //  where DisplayHomeBool='Yes' and DATEDIFF(DAY,GETDATE(),ActivityEndDate)>0";
        IEnumerable <DBEntity.Tab_Activity> ents = new DBEntity.Tab_Activity().ListAll(strSql);

        StringBuilder contentStr = new StringBuilder();
        int           iCount     = 0;
        string        strStyle   = "";

        foreach (DBEntity.Tab_Activity ent in ents)
        {
            if (iCount % 2 == 0)
            {
                contentStr.AppendLine(" <div class='preview_item' style='display: none;'>");
                strStyle = "preview_item_left";
            }
            else
            {
                strStyle = "preview_item_right";
            }


            string beginDate      = Convert.ToDateTime(ent.ActivityStartDate).ToString("MM/dd");
            string endDate        = Convert.ToDateTime(ent.ActivityEndDate).ToString("MM/dd");
            string strYear        = Convert.ToDateTime(ent.ActivityEndDate).Year.ToString();
            string homePreviewImg = ent.DisplayHomePreview;
            if (!Cmn.FileFolder.CheckFileExist(Server.MapPath(string.Format("upload/Activity/{0}", ent.DisplayHomePreview))))
            {
                homePreviewImg = "defaultHomePreview.jpg";
            }
            contentStr.AppendLine(string.Format("    <div class='{0}'>", strStyle));
            contentStr.AppendLine(string.Format("    <div style='padding:0 0 0 1px;'><a href='activity_detail.aspx?Idx={1}'><img src='upload/Activity/{0}' width='147' height='81' /></a></div>", homePreviewImg, ent.Idx));
            contentStr.AppendLine(string.Format("    <div class='preview_item_text'><span>{0}-{1} {2}</span><br /> {3}</div>", beginDate, endDate, strYear, Cmn.Str.GetStr(ent.ActiveTitle, 20, true)));
            contentStr.AppendLine("    </div>");
            iCount++;

            if (iCount % 2 == 0 || iCount == ents.Count <DBEntity.Tab_Activity>())
            {
                contentStr.AppendLine("</div>");
            }
        }

        this.ltl_ActivityHomeList.Text = contentStr.ToString();
        //Cmn.Js.Alert(contentStr.ToString());
        //this.TextBoxTemp.Text = contentStr.ToString();
    }
コード例 #4
0
    private void GetltlHomeActivty()
    {
        StringBuilder sb = new StringBuilder();

        string  strSql = string.Format("select top 1 * from Tab_Activity where DATEDIFF(DAY,getdate(),ActivityEndDate) >0 order by 1 desc ");
        DataSet ds     = SqlHelper.ExecuteDataset(CommandType.Text, strSql);


        if (ds.Tables[0].Rows.Count == 1)
        {
            var iRow = ds.Tables[0].Rows[0];
            DBEntity.Tab_Activity ent = new DBEntity.Tab_Activity();
            ent = ent.Get(iRow["Idx"].ToString());

            string str = string.Format(@"<div class='promo_intro'>
                            <div class='promo_intro_l'><a href='activity_detail.aspx?Idx={6}' title='点击查看详细'><img src='upload/Activity/{0}' width='177' height='142' alt='' /></a></div>
                            <div class='promo_intro_r'>
                            <dl>
                                <dt><span>{1}</span><br />
                                时间:{2} - {3}<br />
                                简介:{4}<br />
                                <span style='color:#c8b772; font-size:12px;'>奖品:{5}</span></dt>
                                <dd style='text-align:right'><a href='activity-mine.aspx'>More..<!--<img src='images/btn_lookmore.jpg' alt='查看更多' />--></a></dd>
                                <!--
                                <dd class='share2'><a href='#'><img src='images/icon_weibo2.jpg' alt='新浪微博' /></a> <a href='#'><img src='images/icon_kaixin2.jpg' alt='开心网' /></a> <a href='#'><img src='images/icon_renren2.jpg' alt='人人网' /></a>
                                </dd>
                                -->
                            </dl>
                            </div>
                            <br class='clr' />
                        </div>",
                                       iRow["PreviewImg"]
                                       , iRow["ActiveTitle"]
                                       , Cmn.Date.ToMonthDayStr(DateTime.Parse(iRow["ActivityStartDate"].ToString()))
                                       , Cmn.Date.ToMonthDayStr(DateTime.Parse(iRow["ActivityEndDate"].ToString()))
                                       , Cmn.Str.GetStr(iRow["Rules"].ToString(), 108, true)
                                       , Cmn.Str.GetStr(iRow["Prizes"].ToString(), 32, false)
                                       , iRow["Idx"]);


            sb.AppendLine(str.ToString());
        }
        ds.Clear();

        ltlHomeActivty.Text = sb.ToString();
    }
コード例 #5
0
        private static Tab_Activity ToModel(DataRow row)
        {
            Tab_Activity model = new Tab_Activity();

            model.Idx                = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.ActiveTitle        = row.IsNull("ActiveTitle")?null:(System.String)row["ActiveTitle"];
            model.PreviewImg         = row.IsNull("PreviewImg")?null:(System.String)row["PreviewImg"];
            model.ActivityStartDate  = row.IsNull("ActivityStartDate")?null:(System.DateTime?)row["ActivityStartDate"];
            model.ActivityEndDate    = row.IsNull("ActivityEndDate")?null:(System.DateTime?)row["ActivityEndDate"];
            model.Rules              = row.IsNull("Rules")?null:(System.String)row["Rules"];
            model.Platform           = row.IsNull("Platform")?null:(System.String)row["Platform"];
            model.Prizes             = row.IsNull("Prizes")?null:(System.String)row["Prizes"];
            model.SharingCopyContent = row.IsNull("SharingCopyContent")?null:(System.String)row["SharingCopyContent"];
            model.DateCreated        = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            model.DisplayHomeBool    = row.IsNull("DisplayHomeBool")?null:(System.String)row["DisplayHomeBool"];
            model.DisplayHomePreview = row.IsNull("DisplayHomePreview")?null:(System.String)row["DisplayHomePreview"];
            return(model);
        }
コード例 #6
0
        public int AddNew(Tab_Activity model)
        {
            string sql = "insert into Tab_Activity(ActiveTitle,PreviewImg,ActivityStartDate,ActivityEndDate,Rules,Platform,Prizes,SharingCopyContent,DisplayHomeBool,DisplayHomePreview)  values(@ActiveTitle,@PreviewImg,@ActivityStartDate,@ActivityEndDate,@Rules,@Platform,@Prizes,@SharingCopyContent,@DisplayHomeBool,@DisplayHomePreview); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@ActiveTitle", model.ActiveTitle)
                                                                 , new SqlParameter("@PreviewImg", model.PreviewImg)
                                                                 , new SqlParameter("@ActivityStartDate", model.ActivityStartDate)
                                                                 , new SqlParameter("@ActivityEndDate", model.ActivityEndDate)
                                                                 , new SqlParameter("@Rules", model.Rules)
                                                                 , new SqlParameter("@Platform", model.Platform)
                                                                 , new SqlParameter("@Prizes", model.Prizes)
                                                                 , new SqlParameter("@SharingCopyContent", model.SharingCopyContent)

                                                                 , new SqlParameter("@DisplayHomeBool", model.DisplayHomeBool)
                                                                 , new SqlParameter("@DisplayHomePreview", model.DisplayHomePreview)
                                                                 ));

            return(Idx);
        }
コード例 #7
0
        public bool Update(Tab_Activity model)
        {
            string sql  = "update Tab_Activity set ActiveTitle=@ActiveTitle,PreviewImg=@PreviewImg,ActivityStartDate=@ActivityStartDate,ActivityEndDate=@ActivityEndDate,Rules=@Rules,Platform=@Platform,Prizes=@Prizes,SharingCopyContent=@SharingCopyContent,DisplayHomeBool=@DisplayHomeBool,DisplayHomePreview=@DisplayHomePreview where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@ActiveTitle", model.ActiveTitle)
                                                    , new SqlParameter("@PreviewImg", model.PreviewImg)
                                                    , new SqlParameter("@ActivityStartDate", model.ActivityStartDate)
                                                    , new SqlParameter("@ActivityEndDate", model.ActivityEndDate)
                                                    , new SqlParameter("@Rules", model.Rules)
                                                    , new SqlParameter("@Platform", model.Platform)
                                                    , new SqlParameter("@Prizes", model.Prizes)
                                                    , new SqlParameter("@SharingCopyContent", model.SharingCopyContent)

                                                    , new SqlParameter("@DisplayHomeBool", model.DisplayHomeBool)
                                                    , new SqlParameter("@DisplayHomePreview", model.DisplayHomePreview)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
コード例 #8
0
        public Tab_Activity Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_Activity  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_Activity model = ToModel(row);

            return(model);
        }