Пример #1
0
        public DataSet deleteOrder(OrderEN o, int i) // It will delete the index passed in the view
        {
            string s;

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

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from OrderList where Buy = '0'", 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: Delete order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Пример #2
0
        public ArrayList searchOrder(OrderEN o)
        {
            ArrayList     a = new ArrayList();
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand    com = new SqlCommand("Select * from Order where Id = " + o.Id, c);
                SqlDataReader dr  = com.ExecuteReader();
                while (dr.Read())
                {
                    a.Add(dr["Id"].ToString());
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Show Order");
            }
            finally
            {
                c.Close();
            }
            return(a);
        }
Пример #3
0
        public void deleteOrder(OrderEN o)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Delete From Order Where Id = " + o.Id, c);
                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Delete Order");
            }
            finally
            {
                c.Close();
            }
        }
Пример #4
0
        public DataSet addOrder(OrderEN o)
        {
            string s;

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

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from OrderList", c);
                da.Fill(virtdb, "order");
                DataTable dt = new DataTable();
                dt = virtdb.Tables["order"];
                DataRow newRow = dt.NewRow();
                newRow[0] = o.id;
                newRow[1] = o.product;
                newRow[2] = o.productName;
                newRow[3] = o.price;
                newRow[4] = o.userN;
                newRow[5] = o.adults;
                newRow[6] = o.children;
                newRow[7] = o.buy;
                newRow[8] = o.totalPrice;
                dt.Rows.Add(newRow);
                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Add order");
            }
            finally
            {
                c.Close();
            }

            return(virtdb);
        }
Пример #5
0
        public DataSet updateOrder(OrderEN o, 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 OrderList", c);
                da.Fill(virtdb, "order");
                DataTable t = new DataTable();
                t = virtdb.Tables["order"];

                t.Rows[i]["Id"]          = o.id;
                t.Rows[i]["Product"]     = o.product;
                t.Rows[i]["ProductName"] = o.productName;
                t.Rows[i]["Price"]       = o.price;
                t.Rows[i]["UserN"]       = o.userN;
                t.Rows[i]["Adults"]      = o.adults;
                t.Rows[i]["Children"]    = o.children;
                t.Rows[i]["Buy"]         = 1;
                t.Rows[i]["TotalPrice"]  = o.totalPrice;

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Delete order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Пример #6
0
        public void updateOrder(OrderEN o)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Update Order Set Product = '" + o.Product + "', Price = '" + o.Price + "', User = '******', Quantity ='" +
                                                o.Quantity + "', Date = '" + o.Date + "' Where Id = " + o.Id, c);
                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Update Order");
            }
            finally
            {
                c.Close();
            }
        }
Пример #7
0
        public void addOrder(OrderEN o)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Insert Into Order (Id,Product,Price,User,Quantity,Date) VALUES ('" + o.Id + "','" + o.Product + "','" + o.Price + "','" +
                                                o.User + "','" + o.Quantity + "','" + o.Date + "')", c);

                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Add Order");
            }
            finally
            {
                c.Close();
            }
        }
Пример #8
0
        public DataSet showOrders(OrderEN o)
        {
            string s;

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

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from OrderList", c);
                da.Fill(virtdb, "order");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: show order");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Пример #9
0
        public void buyOrder(OrderEN O, int ID)
        {
            string s;

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

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Update OrderList Set Buy = '" + 1 + "' Where Id = '" + ID + "'", c);

                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Update Buy");
            }
            finally
            {
                c.Close();
            }
        }