Ejemplo n.º 1
0
 private void cargarData()
 {
     try
     {
         in_Motivo_Inven_Bus         BusMotivo = new in_Motivo_Inven_Bus();
         List <in_Motivo_Inven_Info> lista     = new List <in_Motivo_Inven_Info>();
         lista = BusMotivo.Get_List_Motivo_Inven(param.IdEmpresa);
         gridControlMovi_inve_tipo.DataSource = lista;
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
 void cargar_MotivoInv()
 {
     try
     {
         listMotivoInv = new List <in_Motivo_Inven_Info>();
         listMotivoInv = BusMotivoInv.Get_List_Motivo_Inven(param.IdEmpresa, Tipo_Ing_Egr.ToString());
         cmbMotivoInv.Properties.DataSource = listMotivoInv;
         cmbMotivoInv.EditValue             = listMotivoInv.First(q => q.Genera_Movi_Inven == "S").IdMotivo_Inv;
     }
     catch (Exception ex)
     {
         string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
         MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
     }
 }
Ejemplo n.º 3
0
        private bool grabar_movimientos_x_distribucion()
        {
            try
            {
                info_param_in   = bus_param_in.Get_Info_Parametro(param.IdEmpresa);
                lst_motivo_inve = bus_motivo_inve.Get_List_Motivo_Inven(param.IdEmpresa, "");
                in_Ing_Egr_Inven_distribucion_Info distribucion_sin_lote = bus_distribucion.get_info(info_distribucion.IdEmpresa, info_distribucion.IdSucursal, info_distribucion.IdMovi_inven_tipo, info_distribucion.IdNumMovi, (info_distribucion.signo == "+" ? "-" : "+"));
                in_Ing_Egr_Inven_distribucion_Info distribucion_con_lote = bus_distribucion.get_info(info_distribucion.IdEmpresa, info_distribucion.IdSucursal, info_distribucion.IdMovi_inven_tipo, info_distribucion.IdNumMovi, info_distribucion.signo);
                in_Motivo_Inven_Info info_motivo = new in_Motivo_Inven_Info();
                in_Ing_Egr_Inven_Bus bus_ing_egr = new in_Ing_Egr_Inven_Bus();
                decimal Id      = 0;
                string  mensaje = "";

                #region Crear movimiento sin lote
                in_Ing_Egr_Inven_Info mov_sin_lote = new in_Ing_Egr_Inven_Info();

                #region Cabecera
                if (distribucion_sin_lote != null)
                {
                    mov_sin_lote = bus_ing_egr.Get_Info_Ing_Egr_Inven(distribucion_sin_lote.IdEmpresa_dis, distribucion_sin_lote.IdSucursal_dis, distribucion_sin_lote.IdMovi_inven_tipo_dis, distribucion_sin_lote.IdNumMovi_dis);
                }
                else
                {
                    info_motivo = lst_motivo_inve.FirstOrDefault(q => q.Genera_Movi_Inven == "S" && q.Tipo_Ing_Egr == (info_distribucion.signo == "+" ? ein_Tipo_Ing_Egr.EGR : ein_Tipo_Ing_Egr.ING));
                    if (info_motivo == null)
                    {
                        MessageBox.Show("No existe motivo de inventario parametrizado, por favor corregir", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }

                    mov_sin_lote = new in_Ing_Egr_Inven_Info
                    {
                        IdEmpresa         = param.IdEmpresa,
                        IdSucursal        = info_distribucion.IdSucursal,
                        IdMovi_inven_tipo = info_distribucion.signo == "+" ? Convert.ToInt32(info_param_in.IdMovi_inven_tipo_x_distribucion_egr) : Convert.ToInt32(info_param_in.IdMovi_inven_tipo_x_distribucion_ing),
                        IdNumMovi         = 0,
                        IdBodega          = info_distribucion.IdBodega,
                        signo             = (info_distribucion.signo == "+" ? "-" : "+"),
                        CodMoviInven      = "Dis_" + info_distribucion.IdEmpresa.ToString("00") + "_" + info_distribucion.IdSucursal.ToString("00") + "_" + info_distribucion.IdMovi_inven_tipo.ToString("00") + "_" + info_distribucion.IdNumMovi.ToString("000000000"),
                        cm_observacion    = "Dis. x lote - Sucursal: " + info_distribucion.Su_Descripcion.Trim() + " # Movi: " + info_distribucion.IdNumMovi.ToString("000000000"),
                        cm_fecha          = DateTime.Now.Date,
                        IdUsuario         = param.IdUsuario,
                        Estado            = "A",
                        Fecha_Transac     = DateTime.Now,
                        nom_pc            = param.nom_pc,
                        ip           = param.ip,
                        IdMotivo_Inv = info_motivo.IdMotivo_Inv
                    };
                }
                #endregion

                #region Detalle
                foreach (var item in blst_x_distribuir)
                {
                    if (item.can_distribuida > 0)
                    {
                        in_Ing_Egr_Inven_det_Info info_det = new in_Ing_Egr_Inven_det_Info
                        {
                            IdEmpresa                    = mov_sin_lote.IdEmpresa,
                            IdSucursal                   = mov_sin_lote.IdSucursal,
                            IdMovi_inven_tipo            = mov_sin_lote.IdMovi_inven_tipo,
                            IdNumMovi                    = mov_sin_lote.IdNumMovi,
                            IdBodega                     = mov_sin_lote.IdBodega,
                            IdProducto                   = item.IdProducto,
                            dm_observacion               = "",
                            dm_cantidad                  = item.can_distribuida == null ? 0 : Convert.ToDouble(item.can_distribuida) * (info_distribucion.signo == "+" ? -1 : 1),
                            dm_cantidad_sinConversion    = item.can_distribuida == null ? 0 : Convert.ToDouble(item.can_distribuida),
                            mv_costo                     = item.mv_costo,
                            mv_costo_sinConversion       = item.mv_costo,
                            IdUnidadMedida               = item.IdUnidadMedida,
                            IdUnidadMedida_sinConversion = item.IdUnidadMedida,
                        };
                        mov_sin_lote.listIng_Egr.Add(info_det);
                    }
                }
                #endregion

                #endregion

                #region Crear movimiento con lote
                in_Ing_Egr_Inven_Info mov_con_lote = new in_Ing_Egr_Inven_Info();

                #region Cabecera
                if (distribucion_con_lote != null)
                {
                    mov_con_lote = bus_ing_egr.Get_Info_Ing_Egr_Inven(distribucion_con_lote.IdEmpresa_dis, distribucion_con_lote.IdSucursal_dis, distribucion_con_lote.IdMovi_inven_tipo_dis, distribucion_con_lote.IdNumMovi_dis);
                }
                else
                {
                    info_motivo = lst_motivo_inve.FirstOrDefault(q => q.Genera_Movi_Inven == "S" && q.Tipo_Ing_Egr == (info_distribucion.signo == "+" ? ein_Tipo_Ing_Egr.ING : ein_Tipo_Ing_Egr.EGR));
                    if (info_motivo == null)
                    {
                        MessageBox.Show("No existe motivo de inventario parametrizado, por favor corregir", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }

                    mov_con_lote = new in_Ing_Egr_Inven_Info
                    {
                        IdEmpresa         = param.IdEmpresa,
                        IdSucursal        = info_distribucion.IdSucursal,
                        IdMovi_inven_tipo = info_distribucion.signo == "+" ? Convert.ToInt32(info_param_in.IdMovi_inven_tipo_x_distribucion_ing) : Convert.ToInt32(info_param_in.IdMovi_inven_tipo_x_distribucion_egr),
                        IdNumMovi         = 0,
                        IdBodega          = info_distribucion.IdBodega,
                        signo             = info_distribucion.signo,
                        CodMoviInven      = "Dis_" + info_distribucion.IdEmpresa.ToString("00") + "_" + info_distribucion.IdSucursal.ToString("00") + "_" + info_distribucion.IdMovi_inven_tipo.ToString("00") + "_" + info_distribucion.IdNumMovi.ToString("000000000"),
                        cm_observacion    = "Dis. x lote - Sucursal: " + info_distribucion.Su_Descripcion.Trim() + " # Movi: " + info_distribucion.IdNumMovi.ToString("000000000"),
                        cm_fecha          = DateTime.Now.Date,
                        IdUsuario         = param.IdUsuario,
                        Estado            = "A",
                        Fecha_Transac     = DateTime.Now,
                        nom_pc            = param.nom_pc,
                        ip           = param.ip,
                        IdMotivo_Inv = info_motivo.IdMotivo_Inv
                    };
                }
                #endregion

                #region Detalle
                foreach (var item in blst_distribuido)
                {
                    in_Ing_Egr_Inven_det_Info info_det = new in_Ing_Egr_Inven_det_Info
                    {
                        IdEmpresa                    = mov_sin_lote.IdEmpresa,
                        IdSucursal                   = mov_sin_lote.IdSucursal,
                        IdMovi_inven_tipo            = mov_sin_lote.IdMovi_inven_tipo,
                        IdNumMovi                    = mov_sin_lote.IdNumMovi,
                        IdBodega                     = mov_sin_lote.IdBodega,
                        IdProducto                   = item.IdProducto,
                        dm_observacion               = "",
                        dm_cantidad                  = item.dm_cantidad == null ? 0 : Convert.ToDouble(item.dm_cantidad) * (info_distribucion.signo == "+" ? 1 : -1),
                        dm_cantidad_sinConversion    = item.dm_cantidad == null ? 0 : Convert.ToDouble(item.dm_cantidad),
                        mv_costo                     = item.mv_costo,
                        mv_costo_sinConversion       = item.mv_costo,
                        IdUnidadMedida               = item.IdUnidadMedida,
                        IdUnidadMedida_sinConversion = item.IdUnidadMedida,
                    };
                    mov_con_lote.listIng_Egr.Add(info_det);
                }
                #endregion

                #endregion

                #region guardar movimientos y distribucion
                if (distribucion_sin_lote == null)
                {
                    if (!bus_ing_egr.GuardarDB(mov_sin_lote, ref Id, ref mensaje))
                    {
                        return(false);
                    }

                    distribucion_sin_lote = new in_Ing_Egr_Inven_distribucion_Info
                    {
                        IdEmpresa         = info_distribucion.IdEmpresa,
                        IdSucursal        = info_distribucion.IdSucursal,
                        IdMovi_inven_tipo = info_distribucion.IdMovi_inven_tipo,
                        IdNumMovi         = info_distribucion.IdNumMovi,

                        IdEmpresa_dis         = mov_sin_lote.IdEmpresa,
                        IdSucursal_dis        = mov_sin_lote.IdSucursal,
                        IdMovi_inven_tipo_dis = mov_sin_lote.IdMovi_inven_tipo,
                        IdNumMovi_dis         = mov_sin_lote.IdNumMovi,
                        signo  = mov_sin_lote.signo,
                        estado = true,
                    };

                    if (!bus_distribucion.guardarDB(distribucion_sin_lote))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!bus_ing_egr.Reversar_Aprobacion(distribucion_sin_lote.IdEmpresa_dis, distribucion_sin_lote.IdSucursal_dis, distribucion_sin_lote.IdMovi_inven_tipo_dis, distribucion_sin_lote.IdNumMovi_dis, "S"))
                    {
                        return(false);
                    }

                    if (!bus_ing_egr.ModificarDB(mov_sin_lote, ref mensaje))
                    {
                        return(false);
                    }
                }

                if (distribucion_con_lote == null)
                {
                    if (!bus_ing_egr.GuardarDB(mov_con_lote, ref Id, ref mensaje))
                    {
                        return(false);
                    }

                    distribucion_con_lote = new in_Ing_Egr_Inven_distribucion_Info
                    {
                        IdEmpresa         = info_distribucion.IdEmpresa,
                        IdSucursal        = info_distribucion.IdSucursal,
                        IdMovi_inven_tipo = info_distribucion.IdMovi_inven_tipo,
                        IdNumMovi         = info_distribucion.IdNumMovi,

                        IdEmpresa_dis         = mov_con_lote.IdEmpresa,
                        IdSucursal_dis        = mov_con_lote.IdSucursal,
                        IdMovi_inven_tipo_dis = mov_con_lote.IdMovi_inven_tipo,
                        IdNumMovi_dis         = mov_con_lote.IdNumMovi,
                        signo  = mov_con_lote.signo,
                        estado = true,
                    };

                    if (!bus_distribucion.guardarDB(distribucion_con_lote))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!bus_ing_egr.Reversar_Aprobacion(distribucion_con_lote.IdEmpresa_dis, distribucion_con_lote.IdSucursal_dis, distribucion_con_lote.IdMovi_inven_tipo_dis, distribucion_con_lote.IdNumMovi_dis, "S"))
                    {
                        return(false);
                    }

                    if (!bus_ing_egr.ModificarDB(mov_con_lote, ref mensaje))
                    {
                        return(false);
                    }
                }
                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }