Esempio n. 1
0
        private List <RefProductOrder> TablelistProductFromIdUser(DataTable dt)
        {
            List <RefProductOrder> list = new List <RefProductOrder>();

            foreach (DataRow item in dt.Rows)
            {
                RefProductOrder cart = new RefProductOrder();
                cart._id_product = item[0].ToString();
                cart._quantity   = int.Parse(item[1].ToString());
                cart._price      = Double.Parse(item[2].ToString());
                list.Add(cart);
            }
            return(list);
        }
Esempio n. 2
0
        public void creatRefProductOrder(RefProductOrder refProductOrder, int idOrder)
        {
            String sql = "INSERT dbo.ref_product_order( [_quantity] ,[_id_order] , [_id_product] ,[_price] )VALUES " +
                         " ( @_quantity , @_id_order , @_id_product , @_price )";
            SqlCommand cmd = new SqlCommand(sql, GetConnection());

            if (cmd.Connection.State == ConnectionState.Closed)
            {
                cmd.Connection.Open();
            }
            cmd.Parameters.AddWithValue("@_quantity", refProductOrder._quantity);
            cmd.Parameters.AddWithValue("@_id_order", idOrder);
            cmd.Parameters.AddWithValue("@_id_product", refProductOrder._id_product);
            cmd.Parameters.AddWithValue("@_price", refProductOrder._price);
            int reuslt = cmd.ExecuteNonQuery();

            cmd.Connection.Close();
        }