Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                List <AppOrder> list = AppOrderDAO.getAppOrders();
                byte            cont = 0;
                foreach (var order in list)
                {
                    if ((int)nudidOrder.Value == order.idOrder)
                    {
                        cont++;
                    }
                }

                if (cont > 0)
                {
                    AppOrderDAO.DeleteOrder((int)nudidOrder.Value);
                    MessageBox.Show("Orden eliminada exitosamente.", "Hugo App",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Refresh();
                }
                else
                {
                    MessageBox.Show("El ID de orden ingresado no existe");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo eliminar la orden.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #2
0
 private void btnAddOrder_Click(object sender, EventArgs e)
 {
     try
     {
         Adress  ad  = (Adress)cmbAdress.SelectedItem;
         Product pro = (Product)cmbProducts.SelectedItem;
         AppOrderDAO.InsertOrder(ad, pro);
         MessageBox.Show("Orden agregada exitosamente.", "Hugo App",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show("La orden no pudo ser agregada.", "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Пример #3
0
        private void Refresh()
        {
            cmbAdresses.DataSource    = null;
            cmbAdresses.ValueMember   = nameof(Adress.idAdress);
            cmbAdresses.DisplayMember = nameof(Adress.adress);
            cmbAdresses.DataSource    = AddressDAO.getAdresses();

            cmbBusiness.DataSource    = null;
            cmbBusiness.ValueMember   = "idBusiness";
            cmbBusiness.DisplayMember = "name";
            cmbBusiness.DataSource    = BusinessDAO.getBusinesses();

            cmbAdress.DataSource    = null;
            cmbAdress.ValueMember   = nameof(Adress.idAdress);
            cmbAdress.DisplayMember = nameof(Adress.adress);
            cmbAdress.DataSource    = AddressDAO.getAdresses();

            dgvAdresses.DataSource = AddressDAO.AddressesFromUser(user);
            dgvOrders.DataSource   = AppOrderDAO.ViewUserOrders(user);

            CmbProductUpdate();
        }
Пример #4
0
        private void NormalUser_Load(object sender, EventArgs e)
        {
            dgvAdresses.DataSource = AddressDAO.AddressesFromUser(user);
            dgvOrders.DataSource   = AppOrderDAO.ViewUserOrders(user);

            cmbAdresses.DataSource    = null;
            cmbAdresses.ValueMember   = nameof(Adress.idAdress);
            cmbAdresses.DisplayMember = nameof(Adress.adress);
            cmbAdresses.DataSource    = AddressDAO.getAdresses();

            cmbBusiness.DataSource    = null;
            cmbBusiness.ValueMember   = "idBusiness";
            cmbBusiness.DisplayMember = "name";
            cmbBusiness.DataSource    = BusinessDAO.getBusinesses();

            cmbAdress.DataSource    = null;
            cmbAdress.ValueMember   = nameof(Adress.idAdress);
            cmbAdress.DisplayMember = nameof(Adress.adress);
            cmbAdress.DataSource    = AddressDAO.getAdresses();

            CmbProductUpdate();
        }