Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            DataSet ds = DBEntity.Tab_CourseMain_Type.GetDs();
            this.ddlCourseType.DataSource     = ds.Tables[0];
            this.ddlCourseType.DataTextField  = "CourseMainType";
            this.ddlCourseType.DataValueField = "Idx";
            this.ddlCourseType.DataBind();
            //==========================
            string idx = Request["Idx"];
            if (!String.IsNullOrEmpty(idx))
            {
                DBEntity.Tab_CourseMain ent = new DBEntity.Tab_CourseMain();
                ent                     = ent.Get(idx);
                this.Title.Text         = ent.Title;
                this.CourseContent.Text = ent.CourseContent;
                this.Image1.ImageUrl    = string.Format("~/upload/CourseMain/{0}", ent.PreviewImg);
                this.SortNo.Text        = ent.SortNo.ToString();
                this.ReleaseDate.Text   = ent.ReleaseDate.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;
                    }
                }
                for (int i = 0; i < this.ddlCourseType.Items.Count; i++)
                {
                    if (this.ddlCourseType.Items[i].Value == ent.CourseMainTypeIdx_Fx.ToString())
                    {
                        this.ddlCourseType.Items[i].Selected = true;
                    }
                }

                this.hiddenFileName.Value = ent.PreviewImg;

                //========
                DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select  * from Tab_CourseMain  where Idx=@Idx"
                                                        , new SqlParameter("Idx", idx)).Tables[0];
                if (dt.Rows.Count == 1)
                {
                    this.ActivityDescption.Text = dt.Rows[0]["ActivityDescption"].ToString();
                    this.ActivityUrl.Text       = dt.Rows[0]["ActivityUrl"].ToString();
                }
            }
        }
    }
Example #2
0
        public int AddNew(Tab_CourseMain model)
        {
            string sql = "insert into Tab_CourseMain(PreviewImg,Title,CourseContent,SortNo,ReleaseDate,HomeShowBool,CourseMainTypeIdx_Fx)  values(@PreviewImg,@Title,@CourseContent,@SortNo,@ReleaseDate,@HomeShowBool,@CourseMainTypeIdx_Fx); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@PreviewImg", model.PreviewImg)
                                                                 , new SqlParameter("@Title", model.Title)
                                                                 , new SqlParameter("@CourseContent", model.CourseContent)
                                                                 , new SqlParameter("@SortNo", model.SortNo)

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

            return(Idx);
        }
Example #3
0
        private static Tab_CourseMain ToModel(DataRow row)
        {
            Tab_CourseMain model = new Tab_CourseMain();

            model.Idx           = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.PreviewImg    = row.IsNull("PreviewImg")?null:(System.String)row["PreviewImg"];
            model.Title         = row.IsNull("Title")?null:(System.String)row["Title"];
            model.CourseContent = row.IsNull("CourseContent")?null:(System.String)row["CourseContent"];
            model.SortNo        = row.IsNull("SortNo")?null:(System.Int32?)row["SortNo"];
            model.DateCreated   = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            model.ReleaseDate   = row.IsNull("ReleaseDate")?null:(System.DateTime?)row["ReleaseDate"];
            model.HomeShowBool  = row.IsNull("HomeShowBool")?null:(System.String)row["HomeShowBool"];

            model.CourseMainTypeIdx_Fx = row.IsNull("CourseMainTypeIdx_Fx") ? null : (System.Int32?)row["CourseMainTypeIdx_Fx"];

            return(model);
        }
Example #4
0
        public bool Update(Tab_CourseMain model)
        {
            string sql  = "update Tab_CourseMain set PreviewImg=@PreviewImg,Title=@Title,CourseContent=@CourseContent,SortNo=@SortNo,DateCreated=getdate(),ReleaseDate=@ReleaseDate,HomeShowBool=@HomeShowBool,CourseMainTypeIdx_Fx=@CourseMainTypeIdx_Fx where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@PreviewImg", model.PreviewImg)
                                                    , new SqlParameter("@Title", model.Title)
                                                    , new SqlParameter("@CourseContent", model.CourseContent)
                                                    , new SqlParameter("@SortNo", model.SortNo)

                                                    , new SqlParameter("@ReleaseDate", model.ReleaseDate)
                                                    , new SqlParameter("@HomeShowBool", model.HomeShowBool)
                                                    , new SqlParameter("@CourseMainTypeIdx_Fx", model.CourseMainTypeIdx_Fx)

                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

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

        DBEntity.Tab_CourseMain ent = new DBEntity.Tab_CourseMain();
        ent.Idx                  = int.Parse(Request["Idx"]);
        ent.Title                = this.Title.Text;
        ent.PreviewImg           = fileName;
        ent.CourseContent        = this.CourseContent.Text;
        ent.HomeShowBool         = this.HomeShowBool.SelectedValue;
        ent.SortNo               = Convert.ToInt32(this.SortNo.Text);
        ent.ReleaseDate          = DateTime.Parse(this.ReleaseDate.Text);
        ent.CourseMainTypeIdx_Fx = Convert.ToInt32(this.ddlCourseType.SelectedValue);

        ent.Update(ent);

        string strSql = "update Tab_CourseMain set ActivityDescption='{0}' ,ActivityUrl='{1}' where Idx='{2}'";

        strSql = string.Format(strSql, this.ActivityDescption.Text, this.ActivityUrl.Text, Request["Idx"]);
        SqlHelper.ExecuteNonQuery(CommandType.Text, strSql);

        Cmn.Js.ShowAlert("操作成功!");
        Cmn.Js.ExeScript("location.href='CourseMainManage.aspx'");
    }
Example #6
0
        public Tab_CourseMain Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_CourseMain  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_CourseMain model = ToModel(row);

            return(model);
        }
Example #7
0
    //课件列表
    private void CourseList()
    {
        string strSql = "select top 3 *,DATEDIFF(DAY,ReleaseDate,GETDATE()) from Tab_CourseMain where HomeShowBool='yes' and DATEDIFF(DAY,ReleaseDate,GETDATE())>=0 order by SortNo";
        IEnumerable <DBEntity.Tab_CourseMain> ents = new DBEntity.Tab_CourseMain().ListAll(strSql);

        StringBuilder contentStr = new StringBuilder();
        string        readCount  = "0";

        foreach (DBEntity.Tab_CourseMain ent in ents)
        {
            strSql    = string.Format("select count(1) from Tab_CourseMain_ViewLog where CourseMainIdx={0}", ent.Idx);
            readCount = SqlHelper.ExecuteScalar(CommandType.Text, strSql).ToString().PadLeft(5, '0');

            contentStr.AppendLine("<li>");
            contentStr.AppendLine(string.Format("<div class='num1'>{0}</div>", readCount));
            contentStr.AppendLine(string.Format("<div class='pic'><a href='{0}/sisley-academy.aspx?cmIdx={1}' onclick='AddViewLog(\"{1}\",\"{3}\")'><img src='upload/CourseMain/{2}' width='133' height='75' /></a></div>", Cmn.WebConfig.getApp("app_WebsiteDomain"), ent.Idx, ent.PreviewImg, ent.Title));
            contentStr.AppendLine(string.Format("<div class='text'><span>{0}</span><br />{1}</div>", Cmn.Str.GetStr(ent.Title, 30, false), Cmn.Str.GetStr(ent.CourseContent, 60, true)));
            contentStr.AppendLine("</li>");
        }

        this.ltlCourseList.Text = contentStr.ToString();
    }