Exemplo n.º 1
0
        public string Add()
        {
            ControllerContext.HttpContext.Request.ContentEncoding = Encoding.GetEncoding("UTF-8");
            ControllerContext.HttpContext.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
            ControllerContext.HttpContext.Response.Charset = "UTF-8";

            var ParentId = Request["ParentId"];
            var ParentName = Request["ParentName"];
            var TrainTypeNo = Request["TrainTypeNo"];
            var TrainTypeName = Request["TrainTypeName"];
            var TrainFormatNo = Request["TrainFormatNo"];
            var TrainFormatName = Request["TrainFormatName"];
            var TrainPrice = Request["TrainPrice"];
            var TheYear = Request["TheYear"];
            var ThePeriod = Request["ThePeriod"];
            var StuTime = Request["StuTime"];
            var GraduationTime = Request["GraduationTime"];
            var ProfessionNo = Request["ProfessionNo"];
            var ProfessionName = Request["ProfessionName"];
            var HeadmasterId = Request["HeadmasterId"];
            var HeadmasterName = Request["HeadmasterName"];
            var HeadmasterTel = Request["HeadmasterTel"];
            var StuResearchId = Request["StuResearchId"];
            var StuResearchName = Request["StuResearchName"];
            var Name = Request["Name"];
            var Gender = Request["Gender"];
            var GenderName = Request["GenderName"];
            var StuNo = Request["StuNo"];
            var education = Request["Education"];
            var educationName = Request["EducationName"];
            var workIdNo = Request["WorkIdNo"];
            var tickNo = Request["TickNo"];
            var cellPhoneNo = Request["CellPhoneNo"];
            var post = Request["Post"];
            var postName = Request["PostName"];
            var stuTime = Request["StuTime"];
            var luju = Request["Luju"];
            var zhanduan = Request["zhanduan"];
            var IdNo = Request["IdNo"];
            var DeptName = Request["DeptName"];
            var Ustatus = Request["Ustatus"];
            var Score = Request["Score"];
            var SecurityScore = Request["SecurityScore"];
            var TheoryScore = Request["TheoryScore"];
            var ImpScore = Request["ImpScore"];
            var ReturnInfo = Request["ReturnInfo"];
            var LeavePerson = Request["LeavePerson"];
            var LeaveTime = Request["LeaveTime"];
            var LeaveReason = Request["LeaveReason"];
            var LeaveDays = Request["LeaveDays"];
            var GraduationStatus = Request["GraduationStatus"];

            var model = new Student();
            model.Id = Guid.NewGuid();
            model.ParentId = new Guid(ParentId);
            model.ParentName = ParentName;
            model.TrainTypeNo = TrainTypeNo;
            model.TrainTypeName = TrainTypeName;
            model.TrainFormatNo = TrainFormatNo;
            model.TrainFormatName = TrainFormatName;
            model.ParentName = ParentName;
            model.TrainPrice = TrainPrice;
            model.TheYear = TheYear;
            model.ThePeriod = ThePeriod;
            if (!string.IsNullOrEmpty(stuTime))
            {
                model.StuTime = Convert.ToDateTime(StuTime);
            }
            if (!string.IsNullOrEmpty(GraduationTime))
            {
                model.GraduationTime = Convert.ToDateTime(GraduationTime);
            }
            model.ProfessionNo = ProfessionNo;
            model.ProfessionName = ProfessionName;
            model.HeadmasterId = HeadmasterId;
            model.HeadmasterName = HeadmasterName;
            model.HeadmasterTel = HeadmasterTel;
            model.StuResearchId = StuResearchId;
            model.StuResearchName = StuResearchName;
            model.SecurityScore = SecurityScore;
            model.TheoryScore = TheoryScore;
            model.ImpScore = ImpScore;
            model.ReturnInfo = ReturnInfo;
            model.LeavePerson = LeavePerson;
            model.LeaveTime = LeaveTime;
            model.LeaveReason = LeaveReason;
            model.LeaveDays = LeaveDays;
            model.GraduationStatus = GraduationStatus;
            model.Gender = Gender;
            model.GenderName = GenderName;
            model.Education = education;
            model.EducationName = educationName;
            model.WorkIdNo = workIdNo;
            model.TickNo = tickNo;
            model.CellPhoneNo = cellPhoneNo;
            model.Name = Name;
            model.IdNo = IdNo;
            model.DeptName = DeptName;
            model.Ustatus = Ustatus;
            model.AllPath = DeptName;
            model.Post = post;
            model.PostName = postName;
            model.IsValid = true;
            model.IsExc = false;
            model.StuTime = Convert.ToDateTime(stuTime);
            model.StuNo = GetStuNo(model.ProfessionNo,model.StuTime,StuNo);
            model.CreateTime = System.DateTime.Now;
            model.CreateId = CurrentUser.UserId;
            model.CreateName = CurrentUser.UserName;
            model.Luju = luju;
            model.Zhanduan = zhanduan;
            model.Score = Score;
            unitOfWork.StudentBLL.InsertEntity(model);
            unitOfWork.Save();
            return "";
        }
Exemplo n.º 2
0
        private string StudentImport(DataTable dt, out string msg)
        {
            msg = "";
            try
            {

                if (dt != null)
                {
                    foreach (DataRow row in dt.Rows)
                    {

                        var model = new Student();
                        model.Id = Guid.NewGuid();
                       var classinfo= SetClassInfo(row);
                        model.ParentId = classinfo.Id;
                        model.ParentName = classinfo.Name;
                        model.Name = row["学员姓名"].ToString();
                        var result = unitOfWork.StudentBLL.GetEntitys(m => m.Name == model.Name && m.ParentName == model.ParentName && m.IsValid);
                        if (result.Any())  //存在更新
                        {
                           // continue;
                            model = result.FirstOrDefault();
                            model.Gender = unitOfWork.SysCodeBLL.GetCodeFromName(row["性别"].ToString());
                            model.GenderName = string.IsNullOrEmpty(model.Gender) ? "" : row["性别"].ToString();
                            model.DeptName = row["单位及职务"].ToString();
                            model.Education = unitOfWork.SysCodeBLL.GetCodeFromName(row["学历"].ToString());
                            model.EducationName = string.IsNullOrEmpty(model.Education) ? "" : row["学历"].ToString();
                            model.IdNo = row["身份证号"].ToString();
                            model.WorkIdNo = row["工作证号"].ToString();
                            model.TickNo = row["公免票号"].ToString();
                            model.CellPhoneNo = row["手机号码"].ToString();
                            model.IsValid = true;
                            model.IsExc = false;
                            model.Luju = row["路局"].ToString();
                            model.Zhanduan = row["站段"].ToString();

                            model.Post = classinfo.ProfessionNo;
                            model.PostName = classinfo.ProfessionName;
                            model.TrainTypeNo = classinfo.TrainTypeName;
                            model.TrainTypeName = classinfo.TrainTypeName;
                            model.TrainFormatNo = classinfo.TrainFormatNo;
                            model.TrainFormatName = classinfo.TrainFormatName;
                            model.TrainPrice = classinfo.TrainPrice;
                            model.TheYear = classinfo.TheYear;
                            model.ThePeriod = classinfo.ThePeriod;
                            if (classinfo.BeginTime != null)
                            {
                                model.StuTime = Convert.ToDateTime(classinfo.BeginTime);
                            }
                            if (classinfo.EndTime != null && classinfo.EndTime != DateTime.MinValue)
                            {
                                model.GraduationTime = classinfo.EndTime;
                            }

                            model.ProfessionNo = classinfo.ProfessionNo;
                            model.ProfessionName = classinfo.ProfessionName;
                            if (classinfo.HeadmasterId != null)
                            { model.HeadmasterId = classinfo.HeadmasterId.ToString(); }
                            model.HeadmasterName = classinfo.HeadmasterName;
                            model.HeadmasterTel = classinfo.HeadmasterTel;

                            model.StuResearchId = classinfo.DeptNo;
                            model.StuResearchName = classinfo.DeptName;

                            model.SecurityScore = row["安全成绩"].ToString();
                            model.TheoryScore = row["理论成绩"].ToString();
                            model.ImpScore = row["实作成绩"].ToString();
                            model.ReturnInfo = row["返程信息"].ToString();
                            model.LeavePerson = row["请假人员"].ToString();
                            model.LeaveTime = row["请假时间"].ToString();
                            model.LeaveReason = row["请假事由"].ToString();
                            model.LeaveDays = row["请假天数"].ToString();
                            model.GraduationStatus = row["结业状态"].ToString();

                            // model.Ustatus = (int) EnumStuInfoApprove.Non;
                            model.CreateTime = System.DateTime.Now;
                            model.CreateId = CurrentUser.UserId;
                            model.CreateName = CurrentUser.UserName;
                            model.StuNo = GetStuNo(model.ProfessionNo, model.StuTime, row["学员编号"].ToString());
                            model.Score = row["综合考评"].ToString();
                            unitOfWork.StudentBLL.UpdateEntity(model);
                            unitOfWork.Save();
                        }
                        else
                        {
                            model.Gender = unitOfWork.SysCodeBLL.GetCodeFromName(row["性别"].ToString());
                            model.GenderName = string.IsNullOrEmpty(model.Gender) ? "" : row["性别"].ToString();
                            model.DeptName = row["单位及职务"].ToString();
                            model.Education = unitOfWork.SysCodeBLL.GetCodeFromName(row["学历"].ToString());
                            model.EducationName = string.IsNullOrEmpty(model.Education) ? "" : row["学历"].ToString();
                            model.IdNo = row["身份证号"].ToString();
                            model.WorkIdNo = row["工作证号"].ToString();
                            model.TickNo = row["公免票号"].ToString();
                            model.CellPhoneNo = row["手机号码"].ToString();
                            model.IsValid = true;
                            model.IsExc = false;
                            model.Luju = row["路局"].ToString();
                            model.Zhanduan = row["站段"].ToString();

                            //model.Post = unitOfWork.SysCodeBLL.GetCodeFromName(row["岗位工种"].ToString());
                            //model.PostName = string.IsNullOrEmpty(model.Post) ? "" : row["岗位工种"].ToString();
                            //model.TrainTypeNo = unitOfWork.SysCodeBLL.GetCodeFromName(row["培训类别"].ToString());
                            //model.TrainTypeName = string.IsNullOrEmpty(model.TrainTypeNo) ? "" : row["培训类别"].ToString();
                            //model.TrainFormatNo = unitOfWork.SysCodeBLL.GetCodeFromName(row["培训形式"].ToString());
                            //model.TrainFormatName = string.IsNullOrEmpty(model.TrainFormatNo) ? "" : row["培训形式"].ToString();
                            //model.TrainPrice = row["培训单价"].ToString();
                            //model.TheYear = row["年份"].ToString();
                            //model.ThePeriod = row["期数"].ToString();
                            //if (!string.IsNullOrEmpty(row["开班日期"].ToString()))
                            //{
                            //    model.StuTime = Convert.ToDateTime(row["开班日期"].ToString());
                            //}
                            //if (!string.IsNullOrEmpty(row["结业日期"].ToString()))
                            //{
                            //    model.GraduationTime = Convert.ToDateTime(row["结业日期"].ToString());
                            //}
                            //model.ProfessionNo = unitOfWork.SysCodeBLL.GetCodeFromName(row["专业"].ToString()); ;
                            //model.ProfessionName = string.IsNullOrEmpty(model.ProfessionNo) ? "" : row["专业"].ToString();
                            //var name = row["班主任"].ToString();
                            //var headmaster = unitOfWork.HeadmasterBLL.GetEntitys(m => m.Name == name);
                            //if (headmaster.Any())
                            //{
                            //    model.HeadmasterId = headmaster.ToList()[0].Id.ToString();
                            //    model.HeadmasterName = headmaster.ToList()[0].Name;
                            //}
                            //model.HeadmasterTel = row["班主任联系方式"].ToString();
                            //model.StuResearchId = unitOfWork.SysCodeBLL.GetCodeFromName(row["教研室"].ToString());
                            //model.StuResearchName = string.IsNullOrEmpty(model.StuResearchId) ? "" : row["教研室"].ToString();

                            model.Post = classinfo.ProfessionNo;
                            model.PostName = classinfo.ProfessionName;
                            model.TrainTypeNo = classinfo.TrainTypeName;
                            model.TrainTypeName = classinfo.TrainTypeName;
                            model.TrainFormatNo = classinfo.TrainFormatNo;
                            model.TrainFormatName = classinfo.TrainFormatName;
                            model.TrainPrice = classinfo.TrainPrice;
                            model.TheYear = classinfo.TheYear;
                            model.ThePeriod = classinfo.ThePeriod;
                            if (classinfo.BeginTime != null)
                            {
                                model.StuTime = Convert.ToDateTime(classinfo.BeginTime);
                            }
                            if (classinfo.EndTime != null && classinfo.EndTime != DateTime.MinValue)
                            {
                                model.GraduationTime = classinfo.EndTime;
                            }

                            model.ProfessionNo = classinfo.ProfessionNo;
                            model.ProfessionName = classinfo.ProfessionName;
                            if (classinfo.HeadmasterId != null)
                            { model.HeadmasterId = classinfo.HeadmasterId.ToString(); }
                            model.HeadmasterName = classinfo.HeadmasterName;
                            model.HeadmasterTel = classinfo.HeadmasterTel;

                            model.StuResearchId = classinfo.DeptNo;
                            model.StuResearchName = classinfo.DeptName;

                            model.SecurityScore = row["安全成绩"].ToString();
                            model.TheoryScore = row["理论成绩"].ToString();
                            model.ImpScore = row["实作成绩"].ToString();
                            model.ReturnInfo = row["返程信息"].ToString();
                            model.LeavePerson = row["请假人员"].ToString();
                            model.LeaveTime = row["请假时间"].ToString();
                            model.LeaveReason = row["请假事由"].ToString();
                            model.LeaveDays = row["请假天数"].ToString();
                            model.GraduationStatus = row["结业状态"].ToString();

                            // model.Ustatus = (int) EnumStuInfoApprove.Non;
                            model.CreateTime = System.DateTime.Now;
                            model.CreateId = CurrentUser.UserId;
                            model.CreateName = CurrentUser.UserName;
                            model.StuNo = GetStuNo(model.ProfessionNo, model.StuTime, row["学员编号"].ToString());
                            model.Score = row["综合考评"].ToString();
                            unitOfWork.StudentBLL.InsertEntity(model);
                            unitOfWork.Save();
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                msg ="导入异常:"+ ex.Message;
                Log.Error("StudentImport 异常:", ex);
            }
            return msg;
        }