예제 #1
0
        /// <summary>
        /// Delete registers based on ID informed. Other values are skipped.
        /// </summary>
        /// <param name="parSuppliersInfo">Item to delete</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void DeleteByID(SuppliersInfo parSuppliersInfo, out string errorMessage)
        {
            SuppliersInfo newParam = new SuppliersInfo();

            newParam.SupplierID = parSuppliersInfo.SupplierID;
            this.Delete(newParam, out errorMessage);
        }
예제 #2
0
        /// <summary>
        /// Get one register using only ID as key.
        /// </summary>
        /// <returns></returns>
        public virtual SuppliersInfo GetValueByID(int SupplierID)
        {
            //ToDo: set multiple PK filter
            motor.ClearCommandParameters();
            motor.CommandText = GetSelectCommand() + GetWherePrimaryKey();
            List <DbParameter> paramList = new List <DbParameter>();


            DbParameter paramSupplierID = motor.Command.CreateParameter();

            paramSupplierID.ParameterName = "@param_SupplierID";
            paramSupplierID.Value         = SupplierID;
            paramList.Add(paramSupplierID);


            motor.AddCommandParameters(paramList);
            SuppliersInfo InfoValue = new SuppliersInfo();

            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(SuppliersInfo), dbReader);

            using (dbReader)
            {
                if (dbReader.Read())
                {
                    InfoValue = new SuppliersInfo();
                    classFiller.Fill(InfoValue);
                }
                else
                {
                    return(null);
                }
            }
            return(InfoValue);
        }
