/// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the 'spS_tblOrder' stored procedure parameters.
        /// </summary>
        /// <param name="sqlConnection">A valid SqlConnection object. If it is not opened, it will be opened when used then closed again after the job is done.</param>
        /// <param name="valueMember">name of the field to be used as a primary key.</param>
        /// <param name="displayMember">name of the field to be used for the content display.</param>
        /// <param name="tableName">name of the table to use to populate the control.</param>
        /// <param name="param_Ord_GuidID">Value for the parameter @Ord_GuidID.</param>
        /// <param name="param_Ord_LngCustomerID">Value for the parameter @Ord_LngCustomerID.</param>
        public void Initialize(System.Data.SqlClient.SqlConnection sqlConnection, string valueMember, string displayMember, string tableName, System.Data.SqlTypes.SqlGuid param_Ord_GuidID, System.Data.SqlTypes.SqlInt32 param_Ord_LngCustomerID)
        {
            this.sqlConnection           = sqlConnection;
            this.LastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlConnection;

#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                bool NotAlreadyOpened = false;
                if (sqlConnection.State == System.Data.ConnectionState.Closed)
                {
                    NotAlreadyOpened = true;
                    sqlConnection.Open();
                }

                System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.CommandType = System.Data.CommandType.Text;
                sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'spS_tblOrder'";

                int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                if (NotAlreadyOpened)
                {
                    sqlConnection.Close();
                }

                int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                if (CurrentRevision != OriginalRevision)
                {
                    throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}{3}{3}You can either regenerate the code for this class so that it will be based on the new version or edit the configuration file of the class caller application and paste the following code:{3}{3}<?xml version=\"1.0\" encoding=\"utf-8\" ?>{3}<configuration>{3}\t<appSettings>{3}\t\t<add key=\"OlymarsDebugCheck\" value=\"False\" />{3}\t</appSettings>{3}</configuration>{3}{3}You will need to reload the caller application if it is a Windows Forms based application.", "spS_tblOrder", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                }
            }
#endif

            this.valueMember   = valueMember;
            this.displayMember = displayMember;
            this.tableName     = tableName;

            this.param_Ord_GuidID        = param_Ord_GuidID;
            this.param_Ord_LngCustomerID = param_Ord_LngCustomerID;
        }
