public bool anularDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo_Inv == info.IdMotivo_Inv); if (Entity == null) { return(false); } Entity.estado = Entity.estado = "I"; Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.FechaHoraAnul = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool guardarDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = new in_Motivo_Inven { IdEmpresa = info.IdEmpresa, IdMotivo_Inv = info.IdMotivo_Inv = get_id(info.IdEmpresa), Cod_Motivo_Inv = info.Cod_Motivo_Inv, Desc_mov_inv = info.Desc_mov_inv, estado = info.estado = "A", Genera_Movi_Inven = info.Genera_Movi_Inven_bool == true ? "S" : "N", Tipo_Ing_Egr = info.Tipo_Ing_Egr, IdCtaCble = info.IdCtaCble, Fecha_Transac = DateTime.Now }; Context.in_Motivo_Inven.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool modificarDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo_Inv == info.IdMotivo_Inv); if (Entity == null) { return(false); } Entity.Cod_Motivo_Inv = info.Cod_Motivo_Inv; Entity.Desc_mov_inv = info.Desc_mov_inv; Entity.Tipo_Ing_Egr = info.Tipo_Ing_Egr; Entity.Genera_Movi_Inven = info.Genera_Movi_Inven_bool == true ? "S" : "N"; Entity.IdCtaCble = info.IdCtaCble; Entity.IdUsuarioUltMod = info.IdUsuarioUltMod; Entity.Fecha_UltMod = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public in_Motivo_Inven_Info get_info(int IdEmpresa, int IdMotivo_Inv) { try { in_Motivo_Inven_Info info = new in_Motivo_Inven_Info(); using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdMotivo_Inv == IdMotivo_Inv); if (Entity == null) { return(null); } info = new in_Motivo_Inven_Info { IdEmpresa = Entity.IdEmpresa, IdMotivo_Inv = Entity.IdMotivo_Inv, Cod_Motivo_Inv = Entity.Cod_Motivo_Inv, Desc_mov_inv = Entity.Desc_mov_inv, estado = Entity.estado, Genera_Movi_Inven_bool = Entity.Genera_Movi_Inven == "S" ? true : false, Tipo_Ing_Egr = Entity.Tipo_Ing_Egr, IdCtaCble = Entity.IdCtaCble }; } return(info); } catch (Exception) { throw; } }
public Boolean GuardarDB(in_Motivo_Inven_Info Info, ref int Id, ref string msg) { try { using (EntitiesInventario DBInven = new EntitiesInventario()) { var que = from C in DBInven.in_Motivo_Inven where C.IdEmpresa == Info.IdEmpresa && C.IdMotivo_Inv == Info.IdMotivo_Inv select C; if (que.Count() == 0) { var TablaDb = new in_Motivo_Inven(); TablaDb.IdEmpresa = Info.IdEmpresa; TablaDb.IdMotivo_Inv = Info.IdMotivo_Inv = Id = getId(Info.IdEmpresa); TablaDb.Cod_Motivo_Inv = (Info.Cod_Motivo_Inv == "") ? TablaDb.IdMotivo_Inv.ToString() : Info.Cod_Motivo_Inv; TablaDb.Desc_mov_inv = Info.Desc_mov_inv; TablaDb.Genera_Movi_Inven = Info.Genera_Movi_Inven; TablaDb.estado = "A"; TablaDb.Genera_CXP = Info.Genera_CXP; TablaDb.Exigir_Punto_Cargo = Info.Exigir_Punto_Cargo; TablaDb.IdCtaCble_Costo = Info.IdCtaCble_Costo; TablaDb.IdCtaCble_Inven = Info.IdCtaCble_Inven; TablaDb.IdUsuarioUltMod = Info.IdUsuarioUltMod; TablaDb.Fecha_Transac = DateTime.Now; TablaDb.es_Inven_o_Consumo = Info.es_Inven_o_Consumo.ToString(); TablaDb.Tipo_Ing_Egr = Info.Tipo_Ing_Egr.ToString(); DBInven.in_Motivo_Inven.Add(TablaDb); DBInven.SaveChanges(); } else { msg = ""; return(false); } } 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.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }