///<Summary> ///Select all rows by filter criteria ///This method returns all data rows in the table using criteriaquery api Suppliers ///</Summary> ///<returns> ///IList-IDAOSuppliers. ///</returns> ///<parameters> ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake ///</parameters> public static IList <IDAOSuppliers> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = GetSelectionCriteria(InlineProcs.ctprSuppliers_SelectAllByCriteria, null, listCriterion, listOrder, dataSkip, dataTake); command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Suppliers"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); List <IDAOSuppliers> objList = new List <IDAOSuppliers>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOSuppliers retObj = new DAOSuppliers(); retObj._supplierID = Convert.IsDBNull(row["SupplierID"]) ? (Int32?)null : (Int32?)row["SupplierID"]; retObj._companyName = Convert.IsDBNull(row["CompanyName"]) ? null : (string)row["CompanyName"]; retObj._contactName = Convert.IsDBNull(row["ContactName"]) ? null : (string)row["ContactName"]; retObj._contactTitle = Convert.IsDBNull(row["ContactTitle"]) ? null : (string)row["ContactTitle"]; retObj._address = Convert.IsDBNull(row["Address"]) ? null : (string)row["Address"]; retObj._city = Convert.IsDBNull(row["City"]) ? null : (string)row["City"]; retObj._region = Convert.IsDBNull(row["Region"]) ? null : (string)row["Region"]; retObj._postalCode = Convert.IsDBNull(row["PostalCode"]) ? null : (string)row["PostalCode"]; retObj._country = Convert.IsDBNull(row["Country"]) ? null : (string)row["Country"]; retObj._phone = Convert.IsDBNull(row["Phone"]) ? null : (string)row["Phone"]; retObj._fax = Convert.IsDBNull(row["Fax"]) ? null : (string)row["Fax"]; retObj._homePage = Convert.IsDBNull(row["HomePage"]) ? null : (string)row["HomePage"]; retObj._ctrVersion = Convert.IsDBNull(row["ctr_version"]) ? (Int32?)null : (Int32?)row["ctr_version"]; objList.Add(retObj); } } return(objList); } catch (Exception ex) { Failed(null, ex); Handle(null, ex); return(null); } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select one row by primary key(s) ///This method returns one row from the table Suppliers based on the primary key(s) ///</Summary> ///<returns> ///IDAOSuppliers ///</returns> ///<parameters> ///Int32? supplierID ///</parameters> public static IDAOSuppliers SelectOne(Int32?supplierID) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprSuppliers_SelectOne; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Suppliers"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(CtSqlParameter.Get("@SupplierID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)supplierID ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); DAOSuppliers retObj = null; if (dt.Rows.Count > 0) { retObj = new DAOSuppliers(); retObj._supplierID = Convert.IsDBNull(dt.Rows[0]["SupplierID"]) ? (Int32?)null : (Int32?)dt.Rows[0]["SupplierID"]; retObj._companyName = Convert.IsDBNull(dt.Rows[0]["CompanyName"]) ? null : (string)dt.Rows[0]["CompanyName"]; retObj._contactName = Convert.IsDBNull(dt.Rows[0]["ContactName"]) ? null : (string)dt.Rows[0]["ContactName"]; retObj._contactTitle = Convert.IsDBNull(dt.Rows[0]["ContactTitle"]) ? null : (string)dt.Rows[0]["ContactTitle"]; retObj._address = Convert.IsDBNull(dt.Rows[0]["Address"]) ? null : (string)dt.Rows[0]["Address"]; retObj._city = Convert.IsDBNull(dt.Rows[0]["City"]) ? null : (string)dt.Rows[0]["City"]; retObj._region = Convert.IsDBNull(dt.Rows[0]["Region"]) ? null : (string)dt.Rows[0]["Region"]; retObj._postalCode = Convert.IsDBNull(dt.Rows[0]["PostalCode"]) ? null : (string)dt.Rows[0]["PostalCode"]; retObj._country = Convert.IsDBNull(dt.Rows[0]["Country"]) ? null : (string)dt.Rows[0]["Country"]; retObj._phone = Convert.IsDBNull(dt.Rows[0]["Phone"]) ? null : (string)dt.Rows[0]["Phone"]; retObj._fax = Convert.IsDBNull(dt.Rows[0]["Fax"]) ? null : (string)dt.Rows[0]["Fax"]; retObj._homePage = Convert.IsDBNull(dt.Rows[0]["HomePage"]) ? null : (string)dt.Rows[0]["HomePage"]; retObj._ctrVersion = Convert.IsDBNull(dt.Rows[0]["ctr_version"]) ? (Int32?)null : (Int32?)dt.Rows[0]["ctr_version"]; } return(retObj); } catch (Exception ex) { Failed(null, ex); Handle(null, ex); return(null); } finally { staticConnection.Close(); command.Dispose(); } }