예제 #1
0
 public bool ValidarProceso(int IdEmpresa, decimal IdOrdenPedido)
 {
     try
     {
         return(odata.ValidarProceso(IdEmpresa, IdOrdenPedido));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        public bool ActualizarEstadoAprobacion(List <com_OrdenPedidoDet_Info> Lista)
        {
            try
            {
                using (EntitiesCompras db = new EntitiesCompras())
                {
                    foreach (var item in Lista)
                    {
                        var Entity = db.com_OrdenPedidoDet.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdOrdenPedido == item.IdOrdenPedido && q.Secuencia == item.Secuencia).FirstOrDefault();
                        if (Entity != null)
                        {
                            Entity.opd_CantidadApro  = item.A == true ? item.opd_CantidadApro : 0;
                            Entity.opd_EstadoProceso = item.A == true ? "A" : "RA";
                            Entity.IdUsuarioCantidad = item.IdUsuario;
                            Entity.FechaCantidad     = DateTime.Now;
                        }
                    }
                    db.SaveChanges();
                    var Ordenes = Lista.GroupBy(q => new { q.IdEmpresa, q.IdOrdenPedido }).Select(q => new
                    {
                        IdEmpresa     = q.Key.IdEmpresa,
                        IdOrdenPedido = q.Key.IdOrdenPedido
                    }).ToList();
                    foreach (var item in Ordenes)
                    {
                        odata_c.ValidarProceso(item.IdEmpresa, item.IdOrdenPedido);
                    }
                }


                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #3
0
        public bool GuardarDB(com_CotizacionPedido_Info info)
        {
            try
            {
                EntitiesInventario dbi = new EntitiesInventario();
                EntitiesGeneral    dbg = new EntitiesGeneral();
                int Contadot           = 0;
                using (EntitiesCompras db = new EntitiesCompras())
                {
                    db.com_CotizacionPedido.Add(new com_CotizacionPedido
                    {
                        IdEmpresa               = info.IdEmpresa,
                        IdCotizacion            = info.IdCotizacion = GetID(info.IdEmpresa),
                        IdSucursal              = info.IdSucursal,
                        IdProveedor             = info.IdProveedor,
                        IdTerminoPago           = info.IdTerminoPago,
                        cp_Fecha                = info.cp_Fecha,
                        cp_Plazo                = info.cp_Plazo,
                        IdOrdenPedido           = info.IdOrdenPedido,
                        cp_Observacion          = info.cp_Observacion,
                        IdComprador             = info.IdComprador,
                        IdDepartamento          = info.IdDepartamento,
                        IdSolicitante           = Convert.ToInt32(info.IdSolicitante),
                        EstadoGA                = "P",
                        EstadoJC                = "P",
                        cp_PlazoEntrega         = info.cp_PlazoEntrega,
                        cp_ObservacionAdicional = info.cp_ObservacionAdicional
                    });

                    int Secuencia = 1;
                    foreach (var item in info.ListaDetalle)
                    {
                        var Cont = db.com_CotizacionPedidoDet.Where(q => q.opd_IdEmpresa == item.opd_IdEmpresa && q.opd_IdOrdenPedido == item.opd_IdOrdenPedido && q.opd_Secuencia == item.opd_Secuencia && (q.com_CotizacionPedido.EstadoJC == "P" || q.EstadoJC == true)).Count();
                        if (Cont == 0)
                        {
                            Contadot++;
                            db.com_CotizacionPedidoDet.Add(new com_CotizacionPedidoDet
                            {
                                IdEmpresa         = info.IdEmpresa,
                                IdCotizacion      = info.IdCotizacion,
                                Secuencia         = Secuencia++,
                                opd_IdEmpresa     = item.opd_IdEmpresa,
                                opd_IdOrdenPedido = item.opd_IdOrdenPedido,
                                opd_Secuencia     = item.opd_Secuencia,
                                cd_Cantidad       = item.cd_Cantidad,
                                cd_precioCompra   = item.cd_precioCompra,
                                cd_porc_des       = item.cd_porc_des,
                                cd_descuento      = item.cd_descuento,
                                cd_precioFinal    = item.cd_precioFinal,
                                cd_subtotal       = item.cd_subtotal,
                                IdCod_Impuesto    = item.IdCod_Impuesto,
                                Por_Iva           = item.Por_Iva,
                                cd_iva            = item.cd_iva,
                                cd_total          = item.cd_total,
                                IdProducto        = item.IdProducto ?? 0,
                                IdPunto_cargo     = item.IdPunto_cargo,
                                IdUnidadMedida    = item.IdUnidadMedida,
                                cd_DetallePorItem = item.cd_DetallePorItem,
                                AdjuntoC          = item.AdjuntoC,
                                NombreArchivoC    = !string.IsNullOrEmpty(item.NombreArchivoC) ? Path.GetFileName(item.NombreArchivoC) : item.NombreArchivoC
                            });

                            var det_op = db.com_OrdenPedidoDet.Where(q => q.IdEmpresa == item.opd_IdEmpresa && q.IdOrdenPedido == item.opd_IdOrdenPedido && q.Secuencia == item.opd_Secuencia && q.opd_EstadoProceso == "A").FirstOrDefault();
                            if (det_op != null)
                            {
                                det_op.opd_EstadoProceso = "AC";
                                if (det_op.IdProducto == null)
                                {
                                    det_op.pr_descripcion = dbi.in_Producto.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdProducto == item.IdProducto).FirstOrDefault().pr_descripcion;
                                    det_op.IdUnidadMedida = item.IdUnidadMedida;
                                    det_op.IdProducto     = item.IdProducto;
                                }
                                det_op.FechaCotizacion     = DateTime.Now;
                                det_op.IdUsuarioCotizacion = info.IdUsuario;
                            }
                        }
                    }
                    var persona = dbg.tb_persona.Where(q => q.IdPersona == info.IdPersona).FirstOrDefault();
                    if (persona != null)
                    {
                        persona.pe_correo_secundario1 = info.pe_correo;
                    }


                    if (Contadot > 0)
                    {
                        db.SaveChanges();
                        dbg.SaveChanges();
                    }
                }

                com_OrdenPedido_Data data_ped = new com_OrdenPedido_Data();
                if (Contadot > 0)
                {
                    if (data_ped.SaltarPaso4(info.IdEmpresa, info.IdOrdenPedido ?? 0, info.IdUsuario))
                    {
                    }
                    if (data_ped.ValidarProceso(info.IdEmpresa, info.IdOrdenPedido ?? 0))
                    {
                    }

                    try
                    {
                        #region Adjuntos
                        var lst_adjuntos = info.ListaDetalle.Where(q => q.AdjuntoC == true).ToList();
                        var param        = paramData.Get_Info_parametro(info.IdEmpresa);
                        if (param != null && !string.IsNullOrEmpty(param.UbicacionArchivosCotizacion))
                        {
                            string Comando = "/c Net Use " + param.FileDominio + " /USER:"******" " + param.FileContrasenia;
                            Fx.ExecuteCommand(@"" + Comando);
                            Directory.CreateDirectory(param.UbicacionArchivosCotizacion + @"\" + info.IdCotizacion.ToString());
                            foreach (var item in lst_adjuntos)
                            {
                                var ext = Path.GetFileName(item.NombreArchivoC);
                                System.IO.File.Copy(item.NombreArchivoC, param.UbicacionArchivosCotizacion + @"\" + info.IdCotizacion.ToString() + @"\" + ext, true);
                            }

                            Comando = "/c Net Use /DELETE " + param.FileDominio + " /USER:"******" " + param.FileContrasenia;
                            Fx.ExecuteCommand(@"" + Comando);
                        }
                        #endregion
                    }
                    catch (Exception)
                    {
                        using (SqlConnection connection = new SqlConnection(ConexionERP.GetConnectionString()))
                        {
                            connection.Open();
                            SqlCommand command = new SqlCommand();
                            command.Connection  = connection;
                            command.CommandText = "update com_CotizacionPedidoDet set AdjuntoC = 0, NombreArchivoC = NULL where IdEmpresa = " + info.IdEmpresa.ToString() + " and IdCotizacion = " + info.IdCotizacion.ToString();
                            command.ExecuteNonQuery();
                        }
                    }
                }


                return(true);
            }
            catch (Exception ex)
            {
                string mensaje = string.Empty;
                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.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message
                    , "", arreglo, "",
                    "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
예제 #4
0
        public bool GuardarDB(com_CotizacionPedido_Info info)
        {
            try
            {
                EntitiesInventario dbi = new EntitiesInventario();
                EntitiesGeneral    dbg = new EntitiesGeneral();

                using (EntitiesCompras db = new EntitiesCompras())
                {
                    db.com_CotizacionPedido.Add(new com_CotizacionPedido
                    {
                        IdEmpresa               = info.IdEmpresa,
                        IdCotizacion            = info.IdCotizacion = GetID(info.IdEmpresa),
                        IdSucursal              = info.IdSucursal,
                        IdProveedor             = info.IdProveedor,
                        IdTerminoPago           = info.IdTerminoPago,
                        cp_Fecha                = info.cp_Fecha,
                        cp_Plazo                = info.cp_Plazo,
                        IdOrdenPedido           = info.IdOrdenPedido,
                        cp_Observacion          = info.cp_Observacion,
                        IdComprador             = info.IdComprador,
                        IdDepartamento          = info.IdDepartamento,
                        IdSolicitante           = Convert.ToInt32(info.IdSolicitante),
                        EstadoGA                = "P",
                        EstadoJC                = "P",
                        cp_PlazoEntrega         = info.cp_PlazoEntrega,
                        cp_ObservacionAdicional = info.cp_ObservacionAdicional
                    });

                    int Secuencia = 1;

                    foreach (var item in info.ListaDetalle)
                    {
                        db.com_CotizacionPedidoDet.Add(new com_CotizacionPedidoDet
                        {
                            IdEmpresa         = info.IdEmpresa,
                            IdCotizacion      = info.IdCotizacion,
                            Secuencia         = Secuencia++,
                            opd_IdEmpresa     = item.opd_IdEmpresa,
                            opd_IdOrdenPedido = item.opd_IdOrdenPedido,
                            opd_Secuencia     = item.opd_Secuencia,
                            cd_Cantidad       = item.cd_Cantidad,
                            cd_precioCompra   = item.cd_precioCompra,
                            cd_porc_des       = item.cd_porc_des,
                            cd_descuento      = item.cd_descuento,
                            cd_precioFinal    = item.cd_precioFinal,
                            cd_subtotal       = item.cd_subtotal,
                            IdCod_Impuesto    = item.IdCod_Impuesto,
                            Por_Iva           = item.Por_Iva,
                            cd_iva            = item.cd_iva,
                            cd_total          = item.cd_total,
                            IdProducto        = item.IdProducto ?? 0,
                            IdPunto_cargo     = item.IdPunto_cargo,
                            IdUnidadMedida    = item.IdUnidadMedida,
                            cd_DetallePorItem = item.cd_DetallePorItem
                        });

                        var det_op = db.com_OrdenPedidoDet.Where(q => q.IdEmpresa == item.opd_IdEmpresa && q.IdOrdenPedido == item.opd_IdOrdenPedido && q.Secuencia == item.opd_Secuencia && q.opd_EstadoProceso == "A").FirstOrDefault();
                        if (det_op != null)
                        {
                            det_op.opd_EstadoProceso = "AC";
                            if (det_op.IdProducto == null)
                            {
                                det_op.pr_descripcion = dbi.in_Producto.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdProducto == item.IdProducto).FirstOrDefault().pr_descripcion;
                                det_op.IdUnidadMedida = item.IdUnidadMedida;
                                det_op.IdProducto     = item.IdProducto;
                            }
                            det_op.FechaCotizacion     = DateTime.Now;
                            det_op.IdUsuarioCotizacion = info.IdUsuario;
                        }
                    }
                    var persona = dbg.tb_persona.Where(q => q.IdPersona == info.IdPersona).FirstOrDefault();
                    if (persona != null)
                    {
                        persona.pe_correo_secundario1 = info.pe_correo;
                    }
                    db.SaveChanges();
                    dbg.SaveChanges();
                }

                com_OrdenPedido_Data data_ped = new com_OrdenPedido_Data();
                if (data_ped.SaltarPaso4(info.IdEmpresa, info.IdOrdenPedido ?? 0, info.IdUsuario))
                {
                }

                if (data_ped.ValidarProceso(info.IdEmpresa, info.IdOrdenPedido ?? 0))
                {
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }