Exemple #1
0
        private void navBarItemSelectMotorista_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            try
            {
                using (var ctx = new SlateContext())
                {
                    ctx.LazyLoading(false);

                    var x = XFrmFindEntity.ShowDialogFindEntity <Motorista>(new ParamsFindEntity()
                    {
                        Context       = ctx,
                        Columns       = new string[] { "IdMotorista", "NomeMotorista" },
                        DynamicObject = _motorista,
                        Title         = "Localizar Motorista"
                    });

                    //var x = XFrmFindEntity.ShowDiaglogFindEntity<Motorista>(ctx,
                    //    new string[] { "IdMotorista", "NomeMotorista" }, _motorista,
                    //    "Selecionar Motorista");

                    if (x != null)
                    {
                        //recupera o cliente
                        this._motorista = ctx.MotoristaDao.Find(x.IdMotorista);

                        this.lblMotorista.Text = this._motorista.NomeMotorista;
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionMessage(ex);
            }
        }
Exemple #2
0
        private async Task carregarSerras()
        {
            using (var ctx = new SlateContext())
            {
                var result = await ctx.SerraDao.FindAllAsync();

                cbSerras.AddList(result);
            }
        }
        public async Task <List <OrdemCarga> > GetSales()
        {
            using (var ctx = new SlateContext())
            {
                DateTime dtInicio = dtEditInicio.Value;
                DateTime dtFim    = dtEditFinal.Value;
                var      result   = await ctx.OrdensCargas
                                    .Where(l => l.DataCarregamento >= dtInicio && l.DataCarregamento <= dtFim)
                                    .ToListAsync();

                return(result);
            }
        }
        private async void btnFiltrarOrdens_Click(object sender, EventArgs e)
        {
            using (var ctx = new SlateContext())
            {
                gridViewOrdemCargas.FindFilterText = "";
                var dtInicio = dtEditInicio.Value.Date.ValidateDate();
                var dtFim    = dtEditFinal.Value.Date.ValidateDate();

                var lista = await ctx.OrdemCargaDao
                            .WhereAsync(p => p.DataCarregamento >= dtInicio &&
                                        p.DataCarregamento <= dtFim);

                gridControlProposta.DataSource = lista;
                gridViewOrdemCargas.ExpandAllGroups();
            }
        }
        private async void btnFiltrarProducao_Click(object sender, EventArgs e)
        {
            using (var ctx = new SlateContext())
            {
                gridViewProducaoSerra.FindFilterText = "";
                var dtInicio = dtEditInicio.Value.Date;
                var dtFim    = dtEditFinal.Value.Date;

                var lista = await ctx.ProducaoSerraDao
                            .WhereAsync(p => p.DataProducao >= dtInicio &&
                                        p.DataProducao <= dtFim);

                gridControlProducaoSerra.DataSource = lista;
                gridViewProducaoSerra.ExpandAllGroups();
            }
        }
        //tirando os anexos a performace aumenta significativamente
        //entao os anexos serao caregados somente quando precisar visualizalos
        private async Task carregarProducaoSerra()
        {
            using (var ctx = new SlateContext())
            {
                gridViewProducaoSerra.FindFilterText = "";
                var data = DateTime.Now;
                int mes  = data.Month;
                int ano  = data.Year;

                var lista = await ctx.ProducaoSerraDao
                            .WhereAsync(p => p.DataProducao.Month == mes &&
                                        p.DataProducao.Year == ano);

                gridControlProducaoSerra.DataSource = lista;
                gridViewProducaoSerra.ExpandAllGroups();
            }
        }
        private async Task carregarMaterialSerras()
        {
            try
            {
                //cortou pra mais da metade os selects
                using (var ctx = new SlateContext())
                {
                    var produtos = await ctx.MaterialSerraDao.FindAllAsync();

                    this.gridControlMaterialSerras.DataSource  = produtos;
                    this.gridViewMaterialSerras.FindFilterText = "";
                    this.gridViewMaterialSerras.Focus();
                }
            }
            catch (Exception ex)
            {
                LoggerUtilIts.ShowExceptionMessage(ex);
            }
        }
        private async void searchControl1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string search = "" + searchControl1.EditValue;
                if (!string.IsNullOrEmpty(search))
                {
                    using (var ctx = new SlateContext(false))
                    {
                        //carregando apenas o cliente do lancamento
                        var lista = await ctx.MaterialSerraDao
                                    .Where(p => p.NomeMaterial.Contains(search))
                                    .ToListAsync();

                        this.gridViewMaterialSerras.FindFilterText = search;
                        gridControlMaterialSerras.DataSource       = lista;
                    }
                }
            }
        }
