Ejemplo n.º 1
0
        public Boolean GrabarDB(in_movi_inve_detalle_Info prI, ref string mensaje)
        {
            try
            {
                using (EntitiesInventario context = new EntitiesInventario())
                {
                    EntitiesInventario EDB = new EntitiesInventario();

                    var Q = from per in EDB.in_movi_inve_detalle
                            where per.IdEmpresa == prI.IdEmpresa &&
                            per.IdMovi_inven_tipo == prI.IdMovi_inven_tipo &&
                            per.IdBodega == prI.IdBodega &&
                            per.IdSucursal == prI.IdSucursal &&
                            per.IdNumMovi == prI.IdNumMovi
                            select per;

                    if (Q.ToList().Count == 0)
                    {
                        var address = new in_movi_inve_detalle();

                        address.IdEmpresa         = prI.IdEmpresa;
                        address.IdSucursal        = prI.IdSucursal;
                        address.IdBodega          = prI.IdBodega;
                        address.IdMovi_inven_tipo = prI.IdMovi_inven_tipo;
                        address.IdNumMovi         = prI.IdNumMovi;
                        address.mv_tipo_movi      = prI.mv_tipo_movi;

                        if (prI.mv_tipo_movi == "-")
                        {
                            address.dm_cantidad = Math.Abs(prI.dm_cantidad) * -1;
                        }
                        else
                        {
                            address.dm_cantidad = Math.Abs(prI.dm_cantidad);
                        }

                        address.dm_observacion = prI.dm_observacion;
                        if (prI.dm_observacion.Length > 1000)
                        {
                            address.dm_observacion = prI.dm_observacion.Substring(0, 1000);
                        }
                        //address.dm_precio = (double)prI.dm_precio;
                        address.dm_stock_actu       = (double)prI.dm_stock_actu;
                        address.dm_stock_ante       = (double)prI.dm_stock_ante;
                        address.mv_costo            = (double)prI.mv_costo;
                        address.dm_peso             = prI.peso;
                        address.Secuencia           = prI.Secuencia;
                        address.dm_peso             = prI.peso;
                        address.IdPunto_cargo       = (prI.IdPunto_Cargo == 0) ? null : prI.IdPunto_Cargo;
                        address.IdPunto_cargo_grupo = prI.IdPunto_cargo_grupo;
                        address.IdMotivo_Inv        = prI.IdMotivo_Inv;
                        context.in_movi_inve_detalle.Add(address);
                        context.SaveChanges();

                        mensaje = "Grabacion ok..";
                    }
                    else
                    {
                        return(false);
                    }
                }
                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;
                mensaje = "Error al Grabar .." + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public Boolean GrabarDB(List <in_movi_inve_detalle_Info> list, ref string mensaje)
        {
            try
            {
                int c = 1;
                foreach (var item in list)
                {
                    using (EntitiesInventario context = new EntitiesInventario())
                    {
                        EntitiesInventario EDB = new EntitiesInventario();
                        var Q = from per in EDB.in_movi_inve_detalle
                                where per.IdEmpresa == item.IdEmpresa &&
                                per.IdMovi_inven_tipo == item.IdMovi_inven_tipo &&
                                per.IdBodega == item.IdBodega &&
                                per.IdSucursal == item.IdSucursal &&
                                per.IdNumMovi == item.IdNumMovi &&
                                per.Secuencia == item.Secuencia
                                select per;

                        if (Q.ToList().Count == 0)
                        {
                            in_movi_inve_detalle address = new in_movi_inve_detalle();

                            address.IdEmpresa         = item.IdEmpresa;
                            address.IdSucursal        = item.IdSucursal;
                            address.IdBodega          = item.IdBodega;
                            address.IdMovi_inven_tipo = item.IdMovi_inven_tipo;
                            address.IdNumMovi         = item.IdNumMovi;
                            address.Secuencia         = c;
                            item.Secuencia            = c;
                            c++;
                            address.mv_tipo_movi = item.mv_tipo_movi;
                            address.IdProducto   = item.IdProducto;
                            if (item.dm_stock_ante == null)
                            {
                                address.dm_stock_ante = (double)item.dm_stock_actu;
                            }
                            else
                            {
                                address.dm_stock_ante = (double)item.dm_stock_ante;
                            }
                            if (item.mv_tipo_movi == "-")
                            {
                                address.dm_cantidad = Math.Abs(item.dm_cantidad) * -1;
                            }
                            else
                            {
                                address.dm_cantidad = Math.Abs(item.dm_cantidad);
                            }
                            address.dm_stock_actu = (double)item.dm_stock_actu;

                            address.mv_costo = (double)item.mv_costo;
                            if (item.dm_observacion == null)
                            {
                                address.dm_observacion = "";
                            }
                            else
                            {
                                address.dm_observacion = item.dm_observacion;
                            }
                            address.dm_peso = item.peso;

                            if (item.IdCentroCosto == "")
                            {
                                item.IdCentroCosto = null;
                            }
                            address.IdCentroCosto = item.IdCentroCosto;
                            if (item.IdCentroCosto_sub_centro_costo == "")
                            {
                                item.IdCentroCosto_sub_centro_costo = null;
                            }
                            address.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo;

                            address.IdUnidadMedida = item.IdUnidadMedida;
                            address.IdUnidadMedida_sinConversion = item.IdUnidadMedida_sinConversion;
                            address.mv_costo_sinConversion       = item.mv_costo_sinConversion;
                            if (item.mv_tipo_movi == "-")
                            {
                                address.dm_cantidad_sinConversion = Math.Abs(item.dm_cantidad_sinConversion) * -1;
                            }
                            else
                            {
                                address.dm_cantidad_sinConversion = Math.Abs(item.dm_cantidad_sinConversion);
                            }

                            address.IdPunto_cargo       = (item.IdPunto_Cargo == 0) ? null : item.IdPunto_Cargo;
                            address.IdPunto_cargo_grupo = item.IdPunto_cargo_grupo;
                            address.IdMotivo_Inv        = item.IdMotivo_Inv;
                            //Campos para saber que movimiento esta devolviendose con este
                            address.IdEmpresa_dev         = item.IdEmpresa_dev;
                            address.IdSucursal_dev        = item.IdSucursal_dev;
                            address.IdBodega_dev          = item.IdBodega_dev;
                            address.IdMovi_inven_tipo_dev = item.IdMovi_inven_tipo_dev;
                            address.IdNumMovi_dev         = item.IdNumMovi_dev;
                            address.Secuencia_dev         = item.Secuencia_dev;


                            context.in_movi_inve_detalle.Add(address);
                            context.SaveChanges();
                            mensaje = "Grabacion ok..";
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }


                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;
                mensaje = "Error al Grabar .." + ex.Message;
                throw new Exception(ex.ToString());
            }
        }