public Boolean GuardarBD(ro_empleado_x_centro_costo_Info info, ref string msg) { try { using (EntitiesRoles db = new EntitiesRoles()) { ro_empleado_x_centro_costo item = new ro_empleado_x_centro_costo(); item.IdEmpresa = info.IdEmpresa; item.IdEmpleado = info.IdEmpleado; item.IdCentroCosto = info.IdCentroCosto; item.FechaIngresa = info.FechaIngresa; item.UsuarioIngresa = info.UsuarioIngresa; item.FechaModifica = info.FechaModifica; item.UsuarioModifica = info.UsuarioModifica; db.ro_empleado_x_centro_costo.Add(item); db.SaveChanges(); } 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); mensaje = ex.InnerException + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.InnerException.ToString()); } }
public Boolean GuardarBD(ro_empleado_x_centro_costo_Info info) { try { using (EntitiesRoles db = new EntitiesRoles()) { var datos = (from a in db.ro_empleado_x_centro_costo where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado select a); if (datos.Count() == 0) { ro_empleado_x_centro_costo item = new ro_empleado_x_centro_costo(); item.IdEmpresa = info.IdEmpresa; item.IdEmpleado = info.IdEmpleado; item.IdCentroCosto = info.IdCentroCosto; item.FechaIngresa = info.FechaIngresa; item.UsuarioIngresa = info.UsuarioIngresa; item.FechaModifica = info.FechaModifica; item.UsuarioModifica = info.UsuarioModifica; db.ro_empleado_x_centro_costo.Add(item); db.SaveChanges(); } else { var contact = db.ro_empleado_x_centro_costo.First(obj => obj.IdEmpresa == info.IdEmpresa && obj.IdEmpleado == info.IdEmpleado); if (contact != null) { contact.IdCentroCosto = info.IdCentroCosto; contact.IdCentroCosto_sub_centro_costo = info.IdCentroCosto_sub_centro_costo; db.SaveChanges(); } } } 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); mensaje = ex.InnerException + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.InnerException.ToString()); } }