protected void gvConvocatoriasEnObservacion_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("EliminarConvocatoria")) { if (e.CommandArgument != null) { var codigoConvocatoria = Convert.ToInt32(e.CommandArgument.ToString()); using (Datos.ObservacionEvaluacionDataContext db = new Datos.ObservacionEvaluacionDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["SubComponent"].ConnectionString)) { var entity = db.LOVObjetoSEs.Single(filter => filter.Id_LovObjetoSE.Equals(codigoConvocatoria)); db.LOVObjetoSEs.DeleteOnSubmit(entity); db.SubmitChanges(); gvConvocatoriasEnObservacion.DataBind(); } } } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Sucedio un error detalle :" + ex.Message; } }
protected void btnAddConvocatoria_Click(object sender, EventArgs e) { try { Int32 codigoConvocatoria = Convert.ToInt32(cmbConvocatorias.SelectedValue); using (Datos.FonadeDBDataContext db = new Datos.FonadeDBDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) { var entity = db.Convocatoria.Single(filter => filter.Id_Convocatoria.Equals(codigoConvocatoria)); if (entity == null) { throw new ApplicationException("No se logro obtener la informaciĆ³n de la convocatoria."); } using (Datos.ObservacionEvaluacionDataContext db2 = new Datos.ObservacionEvaluacionDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["SubComponent"].ConnectionString)) { var observacion = new LOVObjetoSE { NomLovObjetoSE = "Convocatorias", Valor = entity.Id_Convocatoria.ToString(), Descripcion = entity.NomConvocatoria }; db2.LOVObjetoSEs.InsertOnSubmit(observacion); db2.SubmitChanges(); gvConvocatoriasEnObservacion.DataBind(); } } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Sucedio un error, detalle :" + ex.Message; } }