private void btnBuscar_Click(object sender, EventArgs e) { frmBuscarDescuento formDescuento = new frmBuscarDescuento(); if (formDescuento.ShowDialog() == DialogResult.OK) { descuento = formDescuento.DescuentoSeleccionado; txtPorcentaje.Text = descuento.porcentaje.ToString(); txtDescripcion.Text = descuento.descripcion; txtNombre.Text = descuento.nombre; if (descuento.tipo.Equals('C')) { cboTipo.SelectedIndex = 0; } else { cboTipo.SelectedIndex = 1; } estadoComponentes(Estado.Buscar); } else { limpiarCompentes(); estadoComponentes(Estado.Inicial); } }
private void cboDescuentos_SelectedIndexChanged(object sender, EventArgs e) { Service.descuento d = (Service.descuento)cboDescuentos.SelectedItem; float t; if (float.TryParse(txtPrecio.Text, out t)) { if (d != null) { t = (float.Parse(txtPrecio.Text) * (100 - d.porcentaje) / 100); } else { t = float.Parse(txtPrecio.Text); } txtTotal.Text = t.ToString(); } else { frmMensaje mensaje = new frmMensaje("Ingrese un precio válido", "Error de precio", ""); if (mensaje.ShowDialog() == DialogResult.OK) { } cboDescuentos.SelectedIndex = -1; txtSaldo.Text = "0"; txtTotal.Text = "0"; } }
private void dgvDescuentos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { Service.descuento data = (Service.descuento)dgvDescuentos.Rows[e.RowIndex].DataBoundItem; if (data != null) { dgvDescuentos.Rows[e.RowIndex].Cells["Nombre"].Value = data.nombre; } }
private void cboDescuentos_SelectedIndexChanged(object sender, EventArgs e) { Service.descuento d = (Service.descuento)cboDescuentos.SelectedItem; float t; if (d != null && txtPrecio.Text != "0") { Console.WriteLine("txtPrecio: ", txtPrecio.Text); if (float.TryParse(txtPrecio.Text, out t)) { t = (float.Parse(txtPrecio.Text) * (100 - d.porcentaje)/100); Console.WriteLine("t: ", t); txtTotal.Text = t.ToString(); } else { txtTotal.Text = "No se puede convertir"; } } }
private void btnGuardar_Click(object sender, EventArgs e) { List <Service.descuento> descuentos = new List <Service.descuento>(); for (int i = 0; i < dgvDescuentos.Rows.Count; i++) { if (dgvDescuentos.Rows[i].Cells[1].Value == null) { } else if ((bool)dgvDescuentos.Rows[i].Cells[1].Value == true) { Service.descuento des = new Service.descuento(); des = (Service.descuento)dgvDescuentos.Rows[i].DataBoundItem; descuentos.Add(des); } } curso.desAplicables = descuentos.ToArray <Service.descuento>(); Program.dbController.actualizarCurso(curso); frmMensaje mensaje = new frmMensaje("Descuentos actualizados", "Mensaje de confirmación", "Confirmar"); }