private void button1_Click(object sender, EventArgs e) { var lista = OrderDAO.getList(); dataGridView1.DataSource = null; dataGridView1.DataSource = lista; }
private void btnOrder_Click(object sender, EventArgs e) { if (cmbBusiness.Items.Count == 0 || cmbProducts.Items.Count == 0 || cmbAddress.Items.Count == 0) { MessageBox.Show("Faltan datos en su compra.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { Order order = new Order(); order.IdProduct = (int)cmbProducts.SelectedValue; order.IdAddress = (int)cmbAddress.SelectedValue; order.CreateDate = DateTime.Now.ToLocalTime(); OrderDAO.CreateOrder(order); MessageBox.Show("La orden ha sido realizada con éxito.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateOrderTable(); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error. " + exception.Message, "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void UpdateOrderTable() { dgvShowOrders.DataSource = null; dgvShowOrders.DataSource = OrderDAO.GetOrderTable(user.IdUser); nudOrderID.Maximum = dgvShowOrders.RowCount > 0 ? Convert.ToInt32( dgvShowOrders.Rows[dgvShowOrders.RowCount - 1].Cells[0].Value.ToString()) : 0; }
public OrdersManage() { InitializeComponent(); removeTextInit = this.label5.Text; this.dataGridView1.DataSource = OrderDAO.SelectOrderUserFromOrder(); resetComboBox1(); resetComboBox2(); resetComboBox3(); }
private void button1_Click(object sender, EventArgs e) { if (this.comboBox1.SelectedIndex != -1 && this.comboBox2.SelectedIndex != -1) { OrderDAO.AddNew(productos[this.comboBox2.SelectedIndex].id + ", " + addreses[this.comboBox1.SelectedIndex].id); this.dataGridView1.DataSource = OrderDAO.SelectOrderUserFromOrder(); resetComboBox1(); resetComboBox2(); resetComboBox3(); } else { MessageBox.Show("Selecciona todas las opciones"); } }
private void resetComboBox3() { orders = OrderDAO.GetList(); var names = new object[orders.Count]; int n = 0; foreach (var i in orders) { names[n] = i.id + " - " + i.product + " (" + i.date + ")"; n++; } this.comboBox3.SelectedIndex = -1; this.comboBox3.Items.Clear(); this.comboBox3.Items.AddRange(names); }
private void button2_Click(object sender, EventArgs e) { int num = this.comboBox3.SelectedIndex; if (num != -1) { OrderDAO.RemoveOrder(orders[num].id); this.dataGridView1.DataSource = OrderDAO.SelectOrderUserFromOrder(); resetComboBox1(); resetComboBox2(); resetComboBox3(); } else { MessageBox.Show("Selecciona una opcion antes de eliminar"); } }
private void btnDeleteOrder_Click(object sender, EventArgs e) { if (nudOrderID.Value == 0) { MessageBox.Show("Debe seleccionar una orden", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { OrderDAO.DeleteOrder(user.IdUser, (int)nudOrderID.Value);//Orden no le pertenece o no existe MessageBox.Show("La orden ha sido eliminada con éxito.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateOrderTable(); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error. " + exception.Message, "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public OrdersHistory() { InitializeComponent(); dataGridView1.DataSource = OrderDAO.SelectFromOrder(); }
private void UpdatedgvShowOrders() { dgvShowOrders.DataSource = null; dgvShowOrders.DataSource = OrderDAO.GetOrderTable(); }