Exemplo n.º 1
0
        public string InsertOrderdetails(orderdetails order)
        {
            MySqlConnection  con = new MySqlConnection(constr);
            MySqlCommand     cmd = new MySqlCommand("Insert Into orderdetails(ProductId,Quantity,orderid) values (@ProductId,@Quantity,@orderid)", con);
            MySqlDataAdapter sda = new MySqlDataAdapter(cmd);

            cmd.Parameters.AddWithValue("@ProductId", order.ProductId);
            cmd.Parameters.AddWithValue("@Quantity", "1");
            cmd.Parameters.AddWithValue("@orderid", order.orderid);
            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (i == 1)
            {
                return("success");
            }
            return("failed");
        }
Exemplo n.º 2
0
        public List <orderdetails> getorderbyorderid(string oid)
        {
            List <orderdetails> detaillst = new List <orderdetails>();
            MySqlConnection     con       = new MySqlConnection(constr);
            MySqlCommand        cmd       = new MySqlCommand("Select * from orderdetails where orderid=@orderid", con);

            cmd.Parameters.AddWithValue("@orderid", oid);
            con.Open();
            MySqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                orderdetails details = new orderdetails();
                //details.orderdetailid = Convert.ToInt64(dr.GetValue(0));
                details.ProductId = dr.GetValue(1).ToString();
                details.Quantity  = dr.GetValue(2).ToString();
                details.orderid   = dr.GetValue(3).ToString();
                detaillst.Add(details);
            }
            con.Close();
            return(detaillst);
        }