Beispiel #1
0
        public static ResAcc Parte(Parte oParte, PartePrecio oPartePrecio)
        {
            // Se llenan datos predeterminados, si no han sido llenados
            oParte.ParteEstatusID = (oParte.ParteEstatusID > 0 ? oParte.ParteEstatusID : Cat.PartesEstatus.Activo);
            oParte.MedidaID       = (oParte.MedidaID > 0 ? oParte.MedidaID : Cat.Medidas.Pieza);
            oParte.UnidadEmpaque  = (oParte.UnidadEmpaque > 0 ? oParte.UnidadEmpaque : 1);
            oParte.AplicaComision = (oParte.AplicaComision.HasValue ? oParte.AplicaComision : true);
            oParte.Etiqueta       = (oParte.Etiqueta.HasValue ? oParte.Etiqueta : true);

            // Se guarda el registro de la parte
            Datos.Guardar <Parte>(oParte);

            // Se guarda el registro del precio
            if (oPartePrecio != null)
            {
                oPartePrecio.ParteID           = oParte.ParteID;
                oPartePrecio.CostoConDescuento = (oPartePrecio.CostoConDescuento.HasValue ? oPartePrecio.CostoConDescuento : oPartePrecio.Costo);
                Datos.Guardar <PartePrecio>(oPartePrecio);
            }

            // Se generan los registros de existencia, uno por cada sucursal
            var oSucursales = Datos.GetListOf <Sucursal>(q => q.Estatus);

            foreach (var oSucursal in oSucursales)
            {
                Datos.Guardar <ParteExistencia>(new ParteExistencia()
                {
                    ParteID    = oParte.ParteID,
                    SucursalID = oSucursal.SucursalID,
                    Existencia = 0
                });
            }

            // Se generan los registros para Máximos y Mínimos, uno por cada sucursal
            foreach (var oSucursal in oSucursales)
            {
                // Se buscan los criterios generales predefinidos, para asignarlos
                var oCriterioPred = Datos.GetEntity <ParteMaxMinCriterioPredefinido>(q => q.SucursalID == oSucursal.SucursalID &&
                                                                                     q.ProveedorID == oParte.ProveedorID && q.MarcaID == oParte.MarcaParteID && q.LineaID == oParte.LineaID);
                //
                Datos.Guardar <ParteMaxMin>(new ParteMaxMin()
                {
                    ParteID        = oParte.ParteID,
                    SucursalID     = oSucursal.SucursalID,
                    Calcular       = (oCriterioPred == null ? null : oCriterioPred.Calcular),
                    VentasGlobales = (oCriterioPred == null ? null : oCriterioPred.VentasGlobales)
                });
            }

            // Se genera el registro de Abc (ParteAbc)
            Datos.Guardar <ParteAbc>(new ParteAbc()
            {
                ParteID     = oParte.ParteID,
                AbcDeVentas = "Z"
            });

            return(new ResAcc(true));
        }
Beispiel #2
0
        public static decimal PartePrecioDeVenta(PartePrecio oPartePrecio, int iListaDePrecios)
        {
            switch (iListaDePrecios)
            {
            case 1:
                return(oPartePrecio.PrecioUno.Valor());

            case 2:
                return(oPartePrecio.PrecioDos.Valor());

            case 3:
                return(oPartePrecio.PrecioTres.Valor());

            case 4:
                return(oPartePrecio.PrecioCuatro.Valor());

            case 5:
                return(oPartePrecio.PrecioCinco.Valor());
            }
            return(0);
        }
Beispiel #3
0
 private void Calculadora_Load(object sender, EventArgs e)
 {
     this.ClearTextBoxes(this);
     this.cboOperacion.SelectedIndex = 0;
     if (Parte != null)
     {
         var precio = Datos.GetEntity <PartePrecio>(p => p.ParteID.Equals(Parte.ParteID));
         if (precio != null)
         {
             PartePrecio                 = precio;
             this.txtCosto.Text          = precio.Costo.ToString();
             this.txtGananciaUno.Text    = precio.PorcentajeUtilidadUno.ToString();
             this.txtGananciaDos.Text    = precio.PorcentajeUtilidadDos.ToString();
             this.txtGananciaTres.Text   = precio.PorcentajeUtilidadTres.ToString();
             this.txtGananciaCuatro.Text = precio.PorcentajeUtilidadCuatro.ToString();
             this.txtGananciaCinco.Text  = precio.PorcentajeUtilidadCinco.ToString();
             this.txtPrecioUno.Text      = precio.PrecioUno.ToString();
             this.txtPrecioDos.Text      = precio.PrecioDos.ToString();
             this.txtPrecioTres.Text     = precio.PrecioTres.ToString();
             this.txtPrecioCuatro.Text   = precio.PrecioCuatro.ToString();
             this.txtPrecioCinco.Text    = precio.PrecioCinco.ToString();
         }
     }
 }
