public ActionResult Index(Ticket t) { var RouteDAL = new RouteDAL(); var OneTicket = RouteDAL.getRoute(t); Session["Ticket"] = OneTicket; return(RedirectToAction("Index", "Route")); }
// Make the ticket object available to JavaScript public string RouteJSON() { Ticket ticket = (Ticket)Session["Ticket"]; var RouteDAL = new RouteDAL(); var OneTicket = RouteDAL.getRoute(ticket); var jsonSerializer = new JavaScriptSerializer(); string json = jsonSerializer.Serialize(OneTicket); return(json); }
public ActionResult Index() { Ticket ticket = (Ticket)Session["Ticket"]; if (ModelState.IsValid) { var RouteDAL = new RouteDAL(); var OneTicket = RouteDAL.getRoute(ticket); return(View(OneTicket)); } return(RedirectToAction("Index", "Home")); }
public RouteController(RouteDAL routeDAL) { this.routeDAL = routeDAL; }
/// <summary> /// 执行导入EXCEL数据 /// </summary> /// <param name="dataTable"></param> /// <param name="fieldNames"></param> /// <returns></returns> public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser) { List <RouteInfo> routeExcelInfos = CommonDAL.DatatableConvertToList <RouteInfo>(dataTable).ToList(); if (routeExcelInfos.Count == 0) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } ///获取业务表中要变更的数据集合,准备对比 List <RouteInfo> routeInfos = new RouteDAL().GetListForInterfaceDataSync(routeExcelInfos.Select(d => d.Route).ToList()); ///执行的SQL语句 string sql = string.Empty; List <string> fields = new List <string>(fieldNames.Keys); ///逐条处理中间表数据 foreach (var routeExcelInfo in routeExcelInfos) { ///当前业务数据表中此工厂的该物流路线时需要新增 RouteInfo routeInfo = routeInfos.FirstOrDefault(d => d.Route == routeExcelInfo.Route); if (routeInfo == null) { ///代码、名称、类型、工厂为必填项 if (string.IsNullOrEmpty(routeExcelInfo.Route) || string.IsNullOrEmpty(routeExcelInfo.RouteName) || routeExcelInfo.RouteType.GetValueOrDefault() == 0) { throw new Exception("MC:0x00000216");///路径代码、名称、类型、对应工厂为必填项 } ///字段 string insertFieldString = string.Empty; ///值 string insertValueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <RouteInfo>(routeExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } insertFieldString += "[" + fieldNames[fields[i]] + "],"; insertValueString += valueStr + ","; } sql += "if not exists (select * from LES.TM_BAS_ROUTE with(nolock) where [ROUTE] = N'" + routeExcelInfo.Route + "' and [VALID_FLAG] = 1) " + "insert into [LES].[TM_BAS_ROUTE] (" + "[FID]," + insertFieldString + "[CREATE_USER]," + "[CREATE_DATE]," + "[VALID_FLAG]" + ") values (" + "NEWID()," ///FID + insertValueString + "N'" + loginUser + "'," ///CREATE_USER + "GETDATE()," ///CREATE_DATE + "1" ///VALID_FLAG + ");"; continue; } ///代码、名称、类型、工厂为必填项 if (string.IsNullOrEmpty(routeExcelInfo.RouteName) || routeExcelInfo.RouteType.GetValueOrDefault() == 0) { throw new Exception("MC:0x00000216");///路径代码、名称、类型、对应工厂为必填项 } ///值 string valueString = string.Empty; for (int i = 0; i < fields.Count; i++) { string valueStr = CommonDAL.GetFieldValueForSql <RouteInfo>(routeExcelInfo, fields[i]); if (string.IsNullOrEmpty(valueStr)) { throw new Exception("MC:1x00000043");///数据格式不符合导入规范 } valueString += "[" + fieldNames[fields[i]] + "] = " + valueStr + ","; } sql += "update [LES].[TM_BAS_ROUTE] set " + valueString + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() " + "where [ID] = " + routeInfo.Id + ";"; } /// if (string.IsNullOrEmpty(sql)) { return(false); } return(CommonDAL.ExecuteNonQueryBySql(sql)); }