Esempio n. 1
0
        private static Tab_CourseDetail ToModel(DataRow row)
        {
            Tab_CourseDetail model = new Tab_CourseDetail();

            model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.CourseMainIdx_FxIdx = row.IsNull("CourseMainIdx_FxIdx")?null:(System.Int32?)row["CourseMainIdx_FxIdx"];
            model.MediaCategory       = row.IsNull("MediaCategory")?null:(System.String)row["MediaCategory"];
            model.MediaFilePath       = row.IsNull("MediaFilePath")?null:(System.String)row["MediaFilePath"];
            model.Content             = row.IsNull("Content")?null:(System.Object)row["Content"];
            model.SortNumbers         = row.IsNull("SortNumbers")?null:(System.Int32?)row["SortNumbers"];
            model.DateCreated         = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            return(model);
        }
Esempio n. 2
0
        public int AddNew(Tab_CourseDetail model)
        {
            string sql = "insert into Tab_CourseDetail(CourseMainIdx_FxIdx,MediaCategory,MediaFilePath,Content,SortNumbers,DateCreated)  values(@CourseMainIdx_FxIdx,@MediaCategory,@MediaFilePath,@Content,@SortNumbers,@DateCreated); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@CourseMainIdx_FxIdx", model.CourseMainIdx_FxIdx)
                                                                 , new SqlParameter("@MediaCategory", model.MediaCategory)
                                                                 , new SqlParameter("@MediaFilePath", model.MediaFilePath)
                                                                 , new SqlParameter("@Content", model.Content)
                                                                 , new SqlParameter("@SortNumbers", model.SortNumbers)
                                                                 , new SqlParameter("@DateCreated", model.DateCreated)
                                                                 ));

            return(Idx);
        }
Esempio n. 3
0
        public bool Update(Tab_CourseDetail model)
        {
            string sql  = "update Tab_CourseDetail set CourseMainIdx_FxIdx=@CourseMainIdx_FxIdx,MediaCategory=@MediaCategory,MediaFilePath=@MediaFilePath,Content=@Content,SortNumbers=@SortNumbers,DateCreated=@DateCreated where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@CourseMainIdx_FxIdx", model.CourseMainIdx_FxIdx)
                                                    , new SqlParameter("@MediaCategory", model.MediaCategory)
                                                    , new SqlParameter("@MediaFilePath", model.MediaFilePath)
                                                    , new SqlParameter("@Content", model.Content)
                                                    , new SqlParameter("@SortNumbers", model.SortNumbers)
                                                    , new SqlParameter("@DateCreated", model.DateCreated)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string  strSql = "select courseName=CourseMainType+'_'+Title,idx from v_CourseMain order by CourseMainType,SortNo";
            DataSet ds     = SqlHelper.ExecuteDataset(CommandType.Text, strSql);
            this.ddlCourse.DataSource     = ds.Tables[0];
            this.ddlCourse.DataTextField  = "courseName";
            this.ddlCourse.DataValueField = "idx";
            this.ddlCourse.DataBind();
            Image1.Visible = false;

            string idx = Request["Idx"];
            if (!string.IsNullOrEmpty(idx))
            {
                Image1.Visible = true;
                DBEntity.Tab_CourseDetail ent = new DBEntity.Tab_CourseDetail();
                ent = ent.Get(idx);
                this.HiddenField1.Value = ent.MediaFilePath;

                for (int i = 0; i < ddlCourse.Items.Count; i++)
                {
                    if (ddlCourse.Items[i].Value == ent.CourseMainIdx_FxIdx.ToString())
                    {
                        ddlCourse.Items[i].Selected = true;
                        break;
                    }
                }
                this.Image1.ImageUrl  = string.Format("../upload/CourseMain/{0}", ent.MediaFilePath);
                this.SortNumbers.Text = ent.SortNumbers.ToString();
                if (ent.MediaCategory == "img")
                {
                    this.RadioButtonList1.Items[0].Selected = true;
                }
                else
                {
                    this.RadioButtonList1.Items[1].Selected = true;
                    this.txtVideoPath.Text = ent.MediaFilePath;
                }
            }
        }
    }
Esempio n. 5
0
        public Tab_CourseDetail Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_CourseDetail  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_CourseDetail model = ToModel(row);

            return(model);
        }