Пример #2
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_Pro_GuidID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Pro_GuidID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Pro_StrName = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Pro_StrName_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Pro_CurPrice = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_Pro_CurPrice_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Pro_LngCategoryID_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Пример #3
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_Oit_GuidID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Oit_GuidID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Oit_GuidOrderID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Oit_GuidOrderID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Oit_GuidProductID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Oit_GuidProductID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Oit_LngAmount = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Oit_LngAmount_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Пример #4
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_Ord_GuidID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Ord_GuidID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_DatOrderedOn = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_Ord_DatOrderedOn_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Ord_LngCustomerID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_CurTotal = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_Ord_CurTotal_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Пример #5
0
        /// <summary>
        /// Allows you to update an existing record from the tblSupplier table.
        /// </summary>
        /// <param name="caller">The IWin32Window this form will display in front of.</param>
        /// <param name="formTitle">Title of this form.</param>
        /// <param name="sqlConnection">A valid System.Data.SqlClient.SqlConnection.</param>
        /// <param name="id">Primary key of the record to update.</param>
        /// <returns>
        /// Returns True if the record was found. Returns False otherwise
        /// (no form is displayed in this case).
        /// </returns>
        public bool EditExistingRecord(System.Windows.Forms.IWin32Window caller, string formTitle, System.Data.SqlClient.SqlConnection sqlConnection, System.Data.SqlTypes.SqlGuid id)
        {
            this.Text = formTitle;

            this.lastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlConnection;
            this.sqlConnection           = sqlConnection;
            this.currentID = id;

            RequestForeignTables();
            EmptyControls();

            if (!RefreshCurrentRecord())
            {
                return(false);
            }

            Check_cmdOK_Button(null);

            ProcessHiddenAndDisabledControlStatus(false);

            this.ShowDialog(caller);

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Allows you to load a specific record of the [tblSupplierProduct] table.
        /// </summary>
        /// <param name="col_Spr_GuidProductID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Spr_GuidProductID&quot; column.</param>
        /// <param name="col_Spr_GuidSupplierID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Spr_GuidSupplierID&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlGuid col_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid col_Spr_GuidSupplierID)
        {
            bool Status;

            Reset();

            if (col_Spr_GuidProductID.IsNull)
            {
                throw new ArgumentNullException("col_Spr_GuidProductID", "The primary key 'col_Spr_GuidProductID' can not have a Null value!");
            }

            if (col_Spr_GuidSupplierID.IsNull)
            {
                throw new ArgumentNullException("col_Spr_GuidSupplierID", "The primary key 'col_Spr_GuidSupplierID' can not have a Null value!");
            }


            this.col_Spr_GuidProductID  = col_Spr_GuidProductID;
            this.col_Spr_GuidSupplierID = col_Spr_GuidSupplierID;

            this.Param.Reset();

            this.Param.Param_Spr_GuidProductID  = this.col_Spr_GuidProductID;
            this.Param.Param_Spr_GuidSupplierID = this.col_Spr_GuidSupplierID;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_tblSupplierProduct          SP = new SPs.spS_tblSupplierProduct(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new OlymarsDemo.DataClasses.CustomException(this.Param, "OlymarsDemo.AbstractClasses.Abstract_tblSupplierProduct", "Refresh");
            }
        }
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblOrderItem class.
 /// The table name in the DataSet will be: tblOrderItem
 /// </summary>
 /// <param name="sqlTransaction">A valid System.Data.SqlClient.SqlTransaction to the database.</param>
 /// <param name="FK_Oit_GuidOrderID">Value for this foreign key.</param>
 /// <param name="FK_Oit_GuidProductID">Value for this foreign key.</param>
 public SqlDataAdapter_tblOrderItem(System.Data.SqlClient.SqlTransaction sqlTransaction, System.Data.SqlTypes.SqlGuid FK_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid FK_Oit_GuidProductID) : this(sqlTransaction) {
     this.Configure(FK_Oit_GuidOrderID, FK_Oit_GuidProductID, "tblOrderItem");
 }
 /// <summary>
 /// Configures the SqlDataAdapter.
 /// The table name in the DataSet will be: tblOrderItem
 /// </summary>
 /// <param name="FK_Oit_GuidOrderID">Value for this foreign key.</param>
 /// <param name="FK_Oit_GuidProductID">Value for this foreign key.</param>
 public void Configure(System.Data.SqlTypes.SqlGuid FK_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid FK_Oit_GuidProductID)
 {
     this.Configure(FK_Oit_GuidOrderID, FK_Oit_GuidProductID, "tblOrderItem");
 }
Пример #9
0
 /// <summary>
 /// Allows you to reset the pre-selected value for the 'Oit_GuidProductID' column.
 /// </summary>
 public void ResetValue_Oit_GuidProductID()
 {
     this.hasBeenPopulated_Oit_GuidProductID = false;
     this.internal_Oit_GuidProductID         = System.Data.SqlTypes.SqlGuid.Null;
 }
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblOrderItem class.
 /// The table name in the DataSet will be: tblOrderItem
 /// </summary>
 /// <param name="connectionString">A valid connection string to the database.</param>
 /// <param name="FK_Oit_GuidOrderID">Value for this foreign key.</param>
 /// <param name="FK_Oit_GuidProductID">Value for this foreign key.</param>
 public SqlDataAdapter_tblOrderItem(string connectionString, System.Data.SqlTypes.SqlGuid FK_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid FK_Oit_GuidProductID) : this(connectionString) {
     this.Configure(FK_Oit_GuidOrderID, FK_Oit_GuidProductID, "tblOrderItem");
 }
Пример #11
0
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblSupplierProduct class.
 /// The table name in the DataSet will be: tblSupplierProduct
 /// </summary>
 /// <param name="sqlTransaction">A valid System.Data.SqlClient.SqlTransaction to the database.</param>
 /// <param name="FK_Spr_GuidProductID">Value for this foreign key.</param>
 /// <param name="FK_Spr_GuidSupplierID">Value for this foreign key.</param>
 public SqlDataAdapter_tblSupplierProduct(System.Data.SqlClient.SqlTransaction sqlTransaction, System.Data.SqlTypes.SqlGuid FK_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid FK_Spr_GuidSupplierID) : this(sqlTransaction) {
     this.Configure(FK_Spr_GuidProductID, FK_Spr_GuidSupplierID, "tblSupplierProduct");
 }
Пример #12
0
        /// <summary>
        /// Configures the SqlDataAdapter.
        /// </summary>
        /// <param name="FK_Spr_GuidProductID">Value for this foreign key.</param>
        /// <param name="FK_Spr_GuidSupplierID">Value for this foreign key.</param>
        /// <param name="tableName">Table name to be use in the DataSet.</param>
        public void Configure(System.Data.SqlTypes.SqlGuid FK_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid FK_Spr_GuidSupplierID, string tableName)
        {
            this.hasBeenConfigured = true;

            this.sqlDataAdapter = null;

            System.Data.SqlClient.SqlCommand   sqlSelectCommand;
            System.Data.SqlClient.SqlCommand   sqlInsertCommand;
            System.Data.SqlClient.SqlCommand   sqlUpdateCommand;
            System.Data.SqlClient.SqlCommand   sqlDeleteCommand;
            System.Data.SqlClient.SqlParameter sqlParameter;

            sqlSelectCommand = new System.Data.SqlClient.SqlCommand();
            sqlInsertCommand = new System.Data.SqlClient.SqlCommand();
            sqlUpdateCommand = new System.Data.SqlClient.SqlCommand();
            sqlDeleteCommand = new System.Data.SqlClient.SqlCommand();

            System.Data.SqlClient.SqlConnection localSqlConnection = null;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:

                string connectionString = this.ConnectionString;

                if (connectionString.Length == 0)
                {
                    connectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromConfigurationFile;
                    if (connectionString.Length == 0)
                    {
                        connectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromRegistry;
                    }
                }

                if (connectionString.Length == 0)
                {
                    throw new System.InvalidOperationException("No connection information was supplied (ConnectionString == \"\")! (OlymarsDemo.SqlDataAdapters.SqlDataAdapter_tblSupplierProduct)");
                }

                localSqlConnection = new System.Data.SqlClient.SqlConnection(connectionString);

                sqlSelectCommand.Connection = localSqlConnection;
                sqlInsertCommand.Connection = localSqlConnection;
                sqlUpdateCommand.Connection = localSqlConnection;
                sqlDeleteCommand.Connection = localSqlConnection;

                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:

                localSqlConnection = this.SqlConnection;

                sqlSelectCommand.Connection = localSqlConnection;
                sqlInsertCommand.Connection = localSqlConnection;
                sqlUpdateCommand.Connection = localSqlConnection;
                sqlDeleteCommand.Connection = localSqlConnection;

                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:

                sqlSelectCommand.Connection  = this.sqlTransaction.Connection;
                sqlSelectCommand.Transaction = this.sqlTransaction;

                sqlInsertCommand.Connection  = this.sqlTransaction.Connection;
                sqlInsertCommand.Transaction = this.sqlTransaction;

                sqlUpdateCommand.Connection  = this.sqlTransaction.Connection;
                sqlUpdateCommand.Transaction = this.sqlTransaction;

                sqlDeleteCommand.Connection  = this.sqlTransaction.Connection;
                sqlDeleteCommand.Transaction = this.sqlTransaction;

                break;
            }

            sqlSelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
            sqlSelectCommand.CommandText = "spS_tblSupplierProduct";

            sqlParameter            = new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4);
            sqlParameter.Direction  = System.Data.ParameterDirection.ReturnValue;
            sqlParameter.IsNullable = true;
            sqlParameter.Value      = System.DBNull.Value;
            sqlSelectCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidProductID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidProductID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlSelectCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidSupplierID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidSupplierID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlSelectCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidProductID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidProductID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            if (!FK_Spr_GuidProductID.IsNull)
            {
                sqlParameter.Value = FK_Spr_GuidProductID;
            }

            else
            {
                sqlParameter.IsNullable = true;
                sqlParameter.Value      = System.DBNull.Value;
            }
            sqlSelectCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidSupplierID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidSupplierID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            if (!FK_Spr_GuidSupplierID.IsNull)
            {
                sqlParameter.Value = FK_Spr_GuidSupplierID;
            }

            else
            {
                sqlParameter.IsNullable = true;
                sqlParameter.Value      = System.DBNull.Value;
            }
            sqlSelectCommand.Parameters.Add(sqlParameter);

            sqlParameter           = new System.Data.SqlClient.SqlParameter("@ReturnXML", System.Data.SqlDbType.Bit, 1);
            sqlParameter.Direction = System.Data.ParameterDirection.Input;
            sqlParameter.Value     = false;
            sqlSelectCommand.Parameters.Add(sqlParameter);


            sqlInsertCommand.CommandType = System.Data.CommandType.StoredProcedure;
            sqlInsertCommand.CommandText = "spI_tblSupplierProduct";

            sqlParameter            = new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4);
            sqlParameter.Direction  = System.Data.ParameterDirection.ReturnValue;
            sqlParameter.IsNullable = true;
            sqlParameter.Value      = System.DBNull.Value;
            sqlInsertCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidProductID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidProductID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlInsertCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidSupplierID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidSupplierID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlInsertCommand.Parameters.Add(sqlParameter);


            sqlUpdateCommand.CommandType = System.Data.CommandType.StoredProcedure;
            sqlUpdateCommand.CommandText = "spU_tblSupplierProduct";

            sqlParameter            = new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4);
            sqlParameter.Direction  = System.Data.ParameterDirection.ReturnValue;
            sqlParameter.IsNullable = true;
            sqlParameter.Value      = System.DBNull.Value;
            sqlUpdateCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidProductID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidProductID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlUpdateCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidSupplierID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidSupplierID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlUpdateCommand.Parameters.Add(sqlParameter);


            sqlDeleteCommand.CommandType = System.Data.CommandType.StoredProcedure;
            sqlDeleteCommand.CommandText = "spD_tblSupplierProduct";

            sqlParameter            = new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4);
            sqlParameter.Direction  = System.Data.ParameterDirection.ReturnValue;
            sqlParameter.IsNullable = true;
            sqlParameter.Value      = System.DBNull.Value;
            sqlDeleteCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidProductID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidProductID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlDeleteCommand.Parameters.Add(sqlParameter);

            sqlParameter = new System.Data.SqlClient.SqlParameter("@Spr_GuidSupplierID", System.Data.SqlDbType.UniqueIdentifier, 16);
            sqlParameter.SourceColumn = "Spr_GuidSupplierID";
            sqlParameter.Direction    = System.Data.ParameterDirection.Input;
            sqlParameter.IsNullable   = true;
            sqlParameter.Value        = System.DBNull.Value;
            sqlDeleteCommand.Parameters.Add(sqlParameter);


            // Let's create the SqlDataAdapter
            this.sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter();

            this.sqlDataAdapter.SelectCommand = sqlSelectCommand;
            this.sqlDataAdapter.InsertCommand = sqlInsertCommand;
            this.sqlDataAdapter.UpdateCommand = sqlUpdateCommand;
            this.sqlDataAdapter.DeleteCommand = sqlDeleteCommand;

            this.sqlDataAdapter.TableMappings.AddRange(

                new System.Data.Common.DataTableMapping[] {
                new System.Data.Common.DataTableMapping(
                    "tblSupplierProduct"
                    , tableName
                    , new System.Data.Common.DataColumnMapping[] {
                    new System.Data.Common.DataColumnMapping("Spr_GuidProductID", "Spr_GuidProductID")
                    , new System.Data.Common.DataColumnMapping("Spr_GuidSupplierID", "Spr_GuidSupplierID")
                }
                    )
            }
                );
        }
