public in_movi_inve_detalle_x_item_Info Get_info_disponible(in_movi_inve_detalle_x_item_Info Movi) { try { in_movi_inve_detalle_x_item_Info info = new in_movi_inve_detalle_x_item_Info(); using (EntitiesInventario Context = new EntitiesInventario()) { var Entity = Context.vwin_movi_inve_detalle_x_item_disponibles.OrderBy(q => q.cm_fecha).FirstOrDefault(q => q.IdEmpresa == Movi.IdEmpresa && q.IdSucursal == Movi.IdSucursal && q.IdBodega == Movi.IdBodega && q.IdProducto == Movi.IdProducto); if (Entity != null) { info.IdEmpresa = Entity.IdEmpresa; info.IdSucursal = Entity.IdSucursal; info.IdBodega = Entity.IdBodega; info.IdProducto = Entity.IdProducto; info.codigo_reg = Entity.codigo_reg; info.cantidad = Entity.cantidad == null ? 0 : (double)Entity.cantidad; } } return(info); } catch (Exception ex) { string mensaje = ""; 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 Boolean GuardarDB(in_movi_inve_detalle_x_item_Info info, ref string mensaje) { try { using (EntitiesInventario Context = new EntitiesInventario()) { in_movi_inve_detalle_x_item Entity = new in_movi_inve_detalle_x_item(); Entity.IdEmpresa = info.IdEmpresa; Entity.IdSucursal = info.IdSucursal; Entity.IdBodega = info.IdBodega; Entity.IdMovi_inven_tipo = info.IdMovi_inven_tipo; Entity.IdNumMovi = info.IdNumMovi; Entity.Secuencia = info.Secuencia; Entity.Secuencia_reg = info.Secuencia_reg; Entity.codigo_reg = info.codigo_reg; Entity.cantidad = info.cantidad; Context.in_movi_inve_detalle_x_item.Add(Entity); 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() + " " + ex.Message; throw new Exception(mensaje); } }
public Boolean GrabarDB(List <in_movi_inve_detalle_Info> List_Movi_Inven_det) { try { string mensaje = ""; int Sec_R = 1; foreach (in_movi_inve_detalle_Info item in List_Movi_Inven_det) { double Cant_R = Math.Abs(item.dm_cantidad); Sec_R = 1; double Unidad = 0; while (Cant_R > 0) { in_movi_inve_detalle_x_item_Info info = new in_movi_inve_detalle_x_item_Info(); info.IdEmpresa = item.IdEmpresa; info.IdSucursal = item.IdSucursal; info.IdBodega = item.IdBodega; info.IdMovi_inven_tipo = item.IdMovi_inven_tipo; info.IdNumMovi = item.IdNumMovi; info.Secuencia = item.Secuencia; info.Secuencia_reg = Sec_R; info.IdProducto = item.IdProducto; if (item.mv_tipo_movi == "+") { info.codigo_reg = "E" + info.IdEmpresa + "S" + info.IdSucursal + "B" + info.IdBodega + "T" + info.IdMovi_inven_tipo + "N" + info.IdNumMovi + "S" + info.Secuencia + "SR" + info.Secuencia_reg; if (Cant_R < 1) { Unidad = Cant_R; } if (Cant_R >= 1) { Unidad = item.mv_tipo_movi == "+" ? 1 : -1; } } info.cantidad = Unidad; Unidad = Math.Abs(Unidad); Cant_R = Cant_R - Unidad; if (info.cantidad == 0) { break; } if (!oData.GuardarDB(info, ref mensaje)) { throw new Exception(mensaje); } Sec_R++; } } return(true); } 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("", "GrabarDB", ex.Message), ex) { EntityType = typeof(in_movi_inve_detalle_x_item_Bus) }; } }
public in_movi_inve_detalle_x_item_Info Get_info_disponible(in_movi_inve_detalle_x_item_Info Movi) { try { return(oData.Get_info_disponible(Movi)); } 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("", "Get_info_disponible", ex.Message), ex) { EntityType = typeof(in_movi_inve_detalle_x_item_Bus) }; } }