Sage.Integration.Northwind.Application.Entities.Product.DataSets.ProductTableAdapters.ProductsTableAdapter.Insert C# (CSharp) Method

Insert() private method

private Insert ( string ProductName, System SupplierID, System CategoryID, string QuantityPerUnit, System UnitPrice, System UnitsInStock, System UnitsOnOrder, System ReorderLevel, bool Discontinued, System CreateID, string CreateUser, System ModifyID, string ModifyUser ) : int
ProductName string
SupplierID System
CategoryID System
QuantityPerUnit string
UnitPrice System
UnitsInStock System
UnitsOnOrder System
ReorderLevel System
Discontinued bool
CreateID System
CreateUser string
ModifyID System
ModifyUser string
return int
        public virtual int Insert(string ProductName, System.Nullable<int> SupplierID, System.Nullable<int> CategoryID, string QuantityPerUnit, System.Nullable<decimal> UnitPrice, System.Nullable<short> UnitsInStock, System.Nullable<short> UnitsOnOrder, System.Nullable<short> ReorderLevel, bool Discontinued, System.Nullable<int> CreateID, string CreateUser, System.Nullable<int> ModifyID, string ModifyUser) {
            if ((ProductName == null)) {
                throw new System.ArgumentNullException("ProductName");
            }
            else {
                this.Adapter.InsertCommand.Parameters[0].Value = ((string)(ProductName));
            }
            if ((SupplierID.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[1].Value = ((int)(SupplierID.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[1].Value = System.DBNull.Value;
            }
            if ((CategoryID.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[2].Value = ((int)(CategoryID.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[2].Value = System.DBNull.Value;
            }
            if ((QuantityPerUnit == null)) {
                this.Adapter.InsertCommand.Parameters[3].Value = System.DBNull.Value;
            }
            else {
                this.Adapter.InsertCommand.Parameters[3].Value = ((string)(QuantityPerUnit));
            }
            if ((UnitPrice.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[4].Value = ((decimal)(UnitPrice.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[4].Value = System.DBNull.Value;
            }
            if ((UnitsInStock.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[5].Value = ((short)(UnitsInStock.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[5].Value = System.DBNull.Value;
            }
            if ((UnitsOnOrder.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[6].Value = ((short)(UnitsOnOrder.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[6].Value = System.DBNull.Value;
            }
            if ((ReorderLevel.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[7].Value = ((short)(ReorderLevel.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[7].Value = System.DBNull.Value;
            }
            this.Adapter.InsertCommand.Parameters[8].Value = ((bool)(Discontinued));
            if ((CreateID.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[9].Value = ((int)(CreateID.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[9].Value = System.DBNull.Value;
            }
            if ((CreateUser == null)) {
                this.Adapter.InsertCommand.Parameters[10].Value = System.DBNull.Value;
            }
            else {
                this.Adapter.InsertCommand.Parameters[10].Value = ((string)(CreateUser));
            }
            if ((ModifyID.HasValue == true)) {
                this.Adapter.InsertCommand.Parameters[11].Value = ((int)(ModifyID.Value));
            }
            else {
                this.Adapter.InsertCommand.Parameters[11].Value = System.DBNull.Value;
            }
            if ((ModifyUser == null)) {
                this.Adapter.InsertCommand.Parameters[12].Value = System.DBNull.Value;
            }
            else {
                this.Adapter.InsertCommand.Parameters[12].Value = ((string)(ModifyUser));
            }
            System.Data.ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State;
            if (((this.Adapter.InsertCommand.Connection.State & System.Data.ConnectionState.Open) 
                        != System.Data.ConnectionState.Open)) {
                this.Adapter.InsertCommand.Connection.Open();
            }
            try {
                int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery();
                return returnValue;
            }
            finally {
                if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
                    this.Adapter.InsertCommand.Connection.Close();
                }
            }
        }