Пример #13
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="col_Spr_GuidProductID">[To be supplied.]</param>
        /// <param name="col_Spr_GuidSupplierID">[To be supplied.]</param>
        /// <returns>[To be supplied.]</returns>
        public tblSupplierProduct_Record this[System.Data.SqlTypes.SqlGuid col_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid col_Spr_GuidSupplierID] {
            get {
                foreach (tblSupplierProduct_Record record in internalRecords)
                {
                    bool equality = true;

                    equality = equality && (record.Col_Spr_GuidProductID == col_Spr_GuidProductID).Value;
                    equality = equality && (record.Col_Spr_GuidSupplierID == col_Spr_GuidSupplierID).Value;

                    if (equality)
                    {
                        return(record);
                    }
                }
                return(null);
            }
        }
Пример #14
0
        public static void SqlDataReader_SqlBuffer_GetFieldValue()
        {
            string         tableName = DataTestUtility.GetUniqueNameForSqlServer("SqlBuffer_GetFieldValue");
            DateTimeOffset dtoffset  = DateTimeOffset.Now;
            DateTime       dt        = DateTime.Now;
            //Exclude the millisecond because of rounding at some points by SQL Server.
            DateTime dateTime = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
            //Arrange
            DbProviderFactory provider = SqlClientFactory.Instance;

            using DbConnection con = provider.CreateConnection();
            con.ConnectionString   = DataTestUtility.TCPConnectionString;
            con.Open();
            string sqlQueryOne = $"CREATE TABLE {tableName} ([CustomerId] [int],[FirstName] [nvarchar](50),[BoolCol] [BIT],[ShortCol] [SMALLINT],[ByteCol] [TINYINT],[LongCol] [BIGINT]);";
            string sqlQueryTwo = $"ALTER TABLE {tableName} ADD [DoubleCol] [FLOAT],[SingleCol] [REAL],[GUIDCol] [uniqueidentifier],[DateTimeCol] [DateTime],[DecimalCol] [SmallMoney],[DateTimeOffsetCol] [DateTimeOffset];";

            try
            {
                using (DbCommand command = provider.CreateCommand())
                {
                    command.Connection  = con;
                    command.CommandText = sqlQueryOne;
                    command.ExecuteNonQuery();
                }
                using (DbCommand command = provider.CreateCommand())
                {
                    command.Connection  = con;
                    command.CommandText = sqlQueryTwo;
                    command.ExecuteNonQuery();
                }

                System.Data.SqlTypes.SqlGuid sqlguid = new System.Data.SqlTypes.SqlGuid(Guid.NewGuid());

                using (SqlCommand sqlCommand = new SqlCommand("", con as SqlConnection))
                {
                    sqlCommand.CommandText = $"INSERT INTO {tableName} "
                                             + "VALUES (@CustomerId,@FirstName,@BoolCol,@ShortCol,@ByteCol,@LongCol,@DoubleCol,@SingleCol"
                                             + ",@GUIDCol,@DateTimeCol,@DecimalCol,@DateTimeOffsetCol)";
                    sqlCommand.Parameters.AddWithValue(@"CustomerId", 1);
                    sqlCommand.Parameters.AddWithValue(@"FirstName", "Microsoft");
                    sqlCommand.Parameters.AddWithValue(@"BoolCol", true);
                    sqlCommand.Parameters.AddWithValue(@"ShortCol", 3274);
                    sqlCommand.Parameters.AddWithValue(@"ByteCol", 253);
                    sqlCommand.Parameters.AddWithValue(@"LongCol", 922222222222);
                    sqlCommand.Parameters.AddWithValue(@"DoubleCol", 10.7);
                    sqlCommand.Parameters.AddWithValue(@"SingleCol", 123.546f);
                    sqlCommand.Parameters.AddWithValue(@"GUIDCol", sqlguid);
                    sqlCommand.Parameters.AddWithValue(@"DateTimeCol", dateTime);
                    sqlCommand.Parameters.AddWithValue(@"DecimalCol", 280);
                    sqlCommand.Parameters.AddWithValue(@"DateTimeOffsetCol", dtoffset);
                    sqlCommand.ExecuteNonQuery();
                }
                using (SqlCommand sqlCommand = new SqlCommand("", con as SqlConnection))
                {
                    sqlCommand.CommandText = "select top 1 * from " + tableName;
                    using (DbDataReader reader = sqlCommand.ExecuteReader())
                    {
                        Assert.True(reader.Read());
                        Assert.Equal(1, reader.GetFieldValue <int>(0));
                        Assert.Equal("Microsoft", reader.GetFieldValue <string>(1));
                        Assert.True(reader.GetFieldValue <bool>(2));
                        Assert.Equal(3274, reader.GetFieldValue <short>(3));
                        Assert.Equal(253, reader.GetFieldValue <byte>(4));
                        Assert.Equal(922222222222, reader.GetFieldValue <long>(5));
                        Assert.Equal(10.7, reader.GetFieldValue <double>(6));
                        Assert.Equal(123.546f, reader.GetFieldValue <float>(7));
                        Assert.Equal(sqlguid, reader.GetFieldValue <Guid>(8));
                        Assert.Equal(sqlguid.Value, reader.GetFieldValue <System.Data.SqlTypes.SqlGuid>(8).Value);
                        Assert.Equal(dateTime.ToString("dd/MM/yyyy HH:mm:ss.fff"), reader.GetFieldValue <DateTime>(9).ToString("dd/MM/yyyy HH:mm:ss.fff"));
                        Assert.Equal(280, reader.GetFieldValue <decimal>(10));
                        Assert.Equal(dtoffset, reader.GetFieldValue <DateTimeOffset>(11));
                    }
                }
            }
            finally
            {
                //cleanup
                using (DbCommand cmd = provider.CreateCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandText = "drop table " + tableName;
                    cmd.ExecuteNonQuery();
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Allows you to load a specific record of the [tblOrder] table.
        /// </summary>
        /// <param name="col_Ord_GuidID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Ord_GuidID&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlGuid col_Ord_GuidID)
        {
            bool Status;

            Reset();

            if (col_Ord_GuidID.IsNull)
            {
                throw new ArgumentNullException("col_Ord_GuidID", "The primary key 'col_Ord_GuidID' can not have a Null value!");
            }


            this.col_Ord_GuidID = col_Ord_GuidID;

            this.Param.Reset();

            this.Param.Param_Ord_GuidID = this.col_Ord_GuidID;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_tblOrder SP = new SPs.spS_tblOrder(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex))
                    {
                        this.col_Ord_DatOrderedOn = DR.GetSqlDateTime(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex))
                    {
                        this.col_Ord_LngCustomerID = DR.GetSqlInt32(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex))
                    {
                        this.col_Ord_CurTotal = DR.GetSqlMoney(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex);
                    }

                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new OlymarsDemo.DataClasses.CustomException(this.Param, "OlymarsDemo.AbstractClasses.Abstract_tblOrder", "Refresh");
            }
        }
Пример #16
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string Language = "en-US";

            if (Request.UserLanguages.Length != 0)
            {
                Language = Request.UserLanguages[0];
            }

            CurrentUserCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Language);
            System.Threading.Thread.CurrentThread.CurrentUICulture = CurrentUserCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture   = CurrentUserCulture;

            /*
             *      Add the following in your web.config file
             *      <appSettings>
             *              <add key="OlymarsDemo ConnectionString" value="Data Source=localhost; Initial Catalog=OlymarsDemo; Integrated Security=SSPI" />
             *      </appSettings>
             */
            if (ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"] != null)
            {
                ConnectionString = ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"];
            }

            else if (Application["ConnectionString"] != null)
            {
                ConnectionString = Application["ConnectionString"].ToString().Trim();
            }

            else
            {
                ConnectionString = String.Empty;
            }

            if (!Page.IsPostBack)
            {
                if (Request.Params["ReturnToUrl"] != null)
                {
                    ReturnURL.NavigateUrl = Request.Params["ReturnToUrl"].ToString();
                    if (Request.Params["ReturnToDisplay"] != null)
                    {
                        ReturnURL.Text = Request.Params["ReturnToDisplay"].ToString();
                    }
                    ReturnURL.Visible = true;
                }
            }

            labError_Oit_LngAmount.Visible = false;

            if (Request.Params["Action"] != null)
            {
                switch (Request.Params["Action"].ToString())
                {
                case "Add":
                    Action    = ActionEnum.Add;
                    CurrentID = System.Data.SqlTypes.SqlGuid.Null;
                    break;

                case "Edit":
                    Action = ActionEnum.Edit;
                    object ID = Request.Params["ID"];

                    if (ID != null)
                    {
                        try {
                            CurrentID = new Guid(Request.Params["ID"].ToString());
                        }
                        catch {
                            MainDisplay.Visible  = false;
                            ErrorDisplay.Visible = true;
                            lab_Error.Text       = "ERROR: Action=Edit-> ID supplied is not a valid Guid";
                            return;
                        }
                    }
                    else
                    {
                        MainDisplay.Visible  = false;
                        ErrorDisplay.Visible = true;
                        lab_Error.Text       = "ERROR: Action=Edit-> No ID was supplied";
                        return;
                    }
                    break;

                case "Delete":
                    Action = ActionEnum.Delete;
                    if (Request.Params["ID"] != null)
                    {
                        try {
                            CurrentID = new Guid(Request.Params["ID"].ToString());
                        }
                        catch {
                            MainDisplay.Visible  = false;
                            ErrorDisplay.Visible = true;
                            lab_Error.Text       = "ERROR: Action=Edit-> ID supplied is not a valid Int32";
                            return;
                        }
                        cmdDelete_Click(null, null);
                        return;
                    }
                    else
                    {
                        MainDisplay.Visible  = false;
                        ErrorDisplay.Visible = true;
                        lab_Error.Text       = "ERROR: Action=Delete-> No ID was supplied";
                        return;
                    }

                default:
                    Action               = ActionEnum.None;
                    CurrentID            = System.Data.SqlTypes.SqlGuid.Null;
                    MainDisplay.Visible  = false;
                    ErrorDisplay.Visible = true;
                    lab_Error.Text       = "ERROR: Action must be Add, Edit Or Delete";
                    return;
                }

                if (!Page.IsPostBack)
                {
                    RefreshAll();
                }
            }

            else
            {
                MainDisplay.Visible  = false;
                ErrorDisplay.Visible = true;
                lab_Error.Text       = "ERROR: No Action was supplied";
            }
        }
