public Boolean guardar(clsMotivo ctm, ref string Mensaje) { try { using (INVENTARIOEntities te = new INVENTARIOEntities()) { Motivo tm = new Motivo(); tm.IdEmpresa = Convert.ToInt32(ctm.empresa); tm.IdMotivo = Convert.ToInt32(ctm.codigo); tm.Descripcion = Convert.ToString(ctm.descripcion); tm.IdEstado = Convert.ToInt32(ctm.estado ); te.AddToMotivo(tm); te.SaveChanges(); } return true; } catch (Exception e) { Mensaje = "ERROR" + e.InnerException + e.Message; //System.Windows.Forms.MessageBox.Show("error al guardar" + e); return false; } }