Exemple #9
0
        public void Convert()
        {
            var ctx      = new BalcaoContext();
            var ctxSlate = new SlateContext();

            var materiais = ctxSlate.MaterialSerraDao.FindAll();

            foreach (var m in materiais)
            {
                var attrib = new AtributoProduto(m);
                try
                {
                    var p = ctx.ProdutoDao.Find(m.IdMaterial);
                    //atualiza os atributos
                    p.Atributos = attrib;

                    p.PrecoVenda       = attrib.ValorMetroQuadrado;
                    p.DescricaoProduto = attrib.NomeMaterial;

                    ctx.ProdutoDao.Update(p);
                }
                catch (System.Exception)
                {
                    //recupra o primeiro produto
                    var p          = ctx.ProdutoDao.Find(1);
                    var newProduto = new Produto();
                    p.Atributos = attrib;

                    newProduto.Update(p);
                    newProduto.IdProduto         = 0;
                    newProduto.CategoriaProduto  = null;
                    newProduto.UnidadeMedida     = null;
                    newProduto.AlteracoesProduto = new List <AlteracaoProduto>();
                    newProduto.TransacoesProduto = new List <TransacoesProduto>();

                    newProduto.CodigoBarras = "000" + (ctx.Produtos.Count() + 1);

                    ctx.ProdutoDao.Save(newProduto);
                }
            }
        }
        private async void searchControl1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string pesquisa = "" + searchControl1.EditValue;
                var    ID       = ParseUtil.ToInt(pesquisa);
                if (!string.IsNullOrEmpty(pesquisa))
                {
                    //encapsular isso posteriormente
                    using (var ctx = new SlateContext())
                    {
                        ctx.LazyLoading(false);
                        List <OrdemCarga> lista;
                        if (ID > 0)
                        {
                            //carregando apenas o que for visivel
                            lista = await ctx.OrdensCargas
                                    .Include(v => v.Cliente)
                                    .Include(v => v.Usuario)
                                    .Where(v => v.IdOrdemCarga == ID)
                                    .ToListAsync();
                        }
                        else
                        {
                            lista = await ctx.OrdensCargas
                                    .Include(v => v.Cliente)
                                    .Include(v => v.Usuario)
                                    .Where(l => l.Cliente.RazaoSocial.Contains(pesquisa))
                                    .ToListAsync();
                        }

                        gridControlProposta.DataSource = lista;


                        this.gridViewOrdemCargas.FindFilterText = pesquisa;
                    }
                }
            }
        }
Exemple #11
0
        private void navBarItemSelecionarCliente_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            try
            {
                using (var ctx = new SlateContext())
                {
                    ctx.LazyLoading(false);
                    //carrega o layout dentro do projeto
                    var layoutStream = GridViewUtil.GetLayoutStreamFromResource(Assembly.GetExecutingAssembly(),
                                                                                "ITE.Slate.GridLayout.cliente_basico.xml");

                    var x = XFrmFindEntity.ShowDialogFindEntity <CliFor>(new ParamsFindEntity()
                    {
                        Context       = ctx,
                        Columns       = new string[] { "IdCliFor", "RazaoSocial", "TipoCliente", "CpfCnpj" },
                        DynamicObject = _cliFor,
                        Title         = "Selecionar Comprador",
                        Layout        = layoutStream
                    });

                    //var x = XFrmFindEntity.ShowDiaglogFindEntity<CliFor>(ctx,
                    //         new string[] { "IdCliFor", "RazaoSocial", "TipoCliente", "CpfCnpj" }, _cliFor, layoutStream,
                    //         "Selecionar Comprador");

                    if (x != null)
                    {
                        //recupera o cliente
                        this._cliFor         = ctx.ClienteDao.Find(x.IdCliFor);
                        this.lblCliente.Text = this._cliFor.RazaoSocial;
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionMessage(ex);
            }
        }
Exemple #12
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (_materiaisProduzido.Count > 0)
            {
                try
                {
                    using (var ctx = new SlateContext())
                    {
                        var dataProducao = dateEditDtProducao.DateTime.ToDateZerada();
                        //essa tabela possui uma chave composta
                        //Serra
                        //Material
                        //Data

                        var itensDuplicados = new List <ProducaoSerra>();

                        foreach (ProducaoSerra s in _materiaisProduzido)
                        {
                            try
                            {
                                var r = ctx.ProducaoSerraDao
                                        .Where(p => p.IdSerra == _serra.IdSerra &&
                                               p.IdMaterial == s.IdMaterial &&
                                               p.DataProducao == dataProducao)
                                        .First();

                                itensDuplicados.Add(r);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Nada encontrado" + ex.Message);
                            }
                        }

                        if (itensDuplicados.Count > 0)
                        {
                            //se existe um material
                            XFrmOptionPane.ShowListTextArea(itensDuplicados,
                                                            "Materiais já produzido anteriormente: \n"
                                                            + _serra.NomeSerra + " em " +
                                                            dateEditDtProducao.DateTime.ToShortDateString());
                            //"*** Atenção - Produto já adicionado ***");
                        }
                        else
                        {
                            this._materiaisProduzido.ForEach(delegate(ProducaoSerra i)
                            {
                                //comunicao o relacionamento que nao deve criar outro material
                                i.Material = null;
                                i.Serra    = null;
                                ctx.ProducaoSerraDao.Save(i);
                            });
                            XMessageIts.Mensagem("Produção da \"" +
                                                 _serra.NomeSerra + "\" salva com sucesso!");
                            this.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    LoggerUtilIts.ShowExceptionLogs(ex);
                    XMessageIts.ExceptionMessageDetails(ex,
                                                        "Falhar ao salvar produçaõ do dia " + dateEditDtProducao.DateTime.ToShortDateString());
                    throw ex;
                }
            }
            else
            {
                XMessageIts.Mensagem("Nada produzido a ser salvo !");
            }
        }