public com_Motivo_Orden_Compra_Info get_info(int IdEmpresa, int IdMotivo) { try { com_Motivo_Orden_Compra_Info info = new com_Motivo_Orden_Compra_Info(); using (Entities_compras Context = new Entities_compras()) { com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == IdEmpresa && q.IdMotivo == IdMotivo).FirstOrDefault(); if (Entity == null) { return(null); } info = new com_Motivo_Orden_Compra_Info { IdEmpresa = Entity.IdEmpresa, IdMotivo = Entity.IdMotivo, Cod_Motivo = Entity.Cod_Motivo, Descripcion = Entity.Descripcion, estado = Entity.estado }; } return(info); } catch (Exception) { throw; } }
public bool guardarDB(com_Motivo_Orden_Compra_Info info) { try { using (Entities_compras Context = new Entities_compras()) { com_Motivo_Orden_Compra Entity = new com_Motivo_Orden_Compra { IdEmpresa = info.IdEmpresa, IdMotivo = info.IdMotivo = get_id(info.IdEmpresa), Cod_Motivo = info.Cod_Motivo, Descripcion = info.Descripcion, estado = "A", Fecha_Transac = DateTime.Now }; Context.com_Motivo_Orden_Compra.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool modificarDB(com_Motivo_Orden_Compra_Info info) { try { using (Entities_compras Context = new Entities_compras()) { com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo == info.IdMotivo).FirstOrDefault(); if (Entity == null) { return(false); } Entity.Cod_Motivo = info.Cod_Motivo; Entity.Descripcion = info.Descripcion; Entity.IdUsuarioUltMod = info.IdUsuarioUltMod; Entity.Fecha_UltMod = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Boolean GuardarDB(com_Motivo_Orden_Compra_Info info, ref int IdMotivo, ref string msg) { try { using (EntitiesCompras Context = new EntitiesCompras()) { var Address = new com_Motivo_Orden_Compra(); Address.IdEmpresa = info.IdEmpresa; Address.IdMotivo = info.IdMotivo = GetId(info.IdEmpresa); Address.Cod_Motivo = info.Cod_Motivo; Address.Descripcion = info.Descripcion; Address.estado = info.estado; Context.com_Motivo_Orden_Compra.Add(Address); Context.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); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString(); throw new Exception(ex.ToString()); } }
public bool anularDB(com_Motivo_Orden_Compra_Info info) { try { using (Entities_compras Context = new Entities_compras()) { com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo == info.IdMotivo).FirstOrDefault(); if (Entity == null) { return(false); } Entity.estado = "I"; Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.FechaHoraAnul = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }