Пример #1
0
 public ActionResult Edit(AccountEditModel model)
 {
     if (bll.Edit(model))
     {
         return Content("<script>alert('修改成功!!!');location.href='/Prepare/AccountEdit/List';</script>");
     }
     else
     {
         return Content("<script>alert('修改失败!!!');location.href='/Prepare/AccountEdit/Index';</script>");
     }
 }
Пример #2
0
 public ActionResult Add(AccountEditModel model)
 {
     model.AccountId = Code.SiteCache.Instance.LoginInfo.UserId;
     if (model != null)
     {
         if (bll.Add(model))
         {
             return Content("<script>alert('修改成功!!!');location.href='/Prepare/AccountEdit/List';</script>");
         }
         else
         {
             return Content("<script>alert('修改失败!!!');location.href='/Prepare/AccountEdit/Index';</script>");
         }
     }
     else
     {
         return Content("<script>alert('数据为空!!!');location.href='/Prepare/AccountEdit/Index';</script>");
     }
 }
Пример #3
0
 public bool Edit(AccountEditModel model)
 {
     return dal.Edit(model);
 }
Пример #4
0
 public bool Add(AccountEditModel model)
 {
     return dal.Add(model);
 }
Пример #5
0
        private void ConvertToModel(IDataReader reader, AccountEditModel 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["Region"] != DBNull.Value)
                model.Region = reader["Region"].ToString();

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

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

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

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

            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 = reader["TraningType"].ToString();

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

            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"]);
        }