Пример #17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string Language = "en-US";

            if (Request.UserLanguages.Length != 0)
            {
                Language = Request.UserLanguages[0];
            }

            CurrentUserCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Language);

            if (ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"] != null)
            {
                ConnectionString = ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"];
            }
            else if (Application["ConnectionString"] != null)
            {
                ConnectionString = Application["ConnectionString"].ToString().Trim();
            }

            if (!Page.IsPostBack)
            {
                // com_Oit_GuidOrderID
                System.Data.SqlTypes.SqlGuid colOit_GuidOrderID = System.Data.SqlTypes.SqlGuid.Null;
                if (Request.Params["Oit_GuidOrderID"] != String.Empty)
                {
                    try {
                        colOit_GuidOrderID = System.Data.SqlTypes.SqlGuid.Parse(Request.Params["Oit_GuidOrderID"]);
                    }
                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }
                com_Oit_GuidOrderID.Initialize(ConnectionString, System.Data.SqlTypes.SqlInt32.Null);
                try {
                    com_Oit_GuidOrderID.RefreshData(colOit_GuidOrderID);
                }
                catch (OlymarsDemo.DataClasses.CustomException customException) {
                    if (customException.Parameter.SqlException != null)
                    {
                        throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblOrder' class. Exception message is: {0}", customException.Parameter.SqlException.Message), customException);
                    }
                    else if (customException.Parameter.OtherException != null)
                    {
                        throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblOrder' class. Exception message is: {0}", customException.Parameter.OtherException.Message), customException);
                    }
                    else
                    {
                        throw;
                    }
                }
                com_Oit_GuidOrderID.Items.Insert(0, "Show all");

                // com_Oit_GuidProductID
                System.Data.SqlTypes.SqlGuid colOit_GuidProductID = System.Data.SqlTypes.SqlGuid.Null;
                if (Request.Params["Oit_GuidProductID"] != String.Empty)
                {
                    try {
                        colOit_GuidProductID = System.Data.SqlTypes.SqlGuid.Parse(Request.Params["Oit_GuidProductID"]);
                    }
                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }
                com_Oit_GuidProductID.Initialize(ConnectionString, System.Data.SqlTypes.SqlInt32.Null);
                try {
                    com_Oit_GuidProductID.RefreshData(colOit_GuidProductID);
                }
                catch (OlymarsDemo.DataClasses.CustomException customException) {
                    if (customException.Parameter.SqlException != null)
                    {
                        throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblProduct' class. Exception message is: {0}", customException.Parameter.SqlException.Message), customException);
                    }
                    else if (customException.Parameter.OtherException != null)
                    {
                        throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblProduct' class. Exception message is: {0}", customException.Parameter.OtherException.Message), customException);
                    }
                    else
                    {
                        throw;
                    }
                }
                com_Oit_GuidProductID.Items.Insert(0, "Show all");

                // Any sort preferences?
                CurrentSortEnum sortColumn = CurrentSortEnum.SortBy_Oit_GuidOrderID;
                if (Request.Params["SortBy"] != String.Empty)
                {
                    try {
                        sortColumn = (CurrentSortEnum)Enum.Parse(typeof(CurrentSortEnum), "SortBy_" + Request.Params["SortBy"]);
                    }

                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }

                SortOrderEnum sortOrder = SortOrderEnum.Ascending;
                if (Request.Params["SortOrder"] != String.Empty)
                {
                    try {
                        sortOrder = (SortOrderEnum)Enum.Parse(typeof(SortOrderEnum), Request.Params["SortOrder"]);
                    }

                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }

                if (ViewState["WebFormList_tblOrderItem_CurrentSort"] == null)
                {
                    ViewState.Add("WebFormList_tblOrderItem_CurrentSort", sortColumn);
                }
                else
                {
                    ViewState["WebFormList_tblOrderItem_CurrentSort"] = sortColumn;
                }

                if (ViewState["sortOrder"] == null)
                {
                    ViewState.Add("sortOrder", sortOrder);
                }
                else
                {
                    ViewState["sortOrder"] = sortOrder;
                }
            }

            repeater_tblOrderItem_SelectDisplay.EnableViewState = true;

            RefreshList();
        }
