private void btnGuardar_Click(object sender, EventArgs e) { try { string Tipo = cboTipo.SelectedItem.ToString(); if (Nuevo == true) { using (Profit_RGEntities context = new Profit_RGEntities()) { context.pInsertarProgramas (txtDescrip.Text.Trim(), txtDesde.Value, txtHasta.Value, new TimeSpan(txtHora.Value.Hour, txtHora.Value.Minute, txtHora.Value.Second), chkLunes.CheckState == CheckState.Checked ? true : false, chkMartes.CheckState == CheckState.Checked ? true : false, chkMiercoles.CheckState == CheckState.Checked ? true : false, chkJueves.CheckState == CheckState.Checked ? true : false, chkViernes.CheckState == CheckState.Checked ? true : false, chkSabado.CheckState == CheckState.Checked ? true : false, chkDomingo.CheckState == CheckState.Checked ? true : false, cboReporte.SelectedValue.ToString(), txtPara.Text.Trim(), txtCopia.Text.Trim(), txtOculto.Text.Trim(), txtGrupo.Text.Trim(), cboHabilitado.SelectedItem.ToString() == "Si" ? true : false, Concurrencia, null, Tipo, null); Int32?Id = context.Programas.OrderByDescending(p => p.id_evento).FirstOrDefault().id_evento; foreach (var item in Vp) { context.pInsertarValores_prog(Id, item.parametro.Trim(), item.Val_char.Trim(), item.Val_int, item.Val_dec, item.Val_date, new TimeSpan(item.Val_time.Value.Hours, item.Val_time.Value.Minutes, item.Val_time.Value.Seconds), item.Val_bit); } P = context.Programas.ToList(); context.pInsertarUsu_Prg(Usuario_Act, Id); Navegar(3); //cboList.DataSource = P; //cboList.ValueMember = "id_evento"; //cboList.DisplayMember = "Descrip"; } } else { using (Profit_RGEntities context = new Profit_RGEntities()) { context.pActualizarProgramas(txtDescrip.Text.Trim(), txtDesde.Value, txtHasta.Value, new TimeSpan(txtHora.Value.Hour, txtHora.Value.Minute, txtHora.Value.Second), chkLunes.CheckState == CheckState.Checked ? true : false, chkMartes.CheckState == CheckState.Checked ? true : false, chkMiercoles.CheckState == CheckState.Checked ? true : false, chkJueves.CheckState == CheckState.Checked ? true : false, chkViernes.CheckState == CheckState.Checked ? true : false, chkSabado.CheckState == CheckState.Checked ? true : false, chkDomingo.CheckState == CheckState.Checked ? true : false, cboReporte.SelectedValue.ToString(), txtPara.Text.Trim(), txtCopia.Text.Trim(), txtOculto.Text.Trim(), txtGrupo.Text.Trim(), cboHabilitado.SelectedItem.ToString() == "Si" ? true : false, Concurrencia, null, Tipo, null, programa.rowguid); context.pEliminarValores_prog(programa.id_evento); foreach (var item in Vp) { context.pInsertarValores_prog(programa.id_evento, item.parametro.Trim(), item.Val_char.Trim(), item.Val_int, item.Val_dec, item.Val_date, new TimeSpan(item.Val_time.Value.Hours, item.Val_time.Value.Minutes, item.Val_time.Value.Seconds), item.Val_bit); } } MessageBox.Show(this, "Se ha guardado la información satisfactoriamente.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (EntityException ex) { MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex1) { MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } }