Esempio n. 1
0
 public int Insert(StoredWheels st)
 {
     SchoolDatabase db = new SchoolDatabase();
     db.Connect();
     SqlCommand command = db.CreateCommand(SQL_INSERT);
     PrepareCommand(command, st);
     int ret = db.ExecuteNonQuery(command);
     db.Close();
     return ret;
 }
Esempio n. 2
0
 private void PrepareCommand(SqlCommand command, StoredWheels st)
 {
     //(@p_Tiremanufacturer, @p_DiscDescription, @p_TireDecription, getdate(), @p_Customers_id, @p_Employees_id_Store)
     command.Parameters.Add(new SqlParameter("@p_Tiremanufacturer", SqlDbType.VarChar, 10));
     command.Parameters["@p_Tiremanufacturer"].Value = st.Tiremanufacturer;
     command.Parameters.Add(new SqlParameter("@p_DiscDescription", SqlDbType.VarChar, 50));
     command.Parameters["@p_DiscDescription"].Value = st.DiscDescription;
     command.Parameters.Add(new SqlParameter("@p_TireDecription", SqlDbType.VarChar, 50));
     command.Parameters["@p_TireDecription"].Value = st.TireDecription;
     command.Parameters.Add(new SqlParameter("@p_Customers_id", SqlDbType.Int));
     command.Parameters["@p_Customers_id"].Value = st.Customers_id;
     command.Parameters.Add(new SqlParameter("@p_Employees_id_Store", SqlDbType.Int));
     command.Parameters["@p_Employees_id_Store"].Value = st.Employees_id_Store;
 }
Esempio n. 3
0
        private List<StoredWheels> Read(SqlDataReader reader)
        {
            List<StoredWheels> stTable = new List<StoredWheels>();
            //StoredWheelsDescription.id 0,
            //StoredWheelsDescription.Customers_id 1,
            //Tiremanufacturer2,
            //DiscDescription 3,
            //TireDecription 4,
            //StoreDate 5, emp1.lname, emp1.fname, UnstoreDate, emp2.lname, emp2.fname,Employees_id_Unstore
            while (reader.Read())
            {
                StoredWheels st = new StoredWheels();
                st.id = reader.GetInt32(0);
                st.Customers_id = reader.GetInt32(1);
                st.Tiremanufacturer = reader.GetString(2);
                st.DiscDescription = reader.GetString(3);
                st.TireDecription = reader.GetString(4);
                st.StoreDate = reader.GetDateTime(5);
                st.EmpStoreFname = reader.GetString(7);
                st.EmpStoreLname = reader.GetString(6);
                try
                {
                    st.UnstoreDate = reader.GetDateTime(8);
                    st.EmpUnStoreFname = reader.GetString(10);
                    st.EmpUnStoreLname = reader.GetString(9);
                    st.Employees_id_Unstore = reader.GetInt32(11);
                }
                catch
                {
                    st.UnstoreDate = null;
                    st.EmpUnStoreFname = null;
                    st.EmpUnStoreLname = null;
                    st.Employees_id_Unstore = null;
                }

                stTable.Add(st);
            }
            return stTable;
        }