private void Aceptar_Click(object sender, EventArgs e) { if (Validar.Validate()) { try { string RCodigo = Convert.ToString(Codigo.EditValue); string RDescripcion = Convert.ToString(Descripcion.EditValue); bool RActivo = Activo.Checked; pasar(RCodigo, RDescripcion, RActivo); this.Close(); } catch (DbEntityValidationException t) { var Formulario = new Elementos.frmResult(); foreach (DbEntityValidationResult item in t.EntityValidationErrors) { DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Formulario.MemoEd.Text += message + "\n"; Formulario.Show(); } } } } }
private void ACEPTAR_Click(object sender, EventArgs e) { int z = 0; int index = 0; if (Validar.Validate()) { try { foreach (DataGridViewRow Fila in dataGridView1.Rows) { foreach (DataGridViewColumn Columna in dataGridView1.Columns) { if (dataGridView1.Rows[Fila.Index].Cells[Columna.Index].Value == null) { z += 1; index = Fila.Index; } } if (z > 7) { dataGridView1.Rows.RemoveAt(index); } } string Rv = Convert.ToString(RVCODIGO.EditValue).Trim(); foreach (DataGridViewRow R in dataGridView1.Rows) { string Zona = Convert.ToString(dataGridView1.Rows[R.Index].Cells["Codigo"].Value).Trim(); foreach (DataGridViewColumn C in dataGridView1.Columns) { string DiaSemana = Convert.ToString(dataGridView1.Columns[C.Index].Name).Trim(); switch (dataGridView1.Columns[C.Index].Name) { case "Lunes": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 1 }); } break; case "Martes": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 2 }); } break; case "Miercoles": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 3 }); } break; case "Jueves": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 4 }); } break; case "Viernes": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 5 }); } break; case "Sabado": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 6 }); } break; case "Domingo": if (Convert.ToBoolean(dataGridView1.Rows[R.Index].Cells[C.Index].Value)) { Visitas.Rows.Add(new object[] { Zona, Rv, DiaSemana, 7 }); } break; } } } pasar(Visitas, Rv); this.Close(); } catch (DbEntityValidationException t) { var Formulario = new Elementos.frmResult(); foreach (DbEntityValidationResult item in t.EntityValidationErrors) { DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Formulario.MemoEd.Text += message + "\n"; Formulario.Show(); } } } } }