public Boolean ModificarDB(ct_cbtecble_Plantilla_Info Pla_I) { try { List <ct_cbtecble_Plantilla_det_Info> listadetalle = new List <ct_cbtecble_Plantilla_det_Info>(); listadetalle = Pla_I.LstDet; using (EntitiesDBConta context = new EntitiesDBConta()) { var contact = context.ct_cbtecble_Plantilla.FirstOrDefault(v => v.IdEmpresa == Pla_I.IdEmpresa && v.IdTipoCbte == Pla_I.IdTipoCbte && v.IdPlantilla == Pla_I.IdPlantilla); if (contact != null) { contact.cb_Estado = Pla_I.cb_Estado; contact.IdPlantilla = Pla_I.IdPlantilla; contact.IdUsuarioUltModi = (Pla_I.IdUsuarioUltModi != "") ? Pla_I.IdUsuarioUltModi : Pla_I.IdUsuario; contact.cb_Fecha = Pla_I.cb_Fecha; contact.cb_FechaUltModi = Convert.ToDateTime(DateTime.Now.ToShortDateString()); contact.cb_Observacion = Pla_I.cb_Observacion; context.SaveChanges(); ct_cbtecble_Plantilla_det_Data _Pla_Det_Data = new ct_cbtecble_Plantilla_det_Data(); int count = 0; if (_Pla_Det_Data.EliminarDB(Pla_I.IdEmpresa, Pla_I.IdTipoCbte, Pla_I.IdPlantilla)) { ct_cbtecble_Plantilla_det_Data data = new ct_cbtecble_Plantilla_det_Data(); foreach (var reg in listadetalle) { reg.IdEmpresa = Pla_I.IdEmpresa; reg.IdTipoCbte = Pla_I.IdTipoCbte; reg.IdPlantilla = Pla_I.IdPlantilla; //reg.secuencia = count++; data.GrabarDB(reg); } } } } return(true); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString(); throw new Exception(ex.ToString()); } }