private void FormOrderDetail_Load(object sender, EventArgs e) { CartProductBox.CartProducts = Order.Products; CartProductBox.UpdateView(); LabelIdHeader.Text = "#" + Order.ID.ToString(); LabelCustomer.Text = Order.Customer.Name; LabelPayment.Text = Order.Payment; LabelCreatedAt.Text = Order.CreatedAt.ToString("d MMM. yyyy"); LabelProductsValue.Text = "$" + Order.ProductsValue.ToString("0.00"); LabelShippingValue.Text = "$" + Order.ShippingValue.ToString("0.00"); LabelDiscountValue.Text = "-$" + Order.DiscountValue.ToString("0.00"); LabelTotalValue.Text = "$" + (Order.ProductsValue + Order.ShippingValue - Order.DiscountValue).ToString("0.00"); ComboBoxStatus.SelectedIndex = ComboBoxStatus.FindStringExact(Order.Status); if (Order.Status.Equals("Entregue") || Order.Status.Equals("Cancelado")) { ComboBoxStatus.Enabled = false; } }
private void ButtonSave_Click(object sender, EventArgs e) { if (!Order.Status.Equals("Pendente") && ComboBoxStatus.GetItemText(ComboBoxStatus.SelectedItem).Equals("Pendente")) { MessageBox.Show("O status do pedido não pode ser retrocedido como pendente.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Order.Status = ComboBoxStatus.GetItemText(ComboBoxStatus.SelectedItem); Order.UpdatedAt = DateTime.Now; try { DAO.Orders.Update(Order); MessageBox.Show("Pedido atualizado com sucesso."); Orders.InitializeOrResetDataGrid(); Close(); } catch { MessageBox.Show("Ocorreu um erro interno, tente novamente mais tarde.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DataGridCredits_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= -1) { DataGridViewRow rows = this.dataGridCredits.Rows[e.RowIndex]; txtCreditId.Text = rows.Cells["CREDIT_ID"].Value.ToString(); txtCreditAmount.Text = rows.Cells["AMOUNT"].Value.ToString(); txtCreditRate.Text = rows.Cells["RATE"].Value.ToString(); txtCreditName.Text = rows.Cells["NAME1"].Value.ToString(); DateTime creStartDate = DateTime.Parse(rows.Cells["START_DATE"].Value.ToString()); CreditStartDate.Value = creStartDate; txtCreditFee.Text = rows.Cells["FEE"].Value.ToString(); ComboBoxStatus.SelectedIndex = ComboBoxStatus.FindStringExact(rows.Cells["STATUS"].Value.ToString()); txtOperationalBalance.Text = rows.Cells["OPERATIONAL_BALANCE"].Value.ToString(); txtFkCustomerId.Text = rows.Cells["FK_CUSTOMER_ID"].Value.ToString(); } }