public int Add1(Manage_Type model) { using (var conn = DapperConnection.GetConnection()) { DynamicParameters dp = new DynamicParameters(); dp.Add("@Id", model.Id); dp.Add("@AdminAccount", model.AdminAccount); dp.Add("@AdminName", model.AdminName); dp.Add("@ApproverAccount", model.ApproverAccount); dp.Add("@ApproverName", model.ApproverName); dp.Add("@CreateDate", model.CreateDate); dp.Add("@CreateUser", model.CreateUser); dp.Add("@IsValid", model.IsValid); dp.Add("@OrderNo", model.OrderNo); dp.Add("@ParentId", model.ParentId); dp.Add("@Path", model.Path); dp.Add("@Remark", model.Remark); dp.Add("@TypeCode", model.TypeCode); dp.Add("@TypeName", model.TypeName); dp.Add("@UpdateDate", model.UpdateDate); dp.Add("@UpdateUser", model.UpdateUser); return(conn.Execute("Manage_Type", dp, null, null, CommandType.TableDirect)); } }
public int Add(Manage_Type model) { using (var conn = DapperConnection.GetConnection()) { string sql = $"Insert into Manage_Type (Id,Path) Values ('{model.Id}','{model.Path}')"; return(conn.Execute(sql)); } }
//解析excel public static List <Manage_Type> RecursionAnalyseExecel() { //1.读取 FileStream fs = File.OpenRead(@"C:\\work\222.xlsx"); //1.1获取execel文档 IWorkbook workBook = new XSSFWorkbook(fs); ISheet sheet = null; IRow row = null; ICell cell = null; //实例文档表数量 var countSheet = workBook.NumberOfSheets; var countRow = 0; // sheet.LastRowNum; var countCell = 0; // row.LastCellNum; var thePointedSheet = 0; Manage_Type model = new Manage_Type(); List <Manage_Type> listModel = new List <Manage_Type>(); var rootId = "1d9e56bd-3064-4dc8-aeef-5c4479903b05"; string[] ApproverAccount = { "Corporate Manuals", "Global & Site Specific Procedures", "Global & Site Specific Regulations", "Operation Instructions", "Technical Specifications", "SOP" }; var arrTemp = new Manage_Type[10]; arrTemp[0] = new Manage_Type() { Id = rootId, ApproverAccount = ApproverAccount[0] }; //数据表对象 sheet = workBook.GetSheetAt(0); for (int i = 0; i < countSheet; i++) { //获取当前sheet sheet = workBook.GetSheetAt(i); //设置制定页 if (thePointedSheet != 0) { sheet = workBook.GetSheetAt(thePointedSheet); countSheet = 0; } countRow = sheet.LastRowNum; for (int j = 1; j <= countRow; j++) { row = sheet.GetRow(j); countCell = row.Cells.Count; bool isNewRow = true; //判断是否为根目录 isNewRow = IsRootPath(row); //添加列 for (int m = 1; m <= countCell; m++) { cell = row.GetCell(m); if (cell == null || string.IsNullOrEmpty(cell.StringCellValue)) { continue; } model = new Manage_Type { ApproverAccount = ApproverAccount[workBook.GetSheetIndex(sheet)], TypeName = cell.StringCellValue, ParentId = arrTemp[m - 1].Id }; if (isNewRow) { arrTemp[m] = model; } listModel.Add(model); } } } return(listModel); }