Пример #18
0
        private void RefreshList()
        {
            System.Data.SqlTypes.SqlGuid Oit_GuidOrderID = System.Data.SqlTypes.SqlGuid.Null;
            if (com_Oit_GuidOrderID.SelectedIndex != 0)
            {
                Oit_GuidOrderID = new System.Data.SqlTypes.SqlGuid(new System.Guid(com_Oit_GuidOrderID.SelectedItem.Value));
            }

            System.Data.SqlTypes.SqlGuid Oit_GuidProductID = System.Data.SqlTypes.SqlGuid.Null;
            if (com_Oit_GuidProductID.SelectedIndex != 0)
            {
                Oit_GuidProductID = new System.Data.SqlTypes.SqlGuid(new System.Guid(com_Oit_GuidProductID.SelectedItem.Value));
            }

            repeater_tblOrderItem_SelectDisplay.Initialize(ConnectionString, System.Data.SqlTypes.SqlGuid.Null, Oit_GuidOrderID, Oit_GuidProductID);
            try {
                repeater_tblOrderItem_SelectDisplay.RefreshData();
            }
            catch (OlymarsDemo.DataClasses.CustomException customException) {
                if (customException.Parameter.SqlException != null)
                {
                    throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebRepeater_tblOrderItem' class. Exception message is: {0}", customException.Parameter.SqlException.Message), customException);
                }
                else if (customException.Parameter.OtherException != null)
                {
                    throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebRepeater_tblOrderItem' class. Exception message is: {0}", customException.Parameter.OtherException.Message), customException);
                }
                else
                {
                    throw;
                }
            }
            System.Data.DataView dataView = (System.Data.DataView)repeater_tblOrderItem_SelectDisplay.DataSource;

            string SortDirective = String.Empty;

            switch ((CurrentSortEnum)ViewState["WebFormList_tblOrderItem_CurrentSort"])
            {
            case CurrentSortEnum.SortBy_Oit_GuidOrderID:
                SortDirective = spS_tblOrderItem_SelectDisplay.Resultset1.Fields.Column_Oit_GuidOrderID_Display.ColumnName;
                break;

            case CurrentSortEnum.SortBy_Oit_GuidProductID:
                SortDirective = spS_tblOrderItem_SelectDisplay.Resultset1.Fields.Column_Oit_GuidProductID_Display.ColumnName;
                break;

            case CurrentSortEnum.SortBy_Oit_LngAmount:
                SortDirective = spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnName;
                break;
            }

            switch ((SortOrderEnum)ViewState["sortOrder"])
            {
            case SortOrderEnum.Ascending:
                SortDirective += " ASC";
                break;

            case SortOrderEnum.Descending:
                SortDirective += " DESC";
                break;
            }

            dataView.Sort = SortDirective;
            repeater_tblOrderItem_SelectDisplay.DataBind();
        }
