Example #1
0
        //bool updateTime = true;
        protected void Page_Load(object sender, EventArgs e)
        {
            // Here is a good place to add which packages should be able to be seen to the dropdown.
            if (!IsPostBack)
            {
                using (var serv = new ServiceReference1.ServiceClient())
                {
                    ServiceReference1.Package[] l = Controller.kewinhalp();
                    foreach (ServiceReference1.Package p in l)
                    {
                        DropDownList1.Items.Add(p.Id.ToString());
                    }
                    fixSource();
                    //DropDownList1.Items.Add("");
                    //DropDownList1.Items.Add("");
                }

                /*
                 *
                 * {
                 *  Somebody get a list of all packages the user is supposed to see, and make it into a list, so my foreach works :)
                 *
                 *  List<ServiceReference1.Package> l = new List<ServiceReference1.Package>(YOUR LIST);
                 *
                 */


                InteractivePanelFiles.CssClass = "rightCol";
                InteractivePanelOther.CssClass = "rightCol";
            }


            //}
        }
Example #2
0
        protected void LogInButton_Click(object sender, EventArgs e)
        {
            using (var serv = new ServiceReference1.ServiceClient())
            {
                string email    = EmailTextBox.Text;
                string password = PasswordTextBox.Text;

                try {
                    Controller.LogIn(email, password);
                    Response.Redirect("Form.aspx");
                }
                catch (NotLoggedOutException)
                {
                    Response.Redirect("LogInForm.aspx");
                    // Shouldn't happen, as the page logs the user out when it loads, but if it does, reload page.
                }
                catch (NoSuchUserException)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('No user exists with that email.');", true);
                }
                catch (IncorrectPasswordException)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('The password does not match the email.');", true);
                }
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            string area = DropDownList1.Text;
            string code = sc1.getPostCode(area);

            CodeLabel.Text = code;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            string zodiac = ZodiacBox.Text;
            string result = sc1.getDate(zodiac);

            DateBox.Text = result;
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            string month  = MonBox.Text;
            string day    = DayBox.Text;
            string result = sc1.getName(month, day);

            NameBox.Text = result;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            List <Book> books = new List <Book>();
            int         index = 1;

            //Dictionary<int, Book> dict = new Dictionary<int, Book>();

            foreach (Book book in sc1.GetAllBooks())
            {
                books.Add(book);
            }

            /*int index = 1;
             * for (int i = 0; i < books.Count; i++)
             * {
             *  dict.Add(index, books[i]);
             *  index++;
             * }*/

            foreach (Book book in books)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                TableCell cell2 = new TableCell();
                TableCell cell3 = new TableCell();
                TableCell cell4 = new TableCell();
                TableCell cell5 = new TableCell();
                TableCell cell6 = new TableCell();
                TableCell cell7 = new TableCell();

                cell1.Text = Convert.ToString(index);
                index++;
                cell2.Text = book.ID;
                cell3.Text = book.name;
                cell4.Text = book.author;
                cell5.Text = Convert.ToString(book.year);
                cell6.Text = '$' + Convert.ToString(book.price);
                cell7.Text = Convert.ToString(book.stock);

                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                row.Cells.Add(cell3);
                row.Cells.Add(cell4);
                row.Cells.Add(cell5);
                row.Cells.Add(cell6);
                row.Cells.Add(cell7);

                Table1.Rows.Add(row);

                Panel1.Controls.Clear();
                AddMoreItem(count);
            }
        }
Example #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (var derp = new ServiceReference1.ServiceClient())
            {
                ServiceReference1.User myUser = derp.GetUserByEmail(TextBox1.Text);
                string type  = myUser.Type.ToString();
                string pw    = myUser.Password;
                string email = myUser.Email;

                GetUserTextBox.Text = "Type: " + type + "\nPassword: "******"\nEmail: " + email;
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            int         index  = 1;
            List <Book> result = new List <Book>();

            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            string choice = DropDownList2.Text;
            string input  = TextBox8.Text;



            foreach (Book book in sc1.SearchBook(choice, input))
            {
                result.Add(book);
            }

            foreach (Book book in result)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                TableCell cell2 = new TableCell();
                TableCell cell3 = new TableCell();
                TableCell cell4 = new TableCell();
                TableCell cell5 = new TableCell();
                TableCell cell6 = new TableCell();
                TableCell cell7 = new TableCell();

                cell1.Text = Convert.ToString(index);
                index++;
                cell2.Text = book.ID;
                cell3.Text = book.name;
                cell4.Text = book.author;
                cell5.Text = Convert.ToString(book.year);
                cell6.Text = '$' + Convert.ToString(book.price);
                cell7.Text = Convert.ToString(book.stock);

                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                row.Cells.Add(cell3);
                row.Cells.Add(cell4);
                row.Cells.Add(cell5);
                row.Cells.Add(cell6);
                row.Cells.Add(cell7);

                Table2.Rows.Add(row);
            }
        }
        protected void Button5_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            BookPurchaseInfo     info           = new BookPurchaseInfo();
            BookPurchaseResponse responce       = new BookPurchaseResponse();
            Boolean valid = true;

            try
            {
                float budget = float.Parse(TextBox9.Text);
                if (budget <= 0)
                {
                    TextBox13.Text = "budget must be positive";
                    return;
                }
                info.budget = budget;
                info.items  = new Dictionary <int, int>();
                //info.items.Add(int.Parse(TextBox10.Text), int.Parse(TextBox11.Text));
                for (int j = 0; j < count; j++)
                {
                    TextBox tb1 = (TextBox)Panel1.FindControl("book" + j);
                    TextBox tb2 = (TextBox)Panel1.FindControl("amount" + j);
                    try
                    {
                        int key   = int.Parse(tb1.Text);
                        int value = int.Parse(tb2.Text);
                        info.items.Add(key, value);
                    }
                    catch
                    {
                        TextBox13.Text = "Book number or amount is invalid";
                    }
                }

                responce.response = sc1.PurchaseBooks(info.budget, info.items, out responce.result);
                TextBox12.Text    = responce.response;
            }
            catch
            {
                TextBox13.Text = "budget is invalid";
            }
        }
