/// <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> /// Delete of Transport items /// </summary> /// <param name="transport"></param> /// <returns></returns> public int DeleteCascadeTransport( RecTransport transport ) { if( transport == null || transport.TransportId == 0 ) { throw new ArgumentNullException( "RecTransport" ); } string project = ""; if( transport.IsTemplate == 1 ) { // Templates are saved on factory level (factory, factory), 2012-04-23 project = transport.Factory; } else { project = transport.Project; } // Delete cascade vehicles ProjectManager vehSvc = new ProjectManager(); List<RecTransportVehicleStd> vehicles = vehSvc.LoadTransportVehicles( transport ); foreach( RecTransportVehicleStd veh in vehicles ) { this.DeleteCascadeVehicleTransport( transport, veh ); } int ret = 0; // Now let's delete the transport using( ImpactDatabase database = new ImpactDatabase() ) { ImpactDelete delete = new ImpactDelete( ImpTransport.Instance ) { Where = { ImpTransport.Factory.Equal( transport.Factory ), ImpTransport.Project.Equal( project ),// Templates are saved on factory level (factory, factory), 2012-04-23 ImpTransport.TransportId.Equal( transport.TransportId )}, }; string statement = delete.ToString(); ret = database.ExecuteNonQuery( statement ); } return ret; }
/// <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> /// Delete the specified record from the database. /// </summary> /// <param name="record">The record to delete from the database.</param> /// <returns>The number of affected records.</returns> public int DeleteSectionStyleStd( RecSectionStyleStd record ) { var delete = new ImpactDelete( ImpSectionStyleStd.Instance ) { Where = { { ImpSectionStyleStd.Factory.Equal( record.Factory )}, { ImpSectionStyleStd.Project.Equal( record.Project )}, { ImpSectionStyleStd.ElementType.Equal( record.ElementType )}, { ImpSectionStyleStd.Name.Equal( record.Name )}, } }; string statement = delete.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <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; }
private int DeleteProductionFormStrand ( RecProductionFormStrandStd record ) { int ret = 0; // Now let's delete the transport using( ImpactDatabase database = new ImpactDatabase() ) { ImpactDelete delete = new ImpactDelete( ImpProductionFormStrand.Instance ) { Where = { ImpProductionFormStrand.Factory.Equal( record.Factory ), ImpProductionFormStrand.Project.Equal( record.Factory ), // (factory, factory) ImpProductionFormStrand.Form.Equal( record.Name ), ImpProductionFormStrand.Strand.Equal( record.StrandPos.ToString() )}, }; var statement = delete.ToString(); ret = database.ExecuteNonQuery( statement ); } return ret; }
/// <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> /// Creates a new record if the desired record is not yet created. /// </summary> /// <param name="rec">RecTransportPlanner</param> /// <param name="factory"> </param> /// <param name="project"> </param> /// <param name="elementId"> </param> public void Verify( string factory, string project, int elementId ) { if( string.IsNullOrEmpty(factory) || string.IsNullOrEmpty(project) || elementId <= 0 ) { return; } var selectQuery = new ImpactQuery() { From = { ImpModelPlanning.As( "T1" ) }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( elementId ), } }; var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, elementId }, } }; switch( ImpactDatabase.DataSource ) { case DataSource.SqlServer: case DataSource.SqlServerExpress: { using( var database = new ImpactDatabase() ) { var statement = string.Format( "IF NOT EXISTS ( {0} ) {1}", selectQuery.ToString(), insert.ToString() ); database.ExecuteNonQuery( statement ); } break; } case DataSource.Ingres92: case DataSource.Ingres100: { List<RecTMElement> result; using( var database = new ImpactDatabase() ) { result = database.GetAll( selectQuery.ToString(), ParseModelPlanning ).ToList(); } if( result.Count == 0 ) { using( var database = new ImpactDatabase() ) { database.ExecuteNonQuery( insert.ToString() ); } } break; } } }
/// <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> /// Shrinks stack order no for elements in a given stack /// with higher stack order if there are no elements on the same level /// </summary> /// <param name="rec"></param> /// <returns></returns> private int ShrinkStackOrder( RecTMElement rec ) { if( rec.Factory == null || rec.Project == null ) { return -1; } if( rec.ElementId <= 0 || rec.TransportId <= 0 || rec.VehicleId <= 0 || rec.StackId <= 0 ) { return -1; } // Find elements on the same level ImpactQuery selectQuery = new ImpactQuery() { From = { ImpModelPlanning.As( "T1" ) }, Where = { ImpModelPlanning.Factory.Equal( rec.Factory ), ImpModelPlanning.Project.Equal( rec.Project ), ImpModelPlanning.TransportId.Equal( rec.TransportId ), ImpModelPlanning.VehicleId.Equal( rec.VehicleId ), ImpModelPlanning.StackId.Equal( rec.StackId ), ImpModelPlanning.StackSequenceNo.Equal( rec.StackSequenceNo ), } }; // Conditional update int result = 0; using( ImpactDatabase database = new ImpactDatabase() ) { string wc = ""; wc = ConcatWC( wc, "TRANSPORT_ID", rec.TransportId ); wc = ConcatWC( wc, "VEHICLE_ID", rec.VehicleId ); wc = ConcatWC( wc, "STACK_ID", rec.StackId ); string sql = "Update IMP_MODEL_PLANNING set " + "Stack_sequence_no=Stack_sequence_no - " + Conv.Sql( 1 ) + " Where " + "Factory =" + Conv.Sql( rec.Factory ) + " AND " + "Project=" + Conv.Sql( rec.Project ) + " AND " + "Stack_sequence_no > " + Conv.Sql( rec.StackSequenceNo ) + " AND " + wc; string statement = string.Format( "IF NOT EXISTS ( {0} ) {1}", selectQuery.ToString(), sql ); result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Resets status /// </summary> /// <param name="rec"></param> /// <param name="settings"> </param> /// <returns></returns> private int SaveElementProductionNoStatus( RecProductionCast rec, List<RecElementIdStatusStd> settings ) { var readyForProduction = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 2 ).StatusId; var notReadyForProduction = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 1 ).StatusId; switch( ImpactDatabase.DataSource ) { case DataSource.SqlServer: case DataSource.SqlServerExpress: { string statement = string.Format( @" UPDATE PLN SET PLN.ELEMENT_ID_STATUS = ( CASE WHEN (GEO.READY_FOR_PRODUCTION > 0 ) THEN {0} ELSE {1} END ) FROM IMP_MODEL_PLANNING PLN INNER JOIN IMP_MODEL_GEOMETRY GEO ON PLN.FACTORY = GEO.FACTORY AND PLN.PROJECT = GEO.PROJECT AND PLN.ELEMENT_ID = GEO.ELEMENT_ID WHERE PLN.CAST_ID = {2} AND PLN.FACTORY = '{3}' ", readyForProduction, notReadyForProduction, rec.CastId, rec.Factory ); //, rec.Project AND PLN.PROJECT = '{4}' int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; } case DataSource.Ingres92: case DataSource.Ingres100: { int result = 0; List<StatusDataHolder> list = LoadElementStatusData( rec.Factory, rec.Project, rec.CastId, 0, false ); if( null == list || list.Count == 0 ) { return 0; } foreach( var data in list ) { var idStatus = 0; if( 1 == data.ReadyForProduction ) { idStatus = readyForProduction; } else { idStatus = notReadyForProduction; } UpdateElementStatus( data.Factory, data.Project, data.ElementId, idStatus ); } return result; } } return 0; }
/// <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> /// 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> /// Remove Transport Vehicles Standard items from transport /// </summary> /// <param name="rec"></param> /// <param name="list"></param> /// <returns></returns> public int RemoveTransportVehicles( RecTransport rec, List<RecTransportVehicleStd> list ) { if( rec == null || list == null || list.Count == 0 ) { return 0; } string project = ""; if( rec.IsTemplate == 1 ) { // Templates are saved on factory level (factory, factory), 2012-04-23 project = rec.Factory; } else { project = rec.Project; } string ids = ""; foreach( RecTransportVehicleStd vehicle in list ) { ids += Conv.Sql( vehicle.VehicleId ) + ","; } // remove last comma(,) if( ids.Length > 0 ) { ids = ids.Substring( 0, ids.Length - 1 ); } string sql = "Delete from IMP_TRANSPORT_VEHICLE Where " + "FACTORY = " + Conv.Sql( rec.Factory ) + " AND " + "PROJECT = " + Conv.Sql( project ) + " AND "// Templates are saved on factory level (factory, factory), 2012-04-23 + "TRANSPORT_ID = " + Conv.Sql( rec.TransportId ) + " AND " + "VEHICLE_ID IN (" + ids + ")"; int result = 0; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( sql ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertProductionCastStrand(RecProductionCastStrand record, RecProductionFormStd form, BedFilter filter) { if (null == record) { return -1; } int castId = record.CastId; if (castId <= 0) { if (null == form || null == filter) { return -1; } var cast = new RecProductionCast { Factory = record.Factory, Project = record.Project, CastType = form.FormType, Description = "", Shift = filter.Shift, StartDate = filter.StartDateFrom, EndDate = filter.StartDateFrom, Form = form.Name, Tolerance = form.Tolerance, ElementType = form.ElementType, Style = form.Style, Strandptn = form.Strandptn, CastStatus = 0, CastDivision = "" }; var svc = new ProjectManager(); var newCast = svc.InsertProductionCast(cast); castId = newCast.CastId; } var insert = new ImpactInsert( ImpProductionCastStrand.Instance ) { Columns = { { ImpProductionCastStrand.Factory, record.Factory }, { ImpProductionCastStrand.Project, record.Factory },// Factory, Factory for productionCast & ProductionCastStrand { ImpProductionCastStrand.CastId, castId }, { ImpProductionCastStrand.StrandPos, record.StrandPos }, { ImpProductionCastStrand.StrandX, record.StrandX }, { ImpProductionCastStrand.StrandY, record.StrandY }, { ImpProductionCastStrand.StrandQuality, record.StrandQuality }, { ImpProductionCastStrand.StrandDimension, record.StrandDimension }, { ImpProductionCastStrand.StrandPrestressing, record.StrandPrestressing }, } }; string statement = insert.ToString(); int result; using( var database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Delete the specified record from the database. /// </summary> /// <param name="record">The record to delete from the database.</param> /// <returns>The number of affected records.</returns> public int DeleteProductionFormStrandStd( RecProductionFormStrandStd record ) { // Delete relation first DeleteProductionFormStrand( record ); // Now delete the record var delete = new ImpactDelete( ImpProductionFormStrandStd.Instance ) { Where = { { ImpProductionFormStrandStd.Factory.Equal( record.Factory )}, { ImpProductionFormStrandStd.Project.Equal( record.Factory )}, { ImpProductionFormStrandStd.Name.Equal( record.Name )}, //Form name } }; if( record.StrandPos > 0 ) { delete.Where.Add( ImpProductionFormStrandStd.StrandPos.Equal( record.StrandPos ) ); } string statement = delete.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Delete the specified record from the database. /// </summary> /// <param name="record">The record to delete from the database.</param> /// <returns>The number of affected records.</returns> public int DeleteProductionCastStrand( RecProductionCastStrand record ) { var delete = new ImpactDelete( ImpProductionCastStrand.Instance ) { Where = { ImpProductionCastStrand.Factory.Equal( record.Factory ), ImpProductionCastStrand.Project.Equal( record.Factory ),// Factory, Factory for productionCast & ProductionCastStrand ImpProductionCastStrand.CastId.Equal( record.CastId ), } }; if (record.StrandPos > 0) { delete.Where.Add( ImpProductionCastStrand.StrandPos.Equal(record.StrandPos) ); } var statement = delete.ToString(); int result; using( var database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
private int InsertProductionFormStrand ( RecProductionFormStrandStd record ) { var insert = new ImpactInsert( ImpProductionFormStrand.Instance ) { Columns = { { ImpProductionFormStrand.Factory, record.Factory }, { ImpProductionFormStrand.Project, record.Factory },// (factory, factory) { ImpProductionFormStrand.Form, record.Name }, { ImpProductionFormStrand.Strand, record.StrandPos.ToString() }, } }; string statement = insert.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 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> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertProductionFormStrandStd( RecProductionFormStrandStd record ) { var insert = new ImpactInsert( ImpProductionFormStrandStd.Instance ) { Columns = { { ImpProductionFormStrandStd.Factory, record.Factory }, { ImpProductionFormStrandStd.Project, record.Factory }, { ImpProductionFormStrandStd.Name, record.Name }, //Form name ?? { ImpProductionFormStrandStd.StrandPos, record.StrandPos }, { ImpProductionFormStrandStd.StrandX, record.StrandX }, { ImpProductionFormStrandStd.StrandY, record.StrandY }, { ImpProductionFormStrandStd.StrandQuality, record.StrandQuality }, { ImpProductionFormStrandStd.StrandDimension, record.StrandDimension }, { ImpProductionFormStrandStd.StrandPrestressing, record.StrandPrestressing }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <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 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> /// Delete of Transport Vehicle Standard items /// </summary> /// <param name="vehicle"></param> /// <returns></returns> public int DeleteTransportVehicleStd( RecTransportVehicleStd record ) { if( record == null ) { throw new ArgumentNullException( "TransportVehicleStd" ); } // Delete underlying std stacks ProjectManager svc = new ProjectManager(); RecTransportVehicleStackStd stack = new RecTransportVehicleStackStd() { Factory = record.Factory, Project = record.Project, Name = record.Name, }; svc.DeleteTransportVehicleStackStd( stack ); // Now delete the std veh var delete = new ImpactDelete( ImpTransportVehicleStd.Instance ) { Where = { { ImpTransportVehicleStd.Factory.Equal( record.Factory )}, { ImpTransportVehicleStd.Project.Equal( record.Factory )},//for Std use Factory, Factory { ImpTransportVehicleStd.Name.Equal( record.Name )}, } }; string statement = delete.ToString(); int result; 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> /// Insert of Transport Vehicle Standard items /// </summary> /// <param name="vehicle"></param> /// <returns></returns> public int InsertTransportVehicleStd( RecTransportVehicleStd record ) { if( record == null ) { throw new ArgumentNullException( "TransportVehicleStd" ); } var insert = new ImpactInsert( ImpTransportVehicleStd.Instance ) { Columns = { { ImpTransportVehicleStd.Factory, record.Factory }, { ImpTransportVehicleStd.Project, record.Factory }, //Std use, Factory, Factory { ImpTransportVehicleStd.Name, record.Name }, { ImpTransportVehicleStd.Division, record.Division }, { 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.CreatedBy, record.Created_By }, { ImpTransportVehicleStd.CreatedDate, record.Created_Date }, //{ ImpTransportVehicleStd.ChangedBy, record.Created_By }, //{ ImpTransportVehicleStd.ChangedDate, record.Created_Date }, } }; string statement = insert.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> /// Insert of Transport Vehicle Standard items /// </summary> /// <param name="rec"></param> /// <param name="vehicle"></param> /// <param name="seq"></param> /// <returns></returns> public RecTransportVehicleStd InsertTransportVehicle( RecTransport rec, RecTransportVehicleStd vehicle, int seq ) { if( rec == null || rec.Factory == null || rec.Project == null ) { throw new ArgumentNullException( "Transport" ); } string project = ""; if( rec.IsTemplate == 1 ) { // Templates are saved on factory level (factory, factory), 2012-04-23 project = rec.Factory; } else { project = rec.Project; } RecTransportVehicleStd res = new RecTransportVehicleStd( vehicle ); using( ImpactDatabase database = new ImpactDatabase() ) { // 1. Instantiate a new command with a query and connection ProjectManager ng = new ProjectManager(); int vehicleId = ng.GetNextNumber( rec.Factory, rec.Project, RecNumberGenerator.NG_VEHICLE_ID ); string sql = "Insert into IMP_TRANSPORT_VEHICLE(FACTORY,PROJECT,TRANSPORT_ID,VEHICLE_ID,VEHICLE,VEHICLE_SEQUENCE_NO,TRANSPORT_TYPE)values(" + Conv.Sql( rec.Factory ) + "," + Conv.Sql( project ) + "," //Templates are saved on factory level (factory, factory), 2012-04-23 + Conv.Sql( rec.TransportId ) + "," + Conv.Sql( vehicleId ) + "," + Conv.Sql( vehicle.Name ) + "," + Conv.Sql( seq ) + "," + Conv.Sql( vehicle.TransportType ) + ")"; database.ExecuteNonQuery( sql ); res.VehicleId = vehicleId; } return res; }
/// <summary> /// Insert of Transport items /// </summary> /// <param name="transport"></param> /// <returns></returns> public RecTransport InsertTransport( RecTransport record ) { if( record == null ) { throw new ArgumentNullException( "Transport" ); } RecTransport newTransport = new RecTransport( record ); string project = ""; if( record.IsTemplate == 1 ) { //Secure and easy solution for unique sequence id's!!! // Use negative value to distinguish templates from transports! ProjectManager ng = new ProjectManager(); newTransport.TransportId = -ng.GetNextNumber( record.Factory, record.Project, RecNumberGenerator.NG_TRANSPORT_ID ); // Templates are saved on factory level (factory, factory), 2012-04-23 project = record.Factory; } else { //Now let's use the slow, unsecure and bad unique id's using max, what a mess :( newTransport.TransportId = GetMaxTransportId( record ) + 1; project = record.Project; } var insert = new ImpactInsert( ImpTransport.Instance ) { Columns = { { ImpTransport.Factory, record.Factory }, { ImpTransport.Project, project },// Templates are saved on factory level (factory, factory), 2012-04-23 { ImpTransport.TransportId, newTransport.TransportId }, // The new Id! { ImpTransport.Description, record.Description }, { ImpTransport.LoadDate, record.LoadDate }, { ImpTransport.DeliveryDate, record.DeliveryDate }, { ImpTransport.IsTemplate, record.IsTemplate }, { ImpTransport.IsVisible, record.IsVisible }, { ImpTransport.TemplateId, record.TemplateId }, { ImpTransport.TimeInterval, record.TimeInterval }, { ImpTransport.TransportStatus, record.TransportStatus }, { ImpTransport.LoadLocation, record.LoadLocation }, { ImpTransport.LoadDivision, record.LoadDivision }, { ImpTransport.DeliveryDivision, record.DeliveryDivision }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return newTransport; }
/// <summary> /// Sets element no status /// </summary> /// <param name="rec"></param> /// <returns></returns> private int SaveElementTransportNoStatus( RecTransport rec, List<RecElementIdStatusStd> settings ) { int produced = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 4 ).StatusId; int notProduced = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 3 ).StatusId; int readyForProduction = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 2 ).StatusId; int notReadyForProduction = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, 1 ).StatusId; switch( ImpactDatabase.DataSource ) { case DataSource.SqlServer: case DataSource.SqlServerExpress: { string statement = string.Format( @" UPDATE PLN SET PLN.ELEMENT_ID_STATUS = ( CASE WHEN (PLN.CAST_ID > 0 AND PLN.PRODUCTION_DATE is not null ) THEN {0} WHEN (PLN.CAST_ID > 0) THEN {1} WHEN (GEO.READY_FOR_PRODUCTION > 0) THEN {2} ELSE {3} END ) FROM IMP_MODEL_PLANNING PLN INNER JOIN IMP_MODEL_GEOMETRY GEO ON PLN.FACTORY = GEO.FACTORY AND PLN.PROJECT = GEO.PROJECT AND PLN.ELEMENT_ID = GEO.ELEMENT_ID WHERE PLN.TRANSPORT_ID = {4} AND PLN.FACTORY = '{5}' AND PLN.PROJECT = '{6}' ", produced, notProduced, readyForProduction, notReadyForProduction, rec.TransportId, rec.Factory, rec.Project ); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; } case DataSource.Ingres92: case DataSource.Ingres100: { int result = 0; List<StatusDataHolder> list = LoadElementStatusData( rec.Factory, rec.Project, 0, rec.TransportId, true ); if( null == list || list.Count == 0 ) { return 0; } foreach( StatusDataHolder data in list ) { int idStatus = 0; if( data.CastId > 0 && data.ProductionDate != null ) { idStatus = produced; } else if( data.CastId > 0 ) { idStatus = notProduced; } else if( 1 == data.ReadyForProduction ) { idStatus = readyForProduction; } else { idStatus = notReadyForProduction; } result = UpdateElementStatus( data.Factory, data.Project, data.ElementId, idStatus ); } return result; } } return 0; }