Пример #1
0
        public static List <tbProcesarPrecio> getProcesarPrecios(long idEmpresa)
        {
            List <tbProcesarPrecio> getProcesarPrecios = new List <tbProcesarPrecio>();

            using (dbCosolemEntities _dbCosolemEntities = new dbCosolemEntities())
            {
                getProcesarPrecios = (from PP in _dbCosolemEntities.tbProcesarPrecio where PP.idEmpresa == idEmpresa && PP.estadoRegistro && PP.procesarPrecio select PP).ToList();
            }
            getProcesarPrecios.ForEach(x =>
            {
                var _tbProducto = getProducto(x.idProducto);
                if (_tbProducto != null)
                {
                    x.marca    = _tbProducto.marca;
                    x.linea    = _tbProducto.linea;
                    x.grupo    = _tbProducto.grupo;
                    x.subgrupo = _tbProducto.subgrupo;
                    x.modelo   = _tbProducto.modelo;
                    x.producto = _tbProducto.producto;
                }
                tbCosto _tbCosto = getCosto(idEmpresa, x.idProducto);
                x.costo          = _tbCosto == null ? 0 : _tbCosto.costo;
                tbIndiceComercial _tbIndiceComercial = getIndiceComercial(idEmpresa, x.idProducto);
                x.indiceComercial = _tbIndiceComercial == null ? 0 : _tbIndiceComercial.indiceComercial;
                tbIndiceFinanciero _tbIndiceFinanciero = getIndiceFinanciero(idEmpresa, x.idProducto);
                x.indiceFinanciero = _tbIndiceFinanciero == null ? 0 : _tbIndiceFinanciero.indiceFinanciero;
                tbIndiceInformativo _tbIndiceInformativo = getIndiceInformativo(idEmpresa, x.idProducto);
                x.indiceInformativo = _tbIndiceInformativo == null ? 0 : _tbIndiceInformativo.indiceInformativo;
            });
            return(getProcesarPrecios);
        }
Пример #2
0
        private void CargarProductos()
        {
            long idEmpresa = ((Empresa)cmbEmpresa.SelectedItem).idEmpresa.Value;

            dtpFechaHasta_CloseUp(null, null);
            _BindingListtbProducto.Clear();
            ((Modelo)cmbModelo.SelectedItem).tbProducto.Where(x => x.estadoRegistro).ToList().ForEach(x =>
            {
                x.seleccionado      = false;
                x.producto          = x.idProducto.ToString() + " - " + x.descripcion;
                x.idIndiceComercial = 0;
                x.indiceComercial   = 0;
                x.idCosto           = 0;
                x.costo             = 0;
                x.fechaHasta        = new DateTime(2020, 12, 31);
                x.idProcesarPrecio  = 0;
                tbIndiceComercial _tbIndiceComercial = edmCosolemFunctions.getIndiceComercial(idEmpresa, x.idProducto);
                if (_tbIndiceComercial != null)
                {
                    x.idIndiceComercial = _tbIndiceComercial.idIndiceComercial;
                    x.indiceComercial   = _tbIndiceComercial.indiceComercial;
                }
                tbIndiceFinanciero _tbIndiceFinanciero = edmCosolemFunctions.getIndiceFinanciero(idEmpresa, x.idProducto);
                if (_tbIndiceFinanciero != null)
                {
                    x.idIndiceFinanciero = _tbIndiceFinanciero.idIndiceFinanciero;
                    x.indiceFinanciero   = _tbIndiceFinanciero.indiceFinanciero;
                }
                tbIndiceInformativo _tbIndiceInformativo = edmCosolemFunctions.getIndiceInformativo(idEmpresa, x.idProducto);
                if (_tbIndiceInformativo != null)
                {
                    x.idIndiceInformativo = _tbIndiceInformativo.idIndiceInformativo;
                    x.indiceInformativo   = _tbIndiceInformativo.indiceInformativo;
                }
                tbCosto _tbCosto = edmCosolemFunctions.getCosto(idEmpresa, x.idProducto);
                if (_tbCosto != null)
                {
                    x.idCosto    = _tbCosto.idCosto;
                    x.costo      = _tbCosto.costo;
                    x.fechaHasta = _tbCosto.fechaHasta;
                }
                tbProcesarPrecio _tbProcesarPrecio = edmCosolemFunctions.getProcesarPrecio(idEmpresa, x.idProducto);
                if (_tbProcesarPrecio != null)
                {
                    x.idProcesarPrecio = _tbProcesarPrecio.idProcesarPrecio;
                }
                _BindingListtbProducto.Add(x);
            });
        }
Пример #3
0
        private void tsbGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                dgvProductos_CellEndEdit(null, null);

                long idEmpresa = ((Empresa)cmbEmpresa.SelectedItem).idEmpresa.Value;

                string mensaje = String.Empty;
                if (idEmpresa == 0)
                {
                    mensaje += "Seleccione empresa\n";
                }
                if (((Marca)cmbMarca.SelectedItem).idMarca == 0)
                {
                    mensaje += "Seleccione marca\n";
                }
                if (((Linea)cmbLinea.SelectedItem).idLinea == 0)
                {
                    mensaje += "Seleccione línea\n";
                }
                if (((Grupo)cmbGrupo.SelectedItem).idGrupo == 0)
                {
                    mensaje += "Seleccione grupo\n";
                }
                if (((SubGrupo)cmbSubGrupo.SelectedItem).idSubGrupo == 0)
                {
                    mensaje += "Seleccione subgrupo\n";
                }
                if (((Modelo)cmbModelo.SelectedItem).idModelo == 0)
                {
                    mensaje += "Seleccione modelo\n";
                }
                if (_BindingListtbProducto.Count == 0)
                {
                    mensaje += "Ingrese al menos 1 producto\n";
                }
                if (_BindingListtbProducto.Where(x => x.fechaHasta.Date < Program.fechaHora.Date).Any())
                {
                    mensaje += "Indice comercial con fecha de vigencia menor a la fecha actual\n";
                }

                if (String.IsNullOrEmpty(mensaje.Trim()))
                {
                    _BindingListtbProducto.ToList().ForEach(x =>
                    {
                        tbIndiceComercial _tbIndiceComercial = (from IC in _dbCosolemEntities.tbIndiceComercial where IC.idIndiceComercial == x.idIndiceComercial select IC).FirstOrDefault();
                        if (_tbIndiceComercial == null)
                        {
                            _tbIndiceComercial                  = new tbIndiceComercial();
                            _tbIndiceComercial.idEmpresa        = idEmpresa;
                            _tbIndiceComercial.idProducto       = x.idProducto;
                            _tbIndiceComercial.indiceComercial  = x.indiceComercial;
                            _tbIndiceComercial.fechaDesde       = Program.fechaHora.Date;
                            _tbIndiceComercial.fechaHasta       = x.fechaHasta.Date;
                            _tbIndiceComercial.estadoRegistro   = true;
                            _tbIndiceComercial.fechaHoraIngreso = Program.fechaHora;
                            _tbIndiceComercial.idUsuarioIngreso = idUsuario;
                            _tbIndiceComercial.terminalIngreso  = Program.terminal;
                            _dbCosolemEntities.tbIndiceComercial.AddObject(_tbIndiceComercial);
                        }
                        else
                        {
                            _tbIndiceComercial.indiceComercial             = x.indiceComercial;
                            _tbIndiceComercial.fechaHoraUltimaModificacion = Program.fechaHora;
                            _tbIndiceComercial.idUsuarioUltimaModificacion = idUsuario;
                            _tbIndiceComercial.terminalUltimaModificacion  = Program.terminal;
                        }
                        if (x.indiceComercial > 0 && x.indiceFinanciero > 0 && x.indiceInformativo > 0 && x.costo > 0)
                        {
                            tbProcesarPrecio _tbProcesarPrecio = (from PP in _dbCosolemEntities.tbProcesarPrecio where PP.idProcesarPrecio == x.idProcesarPrecio select PP).FirstOrDefault();
                            if (_tbProcesarPrecio == null)
                            {
                                _tbProcesarPrecio                  = new tbProcesarPrecio();
                                _tbProcesarPrecio.idEmpresa        = idEmpresa;
                                _tbProcesarPrecio.idProducto       = x.idProducto;
                                _tbProcesarPrecio.procesarPrecio   = true;
                                _tbProcesarPrecio.estadoRegistro   = true;
                                _tbProcesarPrecio.fechaHoraIngreso = Program.fechaHora;
                                _tbProcesarPrecio.idUsuarioIngreso = idUsuario;
                                _tbProcesarPrecio.terminalIngreso  = Program.terminal;
                                _dbCosolemEntities.tbProcesarPrecio.AddObject(_tbProcesarPrecio);
                            }
                            else
                            {
                                _tbProcesarPrecio.fechaHoraUltimaModificacion = Program.fechaHora;
                                _tbProcesarPrecio.idUsuarioUltimaModificacion = idUsuario;
                                _tbProcesarPrecio.terminalUltimaModificacion  = Program.terminal;
                            }
                        }
                    });
                    _dbCosolemEntities.SaveChanges();

                    MessageBox.Show("Registro grabado satisfactoriamente", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmIndicesComerciales_Load(null, null);
                }
                else
                {
                    MessageBox.Show(mensaje, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                Util.MostrarException(this.Text, ex);
            }
        }