Beispiel #1
0
        private void ConvertToModelTo(IDataReader reader, AccountEdit model)
        {
            if (reader["UserName"] != DBNull.Value)
                model.UserName = reader["UserName"].ToString();

            if (reader["AccountId"] != DBNull.Value)
                model.AccountId = Convert.ToInt32(reader["AccountId"]);

            if (reader["Pic"] != DBNull.Value)
                model.Pic = reader["Pic"].ToString();

            if (reader["RealName"] != DBNull.Value)
                model.RealName = reader["RealName"].ToString();

            if (reader["TeacherNo"] != DBNull.Value)
                model.TeacherNo = reader["TeacherNo"].ToString();

            if (reader["Email"] != DBNull.Value)
                model.Email = reader["Email"].ToString();

            if (reader["Sex"] != DBNull.Value)
                model.Sex = Convert.ToInt32(reader["Sex"]);

            if (reader["Birthday"] != DBNull.Value)
                model.Birthday = Convert.ToDateTime(reader["Birthday"]);

            if (reader["CredentialsNumber"] != DBNull.Value)
                model.CredentialsNumber = reader["CredentialsNumber"].ToString();

            if (reader["Mobile"] != DBNull.Value)
                model.Mobile = reader["Mobile"].ToString();

            if (reader["Nation"] != DBNull.Value)
                model.Nation = Convert.ToInt32(reader["Nation"]);

            if (reader["PoliticalStatus"] != DBNull.Value)
                model.PoliticalStatus = Convert.ToInt32(reader["PoliticalStatus"]);

            if (reader["RegionId"] != DBNull.Value)
                model.Region = Convert.ToInt32(reader["RegionId"]);

            if (reader["OrganId"] != DBNull.Value)
                model.Organ = Convert.ToInt32(reader["OrganId"]);

            if (reader["Job"] != DBNull.Value)
                model.Job = Convert.ToInt32(reader["Job"]);

            if (reader["WorkRank"] != DBNull.Value)
                model.WorkRank = Convert.ToInt32(reader["WorkRank"]);

            if (reader["TeachDate"] != DBNull.Value)
                model.TeachDate = Convert.ToDateTime(reader["TeachDate"]);

            //if (reader["TeachStudySection"] != DBNull.Value)
            //    model.TeachStudySection = reader["TeachStudySection"].ToString();

            //if (reader["TeachSubject"] != DBNull.Value)
            //    model.TeachSubject = reader["TeachSubject"].ToString();

            //if (reader["TeachGrade"] != DBNull.Value)
            //    model.TeachGrade = reader["TeachGrade"].ToString();

            if (reader["TraningType"] != DBNull.Value)
                model.TraningType = Convert.ToInt32(reader["TraningType"]);

            if (reader["TraningObject"] != DBNull.Value)
                model.TraningObject = Convert.ToInt32(reader["TraningObject"]);

            if (reader["EduLevel"] != DBNull.Value)
                model.EduLevel = Convert.ToInt32(reader["EduLevel"]);

            if (reader["EduDegree"] != DBNull.Value)
                model.EduDegree = Convert.ToInt32(reader["EduDegree"]);

            if (reader["EduMajor"] != DBNull.Value)
                model.EduMajor = Convert.ToInt32(reader["EduMajor"]);

            //if (reader["EduMajorOhter"] != DBNull.Value)
            //    model.EduMajorOhter = reader["EduMajorOhter"].ToString();

            if (reader["GraduateSchool"] != DBNull.Value)
                model.GraduateSchool = reader["GraduateSchool"].ToString();

            if (reader["GraduateTime"] != DBNull.Value)
                model.GraduateTime = Convert.ToDateTime(reader["GraduateTime"]);
        }
        public ActionResult Index()
        {
            int AccountId = Code.SiteCache.Instance.LoginInfo.UserId;
            DataTable Nationdt = bll.GetNation(1);
            DataTable Politicaldt = bll.GetNation(3);
            DataTable EduLeveldt = bll.GetNation(4);
            DataTable EduDegreedt = bll.GetNation(5);
            DataTable EduMajordt = bll.GetNation(6);
            DataTable Jobdt = bll.GetTraning_InfoFk(10);
            DataTable Regindt = bll.GetOutRegin(5, 4);
            DataTable WorkRankdt = bll.GetTraning_InfoFk(8);
            DataTable TeachStudySectiondt = bll.GetTraning_InfoFk(4);
            DataTable TeachSubjectdt = bll.GetTraning_InfoFk(3);
            DataTable TeachGradedt = bll.GetTraning_InfoFk(7);
            DataTable TraningTypedt = bll.GetTraning_InfoFk(5);
            DataTable TraningObjectdt = bll.GetTraning_InfoFk(2);
            List<SelectListItem> Nation = new List<SelectListItem>();
            List<SelectListItem> Political = new List<SelectListItem>();
            List<SelectListItem> EduLevel = new List<SelectListItem>();
            List<SelectListItem> EduDegree = new List<SelectListItem>();
            List<SelectListItem> EduMajor = new List<SelectListItem>();
            List<SelectListItem> Regin = new List<SelectListItem>();
            List<SelectListItem> Job = new List<SelectListItem>();
            List<SelectListItem> WorkRank = new List<SelectListItem>();
            List<SelectListItem> TraningType = new List<SelectListItem>();
            List<SelectListItem> TraningObject = new List<SelectListItem>();

            for (int i = 0; i < Nationdt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = Nationdt.Rows[i][1].ToString();
                item.Value = Nationdt.Rows[i][0].ToString();
                Nation.Add(item);
            }
            for (int i = 0; i < Politicaldt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = Politicaldt.Rows[i][1].ToString();
                item.Value = Politicaldt.Rows[i][0].ToString();
                Political.Add(item);
            }
            for (int i = 0; i < EduLeveldt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = EduLeveldt.Rows[i][1].ToString();
                item.Value = EduLeveldt.Rows[i][0].ToString();
                EduLevel.Add(item);
            }
            for (int i = 0; i < EduDegreedt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = EduDegreedt.Rows[i][1].ToString();
                item.Value = EduDegreedt.Rows[i][0].ToString();
                EduDegree.Add(item);
            }
            for (int i = 0; i < EduMajordt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = EduMajordt.Rows[i][1].ToString();
                item.Value = EduMajordt.Rows[i][0].ToString();
                EduMajor.Add(item);
            }
            for (int i = 0; i < Regindt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = Regindt.Rows[i][1].ToString();
                item.Value = Regindt.Rows[i][0].ToString();
                Regin.Add(item);
            }
            for (int i = 0; i < Jobdt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = Jobdt.Rows[i][1].ToString();
                item.Value = Jobdt.Rows[i][0].ToString();
                Job.Add(item);
            }
            for (int i = 0; i < WorkRankdt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = WorkRankdt.Rows[i][1].ToString();
                item.Value = WorkRankdt.Rows[i][0].ToString();
                WorkRank.Add(item);
            }
            for (int i = 0; i < TraningTypedt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = TraningTypedt.Rows[i][1].ToString();
                item.Value = TraningTypedt.Rows[i][0].ToString();
                TraningType.Add(item);
            }
            for (int i = 0; i < TraningObjectdt.Rows.Count; i++)
            {
                SelectListItem item = new SelectListItem();
                item.Text = TraningObjectdt.Rows[i][1].ToString();
                item.Value = TraningObjectdt.Rows[i][0].ToString();
                TraningObject.Add(item);
            }

            ViewData["NationList"] = Nation;
            ViewData["PoliticalList"] = Political;
            ViewData["EduLevelList"] = EduLevel;
            ViewData["EduDegreeList"] = EduDegree;
            ViewData["EduMajorList"] = EduMajor;
            ViewData["ReginList"] = Regin;
            ViewData["OrganList"] = Regin;
            ViewData["JobList"] = Job;
            ViewData["WorkRankList"] = WorkRank;
            ViewData["TeachStudySectiondt"] = TeachStudySectiondt;
            ViewData["TeachSubjectdt"] = TeachSubjectdt;
            ViewData["TeachGradedt"] = TeachGradedt;
            ViewData["TraningTypeList"] = TraningType;
            ViewData["TraningObjectList"] = TraningObject;

            AccountEdit model = bll.GetModel(AccountId);
            ViewData["UserName"] = Code.SiteCache.Instance.UserName.ToString();
            ViewData["Email"] = bll.GetEmail(AccountId);
            ViewData["Region"] = bll.GetAccountOrgan(AccountId).Rows[0][1];
            ViewData["OrganId"] = bll.GetAccountOrgan(AccountId).Rows[0][0];
            if (bll.GetAccountCount(Code.SiteCache.Instance.LoginInfo.UserId) == 0)
            {
                if(model==null)
                {
                    model = new AccountEdit();
                }

                ViewData["Type"] = "Add";
            }
            else
            {
                ViewData["Type"] = "Edit";
                model.TeachStudySection = bll.TeachStudySection(model.AccountId);
                model.TeachSubject = bll.TeachSubject(model.AccountId);
                model.TeachGrade = bll.TeachGrade(model.AccountId);
                ViewData["Nation"] = model.Nation;
                ViewData["PoliticalStatus"] = model.PoliticalStatus;
                ViewData["EduLevel"] = model.EduLevel;
                ViewData["EduDegree"] = model.EduDegree;
                ViewData["EduMajor"] = model.EduMajor;
                ViewData["Sex"] = model.Sex;
                ViewData["Job"] = model.Job;
                ViewData["WorkRank"] = model.WorkRank;
                ViewData["TeachStudySection"] = model.TeachStudySection;
                ViewData["TeachSubject"] = model.TeachSubject;
                ViewData["TeachGrade"] = model.TeachGrade;
                ViewData["TraningType"] = model.TraningType;
                ViewData["TraningObject"] = model.TraningObject;
            }
            return View(model);
        }