Example #10
0
        protected void finalUpload_Click(object sender, EventArgs e)
        {
            using (var serv = new ServiceReference1.ServiceClient())
            {
                //make new file from the file coming from this bytearray!
                if (FileUpload1.FileName != "")
                {
                    byte[] filebytes = FileUpload1.FileBytes;
                    string desc      = Description.Value;
                    string filename  = FileUpload1.FileName;
                    string origin    = Origin.Value;

                    ServiceReference1.FileTransfer filetrans = new ServiceReference1.FileTransfer();

                    filetrans.Data = filebytes;

                    ServiceReference1.FileInfo fileinf = new ServiceReference1.FileInfo();

                    fileinf.Date        = DateTime.Now;
                    fileinf.Description = desc;
                    fileinf.Name        = FileUpload1.FileName;
                    fileinf.Origin      = origin;
                    filetrans.Info      = fileinf;

                    try { Controller.UploadFile(filetrans); }
                    catch (NotLoggedInException)
                    {
                        // #Kewin
                    }
                    catch (InadequateObjectException)
                    {
                        // Tell the user he has to selece a file from file system # Kewin
                    }
                    //Check if everything is fine, and upload the file.
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            Boolean valid  = true;
            string  ID     = TextBox1.Text;
            string  name   = TextBox2.Text;
            string  author = TextBox3.Text;

            try {
                int year  = int.Parse(TextBox4.Text);
                int price = int.Parse(TextBox5.Text);
                int stock = int.Parse(TextBox6.Text);

                List <Book> books = new List <Book>();
                foreach (Book book in sc1.GetAllBooks())
                {
                    books.Add(book);
                }
                foreach (Book book in books)
                {
                    if (book.ID.Equals(ID))
                    {
                        valid          = false;
                        TextBox13.Text = "Duplicate IDs";
                    }
                }
                if (year <= 0)
                {
                    valid          = false;
                    TextBox13.Text = "Year must be positive";
                }
                if (price <= 0)
                {
                    valid          = false;
                    TextBox13.Text = "Price must be positive";
                }
                if (stock <= 0)
                {
                    valid          = false;
                    TextBox13.Text = "Stock must be positive";
                }
                foreach (Book book in books)
                {
                    if (book.ID.Equals(ID))
                    {
                        valid = false;
                    }
                }

                if (valid)
                {
                    sc1.AddBook(ID, name, author, year, price, stock);
                    List <Book> newBooks = new List <Book>();
                    Table1.Rows.Clear();

                    int index = 1;


                    foreach (Book book in sc1.GetAllBooks())
                    {
                        newBooks.Add(book);
                    }

                    foreach (Book book in newBooks)
                    {
                        TableRow  row   = new TableRow();
                        TableCell cell1 = new TableCell();
                        TableCell cell2 = new TableCell();
                        TableCell cell3 = new TableCell();
                        TableCell cell4 = new TableCell();
                        TableCell cell5 = new TableCell();
                        TableCell cell6 = new TableCell();
                        TableCell cell7 = new TableCell();

                        cell1.Text = Convert.ToString(index);
                        index++;
                        cell2.Text = book.ID;
                        cell3.Text = book.name;
                        cell4.Text = book.author;
                        cell5.Text = Convert.ToString(book.year);
                        cell6.Text = '$' + Convert.ToString(book.price);
                        cell7.Text = Convert.ToString(book.stock);

                        row.Cells.Add(cell1);
                        row.Cells.Add(cell2);
                        row.Cells.Add(cell3);
                        row.Cells.Add(cell4);
                        row.Cells.Add(cell5);
                        row.Cells.Add(cell6);
                        row.Cells.Add(cell7);

                        Table1.Rows.Add(row);
                    }
                }
            } catch
            {
                TextBox13.Text = "invalid input";
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
            string choice = DropDownList1.Text;
            string input  = TextBox7.Text;


            /*int number = int.Parse(input);
             * if (number <= 0)
             * {
             *
             *  TextBox13.Text = "Input must be positive";
             * }*/
            sc1.DeleteBook(choice, input);
            List <Book> newBooks = new List <Book>();

            Table1.Rows.Clear();

            int index = 1;


            foreach (Book book in sc1.GetAllBooks())
            {
                newBooks.Add(book);
            }

            foreach (Book book in newBooks)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                TableCell cell2 = new TableCell();
                TableCell cell3 = new TableCell();
                TableCell cell4 = new TableCell();
                TableCell cell5 = new TableCell();
                TableCell cell6 = new TableCell();
                TableCell cell7 = new TableCell();

                cell1.Text = Convert.ToString(index);
                index++;
                cell2.Text = book.ID;
                cell3.Text = book.name;
                cell4.Text = book.author;
                cell5.Text = Convert.ToString(book.year);
                cell6.Text = '$' + Convert.ToString(book.price);
                cell7.Text = Convert.ToString(book.stock);

                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                row.Cells.Add(cell3);
                row.Cells.Add(cell4);
                row.Cells.Add(cell5);
                row.Cells.Add(cell6);
                row.Cells.Add(cell7);

                Table1.Rows.Add(row);
            }



            //sc1.DeleteBook(choice, input);
        }