Beispiel #1
0
        public string Add()
        {
            //   OrgId: $('#OrgId').combobox("getValue"), OrgName: $('#OrgId').combobox("getText"),
            //Name: $('#Name').textbox("getValue"),
            //Remark: $('#Remark').textbox("getText")

            string orgId = Request["OrgId"];
            string orgName = Request["OrgName"];
            string name = Request["Name"];
            string remark = Request["Remark"];

            var model = new CourseInfo();
            var classroom = unitOfWork.CourseInfoBLL.GetEntitys(m => m.Name == orgName && m.IsValid);
            if (classroom.Any())
            {
                return "课程已存在!如要修改,请点击编辑按钮!";
            }
            else
            {
                model.Id = Guid.NewGuid();
                model.OrgId = orgId;
                model.OrgName = orgName;
                model.Name = name;
                model.Remark = remark;
                model.CreateId = CurrentUser.UserId;
                model.CreateName = CurrentUser.UserName;
                model.CreateTime = System.DateTime.Now;
                model.IsValid = true;
                try
                {
                    unitOfWork.CourseInfoBLL.InsertEntity(model);
                    unitOfWork.Save();
                    return "";
                }
                catch (Exception ex)
                {
                    Log.Error("保存课程信息异常:" + ex.Message, ex);
                    return "系统异常,请联系管理员!";
                }
            }
        }
Beispiel #2
0
        private string CourseInfoImport(DataTable dt, string filename)
        {
            if (dt != null)
            {
                var preOrg = "";
                foreach (DataRow row in dt.Rows)
                {

                    // 		教研室	课程名称	备注
                    CourseInfo model;
                    var courseName = row["课程名称"].ToString();
                    var modeles = unitOfWork.CourseInfoBLL.GetEntitys(m => m.Name == courseName && m.IsValid);
                    if (modeles.Any())
                    {
                        model = modeles.ToArray()[0];

                        if (!string.IsNullOrEmpty(row["教研室"].ToString())) //处理合并单元格的问题
                        {
                            preOrg = row["教研室"].ToString();
                            model.OrgName = preOrg;
                        }
                        else
                        {
                            model.OrgName = preOrg;
                        }
                        model.OrgId = unitOfWork.SysCodeBLL.GetCodeFromName(model.OrgName);
                        model.Name = courseName;
                        model.Remark = row["备注"].ToString();
                        model.LastModifyTime = System.DateTime.Now;
                        model.LastModifyId = CurrentUser.UserId;
                        model.LastModifyName = CurrentUser.UserName;
                        model.IsValid = true;
                        unitOfWork.CourseInfoBLL.UpdateEntity(model);
                    }
                    else
                    {
                        model = new CourseInfo();
                        model.Name = row["课程名称"].ToString();
                        model.OrgName = row["教研室"].ToString();
                        model.OrgId = unitOfWork.SysCodeBLL.GetCodeFromName(model.OrgName);
                        model.Remark = row["备注"].ToString();
                        model.Id = Guid.NewGuid();
                        model.CreateTime = System.DateTime.Now;
                        model.CreateId = CurrentUser.UserId;
                        model.CreateName = CurrentUser.UserName;
                        model.IsValid = true;
                        unitOfWork.CourseInfoBLL.InsertEntity(model);
                    }
                }
                unitOfWork.Save();
            }

            return "";
        }