Exemplo n.º 1
0
        public DataSet delete(ProductEN producto_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 Product", c);
                da.Fill(virtdb, "product");
                DataTable t = new DataTable();
                t = virtdb.Tables["product"];

                t.Rows[i].Delete();

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "product");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR Deleting the product");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Exemplo n.º 2
0
 //Copy constructor
 public OrderEN(int orderId, ClientEN client, ProductEN product, DateTime date, String address, int postalCode)
 {
     this.orderId    = orderId;
     this.client     = client;
     this.product    = product;
     this.date       = date;
     this.address    = address;
     this.postalCode = postalCode;
 }
Exemplo n.º 3
0
        public DataSet addProduct(ProductEN producto_nuevo)
        {
            String str;

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

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Product", c);
                da.Fill(virtdb, "product");
                DataTable dt = new DataTable();
                dt = virtdb.Tables["product"];
                DataRow newRow = dt.NewRow();
                newRow[0] = producto_nuevo.Id;
                newRow[1] = producto_nuevo.Price;
                newRow[2] = producto_nuevo.Color;
                newRow[3] = producto_nuevo.FilepathPicture;
                newRow[4] = producto_nuevo.Name;
                newRow[5] = producto_nuevo.Brand;
                dt.Rows.Add(newRow);
                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "product");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR adding the new product");
            }
            finally
            {
                c.Close();
            }

            return(virtdb);
        }
Exemplo n.º 4
0
        public DataSet update(ProductEN producto_actualizado, 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 Product'", c);
                da.Fill(virtdb, "product");
                DataTable t = new DataTable();
                t = virtdb.Tables["product"];

                t.Rows[i]["Id"]              = producto_actualizado.Id;
                t.Rows[i]["Price"]           = producto_actualizado.Price;
                t.Rows[i]["Color"]           = producto_actualizado.Color;
                t.Rows[i]["FilepathPicture"] = producto_actualizado.FilepathPicture;
                t.Rows[i]["Name"]            = producto_actualizado.Name;
                t.Rows[i]["Brand"]           = producto_actualizado.Brand;

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "product");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR Updating the product");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Exemplo n.º 5
0
        public DataSet read(ProductEN producto_leido)
        {
            string s;

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

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