コード例 #1
0
ファイル: ClassInfoController.cs プロジェクト: uunniie/ctnew
        //Name: $('#Name').textbox("getText"), BeginTime: $('#BeginTime').datebox('getValue'), EndTime: $('#EndTime').datebox('getValue'),
        // ClassPlanSum: $('#ClassPlanSum').textbox("getText"), ClassSum: $('#ClassSum').textbox("getText"), ClassRoomNo: $('#ClassRoomNo').textbox("getText"),
        // HeadmasterName: $('#HeadmasterName').textbox("getText"), HeadmasterTel: $('#HeadmasterTel').textbox("getText"),
        // TelNum: $('#TelNum').textbox("getText"),
        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 name = Request["Name"];
            var deptNo = Request["DeptNo"];
            var deptName = Request["DeptName"];
            var headmasterId = ConvertUtil.ConvertStringToNullableGuid(Request["HeadmasterId"]);
            var headmasterName = Request["HeadmasterName"];
            var headmasterTel = Request["HeadmasterTel"];
            var professionNo = Request["ProfessionNo"];
            var professionName = Request["ProfessionName"];
            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 beginTime = Request["BeginTime"];
            var endTime = Request["EndTime"];
            var classPlanSum = Request["ClassPlanSum"];
            var classSum = Request["ClassSum"];
            var classRoomNo = Request["ClassRoomNo"];
            var telexNum = Request["TelexNum"];
            var classActivityTime = Request["ClassActivityTime"];
            var classActivityProject = Request["ClassActivityProject"];
            var classActivityFunds = Request["ClassActivityFunds"];

            var model = new ClassInfo();
            model.Id = Guid.NewGuid();
            model.Name = name;
            model.DeptNo = deptNo;
            model.DeptName = deptName;
            model.HeadmasterId = headmasterId;
            model.HeadmasterName = headmasterName;
            model.HeadmasterTel = headmasterTel;
            model.ProfessionNo = professionNo;
            model.ProfessionName = professionName;
            model.TrainTypeNo = trainTypeNo;
            model.TrainTypeName = trainTypeName;
            model.TrainFormatNo = trainFormatNo;
            model.TrainFormatName = trainFormatName;
            model.TrainPrice = trainPrice;
            model.TheYear = theYear;
            model.ThePeriod = thePeriod;

            if (!string.IsNullOrEmpty(beginTime))
            {
                model.BeginTime = Convert.ToDateTime(beginTime);
            }
            if (!string.IsNullOrEmpty(endTime))
            {
                model.EndTime = Convert.ToDateTime(endTime);
            }
            model.ClassPlanSum = string.IsNullOrEmpty(classPlanSum) ? 0 : Convert.ToInt32(classPlanSum);
            model.ClassSum = string.IsNullOrEmpty(classSum) ? 0 : Convert.ToInt32(classSum);
            model.ClassRoomNo = classRoomNo;
            model.TelexNum = telexNum;
            model.ClassActivityTime = classActivityTime;
            model.ClassActivityProject = classActivityProject;
            model.ClassActivityFunds = classActivityFunds;

            model.IsValid = true;
            model.CreateTime = System.DateTime.Now;
            model.CreateId = CurrentUser.UserId;
            model.CreateName = CurrentUser.UserName;
            unitOfWork.ClassInfoBLL.InsertEntity(model);
            unitOfWork.Save();
            return "";
        }
