private void btnAdd_Click(object sender, EventArgs e) { frmAddTarjetaMaster ventanaSetbadge = new frmAddTarjetaMaster(listViewMasterBadges, listaVirtualZones); ventanaSetbadge.txtBadge.Visible = true; ventanaSetbadge.lblBadge.Visible = false; ventanaSetbadge.txtBadge.Text = ""; ventanaSetbadge.txtBadge.Select(); ventanaSetbadge.ShowDialog(); if (ventanaSetbadge.Tag.ToString() == "True") { ListViewItem list = listViewMasterBadges.Items.Add(ventanaSetbadge.txtBadge.Text); list.UseItemStyleForSubItems = false; list.SubItems.Add(ventanaSetbadge.rdbEntrada.Checked ? TiposAcceso.Entrada.ToString() : TiposAcceso.Salida.ToString()); list.SubItems.Add(ventanaSetbadge.cmbVZone.Text); } ventanaSetbadge.Dispose(); }
private void btnModify_Click(object sender, EventArgs e) { frmAddTarjetaMaster ventanaSetbadge = new frmAddTarjetaMaster(listViewMasterBadges, listaVirtualZones); if (listViewMasterBadges.SelectedIndices.Count == 0) { MessageBox.Show("Please select at least one Badge", "Warning"); return; } ventanaSetbadge.txtBadge.Visible = false; ventanaSetbadge.lblBadge.Visible = true; if (listViewMasterBadges.SelectedIndices.Count == 1) { ventanaSetbadge.lblBadge.Text = listViewMasterBadges.SelectedItems[0].Text; if (listViewMasterBadges.SelectedItems[0].SubItems[1].Text == TiposAcceso.Entrada.ToString()) { ventanaSetbadge.rdbEntrada.Checked = true; } else { ventanaSetbadge.rdbSalida.Checked = true; } ventanaSetbadge.cmbVZone.Text = listViewMasterBadges.SelectedItems[0].SubItems[2].Text; } else { ventanaSetbadge.lblBadge.Text = listViewMasterBadges.SelectedItems.Count + " selected badges"; // Si todas los Tipos de los seleccionados coinciden, se la precargo a al formulario string tipoAccesoRef = listViewMasterBadges.SelectedItems[0].SubItems[1].Text; bool cambio = false; foreach (ListViewItem l in listViewMasterBadges.SelectedItems) { if (!l.SubItems[1].Text.Equals(tipoAccesoRef)) { cambio = true; break; } } if (!cambio) { if (tipoAccesoRef == TiposAcceso.Entrada.ToString()) { ventanaSetbadge.rdbEntrada.Checked = true; } else { ventanaSetbadge.rdbSalida.Checked = true; } } ventanaSetbadge.cmbVZone.Text = listViewMasterBadges.SelectedItems[0].SubItems[2].Text; } ventanaSetbadge.ShowDialog(); if (bool.Parse(ventanaSetbadge.Tag.ToString())) // Click en OK. Actualizar el listBox. { foreach (ListViewItem l in listViewMasterBadges.SelectedItems) { string tipo = ventanaSetbadge.rdbEntrada.Checked ? TiposAcceso.Entrada.ToString() : TiposAcceso.Salida.ToString(); l.SubItems[1].Text = tipo; l.SubItems[2].Text = ventanaSetbadge.cmbVZone.Text; } somethingChanged = true; } ventanaSetbadge.Dispose(); }