/// <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;
		}
		/// <summary>
		/// Delete the specified record from the database.
		/// This method should be optimized
		/// </summary>
		/// <param name="record">The record to delete from the database.</param>
		/// <returns>The number of affected records.</returns>
		public int DeleteProductionFormStd( RecProductionFormStd record )
		{
			ProjectManager castSvc = new ProjectManager( );
			int count = castSvc.GetCastCount( record );
			if( count > 0 )
			{
				return 0;
			}

			// Delete form std strands
			RecProductionFormStrandStd strand = new RecProductionFormStrandStd( );
			strand.Factory = record.Factory;
			strand.Project = record.Project;
			strand.Name = record.Name;
			strand.StrandPos = 0;//Means delete all strands related to this form
			ProjectManager svc = new ProjectManager();
			svc.DeleteProductionFormStrandStd( strand );

			// (2) Now delete form
			var delete = new ImpactDelete( ImpProductionFormStd.Instance )
			{
				Where = 
				{
					{ ImpProductionFormStd.Factory.Equal( record.Factory )},
					{ ImpProductionFormStd.Project.Equal( record.Factory )}, //Factory Level, ie(Factory, Factory)
					{ ImpProductionFormStd.Name.Equal( record.Name )},
				}
			};

			string statement = delete.ToString();

			int result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.ExecuteNonQuery( statement );
			}

			return result;
		}