Beispiel #3
0
 public AccountEdit GetModel(int AccountId)
 {
     List<AccountEditModel> list = new List<AccountEditModel>();
     StringBuilder sql = new StringBuilder();
     sql.Append(" select a.UserName,a.Pic,b.RealName,b.AccountId,b.TeacherNo,a.Email,b.Sex,b.Birthday, ");
     sql.Append(" b.CredentialsNumber,b.Mobile,b.Nation,b.PoliticalStatus, ");
     sql.Append(" (select ParentId from Organ_Detail where Id = a.OrganId) as RegionId,a.OrganId,b.Job, ");
     sql.Append(" b.WorkRank,b.TeachDate,b.TraningType,b.TraningObject, ");
     sql.Append(" b.EduLevel,b.EduDegree,b.EduMajor, ");
     sql.Append(" GraduateSchool,GraduateTime ");
     sql.Append(" from dbo.Member_Account a ");
     sql.Append(" left join dbo.Member_BaseInfo b on a.Id=b.AccountId ");
     sql.Append(" where a.id = " + AccountId + " and b.Delflag = 'false' ");
     IDataReader dr = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString());
     if (dr.Read())
     {
         AccountEdit model = new AccountEdit();
         ConvertToModelTo(dr, model);
         return model;
     }
     else
     {
         return null;
     }
 }