Exemple #1
0
        public Boolean AdminUsers_Insert(List <object> bookstore, SqlConnection conn)
        {
            DBGetID gID = new DBGetID();
            int     id  = gID.GetID("AdminUsers", conn);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "INSERT INTO AdminUsers VALUES "
                              + "(@UserID, @AdminLevel)";
            cmd.Parameters.AddWithValue("@UserID", id);
            cmd.Parameters.AddWithValue("@AdminLevel", bookstore[0]);
            conn.Open();
            int result = cmd.ExecuteNonQuery();

            return(!(result < 0));
        }
Exemple #2
0
        public Boolean Supplier_Insert(List <object> bookstore, SqlConnection conn)
        {
            DBGetID gID = new DBGetID();
            int     id  = gID.GetID("Supplier", conn);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "INSERT INTO Supplier VALUES "
                              + "(@SupplierId, @Name)";
            cmd.Parameters.AddWithValue("@SupplierId", id);
            cmd.Parameters.AddWithValue("@Name", bookstore[0]);
            conn.Open();
            int result = cmd.ExecuteNonQuery();

            return(!(result < 0));
        }
Exemple #3
0
        public Boolean Category_Insert(List <object> bookstore, SqlConnection conn)
        {
            DBGetID gID = new DBGetID();
            int     id  = gID.GetID("Category", conn);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "INSERT INTO Category VALUES "
                              + "(@CategoryID, @Name, @Description)";
            cmd.Parameters.AddWithValue("@CategoryID", id);
            cmd.Parameters.AddWithValue("@Name", bookstore[0]);
            cmd.Parameters.AddWithValue("@Description", bookstore[1]);
            conn.Open();
            int result = cmd.ExecuteNonQuery();

            return(!(result < 0));
        }
Exemple #4
0
        public int PlaceOrderFinal(int userID)
        {
            DBQueries dbQ     = new DBQueries();
            bool      res     = false;
            var       conn    = new SqlConnection(Properties.Settings.Default.dbConnectionString);
            int       orderId = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "INSERT INTO Orders (UserID, Status) VALUES "
                                  + " (@UserID, @Status)";
                cmd.Parameters.AddWithValue("@UserID", userID);
                cmd.Parameters.AddWithValue("@Status", "P");
                conn.Open();
                cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            DBGetID dbG = new DBGetID();

            orderId = (dbG.GetID("Orders", conn)) - 1;
            foreach (var item in orderItemList)
            {
                List <object> bookstore1 = new List <object>(
                    new object[] { orderId, item.BookID, item.Quantity }
                    );
                dbQ.INSERT_INTO_TABLE("OrderItem", bookstore1);
            }

            return(orderId);
        }
Exemple #5
0
        public Boolean UserData_Insert(List <object> bookstore, SqlConnection conn)
        {
            DBGetID gID = new DBGetID();
            int     id  = gID.GetID("UserData", conn);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "INSERT INTO UserData VALUES "
                              + "(@UserID, @Username, @Password, @Type, @Manager, @FullName)";
            cmd.Parameters.AddWithValue("@UserID", id);
            cmd.Parameters.AddWithValue("@Username", bookstore[0]);
            cmd.Parameters.AddWithValue("@Password", bookstore[1]);
            cmd.Parameters.AddWithValue("@Type", bookstore[2]);
            cmd.Parameters.AddWithValue("@Manager", bookstore[3]);
            cmd.Parameters.AddWithValue("@FullName", bookstore[4]);
            conn.Open();
            int result = cmd.ExecuteNonQuery();

            return(!(result < 0));
        }