public Boolean ModificarDB(List <fa_guia_remision_det_Info> listDetalle_Guia_Info) { try { foreach (var item in listDetalle_Guia_Info) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { if (item.Secuencia != 0) { var Contact = Context.fa_guia_remision_det.FirstOrDefault(var => var.IdEmpresa == item.IdEmpresa && var.IdSucursal == item.IdSucursal && var.IdBodega == item.IdBodega && var.IdGuiaRemision == item.IdGuiaRemision && var.IdProducto == item.IdProducto && var.Secuencia == item.Secuencia); if (Contact != null) { Contact.gi_cantidad = item.gi_cantidad; Contact.gi_detallexItems = item.gi_detallexItems; Context.SaveChanges(); Context.Dispose(); } } else { item.Secuencia = listDetalle_Guia_Info.Where(var => var.IdEmpresa == item.IdEmpresa && var.IdGuiaRemision == item.IdGuiaRemision && var.IdBodega == item.IdBodega && var.IdSucursal == item.IdSucursal).Count(); var Address = new fa_guia_remision_det(); Address.IdEmpresa = item.IdEmpresa; Address.IdSucursal = item.IdSucursal; Address.IdBodega = item.IdBodega; Address.IdGuiaRemision = item.IdGuiaRemision; Address.Secuencia = item.Secuencia; Address.IdProducto = item.IdProducto; Address.gi_cantidad = item.gi_cantidad; Address.gi_detallexItems = (item.gi_detallexItems == null) ? "" : item.gi_detallexItems; Context.fa_guia_remision_det.Add(Address); Context.SaveChanges(); Context.Dispose(); } } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean EliminarDB(fa_orden_Desp_Info info) { try { foreach (var item in info.ListaAuxiliar) { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_orden_Desp_det_x_fa_pedido_det.FirstOrDefault(obj => obj.od_IdEmpresa == item.od_IdEmpresa && obj.od_IdSucursal == item.od_IdSucursal && obj.od_IdBodega == item.od_IdBodega && obj.od_IdOrdenDespacho == item.od_IdOrdenDespacho && obj.od_Secuencia == item.od_Secuencia && obj.od_IdProducto == item.od_IdProducto && obj.pe_IdEmpresa == item.pe_IdEmpresa && obj.pe_IdSucursal == item.pe_IdSucursal && obj.pe_IdBodega == item.pe_IdBodega && obj.pe_IdPedido == item.pe_IdPedido && obj.pe_Secuencia == item.pe_Secuencia && obj.pe_IdProducto == item.pe_IdProducto); if (contact != null) { context.fa_orden_Desp_det_x_fa_pedido_det.Remove(contact); context.SaveChanges(); context.Dispose(); } } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean EliminarDB(fa_notaCreDeb_Info info) { try { List <fa_notaCreDeb_det_Info> ListaEliminar = new List <fa_notaCreDeb_det_Info>(); ListaEliminar = Get_List_notaCreDeb_det(info); foreach (var item in ListaEliminar) { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_notaCreDeb_det.FirstOrDefault(obj => obj.IdEmpresa == info.IdEmpresa && obj.IdSucursal == info.IdSucursal && obj.IdBodega == info.IdBodega && obj.IdNota == item.IdNota && obj.Secuencia == item.Secuencia); if (contact != null) { context.fa_notaCreDeb_det.Remove(contact); context.SaveChanges(); context.Dispose(); } } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean EliminarDB(fa_pedido_det_Info info, ref string msg) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_pedido_det.FirstOrDefault(obj => obj.IdEmpresa == info.IdEmpresa && obj.IdSucursal == info.IdSucursal && obj.IdBodega == info.IdBodega && obj.IdPedido == info.IdPedido && obj.Secuencial == info.Secuencial); if (contact != null) { context.fa_pedido_det.Remove(contact); context.SaveChanges(); context.Dispose(); } } 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); msg = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg); throw new Exception(ex.ToString()); } }
public Boolean ActualizarEstadoApro(List <fa_pedido_Info> Lst, string IdEstadoAprobacion) { try { foreach (var item in Lst) { EntitiesFacturacion Context = new EntitiesFacturacion(); var Contact = Context.fa_pedido.FirstOrDefault(var => var.IdEmpresa == item.IdEmpresa && var.IdSucursal == item.IdSucursal && var.IdBodega == item.IdBodega && var.IdPedido == item.IdPedido); if (Contact != null) { Contact.IdEstadoAprobacion = IdEstadoAprobacion; Context.SaveChanges(); Context.Dispose(); } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(List <fa_cliente_contactos_Info> listDetalle_Guia_Info) { try { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { foreach (var item in listDetalle_Guia_Info) { fa_cliente_contactos Entity = Context.fa_cliente_contactos.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdCliente == item.IdCliente && q.IdContacto == item.IdContacto).FirstOrDefault(); if (Entity == null) { var Address = new fa_cliente_contactos { IdEmpresa = item.IdEmpresa, IdCliente = item.IdCliente, IdContacto = item.IdContacto, Telefono = item.Telefono, Celular = item.Celular, Correo = item.Correo, Nombres = item.Nombres, IdCiudad = item.IdCiudad, IdParroquia = item.IdParroquia, Direccion = item.Direccion }; Context.fa_cliente_contactos.Add(Address); } else { Entity.Telefono = item.Telefono; Entity.Celular = item.Celular; Entity.Correo = item.Correo; Entity.Nombres = item.Nombres; Entity.IdCiudad = item.IdCiudad; Entity.IdParroquia = item.IdParroquia; Entity.Direccion = item.Direccion; } } Context.SaveChanges(); Context.Dispose(); } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(List <fa_guia_remision_det_Info> listDetalle_Guia_Info) { try { int c = 1; listDetalle_Guia_Info.ForEach(var => { var.Secuencia = c; c++; }); foreach (var item in listDetalle_Guia_Info) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { var Address = new fa_guia_remision_det(); Address.IdEmpresa = item.IdEmpresa; Address.IdSucursal = item.IdSucursal; Address.IdBodega = item.IdBodega; Address.IdGuiaRemision = item.IdGuiaRemision; Address.Secuencia = item.Secuencia; Address.IdProducto = item.IdProducto; Address.gi_peso = (item.gi_peso == null) ? 0 : item.gi_peso; Address.gi_cantidad = item.gi_cantidad; Address.gi_Precio = item.gi_Precio; Address.gi_PorDescUnitario = item.gi_PorDescUnitario; Address.gi_DescUnitario = item.gi_DescUnitario; Address.gi_PrecioFinal = item.gi_Precio - item.gi_DescUnitario; Address.gi_Subtotal = item.Subtotal; Address.gi_iva = item.gi_iva; Address.gi_total = item.gi_total; Address.gi_costo = item.gi_costo; Address.gi_tieneIVA = item.gi_tieneIVA; Address.gi_detallexItems = (item.gi_detallexItems == null) ? "" : item.gi_detallexItems; Context.fa_guia_remision_det.Add(Address); Context.SaveChanges(); Context.Dispose(); } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(fa_guia_remision_Info Info, ref string mensaje2) { try { foreach (var item in Info.ListaDetalle) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { var Address = new fa_guia_remision_det_x_fa_orden_Desp_det(); Address.od_IdEmpresa = item.IdEmpresa; Address.od_IdSucursal = item.IdSucursal; Address.od_IdBodega = item.IdBodega; Address.od_IdOrdenDespacho = item.od_IdOrdenDespacho; Address.od_Secuencia = item.Secuencia; Address.od_IdProducto = item.IdProducto; Address.gi_cantidad = item.gi_cantidad; Address.gi_IdEmpresa = item.IdEmpresa; Address.gi_IdSucursal = item.IdSucursal; Address.gi_IdBodega = item.IdBodega; Address.gi_IdGuiaRemision = item.IdGuiaRemision; Address.gi_Secuencia = item.Secuencia; Address.gi_IdProducto = item.IdProducto; Context.fa_guia_remision_det_x_fa_orden_Desp_det.Add(Address); Context.SaveChanges(); Context.Dispose(); } } 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.ToString(); mensaje2 = mensaje; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean ModificarDB(fa_guia_remision_Info Info) { try { foreach (var item in Info.ListaDetalle) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { var Contact = Context.fa_guia_remision_det_x_fa_orden_Desp_det.FirstOrDefault(Address => Address.od_IdEmpresa == item.IdEmpresa && Address.od_IdSucursal == item.IdSucursal && Address.od_IdBodega == item.IdBodega && Address.od_IdOrdenDespacho == item.od_IdOrdenDespacho && Address.od_Secuencia == item.Secuencia && Address.od_IdProducto == item.IdProducto && Address.gi_IdEmpresa == item.IdEmpresa && Address.gi_IdSucursal == item.IdSucursal && Address.gi_IdBodega == item.IdBodega && Address.gi_IdGuiaRemision == item.IdGuiaRemision && Address.gi_Secuencia == item.Secuencia && Address.gi_IdProducto == item.IdProducto); if (Contact != null) { Contact.gi_cantidad = item.gi_cantidad; Context.SaveChanges(); Context.Dispose(); } } } 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 GuardarDB(List <fa_guia_remision_det_x_factura_Info> listDetalle_Guia_Info) { try { int c = 0; foreach (var item in listDetalle_Guia_Info) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { var Address = new fa_guia_remision_det_x_factura(); c++; Address.IdEmpresa_guia = item.IdEmpresa_guia; Address.IdSucursal_guia = item.IdSucursal_guia; Address.IdBodega_guia = item.IdBodega_guia; Address.IdGuiaRemision_guia = item.IdGuiaRemision_guia; Address.Secuencia_guia = c; Address.IdEmpresa_fact = item.IdEmpresa_fact; Address.IdSucursal_fact = item.IdSucursal_fact; Address.IdBodega_fact = item.IdBodega_fact; Address.IdCbteVta_fact = item.IdCbteVta_fact; Address.Secuencia_fact = item.Secuencia_fact; Context.fa_guia_remision_det_x_factura.Add(Address); Context.SaveChanges(); Context.Dispose(); } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(fa_notaCreDeb_Info Info) { try { int c = 1; Info.ListaDetalles.ForEach(var => { var.Secuencia = c; c++; }); foreach (var item in Info.ListaDetalles) { using (EntitiesFacturacion Context = new EntitiesFacturacion()) { fa_notaCreDeb_det Address = new fa_notaCreDeb_det(); Address.IdEmpresa = item.IdEmpresa; Address.IdSucursal = item.IdSucursal; Address.IdBodega = item.IdBodega; Address.IdNota = item.IdNota; Address.Secuencia = item.Secuencia; Address.IdProducto = item.IdProducto; Address.sc_cantidad = item.sc_cantidad; Address.sc_Precio = item.sc_Precio; Address.sc_descUni = item.sc_descUni; Address.sc_PordescUni = item.sc_PordescUni; Address.sc_precioFinal = (item.sc_precioFinal == 0) ? item.sc_Precio : item.sc_precioFinal; Address.sc_subtotal = item.sc_subtotal; Address.sc_iva = item.sc_iva; Address.sc_total = item.sc_total; Address.sc_costo = item.sc_costo; Address.sc_estado = "A"; Address.vt_por_iva = item.vt_por_iva; Address.IdPunto_Cargo = item.IdPunto_cargo; Address.IdPunto_cargo_grupo = item.IdPunto_cargo_grupo; Address.IdCod_Impuesto_Iva = item.IdCod_Impuesto_Iva; Address.IdCod_Impuesto_Ice = item.IdCod_Impuesto_Ice; Address.IdCentroCosto = item.IdCentroCosto; Address.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo; if (item.DetallexItems == null) { Address.sc_observacion = ""; } else { Address.sc_observacion = item.DetallexItems; } Context.fa_notaCreDeb_det.Add(Address); Context.SaveChanges(); Context.Dispose(); } } 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.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }