public static ResponseModel UpdateStatusAssignMaterialToRoutingFile(int AssignMaterialToRoutingFileID, int AssignMaterialToRoutingFileStatus) { string action = "UpdateStatusAssignMaterialToRoutingFile(AssignMaterialToRoutingFileID, AssignMaterialToRoutingFileStatus)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE _obj = context.USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE.FirstOrDefault(o => o.AssignMaterialToRoutingFileID == AssignMaterialToRoutingFileID); if (_obj != null) { _obj.AssignMaterialToRoutingFileStatus = AssignMaterialToRoutingFileStatus; context.SaveChanges(); return(new ResponseModel() { Source = SOURCE, Action = action, Status = true, Message = "Success" }); } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "AssignMaterialToRoutingFileID Not Exist" }); } } catch (DbEntityValidationException ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } catch (Exception ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } }
public static ResponseModel UpdateStatusBOMFile(int BOMFileID, int BOMFileStatus) { string action = "UpdateStatusBOMFile(BOMFileModel)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_BOM_FILE _obj = context.USR_TMMA_BOM_FILE.FirstOrDefault(o => o.BOMFileID == BOMFileID); if (_obj != null) { _obj.BOMFileStatus = BOMFileStatus; context.SaveChanges(); return(new ResponseModel() { Source = SOURCE, Action = action, Status = true, Message = "Success" }); } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "BOMFileID Not Exist" }); } } catch (DbEntityValidationException ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } catch (Exception ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } }
public static List <AssignMaterialToRoutingFileModel> GetAssignMaterialToRoutingFileList(AssignMaterialToRoutingFileFilterModel filter, ref int totalRecord, ref ResponseModel response) { ACTION = "GetAssignMaterialToRoutingFileList(AssignMaterialToRoutingFileFilterModel)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { filter.AssignMaterialToRoutingFileIDs = filter.AssignMaterialToRoutingFileIDs != null ? filter.AssignMaterialToRoutingFileIDs : new int[] { }; var IQuery = context.USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE .Where(o => (!string.IsNullOrEmpty(filter.Keywords) ? (o.RecObjectName.Contains(filter.Keywords)) || (o.CreatedBy.Contains(filter.Keywords)) : true) && (filter.AssignMaterialToRoutingFileID.HasValue ? o.AssignMaterialToRoutingFileID == filter.AssignMaterialToRoutingFileID.Value : true) && (filter.AssignMaterialToRoutingFileIDs.Count() > 0 ? filter.AssignMaterialToRoutingFileIDs.Contains(o.AssignMaterialToRoutingFileID) : true) && (!string.IsNullOrEmpty(filter.RecObjectName) ? filter.CreatedBy.Contains(o.RecObjectName) : true) && (filter.ProductsTypeID.HasValue ? o.ProductsTypeID == filter.ProductsTypeID.Value : true) && (filter.IsActive.HasValue ? o.IsActive == 1 : true) ); totalRecord = IQuery.Count(); List <USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE> list = filter.Pagination.IsPaging ? IQuery.OrderBy(o => o.CreatedDate).Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : IQuery.ToList(); List <AssignMaterialToRoutingFileModel> mList = Mapping(list); response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = true, Message = "Success" }; return(mList); } } catch (Exception ex) { totalRecord = 0; response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = false, Message = ex.Message }; return(null); } }
public static List <ProductsModel> GetProductsList(ProductsFilterModel filter, ref int totalRecord, ref ResponseModel response) { ACTION = "GetProductsList(ProductsFilterModel)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { filter.ProductsIDs = filter.ProductsIDs != null ? filter.ProductsIDs : new int[] { }; var IQuery = context.USR_TMMA_PRODUCTS .Where(o => (!string.IsNullOrEmpty(filter.Keywords) ? (o.CreatedBy.Contains(filter.Keywords)) : true) && (filter.ProductsID.HasValue ? o.ProductsID == filter.ProductsID.Value : true) && (filter.ProductsIDs.Count() > 0 ? filter.ProductsIDs.Contains(o.ProductsID) : true) && (!string.IsNullOrEmpty(filter.CreatedBy) ? filter.CreatedBy.Contains(o.CreatedBy) : true) && (filter.IsActive.HasValue ? o.IsActive == 1 : true) ); totalRecord = IQuery.Count(); List <USR_TMMA_PRODUCTS> list = filter.Pagination.IsPaging ? IQuery.OrderBy(o => o.CreatedDate).Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : IQuery.ToList(); List <ProductsModel> mList = Mapping(list); response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = true, Message = "Success" }; return(mList); } } catch (Exception ex) { totalRecord = 0; response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = false, Message = ex.Message }; return(null); } }
public static BOMFileModel GetBOMFile(int bomFileID) { ACTION = "GetBOMFile(bomFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_BOM_FILE obj = context.USR_TMMA_BOM_FILE.Where(o => o.BOMFileID == bomFileID).FirstOrDefault(); BOMFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static InspectionPlanFileModel GetInspectionPlanFile(int inspectionPlanFileID) { ACTION = "GetInspectionPlanFile(inspectionPlanFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_INSPECTION_PLAN_FILE obj = context.USR_TMMA_INSPECTION_PLAN_FILE.Where(o => o.InspectionPlanFileID == inspectionPlanFileID).FirstOrDefault(); InspectionPlanFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static RoutingFileModel GetRoutingFile(int routingFileID) { ACTION = "GetRoutingFile(routingFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_ROUTING_FILE obj = context.USR_TMMA_ROUTING_FILE.Where(o => o.RoutingFileID == routingFileID).FirstOrDefault(); RoutingFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static UserModel GetUserByUsernamePassword(string username, string password) { ACTION = "GetUserByUsernamePassword(username, password)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_USER obj = context.USR_TMMA_USER.Where(o => o.Username == username && o.PasswordHash == password).FirstOrDefault(); UserModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static MasterPermissionModel GetMasterPermission(int permissionID) { ACTION = "GetMasterPermission(permissionID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_MASTER_PERMISSION obj = context.USR_TMMA_MASTER_PERMISSION.Where(o => o.PermissionID == permissionID).FirstOrDefault(); MasterPermissionModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static UserModel GetUserByUsername(string username) { ACTION = "GetUserByUsername(username)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_USER obj = context.USR_TMMA_USER.Where(x => string.Compare(x.Username, username, true) == 0).FirstOrDefault(); UserModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static UserModel GetUser(int userID) { ACTION = "GetUser(userID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_USER obj = context.USR_TMMA_USER.Where(o => o.UserID == userID).FirstOrDefault(); UserModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static FileStatusModel GetFileStatus(int fileStatusID) { ACTION = "GetFileStatus(fileStatusID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_FILE_STATUS obj = context.USR_TMMA_FILE_STATUS.Where(o => o.FileStatusID == fileStatusID).FirstOrDefault(); FileStatusModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static MasterRoleModel GetMasterRole(int roleID) { ACTION = "GetMasterRole(roleID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_MASTER_ROLE obj = context.USR_TMMA_MASTER_ROLE.Where(o => o.RoleID == roleID).FirstOrDefault(); MasterRoleModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static AssignMaterialToRoutingFileModel GetAssignMaterialToRoutingFile(int assignMaterialToRoutingFileID) { ACTION = "GetAssignMaterialToRoutingFile(assignMaterialToRoutingFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE obj = context.USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE.Where(o => o.AssignMaterialToRoutingFileID == assignMaterialToRoutingFileID).FirstOrDefault(); AssignMaterialToRoutingFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static ProductionVersionFileModel GetProductionVersionFile(int productionVersionFileID) { ACTION = "GetProductionVersionFile(productionVersionFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_PRODUCTION_VERSION_FILE obj = context.USR_TMMA_PRODUCTION_VERSION_FILE.Where(o => o.ProductionVersionFileID == productionVersionFileID).FirstOrDefault(); ProductionVersionFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static List <RolePermissionModel> GetRolePermissionByRoleIDList(int roleID) { ACTION = "GetRolePermissionByRoleIDList(roleID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { List <USR_TMMA_ROLE_PERMISSION> list = context.USR_TMMA_ROLE_PERMISSION.Where(o => o.RoleID == roleID).ToList(); List <RolePermissionModel> mList = Mapping(list); return(mList); } } catch (Exception ex) { throw ex; } }
public static PackagingInstructionFileModel GetPackagingInstructionFile(int packagingInstructionFileID) { ACTION = "GetPackagingInstructionFile(packagingInstructionFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_PACKAGING_INSTRUCTION_FILE obj = context.USR_TMMA_PACKAGING_INSTRUCTION_FILE.Where(o => o.PackagingInstructionFileID == packagingInstructionFileID).FirstOrDefault(); PackagingInstructionFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static RolePermissionModel GetRolePermission(int rolePermissionID) { ACTION = "GetRolePermission(rolePermissionID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_ROLE_PERMISSION obj = context.USR_TMMA_ROLE_PERMISSION.Where(o => o.RolePermissionID == rolePermissionID).FirstOrDefault(); RolePermissionModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static WorkCenterFileModel GetWorkCenterFile(int workCenterFileID) { ACTION = "GetWorkCenterFile(workCenterFileID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_WORK_CENTER_FILE obj = context.USR_TMMA_WORK_CENTER_FILE.Where(o => o.WorkCenterFileID == workCenterFileID).FirstOrDefault(); WorkCenterFileModel m = Mapping(obj); return(m); } } catch (Exception ex) { throw ex; } }
public static PackagingInstructionFileModel GetPackagingInstructionFileLastVersion(int ProductsTypeID) { ACTION = "GetPackagingInstructionFileLastVersion(ProductsTypeID)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { var list = context.USR_TMMA_PACKAGING_INSTRUCTION_FILE.Where(a => a.ProductsTypeID == ProductsTypeID).ToList(); var o = list.Last(); PackagingInstructionFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static WorkCenterFileModel GetWorkCenterFileLastVersion() { ACTION = "GetWorkCenteFileLastVersion()"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { var list = context.USR_TMMA_WORK_CENTER_FILE.ToList(); var o = list.Last(); WorkCenterFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static ProductionVersionFileModel GetProductionVersionFileLastVersion() { ACTION = "GetProductionVersionFileLastVersion()"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { var list = context.USR_TMMA_PRODUCTION_VERSION_FILE.ToList(); var o = list.Last(); ProductionVersionFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static WorkCenterRoutingFileModel GetWorkCenterRoutingFileLastVersion() { ACTION = "GetWorkCenterRoutingFileLastVersion()"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { List <USR_TMMA_WORKCENTER_ROUTING_FILE> list = context.USR_TMMA_WORKCENTER_ROUTING_FILE.ToList(); var o = list.Count > 0 ? list.Last() : null; WorkCenterRoutingFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static BOMFileModel GetBOMFileLastVersion(int ProductsTypeID) { ACTION = "GetBOMFileLastVersion()"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { var list = context.USR_TMMA_BOM_FILE.Where(a => a.ProductsTypeID == ProductsTypeID).ToList(); var o = list.Last(); BOMFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static AssignMaterialToRoutingFileModel GetAssignMaterialToRoutingFileLastVersion(int ProductsTypeID) { ACTION = "GetAssignMaterialToRoutingFileLastVersion()"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { var list = context.USR_TMMA_ASSIGN_MATERIAL_TO_ROUTING_FILE.Where(a => a.ProductsTypeID == ProductsTypeID).ToList(); var o = list.Last(); AssignMaterialToRoutingFileModel m = Mapping(o); return(m); } } catch (Exception ex) { throw ex; } }
public static ResponseModel AddBOMFile(BOMFileModel m, ref int _newID) { string action = "AddBOMFile(BOMFileModel, out _newID)"; _newID = 0; try { if (m != null) { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_BOM_FILE _obj = Mapping(m); context.USR_TMMA_BOM_FILE.Add(_obj); if (context.SaveChanges() > 0) { _newID = _obj.BOMFileID; return(new ResponseModel() { Source = SOURCE, Action = action, Status = true, Message = "Success" }); } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "Fail" }); } } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "Null" }); } catch (DbEntityValidationException ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } catch (Exception ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } }
public static ResponseModel AddUser(UserModel user) { string action = "AddUser(UserModel)"; try { if (user != null) { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { USR_TMMA_USER _obj = Mapping(user); context.USR_TMMA_USER.Add(_obj); if (context.SaveChanges() > 0) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = true, Message = "Success" }); } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "Fail" }); } } return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = "Null" }); } catch (DbEntityValidationException ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } catch (Exception ex) { return(new ResponseModel() { Source = SOURCE, Action = action, Status = false, Message = ex.Message, StackTrace = ex.StackTrace }); } }
public static List <BOMFileModel> GetBOMFileList(BOMFileFilterModel filter, ref int totalRecord, ref ResponseModel response, ref decimal lastVersion) { ACTION = "GetBOMFileList(BOMFileFilterModel)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { filter.BOMFileIDs = filter.BOMFileIDs != null ? filter.BOMFileIDs : new int[] { }; var IQuery = context.USR_TMMA_BOM_FILE .Where(o => (!string.IsNullOrEmpty(filter.Keywords) ? (o.RecObjectName.Contains(filter.Keywords)) || (o.CreatedBy.Contains(filter.Keywords)) : true) && (filter.BOMFileID.HasValue ? o.BOMFileID == filter.BOMFileID.Value : true) && (filter.BOMFileIDs.Count() > 0 ? filter.BOMFileIDs.Contains(o.BOMFileID) : true) && (!string.IsNullOrEmpty(filter.RecObjectName) ? filter.CreatedBy.Contains(o.RecObjectName) : true) && (filter.ProductsTypeID.HasValue ? o.ProductsTypeID == filter.ProductsTypeID.Value : true) && (filter.IsActive.HasValue ? o.IsActive == 1 : true) ); totalRecord = IQuery.Count(); var lists = filter.Sort == "asc" ? filter.Order == "RecObjectName" ? IQuery.OrderBy(o => o.RecObjectName) : filter.Order == "UserSAP" ? IQuery.OrderBy(o => o.UserSAP) : filter.Order == "Version" ? IQuery.OrderBy(o => o.BOMFileVersion) : filter.Order == "Status" ? IQuery.OrderBy(o => o.BOMFileStatus) : filter.Order == "ValidDate" ? IQuery.OrderBy(o => o.ValidDate) : filter.Order == "CreatedBy" ? IQuery.OrderBy(o => o.CreatedBy) : filter.Order == "CreatedDate" ? IQuery.OrderBy(o => o.CreatedDate) : IQuery.OrderBy(o => o.CreatedDate) : filter.Order == "RecObjectName" ? IQuery.OrderByDescending(o => o.RecObjectName) : filter.Order == "UserSAP" ? IQuery.OrderByDescending(o => o.UserSAP) : filter.Order == "Version" ? IQuery.OrderByDescending(o => o.BOMFileVersion) : filter.Order == "Status" ? IQuery.OrderByDescending(o => o.BOMFileStatus) : filter.Order == "ValidDate" ? IQuery.OrderByDescending(o => o.ValidDate) : filter.Order == "CreatedBy" ? IQuery.OrderByDescending(o => o.CreatedBy) : filter.Order == "CreatedDate" ? IQuery.OrderByDescending(o => o.CreatedDate) : IQuery.OrderByDescending(o => o.CreatedDate); lastVersion = IQuery.OrderByDescending(o => o.BOMFileVersion).FirstOrDefault().BOMFileVersion.GetValueOrDefault(); List <USR_TMMA_BOM_FILE> list = filter.Pagination.IsPaging ? lists.Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : lists.ToList(); List <BOMFileModel> mList = Mapping(list); response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = true, Message = "Success" }; return(mList); } } catch (Exception ex) { totalRecord = 0; response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = false, Message = ex.Message }; return(null); } }