Example #1
0
        /// <summary>
        /// Gets the value of the specified text column as an <see cref="System.Enum"/>.
        /// </summary>
        /// <param name="sqlDr">The data reader.</param>
        /// <param name="name">The column name.</param>
        /// <typeparam name="TEnum">The type of enum.</typeparam>
        public static TEnum?GetSqlEnum <TEnum>(this SqlDataReader sqlDr, string name)
            where TEnum : struct, IComparable, IFormattable, IConvertible // We cannot directly constrain by Enum, so approximate by constraining on Enum's implementation
        {
            if (sqlDr is null)
            {
                throw new ArgumentNullException(nameof(sqlDr));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var ord = sqlDr.GetOrdinal(name); // Throws IndexOutOfRangeException

            System.Data.SqlTypes.SqlString val = sqlDr.GetSqlString(ord);

            if (val.IsNull)
            {
                return(null);
            }

            var e = (TEnum)Enum.Parse(typeof(TEnum), val.Value, true);

            return(e);
        }
        private void PerformSearch()
        {
//			if (this.txtContactName.Text.Trim().Length == 0 && this.txtCompanyName.Text.Trim().Length == 0)
//			{
//				MessageBox.Show(this, "Please Enter Search Criteria", "Error");
//				this.txtContactName.Select();
//				return;
//			}

            this.Cursor = Cursors.WaitCursor;

            System.Data.SqlTypes.SqlString CompanyName = new System.Data.SqlTypes.SqlString("%");
            System.Data.SqlTypes.SqlString ContactName = new System.Data.SqlTypes.SqlString("%");

            if (this.txtCompanyName.Text.Trim().Length != 0)
            {
                CompanyName = new System.Data.SqlTypes.SqlString(this.txtCompanyName.Text + "%");
            }

            if (this.txtContactName.Text.Trim().Length != 0)
            {
                ContactName = new System.Data.SqlTypes.SqlString(this.txtContactName.Text + "%");
            }

            this.winListBoxCustom_spS_xSearchCustomer1.Initialize(this.ConnectionString, "ID1", "Display", CompanyName, ContactName);
            this.winListBoxCustom_spS_xSearchCustomer1.RefreshData();
            this.Cursor = Cursors.Default;

//			if (this.winListBoxCustom_spS_xSearchCustomer1.Items.Count==0)
//			{
//				((Bob.Windows.Forms.MDI) this.MdiParent).ShowNotification("No Customers found with the current Search criteria!");
//			}
        }
Example #3
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_Cus_LngID        = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Cus_StrLastName  = System.Data.SqlTypes.SqlString.Null;
     this.col_Cus_StrFirstName = System.Data.SqlTypes.SqlString.Null;
     this.col_Cus_StrEmail     = System.Data.SqlTypes.SqlString.Null;
 }
Example #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_JobId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_JobId_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Description = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Description_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Price = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_Price_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_StartDate = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_StartDate_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_EndDate = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_EndDate_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_CustomerId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_CustomerId_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_Pro_GuidID        = System.Data.SqlTypes.SqlGuid.Null;
     this.col_Pro_StrName       = System.Data.SqlTypes.SqlString.Null;
     this.col_Pro_CurPrice      = System.Data.SqlTypes.SqlMoney.Null;
     this.col_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null;
 }
Example #6
0
        /// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the 'spS_xSearchCustomer' 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_LastName">Value for the parameter @LastName.</param>
        /// <param name="param_FirstName">Value for the parameter @FirstName.</param>
        public void Initialize(string connectionString, string valueMember, string displayMember, System.Data.SqlTypes.SqlString param_LastName, System.Data.SqlTypes.SqlString param_FirstName)
        {
            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_xSearchCustomer'";

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

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

            this.param_LastName  = param_LastName;
            this.param_FirstName = param_FirstName;
        }
Example #7
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_JobId       = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Description = System.Data.SqlTypes.SqlString.Null;
     this.col_Price       = System.Data.SqlTypes.SqlMoney.Null;
     this.col_StartDate   = System.Data.SqlTypes.SqlDateTime.Null;
     this.col_EndDate     = System.Data.SqlTypes.SqlDateTime.Null;
     this.col_CustomerId  = System.Data.SqlTypes.SqlInt32.Null;
 }
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_JobPartId     = System.Data.SqlTypes.SqlInt32.Null;
     this.col_JobId         = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Description   = System.Data.SqlTypes.SqlString.Null;
     this.col_JobPartTypeId = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Units         = System.Data.SqlTypes.SqlDecimal.Null;
     this.col_PricePerUnit  = System.Data.SqlTypes.SqlMoney.Null;
     this.col_TotalPrice    = System.Data.SqlTypes.SqlMoney.Null;
 }
