private void dgvPromociones_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { PromocionWS.promocion promocion = dgvPromociones.Rows[e.RowIndex].DataBoundItem as PromocionWS.promocion; dgvPromociones.Rows[e.RowIndex].Cells["ZONA"].Value = promocion.zona.nombre; }
private void dgvPromociones_CellContentDoubleClick_1(object sender, DataGridViewCellEventArgs e) { promocionSeleccionada = (PromocionWS.promocion)dgv.CurrentRow.DataBoundItem; frmMostrarPromocion formMostrarPromocion = new frmMostrarPromocion(promocionSeleccionada); if (formMostrarPromocion.ShowDialog() == DialogResult.OK) { } }
public frmMostrarPromocion(PromocionWS.promocion promocionSeleccionada) { daoPromocionXProducto = new PromocionXProductoWS.PromocionXProductoWSClient(); daoZona = new ZonaWS.ZonaWSClient(); InitializeComponent(); txtId.Text = promocionSeleccionada.idPromocion.ToString(); txtNombre.Text = promocionSeleccionada.nombre; txtDescripcion.Text = promocionSeleccionada.descripcion; dtpFechaInicio.Value = promocionSeleccionada.fechaInicio; dtpFechaFin.Value = promocionSeleccionada.fechaFin; ZonaWS.zona[] listaZonas = daoZona.listarZonas(); if (listaZonas == null || listaZonas.Length < 1) { cboZona.DataSource = new BindingList <ZonaWS.zona>(); } cboZona.DataSource = new BindingList <ZonaWS.zona>(listaZonas); cboZona.ValueMember = "idZona"; cboZona.DisplayMember = "nombre"; cboZona.SelectedValue = promocionSeleccionada.zona.idZona; PromocionXProductoWS.promocionXProducto[] listaPromocionXProducto = daoPromocionXProducto.listarPromocionXProducto(promocionSeleccionada.idPromocion); dgvPromocionXProducto.AutoGenerateColumns = false; if (listaPromocionXProducto == null || listaPromocionXProducto.Length < 1) { dgvPromocionXProducto.DataSource = new BindingList <PromocionXProductoWS.promocionXProducto>(); } else { dgvPromocionXProducto.DataSource = new BindingList <PromocionXProductoWS.promocionXProducto>(listaPromocionXProducto); } #region colores de seleccion dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowsDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowsDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); #endregion }
public static void eliminar() { promocionSeleccionada = (PromocionWS.promocion)dgv.CurrentRow.DataBoundItem; daoPromocion.eliminarPromocion(promocionSeleccionada.idPromocion); }
public frmNuevaPromocion() { InitializeComponent(); #region colores de seleccion dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowsDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowsDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); #endregion daoPromocion = new PromocionWS.PromocionWSClient(); daoPromocionXProducto = new PromocionXProductoWS.PromocionXProductoWSClient(); daoZona = new ZonaWS.ZonaWSClient(); cboZona.DataSource = new BindingList <ZonaWS.zona>(daoZona.listarZonas().ToArray()); cboZona.ValueMember = "idZona"; cboZona.DisplayMember = "nombre"; if (frmVentanaPrincipal.nBtn == 1) { //OBTNER DATOS DE FILA SELECCIONADA PromocionWS.promocion miPromocion = new PromocionWS.promocion(); if (Program.pantallas[Program.pantallas.Count - 1].Formulario.Name == "frmGestionarPromociones") { frmGestionarPromociones.promocionSeleccionada = (PromocionWS.promocion)frmGestionarPromociones.dgv.CurrentRow.DataBoundItem; miPromocion = frmGestionarPromociones.promocionSeleccionada; } else { frmBuscarPromocion.promocionSeleccionada = (PromocionWS.promocion)frmBuscarPromocion.dgv.CurrentRow.DataBoundItem; miPromocion = frmBuscarPromocion.promocionSeleccionada; } txtId.Text = miPromocion.idPromocion.ToString(); txtNombre.Text = miPromocion.nombre; txtDescripcion.Text = miPromocion.descripcion; dtpFechaInicio.Value = miPromocion.fechaInicio; dtpFechaFin.Value = miPromocion.fechaFin; cboZona.SelectedValue = miPromocion.zona.idZona; //Listar los productos de la promoción. txtDescuento.Enabled = false; txtStock.Enabled = false; btnAddProducto.Enabled = false; btnRemoveProducto.Enabled = false; btnBuscarProducto.Enabled = false; cboZona.Enabled = false; int idPromocion = miPromocion.idPromocion; PromocionXProductoWS.promocionXProducto[] auxPromoXProd = daoPromocionXProducto.listarPromocionXProducto(idPromocion); if (auxPromoXProd.Length == 0) { misPromocionXProducto = new BindingList <PromocionXProductoWS.promocionXProducto>(); } else { misPromocionXProducto = new BindingList <PromocionXProductoWS.promocionXProducto>(auxPromoXProd.ToList()); } cargarTabla(); } else { misPromocionXProducto = new BindingList <PromocionXProductoWS.promocionXProducto>(); cargarTabla(); } #region colores de seleccion dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.ColumnHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowHeadersDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); dgvPromocionXProducto.RowsDefaultCellStyle.SelectionBackColor = Program.colorR; dgvPromocionXProducto.RowsDefaultCellStyle.SelectionForeColor = ThemeColor.ChangeColorBrightness(Program.colorR, -0.7); #endregion }
private void btnGuardar_Click(object sender, EventArgs e) { foreach (Control c in groupBox1.Controls) { if (c is TextBox) { TextBox textBox = c as TextBox; if (textBox.Text == string.Empty && textBox.Name != "txtId") { MessageBox.Show("Falta llenar los datos de " + textBox.Name.Substring(3), "Mensaje de advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } foreach (Control c in groupBox2.Controls) { if (c is ComboBox) { ComboBox cmbBox = c as ComboBox; if (cmbBox.SelectedIndex == -1) { MessageBox.Show("Falta llenar los datos de " + cmbBox.Name.Substring(3), "Mensaje de advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } if (dtpFechaFin.Value < DateTime.Now) { MessageBox.Show("Fecha final de la promocion invalida", "Mensaje de advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dtpFechaInicio.Value > dtpFechaFin.Value) { MessageBox.Show("Rango de fechas invalido", "Mensaje de advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (misPromocionXProducto == null || misPromocionXProducto.Count == 0) { MessageBox.Show("Falta agregar los productos de la promocion", "Mensaje de advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } frmConfirmarInsertar formInsertar = new frmConfirmarInsertar(); if (formInsertar.ShowDialog() == DialogResult.OK) { PromocionWS.promocion promocion = new PromocionWS.promocion(); promocion.zona = new PromocionWS.zona(); promocion.zona.idZona = ((ZonaWS.zona)cboZona.SelectedItem).idZona; promocion.nombre = txtNombre.Text; promocion.descripcion = txtDescripcion.Text; promocion.fechaInicio = dtpFechaInicio.Value; promocion.fechaInicioSpecified = true; promocion.fechaFin = dtpFechaFin.Value; promocion.fechaFinSpecified = true; int numPromocionXProducto = misPromocionXProducto.Count; promocion.listaPromocionXProducto = new PromocionWS.promocionXProducto[numPromocionXProducto]; for (int cont = 0; cont < numPromocionXProducto; cont++) { promocion.listaPromocionXProducto[cont] = new PromocionWS.promocionXProducto(); promocion.listaPromocionXProducto[cont].producto = new PromocionWS.producto(); promocion.listaPromocionXProducto[cont].producto.idProducto = ((PromocionXProductoWS.promocionXProducto)misPromocionXProducto.ElementAt(cont)).producto.idProducto; promocion.listaPromocionXProducto[cont].precioReal = ((PromocionXProductoWS.promocionXProducto)misPromocionXProducto.ElementAt(cont)).precioReal; promocion.listaPromocionXProducto[cont].descuento = ((PromocionXProductoWS.promocionXProducto)misPromocionXProducto.ElementAt(cont)).descuento; promocion.listaPromocionXProducto[cont].stock = ((PromocionXProductoWS.promocionXProducto)misPromocionXProducto.ElementAt(cont)).stock; } if (frmVentanaPrincipal.nBtn == 0) { int resultado = daoPromocion.insertarPromocion(promocion); txtId.Text = resultado.ToString(); if (resultado == 0) { MessageBox.Show("No se insertó correctamente", "Mensaje de error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ((frmGestionarPromociones)Program.pantallas[Program.pantallas.Count - 2].Formulario).recargarDGV(); MessageBox.Show("Se insertó correctamente", "Mensaje de confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (frmVentanaPrincipal.nBtn == 1) { promocion.idPromocion = Int32.Parse(txtId.Text); int resultado = daoPromocion.actualizarPromocion(promocion); if (resultado == 0) { MessageBox.Show("No se actualizó correctamente", "Mensaje de error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ((frmGestionarPromociones)Program.pantallas[Program.pantallas.Count - 2].Formulario).recargarDGV(); MessageBox.Show("Se actualizó correctamente", "Mensaje de confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }