/// <summary> /// 获取具体某个教程信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public Views.courseMsg DataRowToSelectMsg(string id, string token = "") { DAL.course c = new DAL.course(); DataRow course = c.GetModelSelectMsg(id); return(c.DataRowToSelectMsg(course, new BLL.course_().GetModelList("", "", id), token)); }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text == "") { er++; ep.SetError(txtName, "Name Requered"); } if (txtCode.Text == "") { er++; ep.SetError(txtCode, "Code Requered"); } if (txtCredit.Text == "") { er++; ep.SetError(txtCredit, "Input Requered"); } if (txtProgramId.Text == "") { er++; ep.SetError(txtProgramId, "program id Requered"); } if (txtDescription.Text == "") { er++; ep.SetError(txtDescription, "Description is Requered"); } if (er == 0) { Hypertag.Advising.DAL.course courses = new DAL.course(); courses.Name = txtName.Text; //courses.Code = txtCode.Text; courses.Credit = Convert.ToInt32(txtCredit.Text); courses.ProgramId = Convert.ToInt32(txtProgramId.Text); courses.Description = txtDescription.Text; if (courses.Insert()) { MessageBox.Show("Data Saved"); txtName.Text = ""; txtCode.Text = ""; txtCredit.Text = ""; txtProgramId.Text = ""; txtDescription.Text = ""; txtName.Focus(); } else { MessageBox.Show(courses.Error); } } }
/// <summary> /// 获得动态 /// </summary> /// <param name="id"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <Views.trends> GetTrends(string id, int pageIndex, string token = "") { List <Views.trends> trends = new List <Views.trends>(); Cook.DAL.course course = new DAL.course(); foreach (DataRow item in new Cook.DAL.users().GetTrends(id, pageIndex).Rows) { trends.Add(course.DataRowToTrends(item, token)); } return(trends); }
/// <summary> /// 获取最新trends /// </summary> /// <returns></returns> public List <Views.trends> GetNewTrends(int pageIndex, string token = "") { List <Views.trends> List = new List <Views.trends>(); DAL.course c = new DAL.course(); DataTable dt = c.GetListByPage(pageIndex, "", " time desc "); foreach (DataRow item in dt.Rows) { List.Add(c.DataRowToTrends(item, token)); } return(List); }
//我的收藏 public List <Views.trends> GetMyCollectbyid(string tableid) { //string tableid = new Cook.DAL.load().GetIdByToken(token); List <Views.trends> mycollect = new List <Views.trends>(); DAL.course course = new DAL.course(); DataTable dt = new DAL.collect_().getmycollect(tableid); foreach (DataRow itme in dt.Rows) { mycollect.Add(course.DataRowToTrends(itme)); } return(mycollect); }
//获取别人的教程 public List <Views.trends> GetMyCoursebyid(string type, string id, string token = "") { //string id = new Cook.DAL.load().GetIdByToken(token); List <Views.trends> List = new List <Views.trends>(); DAL.course c = new DAL.course(); DataTable dt = c.GetList(" authorid =" + id + " and type = " + type + " ", " time desc "); foreach (DataRow item in dt.Rows) { List.Add(c.DataRowToTrends(item, token)); } return(List); }
public Views.content_T <Views.courseTop> GetListTop() { Views.content_T <Views.courseTop> content = new Views.content_T <Views.courseTop>(); List <Views.courseTop> list = new List <Views.courseTop>(); DAL.course c = new DAL.course(); foreach (DataRow item in c.GetListTop().Rows) { list.Add(c.DataRowToModelTop(item)); } string name = ConfigurationManager.AppSettings["courseTop"]; content.name = name; content.content = list; return(content); }
/// <summary> /// 返回搜索后的DataTable /// </summary> /// <param name="searchKey">搜索关键字</param> /// <param name="type">0图文 1视频</param> /// <returns></returns> public List <Views.course_T> GetListToSelect(int pageIndex, string searchKey, string type) { List <Views.course_T> list = new List <Views.course_T>(); StringBuilder strSql = new StringBuilder(); if (searchKey != "") { strSql.Append(" ( searchkey LIKE @key1 OR content LIKE @key2 ) "); strSql.Append(" and type = @type "); SqlParameter[] parameters = { new SqlParameter("@key1", SqlDbType.NVarChar, 250), new SqlParameter("@key2", SqlDbType.NVarChar, 250), new SqlParameter("@type", SqlDbType.Char, 1) }; parameters[0].Value = string.Format("%{0}%", searchKey.Trim()); parameters[1].Value = string.Format("%{0}%", searchKey.Trim()); parameters[2].Value = type.Trim(); DAL.course c = new DAL.course(); foreach (DataRow itme in c.GetListByPage(pageIndex, strSql.ToString(), parameters, " time desc").Rows) { list.Add(c.DataRowToModel_T(itme)); } return(list); } else { strSql.Append(" type = @type "); SqlParameter[] parameters = { new SqlParameter("@type", SqlDbType.Char, 1) }; parameters[0].Value = type.Trim(); DAL.course c = new DAL.course(); foreach (DataRow itme in c.GetListByPage(pageIndex, strSql.ToString(), parameters, " time desc").Rows) { list.Add(c.DataRowToModel_T(itme)); } return(list); } }
/// <summary> /// 获取动态信息 /// </summary> /// <param name="id"></param> /// <param name="pageIndex"></param> /// <returns></returns> public DataTable GetTrends(string id, int pageIndex) { //获取所有关注的人 DAL.follow_ folloew = new follow_(); DataRowCollection drs = folloew.GetList("", "", id).Rows; StringBuilder str = new StringBuilder(); for (int i = 0; i < drs.Count; i++) { if (i == 0) { str.AppendFormat(" authorid = {0} ", drs[i]["id"].ToString()); } else { str.AppendFormat(" or authorid = {0} ", drs[i]["id"].ToString()); } } //获取关注的人的教程信息 DAL.course course = new DAL.course(); return(course.GetListByPage(pageIndex, "(" + str.ToString() + ") and stats = 0 ", " time desc ")); }
private void Course_Load(object sender, EventArgs e) { DAL.course c = new DAL.course(); dgbCourse.DataSource = c.Select().Tables[0]; }