Example #9
0
        public static System.Data.SqlTypes.SqlBytes GenerateQR(System.Data.SqlTypes.SqlString qrCodeText)
        {
            if (qrCodeText.IsNull)
            {
                return(null);
            }

            // return new System.Data.SqlTypes.SqlBytes(System.Text.Encoding.UTF8.GetBytes(qrCodeText.Value));
            return(new System.Data.SqlTypes.SqlBytes(GenerateQrCode(qrCodeText.Value)));
        }
Example #10
0
        /// <summary>
        /// Disposes the current instance of this object.
        /// </summary>
        public override void Dispose()
        {
            this.param_LastName  = System.Data.SqlTypes.SqlString.Null;
            this.param_FirstName = System.Data.SqlTypes.SqlString.Null;
            if (this.param != null)
            {
                this.param.Dispose();
            }

            base.Dispose();
        }
Example #11
0
        public static Product GetProductByProductId(int productId)
        {
            try
            {
                Product    productReturn = null;
                SqlCommand command       = new SqlCommand();
                command.CommandText = "ViewProduct";
                command.Connection  = DatabaseFactory.GetConnection(DatabaseFactory.SQL_TYPE_MSSQL).GetConnection();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@product_id", Int32.Parse(productId.ToString()));
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    productReturn              = new Product();
                    productReturn.ProductId    = reader.GetInt32(0);
                    productReturn.ProductName  = reader.GetString(1);
                    productReturn.ProductPrice = float.Parse(reader.GetValue(2).ToString());
                    System.Data.SqlTypes.SqlString desc = (System.Data.SqlTypes.SqlString)reader.GetSqlValue(3);
                    if (desc.IsNull)
                    {
                        productReturn.ProductDescription = "N/A";
                    }
                    else
                    {
                        productReturn.ProductDescription = String.Format(desc.Value);
                    }
                    System.Data.SqlTypes.SqlInt32 disc = (System.Data.SqlTypes.SqlInt32)reader.GetSqlValue(4);

                    if (disc.IsNull)
                    {
                        productReturn.ProductDiscount = 0;
                    }
                    else
                    {
                        productReturn.ProductDiscount = disc.Value;
                    }

                    productReturn.ProductImageURL = reader.GetString(5);
                    productReturn.ProductInStock  = reader.GetInt32(6);
                    reader.Close();
                }
                else
                {
                    throw new Exception("Product Id not exits");
                }
                return(productReturn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #12
0
        public static List <Product> GetRandomProduct(int resultCount)
        {
            try
            {
                Dictionary <string, object> listKV = new Dictionary <string, object>();
                List <Product> listReturn          = new List <Product>();

                listKV.Add("@total_item", resultCount);
                SqlDataReader reader = DatabaseFactory.DataReader(CommandType.StoredProcedure, "GetRandomProduct", listKV, DatabaseFactory.GetConnection(DatabaseFactory.SQL_TYPE_MSSQL).GetConnection());

                while (reader.Read())
                {
                    Product product = new Product();
                    product              = new Product();
                    product.ProductId    = reader.GetInt32(0);
                    product.ProductName  = reader.GetString(1);
                    product.ProductPrice = float.Parse(reader.GetValue(2).ToString());
                    System.Data.SqlTypes.SqlString desc = (System.Data.SqlTypes.SqlString)reader.GetSqlValue(3);
                    if (desc.IsNull)
                    {
                        product.ProductDescription = "N/A";
                    }
                    else
                    {
                        product.ProductDescription = String.Format(desc.Value);
                    }

                    System.Data.SqlTypes.SqlInt32 disc = (System.Data.SqlTypes.SqlInt32)reader.GetSqlValue(4);
                    if (disc.IsNull)
                    {
                        product.ProductDiscount = 0;
                    }
                    else
                    {
                        product.ProductDiscount = disc.Value;
                    }

                    product.ProductImageURL = reader.GetString(5);
                    product.ProductInStock  = reader.GetInt32(6);
                    listReturn.Add(product);
                }


                reader.Close();

                return(listReturn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        public static List <Product> GetListProductByCategoryId(int categoryId, int currentPage)
        {
            try
            {
                Dictionary <string, object> listKV = new Dictionary <string, object>();
                listKV.Add("@categoryId", categoryId);
                listKV.Add("@currPage", currentPage);
                listKV.Add("@recodperpage", PRODUCT_STATISTIC_PAGE_SIZE);
                SqlDataReader reader = DatabaseFactory.DataReader(CommandType.StoredProcedure, "GetPageProductByCategory", listKV, DatabaseFactory.GetConnection(DatabaseFactory.SQL_TYPE_MSSQL).GetConnection());

                List <Product> listProductReturn = new List <Product>();

                while (reader.Read())
                {
                    Product product = new Product();
                    product              = new Product();
                    product.ProductId    = reader.GetInt32(1);
                    product.ProductName  = reader.GetString(2);
                    product.ProductPrice = float.Parse(reader.GetValue(3).ToString());
                    System.Data.SqlTypes.SqlString desc = (System.Data.SqlTypes.SqlString)reader.GetSqlValue(4);
                    if (desc.IsNull)
                    {
                        product.ProductDescription = "N/A";
                    }
                    else
                    {
                        product.ProductDescription = String.Format(desc.Value);
                    }

                    System.Data.SqlTypes.SqlInt32 disc = (System.Data.SqlTypes.SqlInt32)reader.GetSqlValue(5);
                    if (disc.IsNull)
                    {
                        product.ProductDiscount = 0;
                    }
                    else
                    {
                        product.ProductDiscount = disc.Value;
                    }

                    product.ProductImageURL = reader.GetString(6);
                    product.ProductInStock  = reader.GetInt32(7);
                    listProductReturn.Add(product);
                }
                reader.Close();
                return(listProductReturn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
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_TitleId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_TitleId_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Title = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Title_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
        /// <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.param_CompanyName = System.Data.SqlTypes.SqlString.Null;
                this.param_ContactName = System.Data.SqlTypes.SqlString.Null;
                if (this.param != null)
                {
                    this.param.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Example #16
0
        public static MyUdfType Parse(System.Data.SqlTypes.SqlString s)
        {
            if (s.IsNull || string.IsNullOrEmpty(s.Value))
            {
                return(new MyUdfType());
            }

            var ff     = new MyUdfType();
            var buffer = new MemoryStream(Encoding.UTF8.GetBytes(s.Value));
            var binRdr = new BinaryReader(buffer);

            ff.Read(binRdr);
            return(ff);
        }
Example #17
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_CustomerID  = System.Data.SqlTypes.SqlInt32.Null;
     this.col_CompanyName = System.Data.SqlTypes.SqlString.Null;
     this.col_ContactName = System.Data.SqlTypes.SqlString.Null;
     this.col_TitleId     = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Address     = System.Data.SqlTypes.SqlString.Null;
     this.col_City        = System.Data.SqlTypes.SqlString.Null;
     this.col_PostalCode  = System.Data.SqlTypes.SqlString.Null;
     this.col_Phone       = System.Data.SqlTypes.SqlString.Null;
     this.col_Email       = System.Data.SqlTypes.SqlString.Null;
     this.col_WebAddress  = System.Data.SqlTypes.SqlString.Null;
     this.col_Fax         = System.Data.SqlTypes.SqlString.Null;
     this.col_Active      = System.Data.SqlTypes.SqlBoolean.Null;
 }
Example #18
0
        public static System.Data.SqlTypes.SqlString Md5Hash(System.Data.SqlTypes.SqlString input)
        {
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();

            byte[] data = md5.ComputeHash(Encoding.Default.GetBytes(input.Value));

            StringBuilder s_builder = new StringBuilder();

            foreach (byte b in data)
            {
                s_builder.Append(b.ToString("x2"));
            }

            // Return the hexadecimal string.
            return((System.Data.SqlTypes.SqlString)s_builder.ToString());
        }
Example #19
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_JobPartTypeId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_JobPartTypeId_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Description = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Description_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_GeneralUnitCost = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_GeneralUnitCost_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
        /// <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_Cat_LngID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Cat_LngID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Cat_StrName = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Cat_StrName_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_ConsiderNull_Cat_StrName = System.Data.SqlTypes.SqlBoolean.Null;
            this.internal_Param_ConsiderNull_Cat_StrName_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Example #21
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;
        }
Example #22
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_Cus_LngID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Cus_LngID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Cus_StrLastName = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Cus_StrLastName_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Cus_StrFirstName = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Cus_StrFirstName_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Cus_StrEmail = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Cus_StrEmail_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Example #23
0
        /// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the spS_xSearchCustomer 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="primaryKey">The field that represents a primary key.</param>
        /// <param name="param_LastName">Value for the parameter @LastName.</param>
        /// <param name="param_FirstName">Value for the parameter @FirstName.</param>
        public void Initialize(System.Data.SqlClient.SqlConnection sqlConnection, string primaryKey, System.Data.SqlTypes.SqlString param_LastName, System.Data.SqlTypes.SqlString param_FirstName)
        {
            this.sqlConnection           = sqlConnection;
            this.LastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlConnection;
            this.primaryKey = primaryKey;
            this.tableName  = "spS_xSearchCustomer";

#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_xSearchCustomer'";

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

            this.param_LastName  = param_LastName;
            this.param_FirstName = param_FirstName;
        }
Example #24
0
//    private static int i_;

        public static System.Data.SqlTypes.SqlString repeatString(
            System.Data.SqlTypes.SqlString str,
            System.Data.SqlTypes.SqlInt16 iter)
        {
            System.Data.SqlTypes.SqlString ret = new System.Data.SqlTypes.SqlString("", str.LCID);

//       -------------------------------------------------------------------------------------------------
//
//         CREATE ASSEMBLY failed because method 'repeatString' on type 'NS.CLS' in safe assembly 'source'
//         is storing to a static field. Storing to a static field is not allowed in safe assemblies.
//
//       i_ = iter.Value;
//       -------------------------------------------------------------------------------------------------

            for (short i = 0; i < iter.Value; i++)
            {
                ret += str;
            }

            return(ret);
        }
Example #25
0
        /// <summary>
        /// method returns all dbnames defined on the SQL server, specified by the SQL connection object
        /// </summary>
        /// <param name="sqlConn"></param>
        /// <returns></returns>
        public static string[] GetDBNames(SqlConnection sqlConn)
        {
            ArrayList arl = new ArrayList();

            using (SqlCommand sqlCommand = new SqlCommand(getDB_Names, sqlConn))
            {
                if (sqlConn.State != ConnectionState.Open)
                {
                    sqlConn.Open();
                }
                using (SqlDataReader sdr = sqlCommand.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        System.Data.SqlTypes.SqlString dbName = sdr.GetSqlString(0);
                        arl.Add(dbName.ToString());
                    }
                    sdr.Close();
                }
            }
            // C01: LLEWIS: added sorted return
            arl.Sort();
            return((string[])arl.ToArray(typeof(string)));
        }
Example #26
0
 /// <summary>
 /// Allows you to reset the pre-selected value for the 'Cat_StrName' column.
 /// </summary>
 public void ResetValue_Cat_StrName()
 {
     this.hasBeenPopulated_Cat_StrName = false;
     this.internal_Cat_StrName         = System.Data.SqlTypes.SqlString.Null;
 }
Example #27
0
 /// <summary>
 /// Allows you to pre-select a value for the 'Cat_StrName' column.
 /// </summary>
 public void SetValue_Cat_StrName(System.Data.SqlTypes.SqlString value)
 {
     this.hasBeenPopulated_Cat_StrName = true;
     this.internal_Cat_StrName         = value;
 }
Example #28
0
 /// <summary>
 /// Allows you to pre-select a value for the 'Title' column.
 /// </summary>
 public void SetValue_Title(System.Data.SqlTypes.SqlString value)
 {
     this.hasBeenPopulated_Title = true;
     this.internal_Title         = value;
 }
Example #29
0
        /// <summary>
        /// Allows you to load a specific record of the [Customers] table.
        /// </summary>
        /// <param name="col_CustomerID">Customer unique identifier</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_CustomerID)
        {
            bool Status;

            Reset();

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


            this.col_CustomerID = col_CustomerID;

            this.Param.Reset();

            this.Param.Param_CustomerID = this.col_CustomerID;

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

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex))
                    {
                        this.col_CompanyName = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex))
                    {
                        this.col_ContactName = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex))
                    {
                        this.col_TitleId = DR.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex))
                    {
                        this.col_Address = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex))
                    {
                        this.col_City = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex))
                    {
                        this.col_PostalCode = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex))
                    {
                        this.col_Phone = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex))
                    {
                        this.col_Email = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex))
                    {
                        this.col_WebAddress = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex))
                    {
                        this.col_Fax = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex))
                    {
                        this.col_Active = DR.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.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 Bob.DataClasses.CustomException(this.Param, "Bob.AbstractClasses.Abstract_Customers", "Refresh");
            }
        }
Example #30
0
        /// <summary>
        /// Allows you to load a specific record of the [tblCustomer] table.
        /// </summary>
        /// <param name="col_Cus_LngID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Cus_LngID&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_Cus_LngID)
        {
            bool Status;

            Reset();

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


            this.col_Cus_LngID = col_Cus_LngID;

            this.Param.Reset();

            this.Param.Param_Cus_LngID = this.col_Cus_LngID;

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

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrLastName.ColumnIndex))
                    {
                        this.col_Cus_StrLastName = DR.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrLastName.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrFirstName.ColumnIndex))
                    {
                        this.col_Cus_StrFirstName = DR.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrFirstName.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrEmail.ColumnIndex))
                    {
                        this.col_Cus_StrEmail = DR.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrEmail.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_tblCustomer", "Refresh");
            }
        }