public void Execute(WSGuid Spr_GuidProductID, WSGuid Spr_GuidSupplierID)
        {
            Params.spI_tblSupplierProduct param = new Params.spI_tblSupplierProduct(true);
            param.SetUpConnection(string.Empty);

            if (Spr_GuidProductID == null || Spr_GuidProductID.UseNull)
            {
                param.Param_Spr_GuidProductID = SqlGuid.Null;
            }
            else if (!Spr_GuidProductID.UseDefault)
            {
                param.Param_Spr_GuidProductID = Spr_GuidProductID.Value;
            }

            if (Spr_GuidSupplierID == null || Spr_GuidSupplierID.UseNull)
            {
                param.Param_Spr_GuidSupplierID = SqlGuid.Null;
            }
            else if (!Spr_GuidSupplierID.UseDefault)
            {
                param.Param_Spr_GuidSupplierID = Spr_GuidSupplierID.Value;
            }

            using (SPs.spI_tblSupplierProduct sp = new SPs.spI_tblSupplierProduct(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        /// <returns>[To be supplied.]</returns>
        public IBusinessComponentRecord Add(IBusinessComponentRecord record)
        {
            tblSupplierProduct_Record recordToAdd = record as tblSupplierProduct_Record;

            if (recordToAdd == null)
            {
                throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.tblSupplierProduct_Record'.", "record");
            }

            switch (this.parentType)
            {
            case tblSupplierProduct_CollectionParentType.Col_Spr_GuidProductID:
                recordToAdd.Col_Spr_GuidProductID = ((Product)this.parent).Col_Pro_GuidID;
                break;

            case tblSupplierProduct_CollectionParentType.Col_Spr_GuidSupplierID:
                recordToAdd.Col_Spr_GuidSupplierID = ((Supplier)this.parent).Col_Sup_GuidID;
                break;
            }

            bool alreadyOpened = false;

            Params.spI_tblSupplierProduct Param = new Params.spI_tblSupplierProduct(true);
            Param.CommandTimeOut = this.insertCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            Param.Param_Spr_GuidProductID  = recordToAdd.Col_Spr_GuidProductID;
            Param.Param_Spr_GuidSupplierID = recordToAdd.Col_Spr_GuidSupplierID;

            SPs.spI_tblSupplierProduct Sp = new SPs.spI_tblSupplierProduct(false);
            if (Sp.Execute(ref Param))
            {
                tblSupplierProduct_Record newRecord = null;

                switch (this.lastKnownConnectionType)
                {
                case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                    newRecord = new tblSupplierProduct_Record(this.connectionString, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                    newRecord = new tblSupplierProduct_Record(this.sqlConnection, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                    newRecord = new tblSupplierProduct_Record(this.sqlTransaction, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID);
                    break;
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                if (internalRecords != null)
                {
                    internalRecords.Add(newRecord);
                }

                if (this.addedRecords == null)
                {
                    this.addedRecords = new System.Collections.ArrayList();
                }
                this.addedRecords.Add(newRecord);

                return(newRecord);
            }
            else
            {
                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblSupplierProduct_Collection", "Add");
            }
        }