Пример #19
0
        /// <summary>
        /// Load or reloads a subset of the table content. You can specify which record you want to be selected
        /// by default. In order to successfully call this method, you need to call first the Initialize method.
        /// </summary>
        /// <param name="PK_Oit_GuidID">Primary key of the record you want to be selected by default.</param>
        /// <param name="startRecord">The zero-based record number to start with.</param>
        /// <param name="maxRecords">The maximum number of records to retrieve.</param>
        public void RefreshData(System.Data.SqlTypes.SqlGuid PK_Oit_GuidID, int startRecord, int maxRecords)
        {
            if (!PK_Oit_GuidID.IsNull && this.SelectionMode == System.Windows.Forms.SelectionMode.None)
            {
                throw new ArgumentException("You cannot supply a value to this parameter when SelectionMode property is set to None.", "PK_Oit_GuidID");
            }

            if (this.LastKnownConnectionType == OlymarsDemo.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }

            this.param = new Params.spS_tblOrderItem_Display(true);

            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;

            default:
                throw new InvalidOperationException("This control has not been initialized. You must call the Initialize method before calling this method.");
            }

            this.param.Param_Oit_GuidOrderID   = this.FK_Oit_GuidOrderID;
            this.param.Param_Oit_GuidProductID = this.FK_Oit_GuidProductID;

            System.Data.DataSet DS = null;

            SPs.spS_tblOrderItem_Display SP = new SPs.spS_tblOrderItem_Display(false);

            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.BeginUpdate();
                this.bindingInProgress = true;
                this.DataSource        = DS.Tables["spS_tblOrderItem_Display"].DefaultView;
                this.ValueMember       = SPs.spS_tblOrderItem_Display.Resultset1.Fields.Column_ID1.ColumnName;
                this.DisplayMember     = SPs.spS_tblOrderItem_Display.Resultset1.Fields.Column_Display.ColumnName;
                this.bindingInProgress = false;

                if (!PK_Oit_GuidID.IsNull)
                {
                    this.SelectedValue = PK_Oit_GuidID.Value;
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }

                this.EndUpdate();
                SP.Dispose();
            }
            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WinListBox_tblOrderItem : System.Windows.Forms.ListBox", "RefreshData");
            }
        }