예제 #3
0
        /// <summary>
        /// Insert one register in database.
        /// </summary>
        /// <param name="parSuppliersInfo">Item to delete</param>
        /// <param name="transaction">Transaction context</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void InsertOne(SuppliersInfo parSuppliersInfo, DbTransaction transaction, out string errorMessage)
        {
            errorMessage = null;
            try
            {
                motor.CommandText = GetInsertCommand();
                ///Warning: performance issues with this automation. See method description for details.
                List <DbParameter> paramList = ParameterBuilder.GetParametersForInsert(typeof(SuppliersInfo), parSuppliersInfo, motor.Command);
                motor.ClearCommandParameters();
                motor.AddCommandParameters(paramList);
                motor.AddTransaction(transaction);


                if (GetIdentity == true)
                {
                    parSuppliersInfo.SupplierID = motor.ExecuteScalar();
                }
                else
                {
                    motor.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,SupplierName,SupplierEmail,SupplierPhone,SupplierAddress,SupplierMobileNo")] SuppliersInfo supplier)
        {
            using (var dbTransaction = _db.Database.BeginTransaction())
            {
                try
                {
                    ModelState.Clear();
                    supplier.SupplierId = string.Format("SI-{0:000000}", _db.SuppliersInfos.Count() + 1);
                    supplier.EntryBy    = _db.Users.First(x => x.UserName == User.Identity.Name).Id;
                    supplier.EntryDate  = DateTime.Now;
                    TryValidateModel(supplier);
                    if (ModelState.IsValid)
                    {
                        _db.SuppliersInfos.Add(supplier);
                        _db.SaveChanges();

                        dbTransaction.Commit();
                        TempData["Toastr"] = Toastr.Added;

                        return(RedirectToAction("Index"));
                    }
                    dbTransaction.Rollback();
                    return(View(supplier));
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    TempData["Toastr"] = Toastr.DbError(ex.Message);
                    return(RedirectToAction("Index"));
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Performs one "select * from MyTable where [InformedProperties]". MinValues and nulls are skipped from filter.
        /// </summary>
        /// <param name="filter">SuppliersInfo</param>
        /// <returns>List of found records.</returns>
        public virtual List <SuppliersInfo> GetSome(SuppliersInfo filter)
        {
            List <SuppliersInfo> AllInfoList = new List <SuppliersInfo>();
            string             filterWhere   = string.Empty;
            List <DbParameter> paramList     = null;

            GenerateWhere(filter, out filterWhere, out paramList);
            motor.ClearCommandParameters();
            motor.AddCommandParameters(paramList);
            motor.CommandText = GetSelectCommand() + " " + filterWhere;
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(SuppliersInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    SuppliersInfo SuppliersInfo = new SuppliersInfo();
                    ///Warning: performance issues with this automation. See method description for details.
                    classFiller.Fill(SuppliersInfo);
                    AllInfoList.Add(SuppliersInfo);
                }
            }
            return(AllInfoList);
        }
예제 #6
0
        /// <summary>
        /// Delete registers based on class values informed. MinValues and nulls are skipped.
        /// </summary>
        /// <param name="parSuppliersInfo">Item to delete</param>
        /// <param name="transaction">Transaction context</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void Delete(SuppliersInfo parSuppliersInfo, DbTransaction transaction, out string errorMessage)
        {
            errorMessage = null;
            try
            {
                string        whereClausule = string.Empty;
                var           pks           = GetPrimaryKey();
                List <string> primaryKeys   = new List <string>();
                foreach (var item in pks)
                {
                    primaryKeys.Add(item.Key);
                }

                List <DbParameter> paramList = ParameterBuilder.GetParametersForDelete(primaryKeys, typeof(SuppliersInfo), parSuppliersInfo, motor.Command, out whereClausule);

                motor.CommandText = GetDeleteCommand() + " " + whereClausule;
                motor.ClearCommandParameters();
                motor.AddCommandParameters(paramList);
                motor.AddTransaction(transaction);
                motor.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
        }
예제 #7
0
        public ActionResult Edit([Bind(Include = "Id,SupplierName,SupplierEmail,SupplierPhone,SupplierAddress,SupplierMobileNo")] SuppliersInfo supplier, int?id)
        {
            using (var dbTransaction = _db.Database.BeginTransaction())
            {
                try
                {
                    if (id == null)
                    {
                        TempData["Toastr"] = Toastr.HttpNotFound;
                        return(RedirectToAction("Index"));
                    }
                    if (_db.SuppliersInfos.Count(x => x.Id == id) < 1)
                    {
                        TempData["Toastr"] = Toastr.HttpNotFound;
                        return(RedirectToAction("Index"));
                    }
                    var suppliersInfo = _db.SuppliersInfos.Single(x => x.Id == id);
                    if (suppliersInfo == null)
                    {
                        TempData["Toastr"] = Toastr.HttpNotFound;
                        return(RedirectToAction("Index"));
                    }

                    ModelState.Clear();
                    supplier.SupplierId = suppliersInfo.SupplierId;
                    supplier.EntryBy    = suppliersInfo.EntryBy;
                    supplier.EntryDate  = suppliersInfo.EntryDate;
                    supplier.DelStatus  = suppliersInfo.DelStatus;

                    TryValidateModel(supplier);

                    if (!ModelState.IsValid)
                    {
                        return(View(supplier));
                    }

                    _db.SuppliersInfos
                    .Where(x => x.Id == id)
                    .Update(u => new SuppliersInfo
                    {
                        SupplierName     = supplier.SupplierName,
                        SupplierEmail    = supplier.SupplierEmail,
                        SupplierPhone    = supplier.SupplierPhone,
                        SupplierAddress  = supplier.SupplierAddress,
                        SupplierMobileNo = supplier.SupplierMobileNo
                    });
                    dbTransaction.Commit();

                    TempData["Toastr"] = Toastr.Updated;
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    TempData["Toastr"] = Toastr.DbError(ex.Message);
                    return(RedirectToAction("Index"));
                }
            }
        }
예제 #8
0
 /// <summary>
 /// Delete registers based on class values informed. MinValues and nulls are skipped.
 /// Must have "MultipleActiveResultSets=True" on connection string.
 /// </summary>
 /// <param name="parSuppliersInfo">Item to delete</param>
 /// <param name="transaction">Transaction context</param>
 /// <param name="errorMessage">Error message</param>
 public virtual void Delete(SuppliersInfo parSuppliersInfo, DbTransaction transaction, out string errorMessage)
 {
     errorMessage = string.Empty;
     SuppliersDAO.Delete(parSuppliersInfo, transaction, out errorMessage);
     //By default, the caller of this method will do the commit.
     //motor.Commit();
     //motor.CloseConnection();
 }
예제 #9
0
        public void DeleteData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(SuppliersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
예제 #10
0
        /// <summary>
        /// Performs one "update" database command.
        /// Will commit the transaction and close the connection. Use for independent delete.
        /// </summary>
        /// <param name="SuppliersInfo">Object to update.</param>
        /// <param name="errorMessage">Error message if exception is throwed</param>
        public virtual void UpdateOne(SuppliersInfo parSuppliersInfo, out string errorMessage)
        {
            errorMessage = string.Empty;
            DbTransaction transaction = motor.BeginTransaction();

            this.UpdateOne(parSuppliersInfo, transaction, out errorMessage);
            motor.Commit();
            motor.CloseConnection();
        }
예제 #11
0
        public void AddData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(SuppliersInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForSuppliers.NewItem = false;
            Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers);
        }
예제 #12
0
        public ModelNotifiedForSuppliers GetSuppliersByID(int SupplierID, out string error)
        {
            error = null;
            SuppliersBsn              bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo             dbItem = bsn.GetValueByID(SupplierID);
            ModelNotifiedForSuppliers item   = new ModelNotifiedForSuppliers();

            Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), item);
            return(item);
        }
예제 #13
0
        /// <summary>
        /// Delete registers based on class ID informed in transactional context. Other values are skipped.
        /// Must have "MultipleActiveResultSets=True" on connection string.
        /// </summary>
        /// <param name="parSuppliersInfo">Item to delete</param>
        /// <param name="transaction">Transaction context</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void DeleteByID(SuppliersInfo parSuppliersInfo, DbTransaction transaction, out string errorMessage)
        {
            SuppliersInfo newParam = new SuppliersInfo();

            newParam.SupplierID = parSuppliersInfo.SupplierID;
            this.Delete(newParam, transaction, out errorMessage);
            //By default, the caller of this method will do the commit.
            //motor.Commit();
            //motor.CloseConnection();
        }
예제 #14
0
        /// <summary>
        /// Perform one "select" command to database. Filter the data using "filter" class.
        /// </summary>
        /// <param name="filter">Class to use as filter</param>
        /// <returns>List with filtered data</returns>
        public virtual List <SuppliersInfo> GetSome(SuppliersInfo filter)
        {
            motor.OpenConnection();
            List <SuppliersInfo> list = SuppliersDAO.GetSome(filter);

            if (this.closeConnectionWhenFinish)
            {
                motor.CloseConnection();
            }
            return(list);
        }
예제 #15
0
        /// <summary>
        /// Retrieves the data using only the primary key ID. Ex.: "Select * from MyTable where id=1"
        /// </summary>
        /// <returns>The class filled if found.</returns>
        public virtual SuppliersInfo GetValueByID(int SupplierID)
        {
            motor.OpenConnection();
            SuppliersInfo value = SuppliersDAO.GetValueByID(SupplierID);

            if (this.closeConnectionWhenFinish)
            {
                motor.CloseConnection();
            }
            return(value);
        }
예제 #16
0
 /// <summary>
 /// Performs a "update [FildList] set [FieldList] where id = @id". Must have the ID informed.
 /// </summary>
 /// <param name="parSuppliersInfo">Item to update</param>
 /// <param name="transaction">Transaction context</param>
 /// <param name="errorMessage">Error message</param>
 public virtual void UpdateOne(SuppliersInfo parSuppliersInfo, DbTransaction transaction, out string errorMessage)
 {
     errorMessage = null;
     try
     {
         motor.CommandText = GetUpdateCommand();
         ///Warning: performance issues with this automation. See method description for details.
         List <DbParameter> paramList = ParameterBuilder.GetParametersForUpdate(typeof(SuppliersInfo), parSuppliersInfo, motor.Command);
         motor.ClearCommandParameters();
         motor.AddCommandParameters(paramList);
         motor.AddTransaction(transaction);
         motor.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         errorMessage = ex.Message;
     }
 }
예제 #17
0
        /// <summary>
        /// Use parameters to apply simple filters
        /// </summary>
        /// <param name="filterExpression"></param>
        /// <returns></returns>
        public virtual List <SuppliersInfo> GetAll(List <DataFilterExpressionDB> filterExpression)
        {
            List <SuppliersInfo> AllInfoList = new List <SuppliersInfo>();

            motor.ClearCommandParameters();
            motor.CommandText = GetSelectCommand() + " where 1=1 ";
            List <DbParameter> paramList = new List <DbParameter>();

            string where = "";
            foreach (DataFilterExpressionDB filter in filterExpression)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_" + filter.FieldName;
                param.Value         = filter.Filter;
                param.DbType        = HelperDBType.GetDBType(typeof(SuppliersInfo), filter.FieldName);
                if (filter.FilterType == DataFilterExpressionDB._FilterType.Equal)
                {
                    param.Value = filter.Filter;
                    where      += string.Format(" and Suppliers.{0} = {1}", filter.FieldName, param.ParameterName);
                }
                else
                {
                    param.Value = "%" + filter.Filter + "%";
                    where      += string.Format(" and Suppliers.{0} like {1}", filter.FieldName, param.ParameterName);
                }
                paramList.Add(param);
            }
            motor.CommandText += where;
            motor.AddCommandParameters(paramList);

            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(SuppliersInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    SuppliersInfo classInfo = new SuppliersInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
예제 #18
0
        /// <summary>
        /// Same as get all but filter the result set
        /// </summary>
        /// <param name="numberOfRowsToSkip">Skip first X rows</param>
        /// <param name="numberOfRows">Like "TOP" in sql server</param>
        /// <returns></returns>
        public List <SuppliersInfo> GetAll(int numberOfRowsToSkip, int numberOfRows)
        {
            List <SuppliersInfo> AllInfoList = new List <SuppliersInfo>();

            motor.CommandText = base.GetFilteredRowNumAndSkipQuery("AttributeLists", "id", numberOfRowsToSkip, numberOfRows);
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(SuppliersInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    SuppliersInfo classInfo = new SuppliersInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
예제 #19
0
        /// <summary>
        /// Performs one "Select * from MyTable". Use wisely.
        /// </summary>
        /// <returns>List of found records.</returns>
        public virtual List <SuppliersInfo> GetAll()
        {
            List <SuppliersInfo> AllInfoList = new List <SuppliersInfo>();

            motor.CommandText = GetSelectCommand();
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(SuppliersInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    SuppliersInfo classInfo = new SuppliersInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
예제 #20
0
        /// <summary>
        /// Delete registers based on class values informed. MinValues and nulls are skipped.
        /// </summary>
        /// <param name="parSuppliersInfo">Item to delete</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void Delete(SuppliersInfo parSuppliersInfo, out string errorMessage)
        {
            errorMessage = string.Empty;

            //1) Start the transaction context.
            DbTransaction transaction = motor.BeginTransaction();

            //2) Call the overload of this method, which call the DAO but does not commit.
            this.Delete(parSuppliersInfo, transaction, out errorMessage);

            //3) Commit the transaction.
            motor.Commit();

            //4) Close the conection (if configured to do so).
            if (this.closeConnectionWhenFinish)
            {
                motor.CloseConnection();
            }
        }
예제 #21
0
        public void TryUpdate(UpdateSuppliersView viewToUpdate, out RestExceptionError error)
        {
            error = null;
            SuppliersInfo dbViewToInclude = new SuppliersInfo();

            try
            {
                Cloner.CopyAllTo(typeof(UpdateSuppliersView), viewToUpdate, typeof(SuppliersInfo), dbViewToInclude);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error parsing data for (Suppliers.TryUpdate/Parsing)";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }

            try
            {
                SuppliersBsn bsn     = new SuppliersBsn(restConfig);
                string       dbError = null;
                bsn.UpdateOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Suppliers.TryUpdate]";
                    error.ExceptionMessage = dbError;
                    error.SourceError      = RestExceptionError._SourceError.ServerSide;
                    error.StackTrace       = "";
                }
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error Update data for [Suppliers.TryUpdate]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }
예제 #22
0
/// <summary>
/// Perform a search to find the class "SuppliersInfo" using as key the field "Suppliers".
/// </summary>
/// <param name="parProductsInfo">Main class that contains the aggregation.</param>
/// <returns>Foreing key attched class.</returns>
        public virtual SuppliersInfo Get_SupplierIDID_FKSuppliers(ProductsInfo parProductsInfo, DbTransaction transaction)
        {
            SuppliersInfo filter = new SuppliersInfo();

            filter.CompanyName = parProductsInfo.FK0_CompanyName;
            SuppliersBsn         myClass = new SuppliersBsn(false, this.motor);
            List <SuppliersInfo> list    = myClass.GetSome(filter);

            if (list.Count == 0)
            {
//This error occurs when try to search for the ID in one table, but it does not find the value.
//Ex.: Select id,SomeField from myTable where SomeField='myValue') If no data return, this error will trigger.
                throw new Exception(string.Format("Can not define ID for parProductsInfo.", parProductsInfo.FK0_CompanyName));

/* [Hint] The code below do one insert in the table "Suppliers" informing only the "SupplierID" field.
 * [Warning] The code may crash if other fields are necessary.
 * [Instructions] Comment the exception above. Uncomment the code below.
 */
//string errorMsg = string.Empty;
//myClass.InsertOne(filter, transaction, out errorMsg);
//if (errorMsg != string.Empty)
//{
//throw new Exception(errorMsg);
//}
//else
//{
//return filter;
//}
            }
            if (list.Count > 1)
            {
//This error occurs when try to search for the ID in one table, but it return more then one value.
//Ex.: Select id,SomeField from myTable where SomeField='myValue') If more then one line return, this error will trigger.
                throw new Exception(string.Format("Can not define ID for parProductsInfo. Theres more then one ID value for this field. ", parProductsInfo.FK0_CompanyName));
            }
            else
            {
//Return the only one class found.
                return(list[0]);
            }
        }
예제 #23
0
        /// <summary>
        /// Performs one "update" database command in a transactional context.
        /// * The method uses a transaction object already created and does not close the connection.
        /// * Must have "MultipleActiveResultSets=True" on connection string.
        /// </summary>
        /// <param name="ProductsInfo">Object to update.</param>
        /// <param name="transaction">Inform "DBTransaction".</param>
        /// <param name="errorMessage">Error message if exception is throwed.</param>
        public virtual void UpdateOne(ProductsInfo parProductsInfo, DbTransaction transaction, out string errorMessage)
        {
            errorMessage = string.Empty;

//If is trying to insert FKValue without the ID but has the unique description,
//the system will try to get the class with the ID and populate it.
            if ((parProductsInfo.SupplierID == null) && (parProductsInfo.FK0_CompanyName != null))
            {
                SuppliersInfo fkClass = Get_SupplierIDID_FKSuppliers(parProductsInfo, transaction);
                parProductsInfo.SupplierID = fkClass.SupplierID;
            }
            if ((parProductsInfo.CategoryID == null) && (parProductsInfo.FK1_CategoryName != null))
            {
                CategoriesInfo fkClass = Get_CategoryIDID_FKCategories(parProductsInfo, transaction);
                parProductsInfo.CategoryID = fkClass.CategoryID;
            }

            ProductsDAO.UpdateOne(parProductsInfo, transaction, out errorMessage);
            //By default, the caller of this method will do the commit.
            //motor.Commit();
            //motor.CloseConnection();
        }
예제 #24
0
        /// <summary>
        /// Generate the "where" clausule, used for select data using "GetSome" method.
        /// </summary>
        /// <param name="filter">Class used to apply the filter</param>
        /// <param name="whereClausule">Result whith a string that add filter to the select comand</param>
        /// <param name="paramList">Result whith the parameters list</param>
        protected void GenerateWhere(SuppliersInfo filter, out string whereClausule, out List <DbParameter> paramList)
        {
            StringBuilder where = new StringBuilder();
            paramList           = new List <DbParameter>();
            where.Append("where 1=1");

// 1) Adding filter for field SupplierID
            if (filter.SupplierID != Int32.MinValue)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_SupplierID";
                param.Value         = filter.SupplierID;
                paramList.Add(param);
                where.Append(" and Suppliers.SupplierID=@param_SupplierID");
            }
// 2) Adding filter for field CompanyName
            if (filter.CompanyName != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_CompanyName";
                param.Value         = filter.CompanyName;
                paramList.Add(param);
                where.Append(" and Suppliers.CompanyName=@param_CompanyName");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_CompanyName";
//param.Value = "%" + filter.CompanyName "%";
//paramList.Add(param);
//where.Append(" and Suppliers.CompanyName like @param_CompanyName");
            }
// 3) Adding filter for field ContactName
            if (filter.ContactName != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_ContactName";
                param.Value         = filter.ContactName;
                paramList.Add(param);
                where.Append(" and Suppliers.ContactName=@param_ContactName");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_ContactName";
//param.Value = "%" + filter.ContactName "%";
//paramList.Add(param);
//where.Append(" and Suppliers.ContactName like @param_ContactName");
            }
// 4) Adding filter for field ContactTitle
            if (filter.ContactTitle != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_ContactTitle";
                param.Value         = filter.ContactTitle;
                paramList.Add(param);
                where.Append(" and Suppliers.ContactTitle=@param_ContactTitle");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_ContactTitle";
//param.Value = "%" + filter.ContactTitle "%";
//paramList.Add(param);
//where.Append(" and Suppliers.ContactTitle like @param_ContactTitle");
            }
// 5) Adding filter for field Address
            if (filter.Address != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_Address";
                param.Value         = filter.Address;
                paramList.Add(param);
                where.Append(" and Suppliers.Address=@param_Address");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_Address";
//param.Value = "%" + filter.Address "%";
//paramList.Add(param);
//where.Append(" and Suppliers.Address like @param_Address");
            }
// 6) Adding filter for field City
            if (filter.City != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_City";
                param.Value         = filter.City;
                paramList.Add(param);
                where.Append(" and Suppliers.City=@param_City");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_City";
//param.Value = "%" + filter.City "%";
//paramList.Add(param);
//where.Append(" and Suppliers.City like @param_City");
            }
// 7) Adding filter for field Region
            if (filter.Region != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_Region";
                param.Value         = filter.Region;
                paramList.Add(param);
                where.Append(" and Suppliers.Region=@param_Region");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_Region";
//param.Value = "%" + filter.Region "%";
//paramList.Add(param);
//where.Append(" and Suppliers.Region like @param_Region");
            }
// 8) Adding filter for field PostalCode
            if (filter.PostalCode != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_PostalCode";
                param.Value         = filter.PostalCode;
                paramList.Add(param);
                where.Append(" and Suppliers.PostalCode=@param_PostalCode");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_PostalCode";
//param.Value = "%" + filter.PostalCode "%";
//paramList.Add(param);
//where.Append(" and Suppliers.PostalCode like @param_PostalCode");
            }
// 9) Adding filter for field Country
            if (filter.Country != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_Country";
                param.Value         = filter.Country;
                paramList.Add(param);
                where.Append(" and Suppliers.Country=@param_Country");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_Country";
//param.Value = "%" + filter.Country "%";
//paramList.Add(param);
//where.Append(" and Suppliers.Country like @param_Country");
            }
// 10) Adding filter for field Phone
            if (filter.Phone != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_Phone";
                param.Value         = filter.Phone;
                paramList.Add(param);
                where.Append(" and Suppliers.Phone=@param_Phone");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_Phone";
//param.Value = "%" + filter.Phone "%";
//paramList.Add(param);
//where.Append(" and Suppliers.Phone like @param_Phone");
            }
// 11) Adding filter for field Fax
            if (filter.Fax != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_Fax";
                param.Value         = filter.Fax;
                paramList.Add(param);
                where.Append(" and Suppliers.Fax=@param_Fax");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_Fax";
//param.Value = "%" + filter.Fax "%";
//paramList.Add(param);
//where.Append(" and Suppliers.Fax like @param_Fax");
            }
// 12) Adding filter for field HomePage
            if (filter.HomePage != null)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_HomePage";
                param.Value         = filter.HomePage;
                paramList.Add(param);
                where.Append(" and Suppliers.HomePage=@param_HomePage");
//Hint: use the code below to add a "like" search. Warning: may cause data performance issues.
//param.ParameterName = "@param_HomePage";
//param.Value = "%" + filter.HomePage "%";
//paramList.Add(param);
//where.Append(" and Suppliers.HomePage like @param_HomePage");
            }

            whereClausule = where.ToString();
        }