///<Summary> ///Select all rows by filter criteria ///This method returns all data rows in the table using criteriaquery api Customers ///</Summary> ///<returns> ///IList-IDAOCustomers. ///</returns> ///<parameters> ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake ///</parameters> public static IList <IDAOCustomers> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = GetSelectionCriteria(InlineProcs.ctprCustomers_SelectAllByCriteria, null, listCriterion, listOrder, dataSkip, dataTake); command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Customers"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); List <IDAOCustomers> objList = new List <IDAOCustomers>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOCustomers retObj = new DAOCustomers(); retObj._customerID = Convert.IsDBNull(row["CustomerID"]) ? null : (string)row["CustomerID"]; 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._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 Customers based on the primary key(s) ///</Summary> ///<returns> ///IDAOCustomers ///</returns> ///<parameters> ///string customerID ///</parameters> public static IDAOCustomers SelectOne(string customerID) { Doing(null); SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprCustomers_SelectOne; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Customers"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(CtSqlParameter.Get("@CustomerID", SqlDbType.NChar, 5, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)customerID ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); Done(null); DAOCustomers retObj = null; if (dt.Rows.Count > 0) { retObj = new DAOCustomers(); retObj._customerID = Convert.IsDBNull(dt.Rows[0]["CustomerID"]) ? null : (string)dt.Rows[0]["CustomerID"]; 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._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(); } }