Пример #20
0
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblSupplierProduct class.
 /// </summary>
 /// <param name="sqlConnection">A valid System.Data.SqlClient.SqlConnection to the database.</param>
 /// <param name="FK_Spr_GuidProductID">Value for this foreign key.</param>
 /// <param name="FK_Spr_GuidSupplierID">Value for this foreign key.</param>
 /// <param name="tableName">Table name to be use in the DataSet.</param>
 public SqlDataAdapter_tblSupplierProduct(System.Data.SqlClient.SqlConnection sqlConnection, System.Data.SqlTypes.SqlGuid FK_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid FK_Spr_GuidSupplierID, string tableName) : this(sqlConnection) {
     this.Configure(FK_Spr_GuidProductID, FK_Spr_GuidSupplierID, tableName);
 }
Пример #21
0
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_Spr_GuidProductID  = System.Data.SqlTypes.SqlGuid.Null;
     this.col_Spr_GuidSupplierID = System.Data.SqlTypes.SqlGuid.Null;
 }
Пример #22
0
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblSupplierProduct class.
 /// The table name in the DataSet will be: tblSupplierProduct
 /// </summary>
 /// <param name="connectionString">A valid connection string to the database.</param>
 /// <param name="FK_Spr_GuidProductID">Value for this foreign key.</param>
 /// <param name="FK_Spr_GuidSupplierID">Value for this foreign key.</param>
 public SqlDataAdapter_tblSupplierProduct(string connectionString, System.Data.SqlTypes.SqlGuid FK_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid FK_Spr_GuidSupplierID) : this(connectionString) {
     this.Configure(FK_Spr_GuidProductID, FK_Spr_GuidSupplierID, "tblSupplierProduct");
 }
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="connectionString">[To be supplied.]</param>
        /// <param name="col_Oit_GuidOrderID">[To be supplied.]</param>
        /// <param name="col_Oit_GuidProductID">[To be supplied.]</param>
        public tblOrderItem_Collection(string connectionString, System.Data.SqlTypes.SqlGuid col_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid col_Oit_GuidProductID)
        {
#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                string DebugConnectionString = connectionString;

                if (DebugConnectionString == System.String.Empty)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromConfigurationFile;
                }

                if (DebugConnectionString == System.String.Empty)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromRegistry;
                }

                if (DebugConnectionString != String.Empty)
                {
                    System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(DebugConnectionString);

                    sqlConnection.Open();

                    System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                    sqlCommand.CommandType = System.Data.CommandType.Text;
                    sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'tblOrderItem'";

                    int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                    sqlConnection.Close();

                    int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                    if (CurrentRevision != OriginalRevision)
                    {
                        throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}", "tblOrderItem", CurrentRevision, OriginalRevision));
                    }
                }
            }
#endif

            this.connectionString        = connectionString;
            this.lastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.ConnectionString;

            this.col_Oit_GuidOrderID   = col_Oit_GuidOrderID;
            this.col_Oit_GuidProductID = col_Oit_GuidProductID;
        }
Пример #24
0
 /// <summary>
 /// Configures the SqlDataAdapter.
 /// The table name in the DataSet will be: tblSupplierProduct
 /// </summary>
 /// <param name="FK_Spr_GuidProductID">Value for this foreign key.</param>
 /// <param name="FK_Spr_GuidSupplierID">Value for this foreign key.</param>
 public void Configure(System.Data.SqlTypes.SqlGuid FK_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid FK_Spr_GuidSupplierID)
 {
     this.Configure(FK_Spr_GuidProductID, FK_Spr_GuidSupplierID, "tblSupplierProduct");
 }
 /// <summary>
 /// Creates and configures a new instance of the SqlDataAdapter_tblOrderItem class.
 /// </summary>
 /// <param name="sqlConnection">A valid System.Data.SqlClient.SqlConnection to the database.</param>
 /// <param name="FK_Oit_GuidOrderID">Value for this foreign key.</param>
 /// <param name="FK_Oit_GuidProductID">Value for this foreign key.</param>
 /// <param name="tableName">Table name to be use in the DataSet.</param>
 public SqlDataAdapter_tblOrderItem(System.Data.SqlClient.SqlConnection sqlConnection, System.Data.SqlTypes.SqlGuid FK_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid FK_Oit_GuidProductID, string tableName) : this(sqlConnection) {
     this.Configure(FK_Oit_GuidOrderID, FK_Oit_GuidProductID, tableName);
 }
 /// <summary>
 /// Load or reloads all the table content. You can specify which record you want to be selected by default.
 /// In order to successfully call this method, you need to call first the Initialize method.
 /// </summary>
 /// <param name="PK_Sup_GuidID">Primary key of the record you want to be selected by default.</param>
 public void RefreshData(System.Data.SqlTypes.SqlGuid PK_Sup_GuidID)
 {
     this.RefreshData(PK_Sup_GuidID, -1, -1);
 }
Пример #27
0
 /// <summary>
 /// Allows you to pre-select a value for the 'Oit_GuidOrderID' column.
 /// </summary>
 public void SetValue_Oit_GuidOrderID(System.Data.SqlTypes.SqlGuid value)
 {
     this.hasBeenPopulated_Oit_GuidOrderID = true;
     this.internal_Oit_GuidOrderID         = value;
 }
        /// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the 'spS_tblOrderItem' stored procedure parameters.
        /// </summary>
        /// <param name="connectionString">A valid connection string to the database.</param>
        /// <param name="valueMember">name of the field to be used as a primary key.</param>
        /// <param name="displayMember">name of the field to be used for the content display.</param>
        /// <param name="param_Oit_GuidID">Value for the parameter @Oit_GuidID.</param>
        /// <param name="param_Oit_GuidOrderID">Value for the parameter @Oit_GuidOrderID.</param>
        /// <param name="param_Oit_GuidProductID">Value for the parameter @Oit_GuidProductID.</param>
        public void Initialize(string connectionString, string valueMember, string displayMember, System.Data.SqlTypes.SqlGuid param_Oit_GuidID, System.Data.SqlTypes.SqlGuid param_Oit_GuidOrderID, System.Data.SqlTypes.SqlGuid param_Oit_GuidProductID)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString", "connectionString can be an empty string but can not be null.");
            }

            this.connectionString        = connectionString;
            this.LastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.ConnectionString;

#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                string DebugConnectionString = connectionString;

                if (DebugConnectionString.Length == 0)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromConfigurationFile;
                }

                if (DebugConnectionString.Length == 0)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromRegistry;
                }

                if (DebugConnectionString.Length != 0)
                {
                    System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(DebugConnectionString);

                    sqlConnection.Open();

                    System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                    sqlCommand.CommandType = System.Data.CommandType.Text;
                    sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'spS_tblOrderItem'";

                    int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                    sqlConnection.Close();

                    int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                    if (CurrentRevision != OriginalRevision)
                    {
                        throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}{3}{3}You can either regenerate the code for this class so that it will be based on the new version or edit the configuration file of the class caller application and paste the following code:{3}{3}<?xml version=\"1.0\" encoding=\"utf-8\" ?>{3}<configuration>{3}\t<appSettings>{3}\t\t<add key=\"OlymarsDebugCheck\" value=\"False\" />{3}\t</appSettings>{3}</configuration>{3}{3}You will need to reload the caller application if it is a Windows Forms based application.", "spS_tblOrderItem", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                    }
                }
            }
#endif

            this.valueMember   = valueMember;
            this.displayMember = displayMember;
            this.tableName     = "spS_tblOrderItem";

            this.param_Oit_GuidID        = param_Oit_GuidID;
            this.param_Oit_GuidOrderID   = param_Oit_GuidOrderID;
            this.param_Oit_GuidProductID = param_Oit_GuidProductID;
        }
Пример #29
0
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_Sup_GuidID  = System.Data.SqlTypes.SqlGuid.Null;
     this.col_Sup_StrName = System.Data.SqlTypes.SqlString.Null;
 }