Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the 'spS_tblSupplierProduct_Full' 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="param_Spr_GuidProductID">Value for the parameter @Spr_GuidProductID.</param>
        /// <param name="param_Spr_GuidSupplierID">Value for the parameter @Spr_GuidSupplierID.</param>
        public void Initialize(System.Data.SqlClient.SqlConnection sqlConnection, string valueMember, string displayMember, System.Data.SqlTypes.SqlGuid param_Spr_GuidProductID, System.Data.SqlTypes.SqlGuid param_Spr_GuidSupplierID)
        {
            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_tblSupplierProduct_Full'";

                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_tblSupplierProduct_Full", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                }
            }
#endif

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

            this.param_Spr_GuidProductID  = param_Spr_GuidProductID;
            this.param_Spr_GuidSupplierID = param_Spr_GuidSupplierID;
        }
        /// <summary>
        /// Creates a new instance of the SqlDataAdapter_tblOrderItem class.
        /// In this constructor version, the SqlDataAdapter is not pre-configured. You need
        /// to call the Configure method before calling the FillDataSet method.
        /// </summary>
        /// <param name="sqlTransaction">A valid System.Data.SqlClient.SqlTransaction to the database.</param>
        public SqlDataAdapter_tblOrderItem(System.Data.SqlClient.SqlTransaction sqlTransaction)
        {
            if (sqlTransaction == null || sqlTransaction.Connection == null)
            {
                throw new ArgumentNullException("sqlTransaction", "Invalid transaction!");
            }

            this.sqlTransaction          = sqlTransaction;
            this.lastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlTransaction;

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

                System.Data.SqlClient.SqlCommand sqlCommand = sqlTransaction.Connection.CreateCommand();

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

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

                if (NotAlreadyOpened)
                {
                    sqlTransaction.Connection.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.", "tblOrderItem", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                }
            }
#endif
        }
        /// <summary>
        /// Allows you to add a new record in the tblCustomer 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>
        public void AddNewRecord(System.Windows.Forms.IWin32Window caller, string formTitle, System.Data.SqlClient.SqlConnection sqlConnection)
        {
            this.Text = formTitle;

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

            RequestForeignTables();
            EmptyControls();

            this.Control_Cus_StrLastName.HandleTextChanged(null, null);
            this.Control_Cus_StrFirstName.HandleTextChanged(null, null);
            this.Control_Cus_StrEmail.HandleTextChanged(null, null);

            Check_cmdOK_Button(null);

            ProcessHiddenAndDisabledControlStatus(true);

            this.ShowDialog(caller);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allows you to update an existing record from the tblCategory 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.SqlInt32 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);
        }