예제 #1
0
        protected void btnAddItem_OnClick(object sender, EventArgs e)
        {
            //Creating a new item dao to update an existing item  in the database
            ItemDao dao = new ItemDao(Properties.Settings.Default.conString);

            if (!float.TryParse(txtPrice.Text, out float price))
            {
                price = -1;
            }

            Item item = new Item(int.Parse(drpDepartment.SelectedValue), TxtName.Text,
                                 hidFinalCoords.Value, txtDescription.Text, price);

            //Inserting item table as well as redirecting back to the admin form
            dao.AddItem(item);

            MessageBox.Show("Item added successfully.", "Item Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Response.Redirect("/User/UserForm.aspx");
        }
예제 #2
0
        protected void btnAddItem_OnClick(object sender, EventArgs e)
        {
            //Creating a new item dao to update an existing item  in the database
            var dao = new ItemDao(Properties.Settings.Default.conString);

            if (!float.TryParse(txtPrice.Text, out float price))
            {
                price = -1;
            }

            var item = new Item(int.Parse(drpDepartment.SelectedValue),
                                TxtName.Text,
                                hidFinalCoords.Value, txtDescription.Text, price);

            Debug.WriteLine("DEP: " + drpDepartment.SelectedValue);
            Debug.WriteLine("DEP: " + drpDepartment.SelectedValue);
            Debug.WriteLine("DEP: " + drpDepartment.SelectedValue);

            //Inserting item table as well as redirecting back to the admin form
            dao.AddItem(item);
        }