Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Class_Detail GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, People, LimitPeopleCnt, Address, Content, ManagerId, OrganId, Subject, StudyLevel, TeachGrade, TeachRank, Title, OrganRange, Instructor, Status, ApplyRemark, Display, Delflag, CreateDate, PartitionId, TraningId, PlanId, SignUpStartTime, SignUpEndTime, OpenClassFrom, OpenClassTo, ClassForm  ");
            strSql.Append("  from Class_Detail ");
            strSql.Append(" where ");
            strSql.Append(" Id = @Id  ");

            SqlParameter[] parameters = {
                                                new SqlParameter("@Id", SqlDbType.Int,4)
                            };
            parameters[0].Value = Id;

            Model.Class_Detail model = new Model.Class_Detail();
            DataSet ds = MSEntLibSqlHelper.ExecuteDataSetBySql(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["People"].ToString() != "")
                {
                    model.People = int.Parse(ds.Tables[0].Rows[0]["People"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LimitPeopleCnt"].ToString() != "")
                {
                    model.LimitPeopleCnt = int.Parse(ds.Tables[0].Rows[0]["LimitPeopleCnt"].ToString());
                }
                model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["ManagerId"].ToString() != "")
                {
                    model.ManagerId = int.Parse(ds.Tables[0].Rows[0]["ManagerId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrganId"].ToString() != "")
                {
                    model.OrganId = int.Parse(ds.Tables[0].Rows[0]["OrganId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Subject"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Subject"].ToString() == "1") || (ds.Tables[0].Rows[0]["Subject"].ToString().ToLower() == "true"))
                    {
                        model.Subject = true;
                    }
                    else
                    {
                        model.Subject = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["StudyLevel"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["StudyLevel"].ToString() == "1") || (ds.Tables[0].Rows[0]["StudyLevel"].ToString().ToLower() == "true"))
                    {
                        model.StudyLevel = true;
                    }
                    else
                    {
                        model.StudyLevel = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["TeachGrade"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["TeachGrade"].ToString() == "1") || (ds.Tables[0].Rows[0]["TeachGrade"].ToString().ToLower() == "true"))
                    {
                        model.TeachGrade = true;
                    }
                    else
                    {
                        model.TeachGrade = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["TeachRank"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["TeachRank"].ToString() == "1") || (ds.Tables[0].Rows[0]["TeachRank"].ToString().ToLower() == "true"))
                    {
                        model.TeachRank = true;
                    }
                    else
                    {
                        model.TeachRank = false;
                    }
                }
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                model.OrganRange = ds.Tables[0].Rows[0]["OrganRange"].ToString();
                if (ds.Tables[0].Rows[0]["Instructor"].ToString() != "")
                {
                    model.Instructor = int.Parse(ds.Tables[0].Rows[0]["Instructor"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                model.ApplyRemark = ds.Tables[0].Rows[0]["ApplyRemark"].ToString();
                if (ds.Tables[0].Rows[0]["Display"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Display"].ToString() == "1") || (ds.Tables[0].Rows[0]["Display"].ToString().ToLower() == "true"))
                    {
                        model.Display = true;
                    }
                    else
                    {
                        model.Display = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Delflag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Delflag"].ToString() == "1") || (ds.Tables[0].Rows[0]["Delflag"].ToString().ToLower() == "true"))
                    {
                        model.Delflag = true;
                    }
                    else
                    {
                        model.Delflag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PartitionId"].ToString() != "")
                {
                    model.PartitionId = int.Parse(ds.Tables[0].Rows[0]["PartitionId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TraningId"].ToString() != "")
                {
                    model.TraningId = int.Parse(ds.Tables[0].Rows[0]["TraningId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PlanId"].ToString() != "")
                {
                    model.PlanId = int.Parse(ds.Tables[0].Rows[0]["PlanId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SignUpStartTime"].ToString() != "")
                {
                    model.SignUpStartTime = DateTime.Parse(ds.Tables[0].Rows[0]["SignUpStartTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SignUpEndTime"].ToString() != "")
                {
                    model.SignUpEndTime = DateTime.Parse(ds.Tables[0].Rows[0]["SignUpEndTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OpenClassFrom"].ToString() != "")
                {
                    model.OpenClassFrom = DateTime.Parse(ds.Tables[0].Rows[0]["OpenClassFrom"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OpenClassTo"].ToString() != "")
                {
                    model.OpenClassTo = DateTime.Parse(ds.Tables[0].Rows[0]["OpenClassTo"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassForm"].ToString() != "")
                {
                    model.ClassForm = int.Parse(ds.Tables[0].Rows[0]["ClassForm"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Class_Detail> DataTableToList(DataTable dt)
        {
            List<Model.Class_Detail> modelList = new List<Model.Class_Detail>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Class_Detail model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Class_Detail();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["People"].ToString() != "")
                    {
                        model.People = int.Parse(dt.Rows[n]["People"].ToString());
                    }
                    if (dt.Rows[n]["LimitPeopleCnt"].ToString() != "")
                    {
                        model.LimitPeopleCnt = int.Parse(dt.Rows[n]["LimitPeopleCnt"].ToString());
                    }
                    model.Address = dt.Rows[n]["Address"].ToString();
                    model.Content = dt.Rows[n]["Content"].ToString();
                    if (dt.Rows[n]["ManagerId"].ToString() != "")
                    {
                        model.ManagerId = int.Parse(dt.Rows[n]["ManagerId"].ToString());
                    }
                    if (dt.Rows[n]["OrganId"].ToString() != "")
                    {
                        model.OrganId = int.Parse(dt.Rows[n]["OrganId"].ToString());
                    }
                    if (dt.Rows[n]["Subject"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Subject"].ToString() == "1") || (dt.Rows[n]["Subject"].ToString().ToLower() == "true"))
                        {
                            model.Subject = true;
                        }
                        else
                        {
                            model.Subject = false;
                        }
                    }
                    if (dt.Rows[n]["StudyLevel"].ToString() != "")
                    {
                        if ((dt.Rows[n]["StudyLevel"].ToString() == "1") || (dt.Rows[n]["StudyLevel"].ToString().ToLower() == "true"))
                        {
                            model.StudyLevel = true;
                        }
                        else
                        {
                            model.StudyLevel = false;
                        }
                    }
                    if (dt.Rows[n]["TeachGrade"].ToString() != "")
                    {
                        if ((dt.Rows[n]["TeachGrade"].ToString() == "1") || (dt.Rows[n]["TeachGrade"].ToString().ToLower() == "true"))
                        {
                            model.TeachGrade = true;
                        }
                        else
                        {
                            model.TeachGrade = false;
                        }
                    }
                    if (dt.Rows[n]["TeachRank"].ToString() != "")
                    {
                        if ((dt.Rows[n]["TeachRank"].ToString() == "1") || (dt.Rows[n]["TeachRank"].ToString().ToLower() == "true"))
                        {
                            model.TeachRank = true;
                        }
                        else
                        {
                            model.TeachRank = false;
                        }
                    }
                    model.Title = dt.Rows[n]["Title"].ToString();
                    model.OrganRange = dt.Rows[n]["OrganRange"].ToString();
                    if (dt.Rows[n]["Instructor"].ToString() != "")
                    {
                        model.Instructor = int.Parse(dt.Rows[n]["Instructor"].ToString());
                    }
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    model.ApplyRemark = dt.Rows[n]["ApplyRemark"].ToString();
                    if (dt.Rows[n]["Display"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Display"].ToString() == "1") || (dt.Rows[n]["Display"].ToString().ToLower() == "true"))
                        {
                            model.Display = true;
                        }
                        else
                        {
                            model.Display = false;
                        }
                    }
                    if (dt.Rows[n]["Delflag"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Delflag"].ToString() == "1") || (dt.Rows[n]["Delflag"].ToString().ToLower() == "true"))
                        {
                            model.Delflag = true;
                        }
                        else
                        {
                            model.Delflag = false;
                        }
                    }
                    if (dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["PartitionId"].ToString() != "")
                    {
                        model.PartitionId = int.Parse(dt.Rows[n]["PartitionId"].ToString());
                    }
                    if (dt.Rows[n]["TraningId"].ToString() != "")
                    {
                        model.TraningId = int.Parse(dt.Rows[n]["TraningId"].ToString());
                    }
                    if (dt.Rows[n]["PlanId"].ToString() != "")
                    {
                        model.PlanId = int.Parse(dt.Rows[n]["PlanId"].ToString());
                    }
                    if (dt.Rows[n]["SignUpStartTime"].ToString() != "")
                    {
                        model.SignUpStartTime = DateTime.Parse(dt.Rows[n]["SignUpStartTime"].ToString());
                    }
                    if (dt.Rows[n]["SignUpEndTime"].ToString() != "")
                    {
                        model.SignUpEndTime = DateTime.Parse(dt.Rows[n]["SignUpEndTime"].ToString());
                    }
                    if (dt.Rows[n]["OpenClassFrom"].ToString() != "")
                    {
                        model.OpenClassFrom = DateTime.Parse(dt.Rows[n]["OpenClassFrom"].ToString());
                    }
                    if (dt.Rows[n]["OpenClassTo"].ToString() != "")
                    {
                        model.OpenClassTo = DateTime.Parse(dt.Rows[n]["OpenClassTo"].ToString());
                    }
                    if (dt.Rows[n]["ClassForm"].ToString() != "")
                    {
                        model.ClassForm = int.Parse(dt.Rows[n]["ClassForm"].ToString());
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }