private void AgregarButton_Click_1(object sender, EventArgs e) { if (BienDeUsoComboBox.SelectedIndex == -1) { errorProvider1.SetError(BienDeUsoComboBox, "Seleccione un bien de uso"); BienDeUsoComboBox.Focus(); return; } errorProvider1.Clear(); if (MarcaComboBox.SelectedIndex == -1) { errorProvider1.SetError(MarcaComboBox, "Seleccione una marca"); BienDeUsoComboBox.Focus(); return; } errorProvider1.Clear(); DMarcaBienUso dMarcaBienUso = new DMarcaBienUso(); int codBienUso = (int)BienDeUsoComboBox.SelectedValue; if (!dMarcaBienUso.BienUsoTieneMarcaAsociada(codBienUso)) { MessageBox.Show("El bien de uso seleccionado no tiene una marca asociada, no se puede agregar a la solicitud", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); BienDeUsoComboBox.SelectedIndex = -1; MarcaComboBox.SelectedIndex = -1; CantidadNumericUpDown.Value = 1; return; } var detalle = new DetalleSolicitud { CodBienUso = codBienUso, NombreBienUso = dBienUso.GetNombreBienUsoByCodBienUso((int)BienDeUsoComboBox.SelectedValue), Marca = marca.GetNombreMarcaByCodMarca((int)MarcaComboBox.SelectedValue), Cantidad = Convert.ToInt32(CantidadNumericUpDown.Value) }; misDetalles.Add(detalle); ActualizarGrid(); BienDeUsoComboBox.SelectedIndex = -1; CantidadNumericUpDown.Value = 1; MarcaComboBox.SelectedIndex = -1; BienDeUsoComboBox.Focus(); }
private void GuardarMarcaButton_Click(object sender, EventArgs e) { if (MarcaComboBox.SelectedIndex == -1) { errorProvider1.SetError(MarcaComboBox, "Debe seleccionar una marca"); MarcaComboBox.Focus(); return; } var dMarcaBienUso = new DMarcaBienUso(); string msg = dMarcaBienUso.InsertMarcaBienUso((int)MarcaComboBox.SelectedValue, (int)DgvBienesUso.SelectedRows[0].Cells[0].Value); MessageBox.Show(msg, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); CancelarMarcaButton_Click(sender, e); }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { DialogResult rta = MessageBox.Show("¿Está seguro de borrar el registro?" + Environment.NewLine + "Si continúa, borrará también la asociación del bien con su(s) marca(s)", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (rta == DialogResult.No) { return; } //Comprobamos que el bien de uso no tenga proveedores asociados var dproveedores = new DProveedores(); int codBuso = (int)DgvBienesUso.SelectedRows[0].Cells[0].Value; if (dproveedores.ExisteBienUsoProveedor(codBuso)) { MessageBox.Show("El bien de uso tiene proveedores asociados, no puede eliminarse", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var dMarcaBienUso = new DMarcaBienUso(); string msg = dMarcaBienUso.DeleteMarcaBienUso(codBuso); MessageBox.Show(msg, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); var mensaje = dBienUso.DeleteBienUso(codBuso); var popup1 = new PopupNotifier() { Image = mensaje == "Se eliminó el registro correctamente" ? Properties.Resources.info100 : Properties.Resources.sql_error, TitleText = "Mensaje", ContentText = msg, ContentFont = new Font("Segoe UI Bold", 11F), TitleFont = new Font("Segoe UI Bold", 10F) }; popup1.Popup(); }