This commit is contained in:
2025-02-22 10:31:57 +08:00
parent 0d78977a77
commit 0c6a49306c
1007 changed files with 24766 additions and 636 deletions
@@ -0,0 +1,119 @@
using Model;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 岗位培训类别
/// </summary>
public static class PostTrainingCategoryService
{
/// <summary>
/// 根据主键获取岗位培训类别信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Category GetCategoryById(string Id)
{
return Funs.DB.PostTraining_Category.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 根据名称获取岗位培训类别信息
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
public static Model.PostTraining_Category GetCategoryByName(string Name)
{
return Funs.DB.PostTraining_Category.FirstOrDefault(e => e.Name == Name);
}
/// <summary>
/// 添加岗位培训类别
/// </summary>
/// <param name="model"></param>
public static void AddCategory(Model.PostTraining_Category model)
{
Model.PostTraining_Category newModel = new Model.PostTraining_Category
{
Id = model.Id,
Code = model.Code,
Name = model.Name,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Category.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateCategory(Model.PostTraining_Category model)
{
Model.PostTraining_Category newModel = Funs.DB.PostTraining_Category.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.Name = model.Name;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteCategoryById(string Id)
{
Model.PostTraining_Category model = Funs.DB.PostTraining_Category.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Category.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有培训类别List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Category> GetCategoryList()
{
return (from x in Funs.DB.PostTraining_Category orderby x.Code select x).ToList();
}
/// <summary>
/// 获取培训类别下拉框
/// </summary>
/// <param name="dropName"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingCategoryDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Id";
dropName.DataTextField = "Name";
dropName.DataSource = GetPostTrainingCategoryList();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 获取培训类别下拉项
/// </summary>
/// <returns></returns>
public static List<Model.PostTraining_Category> GetPostTrainingCategoryList()
{
return (from x in Funs.DB.PostTraining_Category orderby x.Code select x).ToList();
}
}
}
@@ -0,0 +1,326 @@
using EmitMapper;
using Microsoft.Office.Interop.Word;
using MiniExcelLibs;
using Model;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using Quartz.Util;
namespace BLL
{
/// <summary>
/// 岗位培训课程
/// </summary>
public static class PostTrainingCourseService
{
/// <summary>
/// 根据主键获取岗位培训课程信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Course GetCourseById(string Id)
{
return Funs.DB.PostTraining_Course.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 添加岗位培训课程
/// </summary>
/// <param name="model"></param>
public static void AddCourse(Model.PostTraining_Course model)
{
Model.PostTraining_Course newModel = new Model.PostTraining_Course
{
Id = model.Id,
Code = model.Code,
Name = model.Name,
CategoryId = model.CategoryId,
CategoryName = model.CategoryName,
Method1 = model.Method1,
Method2 = model.Method2,
Teachers1 = model.Teachers1,
Teachers2 = model.Teachers2,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Course.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateCourse(Model.PostTraining_Course model)
{
Model.PostTraining_Course newModel = Funs.DB.PostTraining_Course.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.Name = model.Name;
newModel.CategoryId = model.CategoryId;
newModel.CategoryName = model.CategoryName;
newModel.Method1 = model.Method1;
newModel.Method2 = model.Method2;
newModel.Teachers1 = model.Teachers1;
newModel.Teachers2 = model.Teachers2;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteCourseById(string Id)
{
Model.PostTraining_Course model = Funs.DB.PostTraining_Course.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Course.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有岗位培训课程List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Course> GetCourseList()
{
return (from x in Funs.DB.PostTraining_Course orderby x.Code select x).ToList();
}
/// <summary>
/// 导入数据
/// </summary>
/// <param name="path"></param>
/// <param name="projectid"></param>
/// <param name="creatUserId"></param>
/// <param name="errorList"></param>
/// <returns></returns>
public static ResponeData ImportData(string OriFileName, string path, string projectid, string creatUserId, ref List<Model.ErrorInfo> errorList)
{
var responeData = new ResponeData();
List<PostTrainingCourse_InputDataIn> temeplateDtoIns;
try
{
//A2:开始行
temeplateDtoIns = MiniExcel.Query<PostTrainingCourse_InputDataIn>(path, startCell: "A2").ToList();
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "模板错误:" + ex.ToString();
return responeData;
}
if (temeplateDtoIns.Count == 0)
{
responeData.code = 0;
responeData.message = "导入数据为空!";
return responeData;
}
//培训课程
var lstCourse = GetCourseList();
//培训类别
var lstCategory = PostTrainingCategoryService.GetCategoryList();
//培训方式
var lstMethod = PostTrainingMethodService.GetMethodList();
//培训教资
var lstTeachers = PostTrainingTeachersService.GetTeachersList();
#region
string errorMsg = string.Empty;
int rowIndex = 3;
foreach (var item in temeplateDtoIns)
{
string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
string name = !string.IsNullOrWhiteSpace(item.Name) ? item.Name.Trim() : string.Empty;
string method1 = !string.IsNullOrWhiteSpace(item.Method1) ? item.Method1.Trim() : string.Empty;
string method2 = !string.IsNullOrWhiteSpace(item.Method2) ? item.Method2.Trim() : string.Empty;
string teachers1 = !string.IsNullOrWhiteSpace(item.Teachers1) ? item.Teachers1.Trim() : string.Empty;
string teachers2 = !string.IsNullOrWhiteSpace(item.Teachers2) ? item.Teachers2.Trim() : string.Empty;
string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
if (!string.IsNullOrWhiteSpace(categoryName))
{
if (!lstCategory.Where(x => x.Name == categoryName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训类别";
errorInfo.Reason = $"培训类别不存在:{categoryName}";
errorList.Add(errorInfo);
}
}
else
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训类别";
errorInfo.Reason = "不可为空";
errorList.Add(errorInfo);
}
if (string.IsNullOrWhiteSpace(name))
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "课程名称";
errorInfo.Reason = "不可为空";
errorList.Add(errorInfo);
}
if (!string.IsNullOrWhiteSpace(categoryName) && !string.IsNullOrWhiteSpace(name))
{
if (temeplateDtoIns.Where(x => x.Name == name && x.CategoryName == categoryName).Count() > 1)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "课程名称";
errorInfo.Reason = $"导入数据重复:{name}{categoryName}";
errorList.Add(errorInfo);
}
if (lstCourse.Where(x => x.Name == name && x.CategoryName == categoryName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "课程名称";
errorInfo.Reason = $"已存在课程:{name}{categoryName}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(method1))
{
if (!lstMethod.Where(x => x.Name == method1).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训方式一";
errorInfo.Reason = $"培训方式字典不存在:{method1}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(method2))
{
if (!lstMethod.Where(x => x.Name == method2).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训方式二";
errorInfo.Reason = $"培训方式字典不存在:{method2}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(teachers1))
{
if (!lstTeachers.Where(x => x.Name == teachers1).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训师资一";
errorInfo.Reason = $"培训师资字典不存在:{teachers1}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(teachers2))
{
if (!lstTeachers.Where(x => x.Name == teachers2).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训师资二";
errorInfo.Reason = $"培训师资字典不存在:{teachers2}";
errorList.Add(errorInfo);
}
}
rowIndex++;
}
if (errorList.Any())
{
responeData.code = 0;
responeData.message = "存在异常数据!";
return responeData;
}
#endregion
foreach (var item in temeplateDtoIns)
{
string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
string name = !string.IsNullOrWhiteSpace(item.Name) ? item.Name.Trim() : string.Empty;
string method1 = !string.IsNullOrWhiteSpace(item.Method1) ? item.Method1.Trim() : string.Empty;
string method2 = !string.IsNullOrWhiteSpace(item.Method2) ? item.Method2.Trim() : string.Empty;
string teachers1 = !string.IsNullOrWhiteSpace(item.Teachers1) ? item.Teachers1.Trim() : string.Empty;
string teachers2 = !string.IsNullOrWhiteSpace(item.Teachers2) ? item.Teachers2.Trim() : string.Empty;
string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
Model.PostTraining_Course newModel = new Model.PostTraining_Course
{
Id = SQLHelper.GetNewID(typeof(Model.PostTraining_Course)),
Code = SQLHelper.RunProcNewId("SpGetNewCode5", "dbo.PostTraining_Course", "Code", ""),
//ProjectId = this.ProjectId,
CompileDate = DateTime.Now,
CompileMan = creatUserId
};
newModel.Name = name;
newModel.CategoryId = lstCategory.Where(x => x.Name == categoryName).FirstOrDefault().Id;
newModel.CategoryName = categoryName;
newModel.Method1 = method1;
newModel.Method2 = method2;
newModel.Teachers1 = teachers1;
newModel.Teachers2 = teachers2;
newModel.Remark = remark;
AddCourse(newModel);
}
return responeData;
}
/// <summary>
/// 获取培训课程下拉框
/// </summary>
/// <param name="dropName"></param>
/// <param name="categoryId"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingCourseDropDownList(FineUIPro.DropDownList dropName, string categoryId, bool isShowPlease)
{
dropName.DataValueField = "Id";
dropName.DataTextField = "Name";
dropName.DataSource = GetPostTrainingCourseList(categoryId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 获取培训课程下拉项
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
public static List<Model.PostTraining_Course> GetPostTrainingCourseList(string categoryId)
{
var lst = (from x in Funs.DB.PostTraining_Course orderby x.Code select x).ToList();
if (!string.IsNullOrWhiteSpace(categoryId))
{
lst = lst.Where(x => x.CategoryId == categoryId).ToList();
}
return lst;
}
}
}
@@ -0,0 +1,127 @@
using Model;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 岗位培训方式
/// </summary>
public static class PostTrainingMethodService
{
/// <summary>
/// 根据主键获取岗位培训方式信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Method GetMethodById(string Id)
{
return Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 根据名称获取岗位培训方式信息
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
public static Model.PostTraining_Method GetMethodByName(string Name)
{
return Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Name == Name);
}
/// <summary>
/// 添加岗位培训方式
/// </summary>
/// <param name="model"></param>
public static void AddMethod(Model.PostTraining_Method model)
{
Model.PostTraining_Method newModel = new Model.PostTraining_Method
{
Id = model.Id,
Code = model.Code,
Name = model.Name,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Method.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateMethod(Model.PostTraining_Method model)
{
Model.PostTraining_Method newModel = Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.Name = model.Name;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteMethodById(string Id)
{
Model.PostTraining_Method model = Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Method.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有培训方式List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Method> GetMethodList()
{
return (from x in Funs.DB.PostTraining_Method orderby x.Code select x).ToList();
}
/// <summary>
/// 获取培训方式下拉框
/// </summary>
/// <param name="dropName"></param>
/// <param name="excludeName"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingMethodDropDownList(FineUIPro.DropDownList dropName, string excludeName, bool isShowPlease)
{
dropName.DataValueField = "Name";
dropName.DataTextField = "Name";
dropName.DataSource = GetPostTrainingMethodList(excludeName);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 获取培训方式下拉项
/// </summary>
/// <param name="excludeName"></param>
/// <returns></returns>
public static List<Model.PostTraining_Method> GetPostTrainingMethodList(string excludeName)
{
var lst = (from x in Funs.DB.PostTraining_Method orderby x.Code select x).ToList();
if (!string.IsNullOrWhiteSpace(excludeName))
{
lst = lst.Where(x => x.Name != excludeName).ToList();
}
return lst;
}
}
}
@@ -0,0 +1,107 @@
using Model;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 岗位培训角色
/// </summary>
public static class PostTrainingRoleService
{
/// <summary>
/// 根据主键获取岗位培训角色信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Role GetRoleById(string Id)
{
return Funs.DB.PostTraining_Role.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 添加岗位培训角色
/// </summary>
/// <param name="model"></param>
public static void AddRole(Model.PostTraining_Role model)
{
Model.PostTraining_Role newModel = new Model.PostTraining_Role
{
Id = model.Id,
Code = model.Code,
Name = model.Name,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Role.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateRole(Model.PostTraining_Role model)
{
Model.PostTraining_Role newModel = Funs.DB.PostTraining_Role.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.Name = model.Name;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteRoleById(string Id)
{
Model.PostTraining_Role model = Funs.DB.PostTraining_Role.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Role.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有岗位培训角色List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Role> GetRoleList()
{
return (from x in Funs.DB.PostTraining_Role orderby x.Code select x).ToList();
}
/// <summary>
/// 获取岗位培训角色下拉框
/// </summary>
/// <param name="dropName"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingRoleDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Id";
dropName.DataTextField = "Name";
dropName.DataSource = GetPostTrainingRoleList();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 获取岗位培训角色下拉项
/// </summary>
/// <returns></returns>
public static List<Model.PostTraining_Role> GetPostTrainingRoleList()
{
return (from x in Funs.DB.PostTraining_Role orderby x.Code select x).ToList();
}
}
}
@@ -0,0 +1,446 @@
using EmitMapper;
using Microsoft.Office.Interop.Word;
using MiniExcelLibs;
using Model;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using Quartz.Util;
using Microsoft.Office.Interop.Excel;
using RestSharp;
using System.Web.UI.WebControls;
using Microsoft.SqlServer.Dts.Runtime;
namespace BLL
{
/// <summary>
/// 岗位培训标准
/// </summary>
public static class PostTrainingStandardService
{
/// <summary>
/// 根据主键获取岗位培训标准信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Standard GetStandardById(string Id)
{
return Funs.DB.PostTraining_Standard.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 添加岗位培训标准
/// </summary>
/// <param name="model"></param>
public static void AddStandard(Model.PostTraining_Standard model)
{
Model.PostTraining_Standard newModel = new Model.PostTraining_Standard
{
Id = model.Id,
Code = model.Code,
RoleId = model.RoleId,
CourseId = model.CourseId,
ClassHour = model.ClassHour,
Cycle = model.Cycle,
Method = model.Method,
Outcome = model.Outcome,
Teachers = model.Teachers,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Standard.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateStandard(Model.PostTraining_Standard model)
{
Model.PostTraining_Standard newModel = Funs.DB.PostTraining_Standard.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.RoleId = model.RoleId;
newModel.CourseId = model.CourseId;
newModel.ClassHour = model.ClassHour;
newModel.Cycle = model.Cycle;
newModel.Method = model.Method;
newModel.Outcome = model.Outcome;
newModel.Teachers = model.Teachers;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteStandardById(string Id)
{
Model.PostTraining_Standard model = Funs.DB.PostTraining_Standard.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Standard.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有岗位培训标准List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Standard> GetStandardList()
{
return (from x in Funs.DB.PostTraining_Standard orderby x.Code select x).ToList();
}
/// <summary>
/// 获取所有岗位培训标准信息List
/// </summary>
/// <returns></returns>
public static List<PostTrainingStandardInfo> GetStandardInfoList()
{
var db = Funs.DB;
var lst = (from x in db.PostTraining_Standard
join y in db.PostTraining_Course on x.CourseId equals y.Id
join z in db.PostTraining_Role on x.RoleId equals z.Id
orderby x.Code
select new PostTrainingStandardInfo
{
RoleId = x.RoleId,
RoleName = z.Name,
CourseId = x.CourseId,
CourseName = y.Name,
CategoryName = y.CategoryName,
ClassHour = x.ClassHour,
Cycle = x.Cycle,
Method = x.Method,
Outcome = x.Outcome,
Teachers = x.Teachers,
Remark = x.Remark
}).ToList();
return lst;
}
/// <summary>
/// 导入数据
/// </summary>
/// <param name="path"></param>
/// <param name="projectid"></param>
/// <param name="creatUserId"></param>
/// <param name="errorList"></param>
/// <returns></returns>
public static ResponeData ImportData(string OriFileName, string path, string projectid, string creatUserId, ref List<Model.ErrorInfo> errorList)
{
var responeData = new ResponeData();
List<PostTrainingStandard_InputDataIn> temeplateDtoIns;
try
{
temeplateDtoIns = MiniExcel.Query<PostTrainingStandard_InputDataIn>(path, startCell: "A1").ToList();
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "模板错误:" + ex.ToString();
return responeData;
}
if (temeplateDtoIns.Count == 0)
{
responeData.code = 0;
responeData.message = "导入数据为空!";
return responeData;
}
//培训标准
var lstStandard = GetStandardInfoList();
//培训课程
var lstCourse = PostTrainingCourseService.GetCourseList();
//培训角色
var lstRole = PostTrainingRoleService.GetRoleList();
//培训类别
var lstCategory = PostTrainingCategoryService.GetCategoryList();
//培训方式
var lstMethod = PostTrainingMethodService.GetMethodList();
//培训教资
var lstTeachers = PostTrainingTeachersService.GetTeachersList();
//培训效果
var lstOutcome = GetPostTrainingOutcomeList();
#region
string errorMsg = string.Empty;
int rowIndex = 3;
foreach (var item in temeplateDtoIns)
{
string roleName = !string.IsNullOrWhiteSpace(item.RoleName) ? item.RoleName.Trim() : string.Empty;
string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
string courseName = !string.IsNullOrWhiteSpace(item.CourseName) ? item.CourseName.Trim() : string.Empty;
string classHourStr = !string.IsNullOrWhiteSpace(item.ClassHour) ? item.ClassHour.Trim() : string.Empty;
string cycleStr = !string.IsNullOrWhiteSpace(item.Cycle) ? item.Cycle.Trim() : string.Empty;
decimal classHour = 0;
decimal cycle = 0;
string method = !string.IsNullOrWhiteSpace(item.Method) ? item.Method.Trim() : string.Empty;
string outcome = !string.IsNullOrWhiteSpace(item.Outcome) ? item.Outcome.Trim() : string.Empty;
string teachers = !string.IsNullOrWhiteSpace(item.Teachers) ? item.Teachers.Trim() : string.Empty;
string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
if (!string.IsNullOrWhiteSpace(roleName))
{
if (!lstRole.Where(x => x.Name == roleName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "适用岗位角色";
errorInfo.Reason = $"角色不存在:{roleName}";
errorList.Add(errorInfo);
}
}
else
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "适用岗位角色";
errorInfo.Reason = "不可为空";
errorList.Add(errorInfo);
}
if (!string.IsNullOrWhiteSpace(categoryName))
{
if (!lstCategory.Where(x => x.Name == categoryName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训类别";
errorInfo.Reason = $"培训类别不存在:{categoryName}";
errorList.Add(errorInfo);
}
}
else
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训类别";
errorInfo.Reason = "不可为空";
errorList.Add(errorInfo);
}
if (string.IsNullOrWhiteSpace(courseName))
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课程";
errorInfo.Reason = "不可为空";
errorList.Add(errorInfo);
}
if (!string.IsNullOrWhiteSpace(categoryName) && !string.IsNullOrWhiteSpace(courseName))
{
if (temeplateDtoIns.Where(x => x.RoleName == roleName && x.CourseName == courseName && x.CategoryName == categoryName).Count() > 1)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课程";
errorInfo.Reason = $"【{roleName}】导入数据重复:{courseName}{categoryName}";
errorList.Add(errorInfo);
}
if (!lstCourse.Where(x => x.Name == courseName && x.CategoryName == categoryName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课程";
errorInfo.Reason = $"【{roleName}】不存在培训课程:{courseName}{categoryName}";
errorList.Add(errorInfo);
}
else if (lstStandard.Where(x => x.CourseName == courseName && x.CategoryName == categoryName).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课程";
errorInfo.Reason = $"培训标准已存在:{courseName}{categoryName}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrEmpty(classHourStr))
{
try
{
classHour = decimal.Parse(classHourStr);
if (classHour <= 0)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课时";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
}
catch (Exception)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课时";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
}
else
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训课时";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
if (!string.IsNullOrEmpty(cycleStr))
{
try
{
cycle = decimal.Parse(cycleStr);
if (cycle <= 0)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训周期";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
}
catch (Exception)
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训周期";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
}
else
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训周期";
errorInfo.Reason = "请填写大于0的数值";
errorList.Add(errorInfo);
}
if (!string.IsNullOrWhiteSpace(method))
{
if (!lstMethod.Where(x => x.Name == method).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训方式";
errorInfo.Reason = $"培训方式字典不存在:{method}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(outcome))
{
if (!lstOutcome.Where(x => x.Text == outcome).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训效果";
errorInfo.Reason = $"培训效果字典不存在:{outcome}";
errorList.Add(errorInfo);
}
}
if (!string.IsNullOrWhiteSpace(teachers))
{
if (!lstTeachers.Where(x => x.Name == teachers).Any())
{
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = rowIndex.ToString();
errorInfo.Column = "培训师资";
errorInfo.Reason = $"培训师资字典不存在:{teachers}";
errorList.Add(errorInfo);
}
}
rowIndex++;
}
if (errorList.Any())
{
responeData.code = 0;
responeData.message = "存在异常数据!";
return responeData;
}
#endregion
foreach (var item in temeplateDtoIns)
{
string roleName = !string.IsNullOrWhiteSpace(item.RoleName) ? item.RoleName.Trim() : string.Empty;
string categoryName = !string.IsNullOrWhiteSpace(item.CategoryName) ? item.CategoryName.Trim() : string.Empty;
string courseName = !string.IsNullOrWhiteSpace(item.CourseName) ? item.CourseName.Trim() : string.Empty;
decimal classHour = decimal.Parse(item.ClassHour);
decimal cycle = decimal.Parse(item.Cycle);
string method = !string.IsNullOrWhiteSpace(item.Method) ? item.Method.Trim() : string.Empty;
string outcome = !string.IsNullOrWhiteSpace(item.Outcome) ? item.Outcome.Trim() : string.Empty;
string teachers = !string.IsNullOrWhiteSpace(item.Teachers) ? item.Teachers.Trim() : string.Empty;
string remark = !string.IsNullOrWhiteSpace(item.Remark) ? item.Remark.Trim() : string.Empty;
Model.PostTraining_Standard newModel = new Model.PostTraining_Standard
{
Id = SQLHelper.GetNewID(typeof(Model.PostTraining_Standard)),
Code = SQLHelper.RunProcNewId("SpGetNewCode5", "dbo.PostTraining_Standard", "Code", ""),
//ProjectId = this.ProjectId,
CompileDate = DateTime.Now,
CompileMan = creatUserId
};
newModel.CourseId = lstCourse.Where(x => x.Name == courseName).FirstOrDefault().Id;
newModel.RoleId = lstRole.Where(x => x.Name == roleName).FirstOrDefault().Id;
newModel.ClassHour = classHour;
newModel.Cycle = cycle;
newModel.Method = method;
newModel.Outcome = outcome;
newModel.Teachers = teachers;
newModel.Remark = remark;
AddStandard(newModel);
}
return responeData;
}
/// <summary>
/// 培训效果
/// </summary>
/// <param name="dropName"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingOutcomeDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Text";
dropName.DataTextField = "Text";
dropName.DataSource = GetPostTrainingOutcomeList();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 培训效果
/// </summary>
/// <returns></returns>
public static ListItem[] GetPostTrainingOutcomeList()
{
ListItem[] lis = null;
lis = new ListItem[3];
lis[0] = new ListItem("掌握", "0");
lis[1] = new ListItem("熟悉", "1");
lis[2] = new ListItem("了解", "2");
return lis;
}
}
}
@@ -0,0 +1,127 @@
using Model;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 岗位培训师资
/// </summary>
public static class PostTrainingTeachersService
{
/// <summary>
/// 根据主键获取岗位培训师资信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.PostTraining_Teachers GetTeachersById(string Id)
{
return Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 根据名称获取岗位培训师资信息
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
public static Model.PostTraining_Teachers GetTeachersByName(string Name)
{
return Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Name == Name);
}
/// <summary>
/// 添加岗位培训师资
/// </summary>
/// <param name="model"></param>
public static void AddTeachers(Model.PostTraining_Teachers model)
{
Model.PostTraining_Teachers newModel = new Model.PostTraining_Teachers
{
Id = model.Id,
Code = model.Code,
Name = model.Name,
CompileDate = model.CompileDate,
CompileMan = model.CompileMan,
Remark = model.Remark
};
Funs.DB.PostTraining_Teachers.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
public static void UpdateTeachers(Model.PostTraining_Teachers model)
{
Model.PostTraining_Teachers newModel = Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
newModel.Code = model.Code;
newModel.Name = model.Name;
newModel.Remark = model.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
public static void DeleteTeachersById(string Id)
{
Model.PostTraining_Teachers model = Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Id == Id);
if (model != null)
{
CommonService.DeleteAttachFileById(Id);
Funs.DB.PostTraining_Teachers.DeleteOnSubmit(model);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 获取所有培训师资List
/// </summary>
/// <returns></returns>
public static List<PostTraining_Teachers> GetTeachersList()
{
return (from x in Funs.DB.PostTraining_Teachers orderby x.Code select x).ToList();
}
/// <summary>
/// 获取培训师资下拉框
/// </summary>
/// <param name="dropName"></param>
/// <param name="excludeName"></param>
/// <param name="isShowPlease"></param>
public static void InitPostTrainingTeachersDropDownList(FineUIPro.DropDownList dropName, string excludeName, bool isShowPlease)
{
dropName.DataValueField = "Name";
dropName.DataTextField = "Name";
dropName.DataSource = GetPostTrainingTeachersList(excludeName);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 获取培训师资下拉项
/// </summary>
/// <param name="excludeName"></param>
/// <returns></returns>
public static List<Model.PostTraining_Teachers> GetPostTrainingTeachersList(string excludeName)
{
var lst = (from x in Funs.DB.PostTraining_Teachers orderby x.Code select x).ToList();
if (!string.IsNullOrWhiteSpace(excludeName))
{
lst = lst.Where(x => x.Name != excludeName).ToList();
}
return lst;
}
}
}