Exemplo n.º 1
0
        public List <VehiclesClass> SelectAll()
        {
            List <VehiclesClass> ClassList = null;

            try
            {
                string sSQL = "SELECT * FROM VehiclesClass";

                DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, sSQL);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    ClassList = new List <VehiclesClass>();
                    VehiclesClass Class = null;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Class      = new VehiclesClass();
                        Class.Code = Convert.ToInt32(ds.Tables[0].Rows[i]["Code"]);
                        Class.Name = Convert.ToString(ds.Tables[0].Rows[i]["Name"]);

                        ClassList.Add(Class);
                    }
                }
            }
            catch (Exception ex) { }
            return(ClassList);
        }
Exemplo n.º 2
0
        public VehiclesClass SelectByCode(int Code)
        {
            VehiclesClass Class = null;

            try
            {
                string         sSQL     = "SELECT * FROM VehiclesClass WHERE Code=@Code";
                SqlParameter[] sqlParam = new SqlParameter[1];
                sqlParam[0]       = new SqlParameter("@Code", SqlDbType.NVarChar);
                sqlParam[0].Value = Code;
                DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, sSQL, sqlParam);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Class      = new VehiclesClass();
                    Class.Code = Convert.ToInt32(ds.Tables[0].Rows[0]["Code"]);
                    Class.Name = Convert.ToString(ds.Tables[0].Rows[0]["Name"]);
                }
            }
            catch (Exception ex) { }
            return(Class);
        }