private void btnGrabar_Click(object sender, EventArgs e) { try { if (TextBoxDescripcion.Text != string.Empty && comboBoxDesde.SelectedIndex > 0) { MotivoEgreso _newitemMotivo = new MotivoEgreso(); _newitemMotivo.Descripcion = TextBoxDescripcion.Text; _newitemMotivo.tipo_id = Convert.ToInt32(comboBoxDesde.SelectedValue); _Mod.Configuration.AutoDetectChangesEnabled = false; _Mod.Configuration.ValidateOnSaveEnabled = false; if (_motivoID == 0) { _Mod.MotivoEgreso.Add(_newitemMotivo); } else { //_newitemMotivo.motivoEgreso_id = _motivoID; //_Mod.MotivoEgreso.Attach(_newitemMotivo); //_Mod.Entry(_newitemMotivo).Property(m => m.Descripcion).IsModified = true; //LLAMO AL STORED QUE ACTUALIZA // _Mod.Entry(_newitemMotivo).State = System.Data.Entity.EntityState.Modified; _Mod.MED_ActualizaMotivoEgreso(_motivoID, TextBoxDescripcion.Text, _newitemMotivo.tipo_id); } _Mod.SaveChanges(); TraerMotivos(); comboBoxDesde.SelectedIndex = 0; TextBoxDescripcion.Text = string.Empty; MessageBox.Show("Motivo creado o Modificado correctemente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Debe ingresar Descripción y Tipo de Egreso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }