Example #1
0
        public DataSet delete(OrderEN pedido_borrado, int i)
        {
            string s;

            s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Order", c);
                da.Fill(virtdb, "order");
                DataTable t = new DataTable();
                t = virtdb.Tables["order"];

                t.Rows[i].Delete();

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR Deleting the order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Example #2
0
        public DataSet update(OrderEN pedido_nuevo, int i)
        {
            string s;

            s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Order'", c);
                da.Fill(virtdb, "order");
                DataTable t = new DataTable();
                t = virtdb.Tables["order"];

                t.Rows[i]["orderId"]    = pedido_nuevo.OrderId;
                t.Rows[i]["product"]    = pedido_nuevo.Product;
                t.Rows[i]["client"]     = pedido_nuevo.Client;
                t.Rows[i]["date"]       = pedido_nuevo.Date;
                t.Rows[i]["address"]    = pedido_nuevo.Address;
                t.Rows[i]["postalCode"] = pedido_nuevo.PostalCode;
                t.Rows[i]["quantity"]   = pedido_nuevo.Quantity;

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR Updating the order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Example #3
0
        public DataSet addOrder(OrderEN nuevo_pedido)
        {
            string        str    = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            DataSet       virtdb = new DataSet();
            SqlConnection c      = new SqlConnection(str);

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Order", c);
                da.Fill(virtdb, "order");
                DataTable dt = new DataTable();
                dt = virtdb.Tables["order"];
                DataRow newRow = dt.NewRow();
                newRow[0] = nuevo_pedido.OrderId;
                newRow[1] = nuevo_pedido.Product;
                newRow[2] = nuevo_pedido.Client;
                newRow[3] = nuevo_pedido.Date;
                newRow[4] = nuevo_pedido.Address;
                newRow[5] = nuevo_pedido.PostalCode;
                newRow[6] = nuevo_pedido.Quantity;
                dt.Rows.Add(newRow);
                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR adding the new order");
            }
            finally
            {
                c.Close();
            }

            return(virtdb);
        }
Example #4
0
        public DataSet read(OrderEN pedido_leido)
        {
            string s;

            s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Order", c);
                da.Fill(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR showing the order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }