예제 #1
0
		/// <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 RecProductionCast InsertProductionCast( RecProductionCast record )
		{
            // Get new sequence
			ProjectManager ng = new ProjectManager();
			string company = ProjectManager.GetCompany( record.Factory );
			int castId = ng.GetNextNumber( company, company, RecNumberGenerator.CMP_NG_CAST_ID );

			var insert = new ImpactInsert( ImpProductionCast.Instance )
			{
				Columns = 
				{
					{ ImpProductionCast.Factory, record.Factory },
					{ ImpProductionCast.Project, record.Factory }, // Factory, Factory for productionCast
					{ ImpProductionCast.CastId, castId }, //Sequence
					{ ImpProductionCast.CastType, record.CastType },
					{ ImpProductionCast.Description, record.Description },
					{ ImpProductionCast.Shift, record.Shift },
					{ ImpProductionCast.StartDate, record.StartDate },
					{ ImpProductionCast.EndDate, record.EndDate },
					{ 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 },
				}
			};

			string statement = insert.ToString();

			int result;

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

            // Copy strands from template (form)
            if (!string.IsNullOrWhiteSpace(record.Form))
            {
                record.CastId = castId;
                ProjectManager svc = new ProjectManager( );
                svc.CopyStrandsFromTemplate( record );
            }

			return record;
		}