private bool Delete(ref Det_Cotizacion item) { try { if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted) { DataAccessEnterpriseSQL.DAAsignarProcedure("SLI_DCOTSD_UnReg"); DataAccessEnterpriseSQL.DAAgregarParametro("@pintCCOT_Codigo", item.CCOT_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintDCOT_Item", item.DCOT_Item, SqlDbType.Int, 4, ParameterDirection.Input); if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0) { return(true); } else { return(false); } } else { return(true); } } catch (Exception ex) { throw ex; } }
public BLDet_Cotizacion(IUnityContainer container) { this.ContainerService = container; Loader = new BusinessEntityLoader <Det_Cotizacion>(); Det_Cotizacion item = new Det_Cotizacion(); Loader.EntityType = item.GetType(); }
private bool Update(ref Det_Cotizacion item) { try { if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified) { DataAccessEnterpriseSQL.DAAsignarProcedure("SLI_DCOTSU_UnReg"); DataAccessEnterpriseSQL.DAAgregarParametro("@pintCCOT_Codigo", item.CCOT_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintDCOT_Item", item.DCOT_Item, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@psinDTAR_Item", item.DTAR_Item, SqlDbType.SmallInt, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_Codigo", item.CTAR_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCTAR_Tipo", item.CTAR_Tipo, SqlDbType.Char, 1, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintPACK_Codigo", item.PACK_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@psinDCOT_Cantidad", item.DCOT_Cantidad, SqlDbType.SmallInt, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDCOT_CostoSada", item.DCOT_CostoSada, SqlDbType.Decimal, 15, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDCOT_Costo", item.DCOT_Costo, SqlDbType.Decimal, 15, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDCOT_VentaSada", item.DCOT_VentaSada, SqlDbType.Decimal, 15, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDCOT_Venta", item.DCOT_Venta, SqlDbType.Decimal, 15, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDCOT_Minimo", item.DCOT_Minimo, SqlDbType.Decimal, 15, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_CodBas", item.CONS_CodBas, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_TabBas", item.CONS_TabBas, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pnumDCOT_Peso", item.DCOT_Peso, SqlDbType.Decimal, 12, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pnumDCOT_Volumen", item.DCOT_Volumen, SqlDbType.Decimal, 12, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@psinTIPE_Codigo", item.TIPE_Codigo, SqlDbType.SmallInt, 2, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintENTC_Codigo", item.ENTC_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrTIPO_TabZON", item.TIPO_TabZON, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrTIPO_CodZONOrigen", item.TIPO_CodZONOrigen, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrTIPO_CodZONDestino", item.TIPO_CodZONDestino, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pbitDCOT_Roudtrip", item.DCOT_Roudtrip, SqlDbType.Bit, 1, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pnumDCOT_Profit", item.DCOT_Profit, SqlDbType.Decimal, 12, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pnumDCOT_ProfitMinimo", item.DCOT_ProfitMinimo, SqlDbType.Decimal, 12, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_CodTRA", item.CONS_CodTRA, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_TabTRA", item.CONS_TabTRA, SqlDbType.Char, 3, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pvchAUDI_UsrMod", item.AUDI_UsrMod, SqlDbType.VarChar, 20, ParameterDirection.Input); if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0) { return(true); } else { return(false); } } else { return(true); } } catch (Exception ex) { throw ex; } }
public Boolean SaveDet_Cotizacion(ref Det_Cotizacion Item) { try { if (Item.Instance != Infrastructure.Aspect.BusinessEntity.InstanceEntity.Unchanged) { return(BL_Det_Cotizacion.Save(ref Item)); } return(true); } catch (Exception ex) { throw ex; } }
public Boolean Save(ref Det_Cotizacion Item) { try { Boolean m_isCorrect = true; if (Item.Trasanct) { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DABeginTransaction(); switch (Item.Instance) { case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added: m_isCorrect = Insert(ref Item); break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified: m_isCorrect = Update(ref Item); break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted: m_isCorrect = Delete(ref Item); break; } if (m_isCorrect) { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DACommitTransaction(); } else { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); } } else // sin transacción { switch (Item.Instance) { case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added: m_isCorrect = Insert(ref Item); break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified: m_isCorrect = Update(ref Item); break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted: m_isCorrect = Delete(ref Item); break; } } return(m_isCorrect); } catch (Exception) { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); throw; } }
private ObservableCollection <Det_Cotizacion> SelectAllDet_CotizacionByOperacion(Int32?x_CTAR_CodigoLogistico, Int32?x_CTAR_CodigoAduanero, Int32?x_CTAR_CodigoTransporte) { try { ObservableCollection <Det_Cotizacion> items = new ObservableCollection <Det_Cotizacion>(); Det_Cotizacion item = new Det_Cotizacion(); DataAccessEnterpriseSQL.DAAsignarProcedure("SLI_DCOTSS_TodosByOperacion"); if (x_CTAR_CodigoLogistico != null) { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoLogistico", x_CTAR_CodigoLogistico.Value, SqlDbType.Int, 4, ParameterDirection.Input); } else { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoLogistico", DBNull.Value, SqlDbType.Int, 4, ParameterDirection.Input); } if (x_CTAR_CodigoAduanero != null) { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoAduanero", x_CTAR_CodigoAduanero.Value, SqlDbType.Int, 4, ParameterDirection.Input); } else { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoAduanero", DBNull.Value, SqlDbType.Int, 4, ParameterDirection.Input); } if (x_CTAR_CodigoTransporte != null) { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoTransporte", x_CTAR_CodigoTransporte.Value, SqlDbType.Int, 4, ParameterDirection.Input); } else { DataAccessEnterpriseSQL.DAAgregarParametro("@pintCTAR_CodigoTransporte", DBNull.Value, SqlDbType.Int, 4, ParameterDirection.Input); } using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader()) { while (reader.Read()) { item = new Det_Cotizacion(); Loader.LoadEntity(reader, item); item.Instance = InstanceEntity.Unchanged; items.Add(item); } } return(items); } catch (Exception ex) { throw ex; } }
private Det_Cotizacion SelectOne(Int32 CCOT_Codigo, Int32 DCOT_Item) { try { Det_Cotizacion item = new Det_Cotizacion(); DataAccessEnterpriseSQL.DAAsignarProcedure("SLI_DCOTSS_UnReg"); DataAccessEnterpriseSQL.DAAgregarParametro("@pintCCOT_Codigo", CCOT_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pintDCOT_Item", DCOT_Item, SqlDbType.Int, 4, ParameterDirection.Input); using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader()) { if (reader.Read()) { Loader.LoadEntity(reader, item); item.Instance = InstanceEntity.Unchanged; } } return(item); } catch (Exception ex) { throw ex; } }
private ObservableCollection <Det_Cotizacion> SelectAllByCotizacion(Int32 x_CCOT_Codigo, String x_CTAR_Tipo) { try { ObservableCollection <Det_Cotizacion> items = new ObservableCollection <Det_Cotizacion>(); Det_Cotizacion item = new Det_Cotizacion(); DataAccessEnterpriseSQL.DAAsignarProcedure("SLI_DCOTSS_TodosByCotizacion"); DataAccessEnterpriseSQL.DAAgregarParametro("@pintCCOT_Codigo", x_CCOT_Codigo, SqlDbType.Int, 4, ParameterDirection.Input); DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCTAR_Tipo", x_CTAR_Tipo, SqlDbType.Char, 1, ParameterDirection.Input); using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader()) { while (reader.Read()) { item = new Det_Cotizacion(); Loader.LoadEntity(reader, item); item.Instance = InstanceEntity.Unchanged; items.Add(item); } } return(items); } catch (Exception ex) { throw ex; } }
public Boolean Save(ref Cab_Cotizacion Item) { try { Boolean m_isCorrect = true; Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DABeginTransaction(); switch (Item.Instance) { case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added: m_isCorrect = Insert(ref Item); if (m_isCorrect) { /* Items Detalle Cotización */ if (Item.ItemsDet_Cotizacion != null && Item.ItemsDet_Cotizacion.Count > 0) { foreach (var _item in Item.ItemsDet_Cotizacion) { Det_Cotizacion _Deta = new Det_Cotizacion(); _Deta = _item; _Deta.CCOT_Codigo = Item.CCOT_Codigo; _Deta.Trasanct = false; m_isCorrect = BLDet_Cotizacion.Save(ref _Deta); if (!m_isCorrect) { break; } } } /* Items Servicios Cotización */ if (Item.ItemsDet_Cotizacion_Servicio != null && Item.ItemsDet_Cotizacion_Servicio.Count > 0) { foreach (var _itemServ in Item.ItemsDet_Cotizacion_Servicio) { Det_Cotizacion_Servicio _Servicio = new Det_Cotizacion_Servicio(); _Servicio = _itemServ; _Servicio.CCOT_Codigo = Item.CCOT_Codigo; _Servicio.Trasanct = false; m_isCorrect = BLDet_Cotizacion_Servicio.Save(ref _Servicio); if (!m_isCorrect) { break; } } } } break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified: m_isCorrect = Update(ref Item); /* Items Detalle Cotización */ if (Item.ItemsDet_Cotizacion != null && Item.ItemsDet_Cotizacion.Count > 0) { foreach (var _item in Item.ItemsDet_Cotizacion) { Det_Cotizacion _Deta = new Det_Cotizacion(); _Deta = _item; _Deta.CCOT_Codigo = Item.CCOT_Codigo; _Deta.Trasanct = false; m_isCorrect = BLDet_Cotizacion.Save(ref _Deta); if (!m_isCorrect) { break; } } } /* Items Servicios Cotización */ if (Item.ItemsDet_Cotizacion_Servicio != null && Item.ItemsDet_Cotizacion_Servicio.Count > 0) { foreach (var _itemServ in Item.ItemsDet_Cotizacion_Servicio) { Det_Cotizacion_Servicio _Servicio = new Det_Cotizacion_Servicio(); _Servicio = _itemServ; _Servicio.CCOT_Codigo = Item.CCOT_Codigo; _Servicio.Trasanct = false; m_isCorrect = BLDet_Cotizacion_Servicio.Save(ref _Servicio); if (!m_isCorrect) { break; } } } break; case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted: m_isCorrect = Delete(ref Item); break; } if (m_isCorrect) { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DACommitTransaction(); } else { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); } return(m_isCorrect); } catch (Exception) { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); throw; } }
public void SetItemST20_ST40(ref ObservableCollection <Det_Cotizacion> x_items) { try { if (x_items != null) { decimal _TempVenta20 = 0; decimal _TempVentaSada20 = 0; decimal _TempVenta40 = 0; decimal _TempVentaSada40 = 0; Det_Cotizacion _Det_Cotizacion = new Det_Cotizacion(); Int32 _Fila = 0; for (int i = 0; i < x_items.Count; i++) { if (((i % 2) == 0) && i == 0) /* primer registro */ { _Det_Cotizacion = new Det_Cotizacion(); _Det_Cotizacion = x_items.ElementAt(i); _Fila = 1; } else { _Det_Cotizacion = x_items.ElementAt(i); _Det_Cotizacion.DCOT_Venta20 = _TempVenta20; _Det_Cotizacion.DCOT_VentaSada20 = _TempVentaSada20; _Det_Cotizacion.DCOT_Venta40 = _TempVenta40; _Det_Cotizacion.DCOT_VentaSada40 = _TempVentaSada40; } if (_Det_Cotizacion.PACK_Codigo == 1) { _TempVenta20 = 0; _TempVentaSada20 = 0; _Det_Cotizacion.DCOT_Venta20 = x_items[i].DCOT_Venta; _Det_Cotizacion.DCOT_VentaSada20 = _Det_Cotizacion.DCOT_VentaSada; _TempVenta20 = _Det_Cotizacion.DCOT_Venta20; _TempVentaSada20 = _Det_Cotizacion.DCOT_VentaSada20; _Det_Cotizacion.DCOT_Fila = _Fila; } if (_Det_Cotizacion.PACK_Codigo == 2) { _TempVenta40 = 0; _TempVentaSada40 = 0; _Det_Cotizacion.DCOT_Venta40 = x_items[i].DCOT_Venta; _Det_Cotizacion.DCOT_VentaSada40 = _Det_Cotizacion.DCOT_VentaSada; _TempVenta40 = _Det_Cotizacion.DCOT_Venta40; _TempVentaSada40 = _Det_Cotizacion.DCOT_VentaSada40; if (_Det_Cotizacion.TIPE_Codigo != null && _Det_Cotizacion.TIPE_Codigo.Value.ToString(CultureInfo.InvariantCulture) != "13") /* Maritimo */ { _Det_Cotizacion.DCOT_Fila = _Fila; Presenter.ItemsGrillaDet_Cotizacion.Add(_Det_Cotizacion); _Fila++; } else { _Det_Cotizacion.DCOT_Fila = _Fila; } } if (_Det_Cotizacion.TIPE_Codigo != null && _Det_Cotizacion.TIPE_Codigo.Value.ToString(CultureInfo.InvariantCulture).Equals("13")) /* Maritimo */ { if (_Det_Cotizacion.PACK_Codigo == null) { _Det_Cotizacion.DCOT_VentaHBL = x_items[i].DCOT_Venta; _Det_Cotizacion.DCOT_VentaSadaHBL = _Det_Cotizacion.DCOT_VentaSada; _Det_Cotizacion.DCOT_Fila = _Fila; Presenter.ItemsGrillaDet_Cotizacion.Add(_Det_Cotizacion); _Fila++; } } } } } catch (Exception ex) { Dialogos.MostrarMensajeError(Presenter.Title, "Ha ocurrido un error al agregar el nuevo registro.", ex); } }