Beispiel #4
0
        private void Importar()
        {
            string sColumnasFalt = this.ValidarColumnas();

            if (sColumnasFalt != "")
            {
                UtilLocal.MensajeAdvertencia("El archivo especificado no tiene el formato correcto. Falta especificar las siguientes columnas:\n\n" + sColumnasFalt);
                return;
            }

            this.HabilitarControlesProceso(false);
            this.prgProgreso.Inicializar(this.dgvProceso.Rows.Count, 1);

            foreach (DataGridViewRow oFila in this.dgvProceso.Rows)
            {
                this.prgProgreso.EjecutarPaso(true);

                if (oFila.DefaultCellStyle.ForeColor == Color.Green)
                {
                    continue;
                }

                // Se valida que no se repita el número de parte
                string sNumeroDeParte = Util.Cadena(oFila.Cells["NumeroDeParte"].Value);
                if (Datos.Exists <Parte>(c => c.NumeroParte == sNumeroDeParte && c.Estatus))
                {
                    if (UtilLocal.MensajePregunta(string.Format("El Número de Parte especificado ya existe. Aún así deseas importar el registro: {0} - {1}"
                                                                , oFila.Cells["NumeroDeParte"].Value, oFila.Cells["Nombre"].Value)) != DialogResult.Yes)
                    {
                        this.PonerErrorFila(oFila, "El número de parte especificado ya existe en la base de datos. Revisar.");
                        continue;
                    }
                }
                // Se obtiene los Ids (Proveedor, Marca, ..)
                string sProveedor = Util.Cadena(oFila.Cells["Proveedor"].Value);
                var    oProveedor = Datos.GetEntity <Proveedor>(c => c.NombreProveedor == sProveedor && c.Estatus);
                if (oProveedor == null)
                {
                    this.PonerErrorFila(oFila, "El Proveedor especificado es inválido.");
                    continue;
                }
                string sMarca = Util.Cadena(oFila.Cells["Marca"].Value);
                var    oMarca = Datos.GetEntity <MarcaParte>(c => c.NombreMarcaParte == sMarca && c.Estatus);
                if (oMarca == null)
                {
                    this.PonerErrorFila(oFila, "La Marca especificada es inválida.");
                    continue;
                }
                string sLinea = Util.Cadena(oFila.Cells["Linea"].Value);
                var    oLinea = Datos.GetEntity <Linea>(c => c.NombreLinea == sLinea && c.Estatus);
                if (oLinea == null)
                {
                    this.PonerErrorFila(oFila, "La Línea especificada es inválida.");
                    continue;
                }
                string sSubsistema = Util.Cadena(oFila.Cells["Subsistema"].Value);
                var    oSubsistema = Datos.GetEntity <Subsistema>(c => c.NombreSubsistema == sSubsistema && c.Estatus);
                if (oSubsistema == null)
                {
                    this.PonerErrorFila(oFila, "El Subsistema especificado es inválido.");
                    continue;
                }
                string sUnidadDeMedida = Util.Cadena(oFila.Cells["UnidadDeMedida"].Value);
                var    oUnidadDeMedida = Datos.GetEntity <Medida>(c => c.NombreMedida == sUnidadDeMedida && c.Estatus);
                if (oUnidadDeMedida == null)
                {
                    this.PonerErrorFila(oFila, "La Unidad de Medida es inválida.");
                    continue;
                }

                // Se genera el registro de la parte
                var oParte = new Parte()
                {
                    NumeroParte    = Util.Cadena(oFila.Cells["NumeroDeParte"].Value),
                    NombreParte    = Util.Cadena(oFila.Cells["Nombre"].Value),
                    ProveedorID    = oProveedor.ProveedorID,
                    MarcaParteID   = oMarca.MarcaParteID,
                    LineaID        = oLinea.LineaID,
                    SubsistemaID   = oSubsistema.SubsistemaID,
                    MedidaID       = oUnidadDeMedida.MedidaID,
                    UnidadEmpaque  = Util.Entero(oFila.Cells["UnidadDeEmpaque"].Value),
                    AplicaComision = (Util.Cadena(oFila.Cells["AplicaComision"].Value).ToLower() == PartesImportar.CadenaVerdadero),
                    Etiqueta       = (Util.Cadena(oFila.Cells["Etiqueta"].Value).ToLower() == PartesImportar.CadenaVerdadero),
                    Es9500         = true
                };
                // Se genera el registro del precio
                var oPartePrecio = new PartePrecio()
                {
                    Costo = Util.Decimal(oFila.Cells["Costo"].Value),
                    PorcentajeUtilidadUno    = Util.Decimal(oFila.Cells["PorUtil1"].Value),
                    PorcentajeUtilidadDos    = Util.Decimal(oFila.Cells["PorUtil2"].Value),
                    PorcentajeUtilidadTres   = Util.Decimal(oFila.Cells["PorUtil3"].Value),
                    PorcentajeUtilidadCuatro = Util.Decimal(oFila.Cells["PorUtil4"].Value),
                    PorcentajeUtilidadCinco  = Util.Decimal(oFila.Cells["PorUtil5"].Value),
                    PrecioUno    = Util.Decimal(oFila.Cells["Precio1"].Value),
                    PrecioDos    = Util.Decimal(oFila.Cells["Precio2"].Value),
                    PrecioTres   = Util.Decimal(oFila.Cells["Precio3"].Value),
                    PrecioCuatro = Util.Decimal(oFila.Cells["Precio4"].Value),
                    PrecioCinco  = Util.Decimal(oFila.Cells["Precio5"].Value),
                };
                // Se guardan los datos
                Guardar.Parte(oParte, oPartePrecio);
                // Se colorea la fila
                oFila.ErrorText = "";
                oFila.DefaultCellStyle.ForeColor = Color.Green;
            }

            this.prgProgreso.EjecutarPaso(false);
            this.HabilitarControlesProceso(true);
        }
Beispiel #5
0
        private void Importar()
        {
            string sColumnasFalt = this.ValidarColumnas();
            if (sColumnasFalt != "")
            {
                UtilLocal.MensajeAdvertencia("El archivo especificado no tiene el formato correcto. Falta especificar las siguientes columnas:\n\n" + sColumnasFalt);
                return;
            }

            this.HabilitarControlesProceso(false);
            this.prgProgreso.Inicializar(this.dgvProceso.Rows.Count, 1);

            foreach (DataGridViewRow oFila in this.dgvProceso.Rows)
            {
                this.prgProgreso.EjecutarPaso(true);

                if (oFila.DefaultCellStyle.ForeColor == Color.Green)
                    continue;

                // Se valida que no se repita el número de parte
                string sNumeroDeParte = Util.Cadena(oFila.Cells["NumeroDeParte"].Value);
                if (Datos.Exists<Parte>(c => c.NumeroParte == sNumeroDeParte && c.Estatus))
                {
                    if (UtilLocal.MensajePregunta(string.Format("El Número de Parte especificado ya existe. Aún así deseas importar el registro: {0} - {1}"
                        , oFila.Cells["NumeroDeParte"].Value, oFila.Cells["Nombre"].Value)) != DialogResult.Yes)
                    {
                        this.PonerErrorFila(oFila, "El número de parte especificado ya existe en la base de datos. Revisar.");
                        continue;
                    }
                }
                // Se obtiene los Ids (Proveedor, Marca, ..)
                string sProveedor = Util.Cadena(oFila.Cells["Proveedor"].Value);
                var oProveedor = Datos.GetEntity<Proveedor>(c => c.NombreProveedor == sProveedor && c.Estatus);
                if (oProveedor == null)
                {
                    this.PonerErrorFila(oFila, "El Proveedor especificado es inválido.");
                    continue;
                }
                string sMarca = Util.Cadena(oFila.Cells["Marca"].Value);
                var oMarca = Datos.GetEntity<MarcaParte>(c => c.NombreMarcaParte == sMarca && c.Estatus);
                if (oMarca == null)
                {
                    this.PonerErrorFila(oFila, "La Marca especificada es inválida.");
                    continue;
                }
                string sLinea = Util.Cadena(oFila.Cells["Linea"].Value);
                var oLinea = Datos.GetEntity<Linea>(c => c.NombreLinea == sLinea && c.Estatus);
                if (oLinea == null)
                {
                    this.PonerErrorFila(oFila, "La Línea especificada es inválida.");
                    continue;
                }
                string sSubsistema = Util.Cadena(oFila.Cells["Subsistema"].Value);
                var oSubsistema = Datos.GetEntity<Subsistema>(c => c.NombreSubsistema == sSubsistema && c.Estatus);
                if (oSubsistema == null)
                {
                    this.PonerErrorFila(oFila, "El Subsistema especificado es inválido.");
                    continue;
                }
                string sUnidadDeMedida = Util.Cadena(oFila.Cells["UnidadDeMedida"].Value);
                var oUnidadDeMedida = Datos.GetEntity<Medida>(c => c.NombreMedida == sUnidadDeMedida && c.Estatus);
                if (oUnidadDeMedida == null)
                {
                    this.PonerErrorFila(oFila, "La Unidad de Medida es inválida.");
                    continue;
                }

                // Se genera el registro de la parte
                var oParte = new Parte()
                {
                    NumeroParte = Util.Cadena(oFila.Cells["NumeroDeParte"].Value),
                    NombreParte = Util.Cadena(oFila.Cells["Nombre"].Value),
                    ProveedorID = oProveedor.ProveedorID,
                    MarcaParteID = oMarca.MarcaParteID,
                    LineaID = oLinea.LineaID,
                    SubsistemaID = oSubsistema.SubsistemaID,
                    MedidaID = oUnidadDeMedida.MedidaID,
                    UnidadEmpaque = Util.Entero(oFila.Cells["UnidadDeEmpaque"].Value),
                    AplicaComision = (Util.Cadena(oFila.Cells["AplicaComision"].Value).ToLower() == PartesImportar.CadenaVerdadero),
                    Etiqueta = (Util.Cadena(oFila.Cells["Etiqueta"].Value).ToLower() == PartesImportar.CadenaVerdadero),
                    Es9500 = true
                };
                // Se genera el registro del precio
                var oPartePrecio = new PartePrecio()
                {
                    Costo = Util.Decimal(oFila.Cells["Costo"].Value),
                    PorcentajeUtilidadUno = Util.Decimal(oFila.Cells["PorUtil1"].Value),
                    PorcentajeUtilidadDos = Util.Decimal(oFila.Cells["PorUtil2"].Value),
                    PorcentajeUtilidadTres = Util.Decimal(oFila.Cells["PorUtil3"].Value),
                    PorcentajeUtilidadCuatro = Util.Decimal(oFila.Cells["PorUtil4"].Value),
                    PorcentajeUtilidadCinco = Util.Decimal(oFila.Cells["PorUtil5"].Value),
                    PrecioUno = Util.Decimal(oFila.Cells["Precio1"].Value),
                    PrecioDos = Util.Decimal(oFila.Cells["Precio2"].Value),
                    PrecioTres = Util.Decimal(oFila.Cells["Precio3"].Value),
                    PrecioCuatro = Util.Decimal(oFila.Cells["Precio4"].Value),
                    PrecioCinco = Util.Decimal(oFila.Cells["Precio5"].Value),
                };
                // Se guardan los datos
                Guardar.Parte(oParte, oPartePrecio);
                // Se colorea la fila
                oFila.ErrorText = "";
                oFila.DefaultCellStyle.ForeColor = Color.Green;
            }

            this.prgProgreso.EjecutarPaso(false);
            this.HabilitarControlesProceso(true);
        }
Beispiel #6
0
 private void Calculadora_Load(object sender, EventArgs e)
 {
     this.ClearTextBoxes(this);
     this.cboOperacion.SelectedIndex = 0;
     if (Parte != null)
     {
         var precio = Datos.GetEntity<PartePrecio>(p => p.ParteID.Equals(Parte.ParteID));
         if (precio != null)
         {
             PartePrecio = precio;
             this.txtCosto.Text = precio.Costo.ToString();
             this.txtGananciaUno.Text = precio.PorcentajeUtilidadUno.ToString();
             this.txtGananciaDos.Text = precio.PorcentajeUtilidadDos.ToString();
             this.txtGananciaTres.Text = precio.PorcentajeUtilidadTres.ToString();
             this.txtGananciaCuatro.Text = precio.PorcentajeUtilidadCuatro.ToString();
             this.txtGananciaCinco.Text = precio.PorcentajeUtilidadCinco.ToString();
             this.txtPrecioUno.Text = precio.PrecioUno.ToString();
             this.txtPrecioDos.Text = precio.PrecioDos.ToString();
             this.txtPrecioTres.Text = precio.PrecioTres.ToString();
             this.txtPrecioCuatro.Text = precio.PrecioCuatro.ToString();
             this.txtPrecioCinco.Text = precio.PrecioCinco.ToString();
         }
     }
 }
Beispiel #7
0
        public static ResAcc Parte(Parte oParte, PartePrecio oPartePrecio)
        {
            // Se llenan datos predeterminados, si no han sido llenados
            oParte.ParteEstatusID = (oParte.ParteEstatusID > 0 ? oParte.ParteEstatusID : Cat.PartesEstatus.Activo);
            oParte.MedidaID = (oParte.MedidaID > 0 ? oParte.MedidaID : Cat.Medidas.Pieza);
            oParte.UnidadEmpaque = (oParte.UnidadEmpaque > 0 ? oParte.UnidadEmpaque : 1);
            oParte.AplicaComision = (oParte.AplicaComision.HasValue ? oParte.AplicaComision : true);
            oParte.Etiqueta = (oParte.Etiqueta.HasValue ? oParte.Etiqueta : true);

            // Se guarda el registro de la parte
            Datos.Guardar<Parte>(oParte);

            // Se guarda el registro del precio
            if (oPartePrecio != null)
            {
                oPartePrecio.ParteID = oParte.ParteID;
                oPartePrecio.CostoConDescuento = (oPartePrecio.CostoConDescuento.HasValue ? oPartePrecio.CostoConDescuento : oPartePrecio.Costo);
                Datos.Guardar<PartePrecio>(oPartePrecio);
            }

            // Se generan los registros de existencia, uno por cada sucursal
            var oSucursales = Datos.GetListOf<Sucursal>(q => q.Estatus);
            foreach (var oSucursal in oSucursales)
            {
                Datos.Guardar<ParteExistencia>(new ParteExistencia()
                {
                    ParteID = oParte.ParteID,
                    SucursalID = oSucursal.SucursalID,
                    Existencia = 0
                });
            }

            // Se generan los registros para Máximos y Mínimos, uno por cada sucursal
            foreach (var oSucursal in oSucursales)
            {
                // Se buscan los criterios generales predefinidos, para asignarlos
                var oCriterioPred = Datos.GetEntity<ParteMaxMinCriterioPredefinido>(q => q.SucursalID == oSucursal.SucursalID
                    && q.ProveedorID == oParte.ProveedorID && q.MarcaID == oParte.MarcaParteID && q.LineaID == oParte.LineaID);
                //
                Datos.Guardar<ParteMaxMin>(new ParteMaxMin()
                {
                    ParteID = oParte.ParteID,
                    SucursalID = oSucursal.SucursalID,
                    Calcular = (oCriterioPred == null ? null : oCriterioPred.Calcular),
                    VentasGlobales = (oCriterioPred == null ? null : oCriterioPred.VentasGlobales)
                });
            }

            // Se genera el registro de Abc (ParteAbc)
            Datos.Guardar<ParteAbc>(new ParteAbc()
            {
                ParteID = oParte.ParteID,
                AbcDeVentas = "Z"
            });

            return new ResAcc(true);
        }
Beispiel #8
0
        private bool Agregar9500()
        {
            // Se valida la parte de "Partes"
            if (!this.ctlPartes.Validar())
                return false;
            // Se pide el efectivo, si aplica
            if (!this.ctlCobro.CompletarCobro())
                return false;
            // Se valida que exista una Medida genérica, para las nuevas partes
            if (Datos.GetEntity<Medida>(q => q.MedidaID == Cat.Medidas.Pieza && q.Estatus) == null)
            {
                UtilLocal.MensajeAdvertencia("No existe una Medida genérica para asignarle a las partes nuevas. No se puede continuar.");
                return false;
            }

            // Se solicitan la autorizaciones, si se requiere
            int iAutorizoID = 0;
            if (this.ctlPartes.AutorizacionRequeridaPrecio || this.ctlPartes.AutorizacionRequeridaAnticipo)
            {
                string sPermiso = (this.ctlPartes.AutorizacionRequeridaPrecio ? "Autorizaciones.Ventas.9500.PrecioFueraDeRango" :
                    "Autorizaciones.Ventas.9500.NoAnticipo");
                var Res = UtilLocal.ValidarObtenerUsuario(sPermiso, "Autorización");
                iAutorizoID = (Res.Respuesta == null ? 0 : Res.Respuesta.UsuarioID);
            }

            // Se procede a guardar los datos
            DateTime dAhora = DateTime.Now;
            // Se genera la Cotización 9500
            var o9500 = this.ctlPartes.Generar9500();
            o9500.Fecha = dAhora;
            o9500.RealizoUsuarioID = this.ctlCobro.VendodorID;
            if (this.ctlCobro.ComisionistaID > 0)
                o9500.ComisionistaClienteID = this.ctlCobro.ComisionistaID;
            // Se genera el detalle del 9500
            var oParteGanancia = this.ctlPartes.ObtenerParteGanancia(null);
            var o9500Detalle = new List<Cotizacion9500Detalle>();
            foreach (var Parte9500 in this.ctlPartes.Detalle)
            {
                // Si la parte no existe, se agrega
                if (Parte9500.Value.ParteID <= 0)
                {
                    int iFila = UtilLocal.findRowIndex(this.ctlPartes.dgvPartes, "Llave", Parte9500.Key);
                    string sNumeroDeParte = Util.Cadena(this.ctlPartes.dgvPartes["NumeroDeParte", iFila].Value);
                    string sDescripcion = Util.Cadena(this.ctlPartes.dgvPartes["Descripcion", iFila].Value);
                    var oLinea = Datos.GetEntity<Linea>(q => q.LineaID == Parte9500.Value.LineaID && q.Estatus);
                    Parte oParte = new Parte()
                    {
                        NumeroParte = sNumeroDeParte,
                        LineaID = Parte9500.Value.LineaID,
                        MarcaParteID = Parte9500.Value.MarcaParteID,
                        ProveedorID = Parte9500.Value.ProveedorID,
                        NombreParte = sDescripcion,
                        Es9500 = true,
                        SubsistemaID = oLinea.SubsistemaID.Valor()
                    };

                    // Se agregan los precios
                    PartePrecio oPartePrecio = null;
                    if (oParteGanancia != null)
                    {
                        oPartePrecio = new PartePrecio()
                        {
                            Costo = Parte9500.Value.Costo,
                            PorcentajeUtilidadUno = oParteGanancia.PorcentajeDeGanancia1,
                            PorcentajeUtilidadDos = oParteGanancia.PorcentajeDeGanancia2,
                            PorcentajeUtilidadTres = oParteGanancia.PorcentajeDeGanancia3,
                            PorcentajeUtilidadCuatro = oParteGanancia.PorcentajeDeGanancia4,
                            PorcentajeUtilidadCinco = oParteGanancia.PorcentajeDeGanancia5,
                            PrecioUno = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia1),
                            PrecioDos = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia2),
                            PrecioTres = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia3),
                            PrecioCuatro = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia4),
                            PrecioCinco = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia5)
                        };
                    }

                    // Se guarda
                    Guardar.Parte(oParte, oPartePrecio);
                    Parte9500.Value.ParteID = oParte.ParteID;
                }

                // Se agrega la parte al detalle del 9500
                o9500Detalle.Add(Parte9500.Value);
            }

            // Se guardan los datos de 9500
            Guardar.c9500(o9500, o9500Detalle);

            // Se genera la venta con el anticipo
            var oVenta = new Venta()
            {
                ClienteID = o9500.ClienteID,
                RealizoUsuarioID = o9500.RealizoUsuarioID
            };
            var oPrecioAnticipo = Datos.GetEntity<PartePrecio>(c => c.ParteID == Cat.Partes.AnticipoClientes && c.Estatus);
            var oVentaDetalle = new VentaDetalle()
            {
                ParteID = Cat.Partes.AnticipoClientes,
                Cantidad = 1,
                PrecioUnitario = o9500.Anticipo,
                Costo = oPrecioAnticipo.Costo.Valor(),
                CostoConDescuento = (oPrecioAnticipo.CostoConDescuento ?? oPrecioAnticipo.Costo.Valor())
            };
            Guardar.Venta(oVenta, new List<VentaDetalle>() { oVentaDetalle });

            // Se guarda el dato de la venta con el anticipo en el registro de 9500
            o9500.AnticipoVentaID = oVenta.VentaID;
            Datos.Guardar<Cotizacion9500>(o9500);

            // Se guardan las autorizaciones, si hubiera
            if (this.ctlPartes.AutorizacionRequeridaPrecio)
                VentasProc.GenerarAutorizacion(Cat.AutorizacionesProcesos.c9500PrecioFueraDeRango, Cat.Tablas.Tabla9500, o9500.Cotizacion9500ID, iAutorizoID);
            if (this.ctlPartes.AutorizacionRequeridaAnticipo)
                VentasProc.GenerarAutorizacion(Cat.AutorizacionesProcesos.c9500SinAnticipo, Cat.Tablas.Tabla9500, o9500.Cotizacion9500ID, iAutorizoID);

            // Se muestra una notifiación con el resultado
            UtilLocal.MostrarNotificacion("Cotización 9500 guardada correctamente.");

            return true;
        }
Beispiel #9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (!Validaciones())
                return;

            var caracteristicas = new StringBuilder();

            /* int id;
            if (int.TryParse(cboLinea.SelectedValue.ToString(), out id))
            {
                //Validaciones para las caracteristicas segun la linea
                var lineaId = Util.ConvertirEntero(this.cboLinea.SelectedValue);
                var linea = General.GetEntity<Linea>(l => l.LineaID.Equals(lineaId));
                if (linea != null)
                {
                    if (linea.Alto.Equals(true) && this.txtAlto.Text == "")
                        caracteristicas.Append("Alto, ");
                    if (linea.Diametro.Equals(true) && this.txtDiametro.Text == "")
                        caracteristicas.Append("Diametro, ");
                    if (linea.Largo.Equals(true) && this.txtLargo.Text == "")
                        caracteristicas.Append("Largo, ");
                    if (linea.Dientes.Equals(true) && this.txtDientes.Text == "")
                        caracteristicas.Append("Dientes, ");
                    if (linea.Astrias.Equals(true) && this.txtAstrias.Text == "")
                        caracteristicas.Append("Astrias, ");
                    if (linea.Sistema.Equals(true) && Util.ConvertirEntero(this.cboParteSistema.SelectedValue).Equals(1))
                        caracteristicas.Append("Sistema, ");
                    if (linea.Amperaje.Equals(true) && this.txtAmperes.Text == "")
                        caracteristicas.Append("Amperaje, ");
                    if (linea.Voltaje.Equals(true) && this.txtVoltios.Text == "")
                        caracteristicas.Append("Voltaje, ");
                    if (linea.Watts.Equals(true) && this.txtWatts.Text == "")
                        caracteristicas.Append("Watts, ");
                    if (linea.Ubicacion.Equals(true) && Util.ConvertirEntero(this.cboParteUbicacion.SelectedValue).Equals(1))
                        caracteristicas.Append("Ubicacion, ");
                    if (linea.Terminales.Equals(true) && this.txtTerminales.Text == "")
                        caracteristicas.Append("Terminales, ");
                }
            }
            */

            var mensaje = string.Empty;

            if (string.IsNullOrEmpty(caracteristicas.ToString()))
            {
                mensaje = "¿Está seguro de que la información es correcta?";
            }
            else
            {
                mensaje = string.Format("{0}{1}{2}", "Faltan características por llenar, (", caracteristicas.ToString().Substring(0, caracteristicas.ToString().Length - 2), ") ¿Está seguro de que la información es correcta?");
            }

            var res = Util.MensajePregunta(mensaje, GlobalClass.NombreApp);
            if (res == DialogResult.No)
                return;

            object oMotivoFijoCero = null;
            if (this.VerMaxMinFijoCero())
            {
                oMotivoFijoCero = UtilLocal.ObtenerValor("Indica el motivo por el cuál se especificó un MaxMin de cero:", "", MensajeObtenerValor.Tipo.TextoLargo);
                if (oMotivoFijoCero == null)
                    return;
            }

            try
            {
                SplashScreen.Show(new Splash());
                this.btnGuardar.Enabled = false;
                PartePrecio oPartePrecio;
                if (this.EsNuevo)
                {
                    this.oParte = new Parte();
                    oPartePrecio = new PartePrecio();
                }
                else //Modificación
                {
                    oPartePrecio = Datos.GetEntity<PartePrecio>(c => c.ParteID == this.oParte.ParteID && c.Estatus);
                }

                // Se llenan los datos
                oParte.NumeroParte = txtNumeroParte.Text;
                oParte.NombreParte = txtNombreParte.Text;
                oParte.LineaID = Util.Entero(cboLinea.SelectedValue);
                oParte.MarcaParteID = Util.Entero(cboMarca.SelectedValue);
                oParte.SubsistemaID = Util.Entero(cboSubsistema.SelectedValue);
                oParte.ProveedorID = Util.Entero(cboProveedor.SelectedValue);
                oParte.MedidaID = Util.Entero(cboMedida.SelectedValue);
                oParte.ParteEstatusID = Util.Entero(cboEstatus.SelectedValue);
                oParte.AplicaComision = chkAplicaComision.Checked;

                /* Parte.Alto = Util.ConvertirEntero(txtAlto.Text);
                Parte.Largo = Util.ConvertirEntero(txtLargo.Text);
                Parte.Diametro = Util.ConvertirEntero(txtDiametro.Text);
                Parte.Dientes = Util.ConvertirEntero(txtDientes.Text);
                Parte.Astrias = Util.ConvertirEntero(txtAstrias.Text);
                Parte.Amperes = Util.ConvertirEntero(txtAmperes.Text);
                Parte.Voltios = Util.ConvertirEntero(txtVoltios.Text);
                Parte.Watts = Util.ConvertirEntero(txtWatts.Text);
                Parte.Terminales = Util.ConvertirEntero(txtTerminales.Text);
                Parte.Litros = Util.ConvertirEntero(txtLitros.Text);
                */

                oParte.ParteSistemaID = Util.Entero(cboParteSistema.SelectedValue);
                oParte.ParteUbicacionID = Util.Entero(cboParteUbicacion.SelectedValue);

                // Control de Cascos
                this.oParte.EsCasco = (this.cmbEsCascoPara.SelectedValue != null);
                this.oParte.EsCascoPara = (this.oParte.EsCasco.Valor() ? (int?)Util.Entero(this.cmbEsCascoPara.SelectedValue) : null);
                this.oParte.RequiereCascoDe = (this.cmbRequiereCascoDe.SelectedValue == null ? null : (int?)Util.Entero(this.cmbRequiereCascoDe.SelectedValue));
                this.oParte.RequiereDepositoDe = (this.txtRequiereDepositoDe.Tag == null ? null : (int?)Util.Entero(this.txtRequiereDepositoDe.Tag));

                oParte.Es9500 = chk9500.Checked;
                oParte.EsServicio = chkServicio.Checked;

                // Parte.TipoCilindroID = Util.ConvertirEntero(this.cmbCar01.SelectedValue);
                oParte.TipoGarantiaID = Util.Entero(this.cboTipoGarantia.SelectedValue);
                oParte.Etiqueta = this.chkSiEtiqueta.Checked;
                oParte.SoloUnaEtiqueta = this.chkSoloUna.Checked;

                oParte.CodigoBarra = this.txtCodigoBarra.Text;
                oParte.TiempoReposicion = Util.Decimal(this.txtTiempoReposicion.Text);

                oParte.UnidadEmpaque = Util.Decimal(this.txtUnidadEmpaque.Text);
                oParte.AGranel = this.chkAGranel.Checked;
                oParte.EsPar = this.chkEsPar.Checked;

                // Se llenan los datos del precio
                if (oPartePrecio != null)
                {
                    oPartePrecio.Costo = Util.Decimal(txtCosto.Text);
                    oPartePrecio.PorcentajeUtilidadUno = Util.Decimal(txtPorcentaje1.Text);
                    oPartePrecio.PorcentajeUtilidadDos = Util.Decimal(txtPorcentaje2.Text);
                    oPartePrecio.PorcentajeUtilidadTres = Util.Decimal(txtPorcentaje3.Text);
                    oPartePrecio.PorcentajeUtilidadCuatro = Util.Decimal(txtPorcentaje4.Text);
                    oPartePrecio.PorcentajeUtilidadCinco = Util.Decimal(txtPorcentaje5.Text);
                    oPartePrecio.PrecioUno = Util.Decimal(txtPrecio1.Text);
                    oPartePrecio.PrecioDos = Util.Decimal(txtPrecio2.Text);
                    oPartePrecio.PrecioTres = Util.Decimal(txtPrecio3.Text);
                    oPartePrecio.PrecioCuatro = Util.Decimal(txtPrecio4.Text);
                    oPartePrecio.PrecioCinco = Util.Decimal(txtPrecio5.Text);
                }

                // Se guarda la Parte
                if (this.EsNuevo)
                {
                    Guardar.Parte(this.oParte, oPartePrecio);
                }
                else
                {
                    Datos.Guardar<Parte>(this.oParte);
                    Datos.Guardar<PartePrecio>(oPartePrecio);
                }

                // Se mandan guardar las características
                this.GuardarCaracteristicas();

                // Se guardan las existencias y los datos de máximos y mínimos
                foreach (DataGridViewRow row in dgvExistencias.Rows)
                {
                    var sucursalId = Util.Entero(row.Cells["SucursalID"].Value);
                    var parteExistencia = Datos.GetEntity<ParteExistencia>(p => p.ParteID.Equals(oParte.ParteID) && p.SucursalID.Equals(sucursalId));
                    if (parteExistencia != null)
                    {
                        parteExistencia.SucursalID = sucursalId;
                        parteExistencia.Maximo = Util.Entero(row.Cells["Max"].Value);
                        parteExistencia.Minimo = Util.Entero(row.Cells["Min"].Value);
                        // parteExistencia.UnidadEmpaque = Util.ConvertirEntero(row.Cells["UEmp"].Value);
                        parteExistencia.UsuarioID = GlobalClass.UsuarioGlobal.UsuarioID;
                        parteExistencia.FechaModificacion = DateTime.Now;
                        parteExistencia.Estatus = true;
                        parteExistencia.Actualizar = true;
                        Datos.SaveOrUpdate<ParteExistencia>(parteExistencia);
                    }

                    // Se guardan los datos de MaxMin, si fueron modificados
                    bool bMaxMinFijo = Util.Logico(row.Cells["MaxMinFijo"].Value);
                    if (bMaxMinFijo)
                    {
                        var oParteMaxMin = Datos.GetEntity<ParteMaxMin>(q => q.ParteID == oParte.ParteID && q.SucursalID == sucursalId);
                        oParteMaxMin.Fijo = bMaxMinFijo;
                        oParteMaxMin.Maximo = Util.Entero(row.Cells["Max"].Value);
                        oParteMaxMin.Minimo = Util.Entero(row.Cells["Min"].Value);
                        Datos.Guardar<ParteMaxMin>(oParteMaxMin);

                        // Se verifica si fue max min 0, para guardar histórico
                        if (oMotivoFijoCero != null && oParteMaxMin.Maximo == 0 && oParteMaxMin.Minimo == 0)
                        {
                            var oFijoHist = new ParteMaxMinFijoHistorico()
                            {
                                ParteID = this.oParte.ParteID,
                                SucursalID = sucursalId,
                                Fecha = DateTime.Now,
                                Motivo = Util.Cadena(oMotivoFijoCero)
                            };
                            Datos.Guardar<ParteMaxMinFijoHistorico>(oFijoHist);
                        }
                    }
                }

                // Se verifica el máximo, para guardar como 9500 o no
                this.oParte.Es9500 = AdmonProc.VerGuardar9500(this.oParte.ParteID);

                // Si es nuevo, se carga la parte, para que ya no sea nuevo
                if (this.EsNuevo)
                    this.CargarParte(this.oParte.ParteID);

                SplashScreen.Close();
                this.btnGuardar.Enabled = true;
                new Notificacion("Parte Guardada exitosamente", 2 * 1000).Mostrar(Principal.Instance);
                // this.IniciarActualizarListado();
            }
            catch (Exception ex)
            {
                SplashScreen.Close();
                this.btnGuardar.Enabled = true;
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
Beispiel #10
0
 public static decimal PartePrecioDeVenta(PartePrecio oPartePrecio, int iListaDePrecios)
 {
     switch (iListaDePrecios)
     {
         case 1:
             return oPartePrecio.PrecioUno.Valor();
         case 2:
             return oPartePrecio.PrecioDos.Valor();
         case 3:
             return oPartePrecio.PrecioTres.Valor();
         case 4:
             return oPartePrecio.PrecioCuatro.Valor();
         case 5:
             return oPartePrecio.PrecioCinco.Valor();
     }
     return 0;
 }
Beispiel #11
0
        private bool Agregar9500()
        {
            // Se valida la parte de "Partes"
            if (!this.ctlPartes.Validar())
            {
                return(false);
            }
            // Se pide el efectivo, si aplica
            if (!this.ctlCobro.CompletarCobro())
            {
                return(false);
            }
            // Se valida que exista una Medida genérica, para las nuevas partes
            if (Datos.GetEntity <Medida>(q => q.MedidaID == Cat.Medidas.Pieza && q.Estatus) == null)
            {
                UtilLocal.MensajeAdvertencia("No existe una Medida genérica para asignarle a las partes nuevas. No se puede continuar.");
                return(false);
            }

            // Se solicitan la autorizaciones, si se requiere
            int iAutorizoID = 0;

            if (this.ctlPartes.AutorizacionRequeridaPrecio || this.ctlPartes.AutorizacionRequeridaAnticipo)
            {
                string sPermiso = (this.ctlPartes.AutorizacionRequeridaPrecio ? "Autorizaciones.Ventas.9500.PrecioFueraDeRango" :
                                   "Autorizaciones.Ventas.9500.NoAnticipo");
                var Res = UtilLocal.ValidarObtenerUsuario(sPermiso, "Autorización");
                iAutorizoID = (Res.Respuesta == null ? 0 : Res.Respuesta.UsuarioID);
            }

            // Se procede a guardar los datos
            DateTime dAhora = DateTime.Now;
            // Se genera la Cotización 9500
            var o9500 = this.ctlPartes.Generar9500();

            o9500.Fecha            = dAhora;
            o9500.RealizoUsuarioID = this.ctlCobro.VendodorID;
            if (this.ctlCobro.ComisionistaID > 0)
            {
                o9500.ComisionistaClienteID = this.ctlCobro.ComisionistaID;
            }
            // Se genera el detalle del 9500
            var oParteGanancia = this.ctlPartes.ObtenerParteGanancia(null);
            var o9500Detalle   = new List <Cotizacion9500Detalle>();

            foreach (var Parte9500 in this.ctlPartes.Detalle)
            {
                // Si la parte no existe, se agrega
                if (Parte9500.Value.ParteID <= 0)
                {
                    int    iFila          = UtilLocal.findRowIndex(this.ctlPartes.dgvPartes, "Llave", Parte9500.Key);
                    string sNumeroDeParte = Util.Cadena(this.ctlPartes.dgvPartes["NumeroDeParte", iFila].Value);
                    string sDescripcion   = Util.Cadena(this.ctlPartes.dgvPartes["Descripcion", iFila].Value);
                    var    oLinea         = Datos.GetEntity <Linea>(q => q.LineaID == Parte9500.Value.LineaID && q.Estatus);
                    Parte  oParte         = new Parte()
                    {
                        NumeroParte  = sNumeroDeParte,
                        LineaID      = Parte9500.Value.LineaID,
                        MarcaParteID = Parte9500.Value.MarcaParteID,
                        ProveedorID  = Parte9500.Value.ProveedorID,
                        NombreParte  = sDescripcion,
                        Es9500       = true,
                        SubsistemaID = oLinea.SubsistemaID.Valor()
                    };

                    // Se agregan los precios
                    PartePrecio oPartePrecio = null;
                    if (oParteGanancia != null)
                    {
                        oPartePrecio = new PartePrecio()
                        {
                            Costo = Parte9500.Value.Costo,
                            PorcentajeUtilidadUno    = oParteGanancia.PorcentajeDeGanancia1,
                            PorcentajeUtilidadDos    = oParteGanancia.PorcentajeDeGanancia2,
                            PorcentajeUtilidadTres   = oParteGanancia.PorcentajeDeGanancia3,
                            PorcentajeUtilidadCuatro = oParteGanancia.PorcentajeDeGanancia4,
                            PorcentajeUtilidadCinco  = oParteGanancia.PorcentajeDeGanancia5,
                            PrecioUno    = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia1),
                            PrecioDos    = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia2),
                            PrecioTres   = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia3),
                            PrecioCuatro = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia4),
                            PrecioCinco  = UtilTheos.AplicarRedondeo(Parte9500.Value.Costo * oParteGanancia.PorcentajeDeGanancia5)
                        };
                    }

                    // Se guarda
                    Guardar.Parte(oParte, oPartePrecio);
                    Parte9500.Value.ParteID = oParte.ParteID;
                }

                // Se agrega la parte al detalle del 9500
                o9500Detalle.Add(Parte9500.Value);
            }

            // Se guardan los datos de 9500
            Guardar.c9500(o9500, o9500Detalle);

            // Se genera la venta con el anticipo
            var oVenta = new Venta()
            {
                ClienteID        = o9500.ClienteID,
                RealizoUsuarioID = o9500.RealizoUsuarioID
            };
            var oPrecioAnticipo = Datos.GetEntity <PartePrecio>(c => c.ParteID == Cat.Partes.AnticipoClientes && c.Estatus);
            var oVentaDetalle   = new VentaDetalle()
            {
                ParteID           = Cat.Partes.AnticipoClientes,
                Cantidad          = 1,
                PrecioUnitario    = o9500.Anticipo,
                Costo             = oPrecioAnticipo.Costo.Valor(),
                CostoConDescuento = (oPrecioAnticipo.CostoConDescuento ?? oPrecioAnticipo.Costo.Valor())
            };

            Guardar.Venta(oVenta, new List <VentaDetalle>()
            {
                oVentaDetalle
            });

            // Se guarda el dato de la venta con el anticipo en el registro de 9500
            o9500.AnticipoVentaID = oVenta.VentaID;
            Datos.Guardar <Cotizacion9500>(o9500);

            // Se guardan las autorizaciones, si hubiera
            if (this.ctlPartes.AutorizacionRequeridaPrecio)
            {
                VentasProc.GenerarAutorizacion(Cat.AutorizacionesProcesos.c9500PrecioFueraDeRango, Cat.Tablas.Tabla9500, o9500.Cotizacion9500ID, iAutorizoID);
            }
            if (this.ctlPartes.AutorizacionRequeridaAnticipo)
            {
                VentasProc.GenerarAutorizacion(Cat.AutorizacionesProcesos.c9500SinAnticipo, Cat.Tablas.Tabla9500, o9500.Cotizacion9500ID, iAutorizoID);
            }

            // Se muestra una notifiación con el resultado
            UtilLocal.MostrarNotificacion("Cotización 9500 guardada correctamente.");

            return(true);
        }