Пример #6
0
        public bool Edit(AccountEditModel model)
        {
            int i = 0;
            StringBuilder sql = new StringBuilder();
            sql.Append(" update Member_Account set Email = @Email,Pic = @Pic,Nickname=@Nickname,OrganId=@OrganId where Id = @AccountId ");
            SqlParameter[] pame ={
                                    new SqlParameter("@Email",SqlDbType.VarChar),
                                    new SqlParameter("@AccountId",SqlDbType.Int),
                                    new SqlParameter("@Pic",SqlDbType.VarChar),
                                    new SqlParameter("@Nickname",SqlDbType.VarChar),
                                    new SqlParameter("@OrganId",SqlDbType.Int)
                                  };
            pame[0].Value = model.Email;
            pame[1].Value = model.AccountId;
            pame[2].Value = model.Pic;
            pame[3].Value = model.RealName;
            if (model.Organ == null || model.Organ == "")
            {
                pame[4].Value = model.Region;
            }
            else
            {
                pame[4].Value = model.Organ;
            }
            i += MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), pame);

            StringBuilder sb = new StringBuilder();
            sb.Append(" update Member_BaseInfo set RealName=@RealName,TeacherNo=@TeacherNo,Mobile=@Mobile,CredentialsNumber=@CredentialsNumber,Sex=@Sex, ");
            sb.Append(" Birthday=@Birthday,Nation=@Nation,PoliticalStatus=@PoliticalStatus,RegionId=@RegionId,Organid=@Organid,Job=@Job, ");
            sb.Append(" WorkRank=@WorkRank,TeachDate=@TeachDate,TraningType=@TraningType,TraningObject=@TraningObject,EduLevel=@EduLevel, ");
            sb.Append(" EduDegree=@EduDegree,EduMajor=@EduMajor,GraduateSchool=@GraduateSchool,GraduateTime=@GraduateTime ");
            sb.Append(" where AccountId = @AccountId ");
            SqlParameter[] para ={
                                    new SqlParameter("@AccountId",SqlDbType.Int),
                                    new SqlParameter("@Mobile",SqlDbType.VarChar),
                                    new SqlParameter("@CredentialsNumber",SqlDbType.VarChar),
                                    new SqlParameter("@Sex",SqlDbType.Int),
                                    new SqlParameter("@Birthday",SqlDbType.DateTime),
                                    new SqlParameter("@Nation",SqlDbType.Int),
                                    new SqlParameter("@PoliticalStatus",SqlDbType.Int),
                                    new SqlParameter("@RegionId",SqlDbType.Int),
                                    new SqlParameter("@Organid",SqlDbType.Int),
                                    new SqlParameter("@Job",SqlDbType.Int),
                                    new SqlParameter("@WorkRank",SqlDbType.Int),
                                    new SqlParameter("@TeachDate",SqlDbType.DateTime),
                                    new SqlParameter("@TraningType",SqlDbType.Int),
                                    new SqlParameter("@TraningObject",SqlDbType.Int),
                                    new SqlParameter("@EduLevel",SqlDbType.Int),
                                    new SqlParameter("@EduDegree",SqlDbType.Int),
                                    new SqlParameter("@EduMajor",SqlDbType.Int),
                                    new SqlParameter("@GraduateSchool",SqlDbType.VarChar),
                                    new SqlParameter("@GraduateTime",SqlDbType.DateTime),
                                    new SqlParameter("@RealName",SqlDbType.VarChar),
                                    new SqlParameter("@TeacherNo",SqlDbType.VarChar)
                                 };
            para[0].Value = model.AccountId;
            para[1].Value = model.Mobile;
            para[2].Value = model.CredentialsNumber;
            para[3].Value = model.Sex;
            para[4].Value = model.Birthday;
            para[5].Value = model.Nation;
            para[6].Value = model.PoliticalStatus;
            para[7].Value = model.Region;
            para[8].Value = model.Organ;
            para[9].Value = model.Job;
            para[10].Value = model.WorkRank;
            para[11].Value = model.TeachDate;
            para[12].Value = model.TraningType;
            para[13].Value = model.TraningObject;
            para[14].Value = model.EduLevel;
            para[15].Value = model.EduDegree;
            para[16].Value = model.EduMajor;
            para[17].Value = model.GraduateSchool;
            para[18].Value = model.GraduateTime;
            para[19].Value = model.RealName;
            para[20].Value = model.TeacherNo;

            i += MSEntLibSqlHelper.ExecuteNonQueryBySql(sb.ToString(), para);

            string TeachStudySection = "";
            string TeachSubject = "";
            string TeachGrade = "";
            if (model.TeachStudySection != null && model.TeachStudySection != "")
            {
                TeachStudySection = model.TeachStudySection.TrimEnd(',');
            }
            if (model.TeachSubject != null && model.TeachSubject != "")
            {
                TeachSubject = model.TeachSubject.TrimEnd(',');
            }
            if (model.TeachGrade != null && model.TeachGrade != "")
            {
                TeachGrade = model.TeachGrade.TrimEnd(',');
            }

            StringBuilder SectionDel = new StringBuilder();
            SectionDel.Append(" delete from Member_StudySection where AccountId = " + model.AccountId + " ");
            i += MSEntLibSqlHelper.ExecuteNonQueryBySql(SectionDel.ToString());
            string[] src = TeachStudySection.Split(',');
            for (int k = 0; k < src.Length; k++)
            {
                if (src[k] != "" && src[k] != null)
                {
                    StringBuilder Section = new StringBuilder();
                    Section.Append(" insert into Member_StudySection (AccountId,StudySection,Delflag,CreateDate) ");
                    Section.Append(" values (" + model.AccountId + "," + src[k] + ",'false','" + DateTime.Now + "') ");
                    i += MSEntLibSqlHelper.ExecuteNonQueryBySql(Section.ToString());
                }
            }

            StringBuilder SubjectDel = new StringBuilder();
            SubjectDel.Append(" delete from Member_TeachSubject where AccountId = " + model.AccountId + " ");
            i += MSEntLibSqlHelper.ExecuteNonQueryBySql(SubjectDel.ToString());
            string[] src1 = TeachSubject.Split(',');
            for (int k = 0; k < src1.Length; k++)
            {
                if (src1[k] != "" && src1[k] != null)
                {
                    StringBuilder Subject = new StringBuilder();
                    Subject.Append(" insert into Member_TeachSubject (AccountId,TeachSubject,Delflag,CreateDate) ");
                    Subject.Append(" values (" + model.AccountId + "," + src1[k] + ",'false','" + DateTime.Now + "') ");
                    i += MSEntLibSqlHelper.ExecuteNonQueryBySql(Subject.ToString());
                }
            }

            StringBuilder GradeDel = new StringBuilder();
            GradeDel.Append(" delete from Member_TeachGrade where AccountId = " + model.AccountId + " ");
            i += MSEntLibSqlHelper.ExecuteNonQueryBySql(GradeDel.ToString());
            string[] src2 = TeachGrade.Split(',');
            for (int k = 0; k < src2.Length; k++)
            {
                if (src2[k] != "" && src2[k] != null)
                {
                    StringBuilder Grade = new StringBuilder();
                    Grade.Append(" insert into Member_TeachGrade (AccountId,TeachGrade,Delflag,CreateDate) ");
                    Grade.Append(" values (" + model.AccountId + "," + src2[k] + ",'false','" + DateTime.Now + "') ");
                    i += MSEntLibSqlHelper.ExecuteNonQueryBySql(Grade.ToString());
                }
            }
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }