public bool GuardarDB(in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info info) { try { try { using (EntitiesInventario Context = new EntitiesInventario()) { in_transferencia_det_x_in_Guia_x_traspaso_bodega_det Entity = new in_transferencia_det_x_in_Guia_x_traspaso_bodega_det(); Entity.IdEmpresa_trans = info.IdEmpresa_trans; Entity.IdSucursalOrigen_trans = info.IdSucursalOrigen_trans; Entity.IdBodegaOrigen_trans = info.IdBodegaOrigen_trans; Entity.IdTransferencia_trans = info.IdTransferencia_trans; Entity.Secuencia_trans = info.Secuencia_trans; Entity.IdEmpresa_guia = info.IdEmpresa_guia; Entity.IdGuia_guia = info.IdGuia_guia; Entity.Secuencia_guia = info.Secuencia_guia; Entity.Observacion = info.Observacion; Context.in_transferencia_det_x_in_Guia_x_traspaso_bodega_det.Add(Entity); Context.SaveChanges(); } return(true); } catch (DbEntityValidationException ex) { string arreglo = ToString(); foreach (var item in ex.EntityValidationErrors) { foreach (var item_validaciones in item.ValidationErrors) { mensaje = "Propiedad: " + item_validaciones.PropertyName + " Mensaje: " + item_validaciones.ErrorMessage + "\n"; } } 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(mensaje, "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(mensaje); } } 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() + " " + ex.Message; throw new Exception(mensaje); } }
public List <in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info> Get_list_trans_x_guia(int IdEmpresa, decimal IdGuia) { try { List <in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info> Lista = new List <in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info>(); using (EntitiesInventario Context = new EntitiesInventario()) { var lst = from q in Context.vwin_transferencia_det_x_in_Guia_x_traspaso_bodega_det where q.IdEmpresa_guia == IdEmpresa && q.IdGuia_guia == IdGuia select q; foreach (var item in lst) { in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info info = new in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info(); info.IdEmpresa_trans = item.IdEmpresa_trans; info.IdSucursalOrigen_trans = item.IdSucursalOrigen_trans; info.IdBodegaOrigen_trans = item.IdBodegaOrigen_trans; info.IdTransferencia_trans = item.IdTransferencia_trans; info.Secuencia_trans = item.Secuencia_trans; info.IdEmpresa_guia = item.IdEmpresa_guia; info.IdGuia_guia = item.IdGuia_guia; info.Secuencia_guia = item.Secuencia_guia; info.cod_sucursal = item.codigo; info.Su_Descripcion = item.Su_Descripcion; info.cod_bodega = item.cod_bodega; info.bo_Descripcion = item.bo_Descripcion; info.IdProducto = item.IdProducto; info.pr_codigo = item.pr_codigo; info.pr_descripcion = item.pr_descripcion; Lista.Add(info); } } return(Lista); } 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() + " " + ex.Message; throw new Exception(mensaje); } }
public bool GuardarDB(in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info info) { try { return(oData.GuardarDB(info)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GuardarDB", ex.Message), ex) { EntityType = typeof(in_Ing_Egr_Inven_Bus) }; } }
public bool GuardarDB(in_transferencia_Info info, ref decimal _idTransferencia) { try { try { using (EntitiesInventario contex = new EntitiesInventario()) { #region Cabecera EntitiesInventario oInventario = new EntitiesInventario(); var address = new in_transferencia(); address.IdEmpresa = info.IdEmpresa; address.IdSucursalOrigen = info.IdSucursalOrigen; address.IdBodegaOrigen = info.IdBodegaOrigen; address.IdTransferencia = info.IdTransferencia = _idTransferencia = GetId(info.IdEmpresa, info.IdSucursalOrigen, info.IdBodegaOrigen); address.IdSucursalDest = info.IdSucursalDest; address.IdBodegaDest = info.IdBodegaDest; address.tr_Observacion = info.tr_Observacion; address.IdMovi_inven_tipo_SucuOrig = info.IdMovi_inven_tipo_SucuOrig; address.IdMovi_inven_tipo_SucuDest = info.IdMovi_inven_tipo_SucuDest; address.tr_fecha = Convert.ToDateTime(info.tr_fecha.ToShortDateString()); address.Estado = "A"; address.IdUsuario = (info.IdUsuario == null) ? "" : info.IdUsuario; address.ip = (info.ip == null) ? "" : info.ip; address.nom_pc = (info.nom_pc == null) ? "" : info.nom_pc; address.IdEstadoAprobacion_cat = info.IdEstadoAprobacion_cat; address.Codigo = info.Codigo; contex.in_transferencia.Add(address); contex.SaveChanges(); #endregion #region DetalleTransferencia //GRABAR EL DETALLE DE LA TRANSFERENCIA int c = 1; using (EntitiesInventario contexDeta = new EntitiesInventario()) { foreach (var item in info.lista_detalle_transferencia) { var addressDeta = new in_transferencia_det(); addressDeta.IdEmpresa = info.IdEmpresa; addressDeta.IdSucursalOrigen = info.IdSucursalOrigen; addressDeta.IdTransferencia = info.IdTransferencia; addressDeta.IdBodegaOrigen = info.IdBodegaOrigen; addressDeta.IdProducto = item.IdProducto; addressDeta.dt_cantidad = item.dt_cantidad; addressDeta.IdUnidadMedida = item.IdUnidadMedida; addressDeta.tr_Observacion = item.tr_Observacion; addressDeta.IdCentroCosto = item.IdCentroCosto; addressDeta.IdPunto_cargo_grupo = item.IdPunto_cargo_grupo; addressDeta.IdPunto_cargo = item.IdPunto_cargo; addressDeta.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo == "" ? null : item.IdCentroCosto_sub_centro_costo; addressDeta.dt_secuencia = item.dt_secuencia = c; c++; contexDeta.in_transferencia_det.Add(addressDeta); contexDeta.SaveChanges(); } } #endregion #region DetalleTransferencia_x_guia foreach (var item in info.lista_detalle_transferencia) { if (item.Info_Guia_x_traspaso_bodega_det.IdEmpresa != 0) { in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info info_det_trans_x_guia = new in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info(); info_det_trans_x_guia.IdEmpresa_trans = info.IdEmpresa; info_det_trans_x_guia.IdSucursalOrigen_trans = info.IdSucursalOrigen; info_det_trans_x_guia.IdBodegaOrigen_trans = info.IdBodegaOrigen; info_det_trans_x_guia.IdTransferencia_trans = info.IdTransferencia; info_det_trans_x_guia.Secuencia_trans = item.dt_secuencia; info_det_trans_x_guia.IdEmpresa_guia = item.Info_Guia_x_traspaso_bodega_det.IdEmpresa; info_det_trans_x_guia.IdGuia_guia = item.Info_Guia_x_traspaso_bodega_det.IdGuia; info_det_trans_x_guia.Secuencia_guia = item.Info_Guia_x_traspaso_bodega_det.secuencia; odata_trans_x_guia.GuardarDB(info_det_trans_x_guia); } } #endregion } return(true); } catch (DbEntityValidationException ex) { string arreglo = ToString(); foreach (var item in ex.EntityValidationErrors) { foreach (var item_validaciones in item.ValidationErrors) { mensaje = "Propiedad: " + item_validaciones.PropertyName + " Mensaje: " + item_validaciones.ErrorMessage + "\n"; } } 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(mensaje, "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(mensaje); } } 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() + " " + ex.Message; throw new Exception(mensaje); } }
public bool ModificarDB(in_transferencia_Info info) { try { try { using (EntitiesInventario Contex = new EntitiesInventario()) { var contac = Contex.in_transferencia.FirstOrDefault(Obj => Obj.IdTransferencia == info.IdTransferencia && Obj.IdSucursalOrigen == info.IdSucursalOrigen && Obj.IdBodegaOrigen == info.IdBodegaOrigen && Obj.IdEmpresa == info.IdEmpresa); if (contac != null) { contac.tr_Observacion = info.tr_Observacion; contac.Codigo = info.Codigo; contac.IdBodegaDest = info.IdBodegaDest; contac.IdSucursalDest = info.IdSucursalDest; contac.tr_fecha = info.tr_fecha; contac.IdEstadoAprobacion_cat = info.IdEstadoAprobacion_cat; Contex.SaveChanges(); #region DetalleTransferencia //GRABAR EL DETALLE DE LA TRANSFERENCIA int c = 1; odata_trans_x_guia.EliminarDB(info); EliminarDetalle(info); foreach (var item in info.lista_detalle_transferencia) { var addressDeta = new in_transferencia_det(); addressDeta.IdEmpresa = info.IdEmpresa; addressDeta.IdSucursalOrigen = info.IdSucursalOrigen; addressDeta.IdTransferencia = info.IdTransferencia; addressDeta.IdBodegaOrigen = info.IdBodegaOrigen; addressDeta.IdProducto = item.IdProducto; addressDeta.dt_cantidad = item.dt_cantidad; addressDeta.IdUnidadMedida = item.IdUnidadMedida; addressDeta.tr_Observacion = item.tr_Observacion; addressDeta.IdCentroCosto = item.IdCentroCosto; addressDeta.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo; addressDeta.IdPunto_cargo_grupo = item.IdPunto_cargo_grupo; addressDeta.IdPunto_cargo = item.IdPunto_cargo; addressDeta.dt_secuencia = item.dt_secuencia = c; c++; Contex.in_transferencia_det.Add(addressDeta); Contex.SaveChanges(); } foreach (var item in info.lista_detalle_transferencia) { if (item.Info_Guia_x_traspaso_bodega_det.IdEmpresa != 0) { in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info info_det_trans_x_guia = new in_transferencia_det_x_in_Guia_x_traspaso_bodega_det_Info(); info_det_trans_x_guia.IdEmpresa_trans = info.IdEmpresa; info_det_trans_x_guia.IdSucursalOrigen_trans = info.IdSucursalOrigen; info_det_trans_x_guia.IdBodegaOrigen_trans = info.IdBodegaOrigen; info_det_trans_x_guia.IdTransferencia_trans = info.IdTransferencia; info_det_trans_x_guia.Secuencia_trans = item.dt_secuencia; info_det_trans_x_guia.IdEmpresa_guia = item.Info_Guia_x_traspaso_bodega_det.IdEmpresa; info_det_trans_x_guia.IdGuia_guia = item.Info_Guia_x_traspaso_bodega_det.IdGuia; info_det_trans_x_guia.Secuencia_guia = item.Info_Guia_x_traspaso_bodega_det.secuencia; odata_trans_x_guia.GuardarDB(info_det_trans_x_guia); } } #endregion } } return(true); } catch (DbEntityValidationException ex) { string arreglo = ToString(); foreach (var item in ex.EntityValidationErrors) { foreach (var item_validaciones in item.ValidationErrors) { mensaje = "Propiedad: " + item_validaciones.PropertyName + " Mensaje: " + item_validaciones.ErrorMessage + "\n"; } } 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(mensaje, "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(mensaje); } } 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() + " " + ex.Message; throw new Exception(mensaje); } }