/// <summary>
        /// Loads the tblProduct abstract class for the current selected record primary key.
        /// </summary>
        /// <returns>true if the call succeeded; false, otherwise.</returns>
        public bool RefreshCurrentRecord()
        {
            if (this.SelectedIndex == -1)
            {
                if (oAbstract_tblProduct != null)
                {
                    oAbstract_tblProduct.Reset();
                }
                return(false);
            }

            System.Data.SqlTypes.SqlGuid PK_Pro_GuidID = new Guid(this.SelectedItem.Value);

            if (this.oAbstract_tblProduct == null)
            {
                switch (this.LastKnownConnectionType)
                {
                case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                    this.oAbstract_tblProduct = new OlymarsDemo.AbstractClasses.Abstract_tblProduct(this.connectionString);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                    this.oAbstract_tblProduct = new OlymarsDemo.AbstractClasses.Abstract_tblProduct(this.sqlConnection);
                    break;
                }
            }

            return(this.oAbstract_tblProduct.Refresh(PK_Pro_GuidID));
        }
        /// <summary>
        /// Loads the tblProduct abstract class for the current selected record primary key.
        /// </summary>
        /// <returns>true if the call succeeded; false, otherwise.</returns>
        public bool RefreshCurrentRecord()
        {
            if (this.SelectionMode != System.Windows.Forms.SelectionMode.One)
            {
                throw new InvalidOperationException("SelectionMode property is not set to One. Hence, you cannot call this method.");
            }

            if (this.SelectedIndex == -1)
            {
                if (oAbstract_tblProduct != null)
                {
                    oAbstract_tblProduct.Reset();
                }
                return(false);
            }

            System.Data.SqlTypes.SqlGuid PK_Pro_GuidID = (System.Guid) this.SelectedValue;

            if (this.oAbstract_tblProduct == null)
            {
                switch (this.LastKnownConnectionType)
                {
                case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                    this.oAbstract_tblProduct = new OlymarsDemo.AbstractClasses.Abstract_tblProduct(this.connectionString);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                    this.oAbstract_tblProduct = new OlymarsDemo.AbstractClasses.Abstract_tblProduct(this.sqlConnection);
                    break;
                }
            }

            return(this.oAbstract_tblProduct.Refresh(PK_Pro_GuidID));
        }
        /// <summary>
        /// Disposes the current instance of this object.
        /// </summary>
        public override void Dispose()
        {
            this.oAbstract_tblProduct = null;

            this.FK_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null;

            if (this.param != null)
            {
                this.param.Dispose();
            }

            base.Dispose();
        }
        /// <summary>
        /// Disposes the current instance of this object.
        /// </summary>
        /// <param name="disposing">
        /// true to release both managed and unmanaged resources;
        /// false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.oAbstract_tblProduct = null;

                this.FK_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null;

                if (this.param != null)
                {
                    this.param.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Example #5
0
        private bool RefreshCurrentRecord()
        {
            EmptyControls();

            Abstracts.Abstract_tblProduct oAbstract_tblProduct = null;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                oAbstract_tblProduct = new Abstracts.Abstract_tblProduct(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                oAbstract_tblProduct = new Abstracts.Abstract_tblProduct(this.sqlConnection);
                break;
            }

            if (oAbstract_tblProduct.Refresh(this.currentID))
            {
                this.IgnoreChanges = true;

                if (!oAbstract_tblProduct.Col_Pro_StrName.IsNull)
                {
                    Control_Pro_StrName.Text = oAbstract_tblProduct.Col_Pro_StrName.Value.ToString();
                }


                if (!oAbstract_tblProduct.Col_Pro_CurPrice.IsNull)
                {
                    Control_Pro_CurPrice.Text = oAbstract_tblProduct.Col_Pro_CurPrice.Value.ToString();
                }


                if (!oAbstract_tblProduct.Col_Pro_LngCategoryID.IsNull)
                {
                    Control_Pro_LngCategoryID.SelectedValue = oAbstract_tblProduct.Col_Pro_LngCategoryID.Value;
                }

                this.IgnoreChanges = false;
                return(true);
            }

            else
            {
                MessageBox.Show("The record does not exist any more !", "Record not found", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
        }