コード例 #2
0
ファイル: ClassInfoController.cs プロジェクト: uunniie/ctnew
        private string ClassInfoImport(DataTable dt, out string msg)
        {
            msg = "";
            try
            {

                if (dt != null)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        //班级名称	教研室	班主任	班主任联系方式	专业	培训类别	培训方式	培训单价
                        //年份	期数  开班日期	结业日期	计划人数	实到人数	教室编号	电报号
                        //班级活动时间	班级活动项目	班级活动经费

                        var model = new ClassInfo();
                        model.Id = Guid.NewGuid();

                        model.Name = row["班级名称"].ToString();
                        model.DeptName = row["教研室"].ToString();
                        model.DeptNo = unitOfWork.SysCodeBLL.GetCodeFromName(model.DeptName);

                        model.HeadmasterName = row["班主任"].ToString();
                        model.HeadmasterId = unitOfWork.HeadmasterBLL.GetIdFromName(model.HeadmasterName);
                        model.HeadmasterTel = row["班主任联系方式"].ToString();
                        model.ProfessionName = row["专业"].ToString();
                        model.ProfessionNo = unitOfWork.SysCodeBLL.GetCodeFromName(model.ProfessionName);
                        model.TrainTypeName = row["培训类别"].ToString();
                        model.TrainTypeNo = unitOfWork.SysCodeBLL.GetCodeFromName(model.TrainTypeName);
                        model.TrainFormatName = row["培训方式"].ToString();
                        model.TrainFormatNo = unitOfWork.SysCodeBLL.GetCodeFromName(model.TrainFormatName);
                        model.TrainPrice = row["培训单价"].ToString();
                        model.TheYear = row["年份"].ToString();
                        model.ThePeriod = row["期数"].ToString();

                        if (!string.IsNullOrEmpty(row["开班日期"].ToString()))
                        {
                            model.BeginTime = Convert.ToDateTime(row["开班日期"].ToString());
                        }
                        if (!string.IsNullOrEmpty(row["结业日期"].ToString()))
                        {
                            model.EndTime = Convert.ToDateTime(row["结业日期"].ToString());
                        }
                        model.ClassPlanSum = string.IsNullOrEmpty(row["计划人数"].ToString()) ? 0 : Convert.ToInt32(row["计划人数"].ToString());
                        model.ClassSum = string.IsNullOrEmpty(row["实到人数"].ToString()) ? 0 : Convert.ToInt32(row["实到人数"].ToString());
                        model.ClassRoomNo = row["教室编号"].ToString();
                        model.TelexNum = row["电报号"].ToString();
                        model.ClassActivityTime = row["班级活动时间"].ToString();
                        model.ClassActivityProject = row["班级活动项目"].ToString();
                        model.ClassActivityFunds = row["班级活动经费"].ToString();

                        model.IsValid = true;
                        model.CreateTime = System.DateTime.Now;
                        model.CreateId = CurrentUser.UserId;
                        model.CreateName = CurrentUser.UserName;
                        unitOfWork.ClassInfoBLL.InsertEntity(model);
                        unitOfWork.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                msg = "导入异常:" + ex.Message;
                Log.Error("ClassInfoImport 异常:", ex);
            }
            return msg;
        }
コード例 #3
0
        private ClassInfo SetClassInfo(DataRow row)
        {
            var cname = row["班级名称"].ToString();
            var btime = DateTime.MinValue;
            var etime = DateTime.MinValue;
            if (!string.IsNullOrEmpty(row["开班日期"].ToString()))
            {
                btime = Convert.ToDateTime(row["开班日期"]);
            }
            if (!string.IsNullOrEmpty(row["结业日期"].ToString()))
            {
                etime = Convert.ToDateTime(row["结业日期"]);
            }

            var model = unitOfWork.ClassInfoBLL.GetEntitys(m => m.Name == cname);
            if (!model.Any())
            {
                var classInfo = new ClassInfo();
                classInfo.Id = Guid.NewGuid();
                classInfo.Name = row["班级名称"].ToString();
                if (!string.IsNullOrEmpty(row["开班日期"].ToString()))
                {
                    classInfo.BeginTime = Convert.ToDateTime(row["开班日期"].ToString());
                }
                if (!string.IsNullOrEmpty(row["结业日期"].ToString()))
                {
                    classInfo.EndTime = Convert.ToDateTime(row["结业日期"].ToString());
                }

                classInfo.HeadmasterTel = row["班主任联系方式"].ToString();
                classInfo.ProfessionName = row["专业"].ToString();
                classInfo.ProfessionNo = unitOfWork.SysCodeBLL.GetCodeFromName(classInfo.ProfessionName);
                classInfo.TrainTypeName = row["培训类别"].ToString();
                classInfo.TrainTypeNo = unitOfWork.SysCodeBLL.GetCodeFromName(classInfo.TrainTypeName);
                classInfo.TrainFormatName = row["培训形式"].ToString();
                classInfo.TrainFormatNo = unitOfWork.SysCodeBLL.GetCodeFromName(classInfo.TrainFormatName);
                classInfo.TrainPrice = row["培训单价"].ToString();
                classInfo.TheYear = row["年份"].ToString();
                classInfo.ThePeriod = row["期数"].ToString();
                classInfo.ProfessionName = row["专业"].ToString();
                classInfo.ProfessionNo = unitOfWork.SysCodeBLL.GetCodeFromName(classInfo.ProfessionName);
                var name = row["班主任"].ToString();
                var headmaster = unitOfWork.HeadmasterBLL.GetEntitys(m => m.Name == name);
                if (headmaster.Any())
                {
                    classInfo.HeadmasterId = headmaster.ToList()[0].Id;
                    classInfo.HeadmasterName = headmaster.ToList()[0].Name;
                }

               // classInfo.ClassRoomNo = row["教室"].ToString();
                classInfo.IsValid = true;
                classInfo.CreateId = CurrentUser.UserId;
                classInfo.CreateTime = DateTime.Now;
                classInfo.CreateName = CurrentUser.UserName;
                unitOfWork.ClassInfoBLL.InsertEntity(classInfo);
                return classInfo;
            }
            else
            {
                return model.ToArray()[0];
            }
        }