예제 #1
0
        public List <JuicePurchased> Alljuicepurchased()
        {
            List <JuicePurchased> lstjp = new List <JuicePurchased>();

            SqlConnection con = new SqlConnection();

            con.ConnectionString = @"Data Source=IN-5CG0253HJ3\SQLEXPRESS;Initial Catalog=JuiceShop_DB;Integrated Security=True";

            SqlCommand cmd = new SqlCommand("select * from JuicePurchased", con);

            cmd.CommandType = CommandType.Text;

            con.Open();

            SqlDataReader sdr = cmd.ExecuteReader();

            while (sdr.Read())
            {
                JuicePurchased jp = new JuicePurchased
                {
                    juice_id = (int)sdr[1],
                    quantity = (int)sdr[2],
                    amount   = (int)sdr[3]
                };
                lstjp.Add(jp);
            }
            sdr.Close();
            con.Close();
            return(lstjp);
        }
예제 #2
0
        public List <JuicePurchased> GetallJuicePurchased()
        {
            List <JuicePurchased> juiceslst = new List <JuicePurchased>();
            {
                SqlConnection con = new SqlConnection();
                con.ConnectionString = @"Data Source=IN-5CG0255ZN3\SQLEXPRESS;Initial Catalog=JuiceShop_DB;Integrated Security=True";
                SqlCommand cmd = new SqlCommand("select * from JuicePurchased", con);
                cmd.CommandType = CommandType.Text;
                con.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    JuicePurchased j = new JuicePurchased
                    {
                        purchase_no = (int)sdr[0],
                        juiceid     = (int)sdr[1],
                        quantity    = (int)sdr[2],
                        amount      = (int)sdr[3]
                    };
                    juiceslst.Add(j);
                }
                sdr.Close();
                con.Close();

                return(juiceslst);
            }
        }