/// <summary> /// Creates a new record if the desired record is not yet created /// and updates the desired record. /// </summary> /// <param name="rec">RecTransportPlanner</param> private void SaveElementTransport( RecTMElement rec ) { if( rec == null || rec.Factory == null || rec.Project == null ) { return; } // Now update the element with transport information ImpactUpdate update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { //{ ImpTransport.TransportStatus, record.TransportStatus }, }, Where = { ImpModelPlanning.Factory.Equal( rec.Factory ), ImpModelPlanning.Project.Equal( rec.Project ), } }; // Extra Where Clause if( rec.ElementId > 0 ) { update.Where.Add( ImpModelPlanning.ElementId.Equal( rec.ElementId ) ); } else { update.Where.Add( ImpModelPlanning.TransportId.Equal( rec.TransportId ) ); } // Extra Update fields if( rec.TransportId > 0 ) { update.Columns.Add( ImpModelPlanning.TransportId, rec.TransportId ); } if( rec.VehicleId > 0 ) { update.Columns.Add( ImpModelPlanning.VehicleId, rec.VehicleId ); } if( rec.StackId > 0 ) { update.Columns.Add( ImpModelPlanning.StackId, rec.StackId ); } if( rec.StackSequenceNo > 0 ) { update.Columns.Add( ImpModelPlanning.StackSequenceNo, rec.StackSequenceNo ); } string sql = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( sql ); } }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateProductionCastStrand( RecProductionCastStrand record ) { var update = new ImpactUpdate( ImpProductionCastStrand.Instance ) { Columns = { { ImpProductionCastStrand.StrandX, record.StrandX }, { ImpProductionCastStrand.StrandY, record.StrandY }, { ImpProductionCastStrand.StrandQuality, record.StrandQuality }, { ImpProductionCastStrand.StrandDimension, record.StrandDimension }, { ImpProductionCastStrand.StrandPrestressing, record.StrandPrestressing }, }, Where = { { ImpProductionCastStrand.Factory.Equal( record.Factory ) }, { ImpProductionCastStrand.Project.Equal( record.Factory ) },// Factory, Factory for productionCast & ProductionCastStrand { ImpProductionCastStrand.CastId.Equal( record.CastId ) }, { ImpProductionCastStrand.StrandPos.Equal( record.StrandPos ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Creates a new record if the desired record is not yet created /// and updates the desired record. /// </summary> /// <param name="rec">RecTransportPlanner</param> public void ResetTransport( string factory, string project, int elementId, int transportId, int vehicleId, int stackId ) { if( factory == null || project == null ) { return; } if( elementId == 0 && transportId == 0 && vehicleId == 0 && stackId == 0 ) { return; } var where = WhereGroup.And( ImpModelPlanning.Factory.Equal( factory ) ); where.Add( ImpModelPlanning.Project.Equal( project ) ); if( elementId > 0 ) { where.Add( ImpModelPlanning.ElementId.Equal( elementId ) ); } if( transportId > 0 ) { where.Add( ImpModelPlanning.TransportId.Equal( transportId ) ); } if( vehicleId > 0 ) { where.Add( ImpModelPlanning.VehicleId.Equal( vehicleId ) ); } if( stackId > 0 ) { where.Add( ImpModelPlanning.StackId.Equal( stackId ) ); } using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.TransportId, 0 }, { ImpModelPlanning.VehicleId, 0 }, { ImpModelPlanning.StackId, 0 }, { ImpModelPlanning.RackSide, 0 }, { ImpModelPlanning.StackSequenceNo, 0 }, { ImpModelPlanning.StackX, 0 }, { ImpModelPlanning.StackY, 0 }, { ImpModelPlanning.StackZ, 0 }, { ImpModelPlanning.StackRotation, 0 }, { ImpModelPlanning.DeliveryDate, null }, }, Where = { where } }; string sql = update.ToString(); database.ExecuteNonQuery( sql ); } }
/// <summary> /// Resets the cast info /// </summary> /// <param name="factory"></param> /// <param name="project"></param> /// <param name="castId"></param> /// <param name="elementId"></param> /// <param name="verifyExist"></param> /// <returns></returns> public int ResetElementProduction( string factory, string project, int castId, int elementId, bool verifyExist ) { if( string.IsNullOrWhiteSpace( factory ) || string.IsNullOrWhiteSpace( project ) || ( castId == 0 && elementId == 0 ) ) { return -1; } // Create a new record if it doesnt exist if( verifyExist && elementId > 0 ) { Verify( factory, project, elementId ); } var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.CastId, 0 }, { ImpModelPlanning.BedSequenceNo, 0 }, { ImpModelPlanning.BedX, 0 }, { ImpModelPlanning.BedY, 0 }, { ImpModelPlanning.BedZ, 0 }, { ImpModelPlanning.BedRotation, 0 }, }, Where = { { ImpModelPlanning.Factory.Equal( factory ) }, { ImpModelPlanning.Project.Equal( project ) }, }, }; if( castId > 0 ) { update.Where.Add( ImpModelPlanning.CastId.Equal( castId ) ); } if( elementId > 0 ) { update.Where.Add( ImpModelPlanning.ElementId.Equal( elementId ) ); } string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateWallStyleStd( RecWallStyleStd record ) { var update = new ImpactUpdate( ImpWallStyleStd.Instance ) { Columns = { { ImpWallStyleStd.Description, record.Description }, { ImpWallStyleStd.CastType, record.CastType }, { ImpWallStyleStd.RcLayout, record.RcLayout }, { ImpWallStyleStd.RcTemplate, record.RcTemplate }, { ImpWallStyleStd.ProductionLine, record.ProductionLine }, { ImpWallStyleStd.LiftType, record.LiftType }, { ImpWallStyleStd.LiftDistanceMax, record.LiftDistanceMax }, { ImpWallStyleStd.LiftDistanceMin, record.LiftDistanceMin }, { ImpWallStyleStd.LiftSpacing, record.LiftSpacing }, { ImpWallStyleStd.BracingCim, record.BracingCim }, { ImpWallStyleStd.BracingSide, record.BracingSide }, { ImpWallStyleStd.BracingPlacingLs, record.BracingPlacingLs }, { ImpWallStyleStd.BracingPlacingParameterLs, record.BracingPlacingParameterLs }, { ImpWallStyleStd.BracingPlacingEl, record.BracingPlacingEl }, { ImpWallStyleStd.BracingPlacingParameterEl, record.BracingPlacingParameterEl }, { ImpWallStyleStd.ElementGrp, record.ElementGrp }, { ImpWallStyleStd.ProductPrefix, record.ProductPrefix }, { ImpWallStyleStd.Product, record.Product }, { ImpWallStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpWallStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpWallStyleStd.DrawingType, record.DrawingType }, { ImpWallStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpWallStyleStd.CreatedBy, record.CreatedBy }, { ImpWallStyleStd.CreatedDate, record.CreatedDate }, { ImpWallStyleStd.ChangedBy, record.ChangedBy }, { ImpWallStyleStd.ChangedDate, record.ChangedDate }, { ImpWallStyleStd.LiftOtherType, record.LiftOtherType }, }, Where = { { ImpWallStyleStd.Factory.Equal( record.Factory ) }, { ImpWallStyleStd.Project.Equal( record.Project ) }, { ImpWallStyleStd.ElementType.Equal( record.ElementType ) }, { ImpWallStyleStd.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Update of Transport items /// </summary> /// <param name="transport"></param> /// <returns></returns> public int UpdateTransport( RecTransport record ) { if( record == null ) { throw new ArgumentNullException( "Transport" ); } string project = ""; if( record.IsTemplate == 1 ) { // Templates are saved on factory level (factory, factory), 2012-04-23 project = record.Factory; } else { project = record.Project; } using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpTransport.Instance ) { Columns = { { ImpTransport.Description, record.Description }, { ImpTransport.LoadDate, record.LoadDate }, { ImpTransport.DeliveryDate, record.DeliveryDate }, { ImpTransport.TimeInterval, record.TimeInterval }, { ImpTransport.IsTemplate, record.IsTemplate }, { ImpTransport.TemplateId, record.TemplateId }, { ImpTransport.IsVisible, record.IsVisible }, }, Where = { ImpTransport.Factory.Equal( record.Factory ), ImpTransport.Project.Equal( project ),// Templates are saved on factory level (factory, factory), 2012-04-23 ImpTransport.TransportId.Equal( record.TransportId ), } }; string sql = update.ToString(); database.ExecuteNonQuery( sql ); } return 0; }
/// <summary> /// The update erection sequence. /// </summary> /// <param name="factory"> /// The factory. /// </param> /// <param name="project"> /// The project. /// </param> /// <param name="erectionSequenceList"> /// The erection sequence list. /// </param> /// <returns> /// The System.Boolean. /// </returns> public bool UpdateErectionSequence( string factory, string project, List<KeyValuePair<int, int>> erectionSequenceList ) { project = project.PadLeft( 12 ); List<string> statementList = new List<string>( erectionSequenceList.Count ); using( var database = new ImpactDatabase() ) { var allIdArray = erectionSequenceList.Select( x => (object)x.Key ).ToArray(); ImpactQuery query = new ImpactQuery { Select = { ImpModelPlanning.ElementId }, From = { ImpModelPlanning.As( "T1" ) }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.In( allIdArray ), }, }; string statement = query.ToString(); var existingPlanningList = database.GetAll( statement, column => column[0].Cast<int>() ); var groupedByInsertUpdate = erectionSequenceList.GroupBy( x => existingPlanningList.Remove( x.Key ) ).ToList(); var updateList = groupedByInsertUpdate.Find( x => x.Key ); var insertList = groupedByInsertUpdate.Find( x => !x.Key ); if( null != updateList ) { foreach( var item in updateList ) { var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.ErectionSequenceNo, item.Value } }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( item.Key ), } }; statementList.Add( update.ToString() ); } } if( null != insertList ) { foreach( var item in insertList ) { var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, item.Key }, { ImpModelPlanning.ErectionSequenceNo, item.Value }, }, }; statementList.Add( insert.ToString() ); } } int result = database.ExecuteNonQuery( statementList.ToArray() ); return result > 0; } }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateProductionFormStrandStd( RecProductionFormStrandStd record ) { // Update IMP_PRODUCTION_FORM_STRAND check the flag IsUsed // Update IMP_PRODUCTION_FORM_STRAND_STD UpdateProductionFormStrand( record ); var update = new ImpactUpdate( ImpProductionFormStrandStd.Instance ) { Columns = { { ImpProductionFormStrandStd.StrandX, record.StrandX }, { ImpProductionFormStrandStd.StrandY, record.StrandY }, { ImpProductionFormStrandStd.StrandQuality, record.StrandQuality }, { ImpProductionFormStrandStd.StrandDimension, record.StrandDimension }, { ImpProductionFormStrandStd.StrandPrestressing, record.StrandPrestressing }, }, Where = { ImpProductionFormStrandStd.Factory.Equal( record.Factory ), ImpProductionFormStrandStd.Project.Equal( record.Factory ), // Factory, Factory Level ImpProductionFormStrandStd.Name.Equal( record.Name ), ImpProductionFormStrandStd.StrandPos.Equal( record.StrandPos ), }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Saves element production data /// </summary> /// <param name="rec"></param> /// <param name="verifyExist"></param> /// <returns></returns> public int SaveElementProduction( RecTMElement rec, bool verifyExist ) { if( rec == null || string.IsNullOrWhiteSpace( rec.Factory ) || string.IsNullOrWhiteSpace( rec.Project ) || rec.ElementId == 0 ) { return -1; } // Create a new record if it doesnt exist if( verifyExist ) { Verify( rec.Factory, rec.Project, rec.ElementId ); } var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.CastId, rec.CastId }, { ImpModelPlanning.BedSequenceNo, rec.BedSequenceNo }, { ImpModelPlanning.BedX, rec.BedX }, { ImpModelPlanning.BedY, rec.BedY }, { ImpModelPlanning.BedZ, rec.BedZ }, { ImpModelPlanning.BedRotation, rec.BedRotation }, }, Where = { { ImpModelPlanning.Factory.Equal( rec.Factory ) }, { ImpModelPlanning.Project.Equal( rec.Project ) }, { ImpModelPlanning.ElementId.Equal( rec.ElementId ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateCalendar(RecCalendar record) { var update = new ImpactUpdate(ImpCalendar.Instance) { Columns = { { ImpCalendar.Description, record.Description }, { ImpCalendar.ChangedBy, record.ChangedBy }, { ImpCalendar.ChangedDate, record.ChangedDate }, }, Where = { { ImpCalendar.Factory.Equal( record.Factory ) }, { ImpCalendar.Project.Equal( record.Factory ) },// Factory level! { ImpCalendar.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using (ImpactDatabase database = new ImpactDatabase()) { result = database.ExecuteNonQuery(statement); } return result; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateTransportStack( RecTransportStack record ) { var update = new ImpactUpdate( ImpTransportStack.Instance ) { Columns = { { ImpTransportStack.Rack, record.Rack }, { ImpTransportStack.StackX, record.StackX }, { ImpTransportStack.StackY, record.StackY }, { ImpTransportStack.StackZ, record.StackZ }, { ImpTransportStack.StackRotation, record.StackRotation }, { ImpTransportStack.Description, record.Description }, { ImpTransportStack.StackType, record.StackType }, { ImpTransportStack.StackPosition, record.StackPosition }, { ImpTransportStack.MaxLength, record.MaxLength }, { ImpTransportStack.MaxWidth, record.MaxWidth }, { ImpTransportStack.MaxHeight, record.MaxHeight }, { ImpTransportStack.MaxMass, record.MaxMass }, }, Where = { { ImpTransportStack.Factory.Equal( record.Factory ) }, { ImpTransportStack.Project.Equal( record.Project ) }, { ImpTransportStack.TransportId.Equal( record.TransportId ) }, { ImpTransportStack.VehicleId.Equal( record.VehicleId ) }, { ImpTransportStack.StackId.Equal( record.StackId ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateSlabStyleStd( RecSlabStyleStd record ) { var update = new ImpactUpdate( ImpSlabStyleStd.Instance ) { Columns = { { ImpSlabStyleStd.Description, record.Description }, { ImpSlabStyleStd.Width, record.Width }, { ImpSlabStyleStd.Tolerance, record.Tolerance }, { ImpSlabStyleStd.ElementThickness, record.ElementThickness }, { ImpSlabStyleStd.Thickness, record.Thickness }, { ImpSlabStyleStd.Material, record.Material }, { ImpSlabStyleStd.EndStopCim, record.EndStopCim }, { ImpSlabStyleStd.DirectionArrowCim, record.DirectionArrowCim }, { ImpSlabStyleStd.DirectionArrowJustify, record.DirectionArrowJustify }, { ImpSlabStyleStd.ProductionLine, record.ProductionLine }, { ImpSlabStyleStd.RcPrimary, record.RcPrimary }, { ImpSlabStyleStd.RcSecondary, record.RcSecondary }, { ImpSlabStyleStd.RcBentEnds, record.RcBentEnds }, { ImpSlabStyleStd.CoverBottom, record.CoverBottom }, { ImpSlabStyleStd.PlacementLower, record.PlacementLower }, { ImpSlabStyleStd.RcMeshAddPrimary, record.RcMeshAddPrimary }, { ImpSlabStyleStd.RcMeshAddSecondary, record.RcMeshAddSecondary }, { ImpSlabStyleStd.PrimaryRcDistribution, record.PrimaryRcDistribution }, { ImpSlabStyleStd.PrimaryRcDimension, record.PrimaryRcDimension }, { ImpSlabStyleStd.PrimaryRcQuality, record.PrimaryRcQuality }, { ImpSlabStyleStd.PrimaryRcSpacing, record.PrimaryRcSpacing }, { ImpSlabStyleStd.PrimaryRcEdgeDistance, record.PrimaryRcEdgeDistance }, { ImpSlabStyleStd.PrimaryRcCoverCut, record.PrimaryRcCoverCut }, { ImpSlabStyleStd.PrimaryLength1Left, record.PrimaryLength1Left }, { ImpSlabStyleStd.PrimaryLength2Left, record.PrimaryLength2Left }, { ImpSlabStyleStd.PrimaryLength1Right, record.PrimaryLength1Right }, { ImpSlabStyleStd.PrimaryLength2Right, record.PrimaryLength2Right }, { ImpSlabStyleStd.PrimaryAngle1Left, record.PrimaryAngle1Left }, { ImpSlabStyleStd.PrimaryAngle2Left, record.PrimaryAngle2Left }, { ImpSlabStyleStd.PrimaryAngle1Right, record.PrimaryAngle1Right }, { ImpSlabStyleStd.PrimaryAngle2Right, record.PrimaryAngle2Right }, { ImpSlabStyleStd.SecondaryRcDistribution, record.SecondaryRcDistribution }, { ImpSlabStyleStd.SecondaryRcDimension, record.SecondaryRcDimension }, { ImpSlabStyleStd.SecondaryRcQuality, record.SecondaryRcQuality }, { ImpSlabStyleStd.SecondaryRcSpacing, record.SecondaryRcSpacing }, { ImpSlabStyleStd.SecondaryRcEdgeDistance, record.SecondaryRcEdgeDistance }, { ImpSlabStyleStd.SecondaryRcCoverCut, record.SecondaryRcCoverCut }, { ImpSlabStyleStd.LatticeGirderCim, record.LatticeGirderCim }, { ImpSlabStyleStd.LatticeGirderEdgeDistance, record.LatticeGirderEdgeDistance }, { ImpSlabStyleStd.LatticeGirderNumberOf, record.LatticeGirderNumberOf }, { ImpSlabStyleStd.LatticeGirderCover, record.LatticeGirderCover }, { ImpSlabStyleStd.LatticeGirderEdgeMax, record.LatticeGirderEdgeMax }, { ImpSlabStyleStd.LatticeGirderEdgeMin, record.LatticeGirderEdgeMin }, { ImpSlabStyleStd.LatticeGirderAddPrimary, record.LatticeGirderAddPrimary }, { ImpSlabStyleStd.StrandDistribution, record.StrandDistribution }, { ImpSlabStyleStd.StrandDimension, record.StrandDimension }, { ImpSlabStyleStd.StrandQuality, record.StrandQuality }, { ImpSlabStyleStd.StrandSpacing, record.StrandSpacing }, { ImpSlabStyleStd.StrandEdgeDistance, record.StrandEdgeDistance }, { ImpSlabStyleStd.StrandPrestressing, record.StrandPrestressing }, { ImpSlabStyleStd.StrandZ, record.StrandZ }, { ImpSlabStyleStd.LiftRotation, record.LiftRotation }, { ImpSlabStyleStd.LiftCim, record.LiftCim }, { ImpSlabStyleStd.LiftPlacingSs, record.LiftPlacingSs }, { ImpSlabStyleStd.LiftPlacingParameterSs, record.LiftPlacingParameterSs }, { ImpSlabStyleStd.LiftPlacingLs, record.LiftPlacingLs }, { ImpSlabStyleStd.LiftPlacingParameterLs, record.LiftPlacingParameterLs }, { ImpSlabStyleStd.LiftLargeElements, record.LiftLargeElements }, { ImpSlabStyleStd.LiftMassLimit, record.LiftMassLimit }, { ImpSlabStyleStd.LiftWidthLimit, record.LiftWidthLimit }, { ImpSlabStyleStd.LiftLengthLimit, record.LiftLengthLimit }, { ImpSlabStyleStd.LiftSpacing, record.LiftSpacing }, { ImpSlabStyleStd.LiftType, record.LiftType }, { ImpSlabStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpSlabStyleStd.ElementGrp, record.ElementGrp }, { ImpSlabStyleStd.ProductPrefix, record.ProductPrefix }, { ImpSlabStyleStd.Product, record.Product }, { ImpSlabStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpSlabStyleStd.DrawingType, record.DrawingType }, { ImpSlabStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpSlabStyleStd.EdgeStandardBetweenElements, record.EdgeStandardBetweenElements }, { ImpSlabStyleStd.EdgeStandardOther, record.EdgeStandardOther }, { ImpSlabStyleStd.CreatedBy, record.CreatedBy }, { ImpSlabStyleStd.CreatedDate, record.CreatedDate }, { ImpSlabStyleStd.ChangedBy, record.ChangedBy }, { ImpSlabStyleStd.ChangedDate, record.ChangedDate }, }, Where = { { ImpSlabStyleStd.Factory.Equal( record.Factory ) }, { ImpSlabStyleStd.Project.Equal( record.Project ) }, { ImpSlabStyleStd.ElementType.Equal( record.ElementType ) }, { ImpSlabStyleStd.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
}//end generate /// <summary> /// Returns the next sequence from the number generator object /// </summary> /// <param name="rec"></param> /// <param name="next"></param> private void SetNextNumber( RecNumberGenerator rec, int next ) { using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpNumGen.Instance ) { Columns = { { ImpNumGen.NextNumber, next }, { ImpNumGen.ChangedDate, DateTime.Now } }, Where = { ImpNumGen.Factory.Equal( rec.Factory ), ImpNumGen.Project.Equal( rec.Project ), ImpNumGen.Variable.Equal( rec.Variable ), } }; string statement = update.ToString(); database.ExecuteNonQuery( statement ); } }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public CastResult UpdateProductionCast( RecProductionCast record ) { bool hasScheduleCollision = false; BedFilter filter = new BedFilter(); filter.Factory = record.Factory; filter.Project = record.Project; filter.Shift = record.Shift; List<RecProductionCast> casts = this.LoadProductionCast( filter, record ); if( null != casts && casts.Count > 0 ) { List<RecProductionCast> otherCasts = (from o in casts where o.CastId != record.CastId select o).ToList(); if( null != otherCasts && otherCasts.Count > 0 ) { hasScheduleCollision = true; } } var update = new ImpactUpdate( ImpProductionCast.Instance ) { Columns = { { ImpProductionCast.CastType, record.CastType }, { ImpProductionCast.Description, record.Description }, { ImpProductionCast.Form, record.Form }, { ImpProductionCast.Tolerance, record.Tolerance }, { ImpProductionCast.ElementType, record.ElementType }, { ImpProductionCast.Style, record.Style }, { ImpProductionCast.Strandptn, record.Strandptn }, { ImpProductionCast.CastStatus, record.CastStatus }, { ImpProductionCast.CastDivision, record.CastDivision }, }, Where = { { ImpProductionCast.Factory.Equal( record.Factory ) }, { ImpProductionCast.Project.Equal( record.Factory ) },// Factory, Factory for productionCast & ProductionCastStrand { ImpProductionCast.CastId.Equal( record.CastId ) }, }, }; if( !hasScheduleCollision ) { update.Columns.Add( ImpProductionCast.Shift, record.Shift ); update.Columns.Add( ImpProductionCast.StartDate, record.StartDate ); update.Columns.Add( ImpProductionCast.EndDate, record.EndDate ); } string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return new CastResult { HasScheduleCollision = hasScheduleCollision, EffectedRows = result }; }
/// <summary> /// Update the cast and elements with new status /// </summary> /// <param name="transports"></param> /// <param name="recTransportStatus"></param> /// <returns></returns> private int UpdateStatus( RecProductionCast cast, RecProductionCast recProductionCastStatus, List<RecElementIdStatusStd> settings ) { if( null == cast || null == recProductionCastStatus ) { return 0; } ModelPlanner plannerService = new ModelPlanner(); plannerService.SaveElementProductionStatus( cast, recProductionCastStatus, settings ); int ret = 0; using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpProductionCast.Instance ) { Columns = { { ImpProductionCast.CastStatus, recProductionCastStatus.CastStatus }, }, Where = { ImpProductionCast.Factory.Equal( cast.Factory ), ImpProductionCast.Project.Equal( cast.Factory ), //Factory, Factory ImpProductionCast.CastId.Equal( cast.CastId ), } }; string sql = update.ToString(); ret = database.ExecuteNonQuery( sql ); } return ret; }
/// <summary> /// The update current project. /// </summary> /// <param name="currentProject"> /// The current project. /// </param> public static void UpdateCurrentProject( CurrentProject currentProject ) { if( null == currentProject ) return; using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpUser.Instance ) { Columns = { { ImpUser.CurrentFactory, currentProject.Factory }, { ImpUser.CurrentProject, currentProject.Project.PadLeft( 12 ) }, }, Where = { ImpUser.Userid.Equal( currentProject.User ) } }; string statement = update.ToString(); database.ExecuteNonQuery( statement ); } }
/// <summary> /// Update of Transport Vehicle Standard items /// </summary> /// <param name="vehicle"></param> /// <returns></returns> public int UpdateTransportVehicleStd( RecTransportVehicleStd record ) { if( record == null ) { throw new ArgumentNullException( "TransportVehicleStd" ); } var update = new ImpactUpdate( ImpTransportVehicleStd.Instance ) { Columns = { { ImpTransportVehicleStd.Description, record.Description }, { ImpTransportVehicleStd.VehicleType, record.VehicleType }, { ImpTransportVehicleStd.TransportType, record.TransportType }, { ImpTransportVehicleStd.Length, record.Length }, { ImpTransportVehicleStd.Width, record.Width }, { ImpTransportVehicleStd.Height, record.Height }, { ImpTransportVehicleStd.Mass, record.Mass }, { ImpTransportVehicleStd.MaxLength, record.MaxLength }, { ImpTransportVehicleStd.MaxWidth, record.MaxWidth }, { ImpTransportVehicleStd.MaxHeight, record.MaxHeight }, { ImpTransportVehicleStd.MaxMass, record.MaxMass }, { ImpTransportVehicleStd.Division, record.Division }, { ImpTransportVehicleStd.ChangedBy, record.Changed_By }, { ImpTransportVehicleStd.ChangedDate, record.Changed_Date }, }, Where = { { ImpTransportVehicleStd.Factory.Equal( record.Factory ) }, { ImpTransportVehicleStd.Project.Equal( record.Factory ) },//for Std use Factory, Factory { ImpTransportVehicleStd.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Creates a new record if the desired record is not yet created /// and updates the desired record. /// </summary> /// <param name="rec">RecTransportPlanner</param> public int SaveElementTransportStatus( RecTransport rec, List<RecElementIdStatusStd> settings ) { if( rec == null || rec.Factory == null || rec.Project == null || rec.TransportId == 0 ) { return 0; } bool isValidElementIdStatus = rec.ElementIdStatus != -1; bool noStatus = rec.TransportStatus == (int)TransportStatus.NoStatus; int result = 0; if( noStatus ) { result = SaveElementTransportNoStatus( rec, settings ); } // Now update the element with transport information ImpactUpdate update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { //{ ImpTransport.TransportStatus, record.TransportStatus }, }, Where = { ImpModelPlanning.Factory.Equal( rec.Factory ), ImpModelPlanning.Project.Equal( rec.Project ), ImpModelPlanning.TransportId.Equal( rec.TransportId ), } }; if( noStatus ) { if( rec.ClearDeliveryDate ) { update.Columns.Add( ImpModelPlanning.DeliveryDate, null ); } if( rec.ClearPlannedDeliveryDate ) { update.Columns.Add( ImpModelPlanning.PlannedDeliveryDate, null ); } } else if( rec.TransportStatus == (int)TransportStatus.Planned ) { if( rec.UpdateElementStatus && isValidElementIdStatus ) { update.Columns.Add( ImpModelPlanning.ElementIdStatus, rec.ElementIdStatus ); } if( rec.UpdateDeliveryDate && rec.DeliveryDate != null ) { //update.Columns.Add( ImpModelPlanning.DeliveryDate, rec.DeliveryDate ); update.Columns.Add( ImpModelPlanning.PlannedDeliveryDate, rec.DeliveryDate ); } } else if( rec.TransportStatus == (int)TransportStatus.CallOff ) { if( rec.UpdateElementStatus && isValidElementIdStatus ) { update.Columns.Add( ImpModelPlanning.ElementIdStatus, rec.ElementIdStatus ); } } else if( rec.TransportStatus == (int)TransportStatus.Delivered ) { if( rec.UpdateElementStatus && isValidElementIdStatus ) { update.Columns.Add( ImpModelPlanning.ElementIdStatus, rec.ElementIdStatus ); } if( rec.UpdateDeliveryDate && rec.DeliveryDate != null ) { update.Columns.Add( ImpModelPlanning.DeliveryDate, rec.DeliveryDate ); } } if( update.Columns.Count == 0 ) { return 0; // Nothing to update } string sql = update.ToString(); using( ImpactDatabase database = new ImpactDatabase() ) { result += database.ExecuteNonQuery( sql ); } return result; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateSectionStyleStd( RecSectionStyleStd record ) { var update = new ImpactUpdate( ImpSectionStyleStd.Instance ) { Columns = { { ImpSectionStyleStd.SectionType, record.SectionType }, { ImpSectionStyleStd.Description, record.Description }, { ImpSectionStyleStd.Width, record.Width }, { ImpSectionStyleStd.WidthTolerance, record.WidthTolerance }, { ImpSectionStyleStd.DiffBottomTop, record.DiffBottomTop }, { ImpSectionStyleStd.Height, record.Height }, { ImpSectionStyleStd.Endcap, record.Endcap }, { ImpSectionStyleStd.Strandptn, record.Strandptn }, { ImpSectionStyleStd.RcTemplate, record.RcTemplate }, { ImpSectionStyleStd.Material, record.Material }, { ImpSectionStyleStd.ProductionLine, record.ProductionLine }, { ImpSectionStyleStd.CutType, record.CutType }, { ImpSectionStyleStd.UseCutZone, record.UseCutZone }, { ImpSectionStyleStd.LiftMethod, record.LiftMethod }, { ImpSectionStyleStd.LiftRotation1, record.LiftRotation1 }, { ImpSectionStyleStd.LiftRotation2, record.LiftRotation2 }, { ImpSectionStyleStd.LiftPlacingLs, record.LiftPlacingLs }, { ImpSectionStyleStd.LiftParameterLs, record.LiftParameterLs }, { ImpSectionStyleStd.LiftPlacingSs, record.LiftPlacingSs }, { ImpSectionStyleStd.LiftParameterSs, record.LiftParameterSs }, { ImpSectionStyleStd.LiftCores, record.LiftCores }, { ImpSectionStyleStd.LiftCoreLength, record.LiftCoreLength }, { ImpSectionStyleStd.LiftCoreDisplayMode, record.LiftCoreDisplayMode }, { ImpSectionStyleStd.LiftDistanceMax, record.LiftDistanceMax }, { ImpSectionStyleStd.LiftDistanceMin, record.LiftDistanceMin }, { ImpSectionStyleStd.LiftSpacing, record.LiftSpacing }, { ImpSectionStyleStd.LiftType, record.LiftType }, { ImpSectionStyleStd.SectionViewDimStrandGrp, record.SectionViewDimStrandGrp }, { ImpSectionStyleStd.SectionViewTxtStrandGrp, record.SectionViewTxtStrandGrp }, { ImpSectionStyleStd.SectionViewNbrCores, record.SectionViewNbrCores }, { ImpSectionStyleStd.SectionViewScale, record.SectionViewScale }, { ImpSectionStyleStd.UseSectionViewSymbol, record.UseSectionViewSymbol }, { ImpSectionStyleStd.SectionViewFilename, record.SectionViewFilename }, { ImpSectionStyleStd.ChamferDistance, record.ChamferDistance }, { ImpSectionStyleStd.ChamferText, record.ChamferText }, { ImpSectionStyleStd.ChamferVisibility, record.ChamferVisibility }, { ImpSectionStyleStd.RcCoverCut1, record.RcCoverCut1 }, { ImpSectionStyleStd.RcCoverCut2, record.RcCoverCut2 }, { ImpSectionStyleStd.ElementGrp, record.ElementGrp }, { ImpSectionStyleStd.ProductPrefix, record.ProductPrefix }, { ImpSectionStyleStd.Product, record.Product }, { ImpSectionStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpSectionStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpSectionStyleStd.DrawingType, record.DrawingType }, { ImpSectionStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpSectionStyleStd.CreatedBy, record.CreatedBy }, { ImpSectionStyleStd.CreatedDate, record.CreatedDate }, { ImpSectionStyleStd.ChangedBy, record.ChangedBy }, { ImpSectionStyleStd.ChangedDate, record.ChangedDate }, { ImpSectionStyleStd.LiftHolePosition, record.LiftHolePosition }, }, Where = { { ImpSectionStyleStd.Factory.Equal( record.Factory ) }, { ImpSectionStyleStd.Project.Equal( record.Project ) }, { ImpSectionStyleStd.ElementType.Equal( record.ElementType ) }, { ImpSectionStyleStd.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Update Element IdStatus /// </summary> /// <param name="factory"></param> /// <param name="project"></param> /// <param name="elementId"></param> /// <param name="status"></param> /// <returns></returns> private int UpdateElementStatus( string factory, string project, int elementId, int idStatus ) { int result = 0; var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.ElementIdStatus, idStatus }, }, Where = { { ImpModelPlanning.Factory.Equal( factory ) }, { ImpModelPlanning.Project.Equal( project ) }, { ImpModelPlanning.ElementId.Equal( elementId ) }, }, }; string statement = update.ToString(); using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// The update planning element data. /// </summary> /// <param name="factory"> /// The factory. /// </param> /// <param name="project"> /// The project. /// </param> /// <param name="planningElementList"> /// The planning element list. /// </param> /// <exception cref="InvalidOperationException"> /// Thrown when the database source is unknown. /// </exception> public void UpdatePlanningElementData( string factory, string project, List<PlanningElementDataUpdate> planningElementList ) { project = Util.CorrectProjectName( project ); switch( ImpactDatabase.DataSource ) { case DataSource.Ingres92: case DataSource.Ingres100: { // Create a query that return all the id's of those elements that aldready has planning data. ImpactQuery query = new ImpactQuery() { From = { ImpModelPlanning.As( "T1" ) }, Select = { ImpModelPlanning.ElementId }, Where = { ImpModelPlanning.Factory.Equal(factory), ImpModelPlanning.Project.Equal(project), ImpModelPlanning.ElementId.In<int>( planningElementList.Select( element => element.ElementId ) ) } }; using( var database = new ImpactDatabase() ) { var existingIds = database.GetAll( query.ToString(), reader => reader[0].Cast<int>() ); var statementList = new List<string>( planningElementList.Count ); foreach( var element in planningElementList ) { string producingFactory; if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) ) { producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue; } else { producingFactory = element.ProducingFactory; } if( existingIds.Contains( element.ElementId ) ) { // We have an update. var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( element.ElementId ), }, Columns = { { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( update.ToString() ); } else { // We must insert a new row. var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, element.ElementId }, { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( insert.ToString() ); } } database.ExecuteNonQuery( statementList.ToArray() ); } break; } case DataSource.SqlServer: case DataSource.SqlServerExpress: { List<string> statementList = new List<string>( planningElementList.Count ); foreach( var element in planningElementList ) { string producingFactory; if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) ) { producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue; } else { producingFactory = element.ProducingFactory; } ImpactInsertOrUpdate insertOrUpdate = new ImpactInsertOrUpdate( ImpModelPlanning.Instance ) { Keys = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, element.ElementId }, }, Columns = { { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( insertOrUpdate.ToString() ); } using( var database = new ImpactDatabase() ) { database.ExecuteNonQuery( statementList.ToArray() ); } break; } default: { throw new InvalidOperationException( "Unknown database source." ); } } }
/// <summary> /// Sets the cast status /// </summary> /// <param name="rec"></param> /// <returns></returns> public int SaveElementProductionStatus( RecProductionCast rec, RecProductionCast productionCastStatus, List<RecElementIdStatusStd> settings ) { if( null == rec || string.IsNullOrWhiteSpace( rec.Factory ) || string.IsNullOrWhiteSpace( rec.Project ) || 0 == rec.CastId ) { return 0; } bool isValidElementIdStatus = productionCastStatus.ElementIdStatus != -1; bool noStatus = productionCastStatus.CastStatus == (int)CastStatus.NoStatus; int result = 0; if( noStatus ) { SaveElementProductionNoStatus( rec, settings ); } var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { //{ ImpModelPlanning.ElementIdStatus, rec.ElementIdStatus }, }, Where = { { ImpModelPlanning.Factory.Equal( rec.Factory ) }, //{ ImpModelPlanning.Project.Equal( rec.Project ) }, { ImpModelPlanning.CastId.Equal( rec.CastId ) }, }, }; if( noStatus ) { if( productionCastStatus.ClearProductionDate ) { update.Columns.Add( ImpModelPlanning.ProductionDate, null ); } if( productionCastStatus.ClearPlannedProductionDate ) { update.Columns.Add( ImpModelPlanning.PlannedProductionDate, null ); } } else if( productionCastStatus.CastStatus == (int)CastStatus.Planned ) { if( productionCastStatus.UpdateElementStatus && isValidElementIdStatus ) { update.Columns.Add( ImpModelPlanning.ElementIdStatus, productionCastStatus.ElementIdStatus ); } if( productionCastStatus.UpdateProductionDate && productionCastStatus.StartDate != null ) { update.Columns.Add( ImpModelPlanning.PlannedProductionDate, productionCastStatus.StartDate ); } } else if( productionCastStatus.CastStatus == (int)CastStatus.Produced ) { if( productionCastStatus.UpdateElementStatus && isValidElementIdStatus ) { update.Columns.Add( ImpModelPlanning.ElementIdStatus, productionCastStatus.ElementIdStatus ); } if( productionCastStatus.UpdateProductionDate && productionCastStatus.StartDate != null ) { update.Columns.Add( ImpModelPlanning.ProductionDate, productionCastStatus.StartDate ); } } if( update.Columns.Count == 0 ) { return 0; // Nothing to update } string sql = update.ToString(); using( ImpactDatabase database = new ImpactDatabase() ) { result += database.ExecuteNonQuery( sql ); } return result; }
/// <summary> /// Update the transport and elements with new status /// </summary> /// <param name="transports"></param> /// <param name="recTransportStatus"></param> /// <returns></returns> public int UpdateStatus( RecTransport record, RecTransport recTransportStatus, List<RecElementIdStatusStd> settings ) { if( null == record || null == recTransportStatus ) { return 0; } ModelPlanner plannerService = new ModelPlanner(); recTransportStatus.Factory = record.Factory; recTransportStatus.Project = record.Project; recTransportStatus.TransportId = record.TransportId; plannerService.SaveElementTransportStatus( recTransportStatus, settings ); int ret = 0; using( ImpactDatabase database = new ImpactDatabase() ) { ImpactUpdate update = new ImpactUpdate( ImpTransport.Instance ) { Columns = { { ImpTransport.TransportStatus, recTransportStatus.TransportStatus }, }, Where = { ImpTransport.Factory.Equal( record.Factory ), ImpTransport.Project.Equal( record.Project ), ImpTransport.TransportId.Equal( record.TransportId ), } }; bool b1 = recTransportStatus.TransportStatus == (int)TransportStatus.Planned && recTransportStatus.UpdateDeliveryDate && null != recTransportStatus.DeliveryDate; bool b2 = recTransportStatus.TransportStatus == (int)TransportStatus.Delivered && recTransportStatus.UpdateDeliveryDate && null != recTransportStatus.DeliveryDate; if( b1 || b2 ) { update.Columns.Add( ImpTransport.DeliveryDate, recTransportStatus.DeliveryDate ); } string sql = update.ToString(); ret = database.ExecuteNonQuery( sql ); } return ret; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateProductionFormStd( RecProductionFormStd record ) { var update = new ImpactUpdate( ImpProductionFormStd.Instance ) { Columns = { { ImpProductionFormStd.FormType, record.FormType }, { ImpProductionFormStd.Description, record.Description }, { ImpProductionFormStd.Location, record.Location }, { ImpProductionFormStd.NbrOfShift, record.NbrOfShift }, { ImpProductionFormStd.Length, record.Length }, { ImpProductionFormStd.Width, record.Width }, { ImpProductionFormStd.Height, record.Height }, { ImpProductionFormStd.Tolerance, record.Tolerance }, { ImpProductionFormStd.MaxMass, record.MaxMass }, { ImpProductionFormStd.ElementType, record.ElementType }, { ImpProductionFormStd.Style, record.Style }, { ImpProductionFormStd.StrandType, record.StrandType }, { ImpProductionFormStd.Strandptn, record.Strandptn }, { ImpProductionFormStd.Division, record.Division }, { ImpProductionFormStd.CreatedBy, record.CreatedBy }, { ImpProductionFormStd.CreatedDate, record.CreatedDate }, { ImpProductionFormStd.ChangedBy, record.ChangedBy }, { ImpProductionFormStd.ChangedDate, record.ChangedDate }, }, Where = { { ImpProductionFormStd.Factory.Equal( record.Factory ) }, { ImpProductionFormStd.Project.Equal( record.Factory ) },//Factory Leveö { ImpProductionFormStd.Name.Equal( record.Name ) }, }, }; // Never change bed dimensions if it is used in some casts! ProjectManager castSvc = new ProjectManager( ); int numOfExistingCasts = castSvc.GetCastCount( record ); if( 0 == numOfExistingCasts ) { update.Columns.Add(ImpProductionFormStd.MaxLength, record.MaxLength); update.Columns.Add(ImpProductionFormStd.MaxWidth, record.MaxWidth); update.Columns.Add(ImpProductionFormStd.MaxHeight, record.MaxHeight); } string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }