Exemplo n.º 1
0
        //

        public string DevolveNumTerminal(Guid value)
        {
            var resultado = "Sem Numero";

            try
            {
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    try
                    {
                        tmp.Configuration.AutoDetectChangesEnabled = false;
                        var tmpd = (from t in tmp.Terminais
                                    where t.FkIDOT == value
                                    select t.NumPda).SingleOrDefault();


                        if (tmpd != null)
                        {
                            resultado = tmpd;
                        }
                    }
                    finally
                    {
                        tmp.Configuration.AutoDetectChangesEnabled = true;
                    }
                    return(resultado);
                }
            }
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
            return(resultado);
        }
Exemplo n.º 2
0
        public void DeleteTerminal(Guid value)
        {
            try
            {
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    var e = tmp.Terminais.Find(value);

                    if (e == null)
                    {
                        return;
                    }
                    var tmpTerminals = tmp.OpcoesTerminais.Find(e.FkIDOT);

                    tmp.OpcoesTerminais.Remove(tmpTerminals);
                    tmp.Terminais.Remove(e);

                    tmp.SaveChanges();
                }
            }
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
            //using (var tmp=new DbTerminalContext(_utilities.GetSqlConfigData("DbTerminalContext").ProviderConnectionString))
        }
Exemplo n.º 3
0
        public bool CreateTerminal(TbTerminal valuet, TbOpcoesTerminal valueOp)
        {
            try
            {
                //using (var tmp = new DbTerminalContext(_utilities.GetSqlConfigData("DbTerminalContext").ProviderConnectionString))
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    if (valueOp != null)
                    {
                        valuet.FkIDOT = valueOp.Id;
                        tmp.OpcoesTerminais.Add(valueOp);
                    }


                    tmp.Terminais.Add(valuet);
                    tmp.SaveChanges();
                }
            }
            //catch(DbEntityValidationException dbex)
            //{
            //    foreach (var validationErrors in dbex.EntityValidationErrors)
            //    {
            //        foreach (var Errovalidacao in validationErrors.ValidationErrors)
            //        {
            //            Debug.WriteLine("Property:{0} Error{1}",Errovalidacao.PropertyName,Errovalidacao.ErrorMessage);
            //        }
            //    }
            //}
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
            return(true);
        }
Exemplo n.º 4
0
        public bool VerificaTerminalNum(string value)
        {
            var resultado = false;

            try
            {
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    try
                    {
                        tmp.Configuration.AutoDetectChangesEnabled = false;
                        var tmpd = (from t in tmp.Terminais
                                    where t.NumPda == value
                                    select t.NumPda).SingleOrDefault();


                        resultado = tmpd != null;
                    }
                    finally
                    {
                        tmp.Configuration.AutoDetectChangesEnabled = true;
                    }
                }
            }
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
            return(resultado);
        }
Exemplo n.º 5
0
        public TbOpcoesTerminal GetEntityOpcoes(Guid opcoesTerminalId)
        {
            using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
            {
                var tmpData = (from t in tmp.OpcoesTerminais
                               where t.Id == opcoesTerminalId
                               select t).SingleOrDefault();

                return(tmpData);
            }
        }
Exemplo n.º 6
0
        public BindableCollection <TbTerminal> LoadTerminais()
        {
            BindableCollection <TbTerminal> resultado = null;

            try
            {
                //using (var tmp= new DbTerminalContext(_utilities.GetSqlConfigData("DbTerminalContext").ProviderConnectionString))
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    var x = (from t in tmp.Terminais
                             select t).ToList();
                    resultado = x.Any() ? new BindableCollection <TbTerminal>(x) : new BindableCollection <TbTerminal>();
                }
            }
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
            return(resultado);
        }
Exemplo n.º 7
0
        public BindableCollection <string> GetDataBasesFromInstance(string valueInstance)
        {
            var resultado = new BindableCollection <string>();

            try
            {
                //var t = _utilities.GetSqlConfigData("DbTerminalContext");
                //var t = _utilities.GetIfConnection();
                //var t = GetSqlConfigData("DbTerminalContext");

                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    tmp.Database.Initialize(true);
                    StoredProc ldbStoredProc =
                        new StoredProc().HasName("sp_databases").ReturnsTypes(typeof(ListDataBaseResultSet));
                    ResultsList results = tmp.CallStoredProc(ldbStoredProc);
                    List <ListDataBaseResultSet> tmplst = results.ToList <ListDataBaseResultSet>();

                    List <string> x = (from b in tmplst
                                       where
                                       b.DbName != "master" && b.DbName != "msdb" && b.DbName != "model" &&
                                       b.DbName != "IFDB" && b.DbName != "tempdb" &&
                                       b.DbName != "ReportServer$" + valueInstance &&
                                       b.DbName != "ReportServer$" + valueInstance + "TempDB"
                                       orderby b.DbName ascending
                                       select b.DbName).ToList();

                    if (x.Count > 0)
                    {
                        resultado = new BindableCollection <string>(x);
                    }
                }
            }
            catch (Exception ex)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, ex.Message));
            }

            return(resultado);
        }
Exemplo n.º 8
0
        public void UpdateTerminal(TbTerminal value, TbOpcoesTerminal valueop)
        {
            try
            {
                //using (var tmp = new DbTerminalContext(_utilities.GetSqlConfigData("DbTerminalContext").ProviderConnectionString))
                using (var tmp = new DbTerminalContext(_utilities.GetIfConnection()))
                {
                    if (valueop != null)
                    {
                        var tmpOp = (from t in tmp.OpcoesTerminais
                                     where t.Id == valueop.Id
                                     select t).SingleOrDefault();
                        if (tmpOp != null)
                        {
                            tmpOp.PhcNomeFiltroClientes   = valueop.PhcNomeFiltroClientes;
                            tmpOp.PhcNomeFiltroArtigos    = valueop.PhcNomeFiltroArtigos;
                            tmpOp.ArmazemEnvio            = valueop.ArmazemEnvio;
                            tmpOp.ArmazemRegisto          = valueop.ArmazemRegisto;
                            tmpOp.TipoRetencaoEncomendas  = valueop.TipoRetencaoEncomendas;
                            tmpOp.NumeroEncomendasRetidas = valueop.NumeroEncomendasRetidas;
                            tmpOp.NumeroInicioEncomendas  = valueop.NumeroInicioEncomendas;
                            tmpOp.NumeroFimEncomendas     = valueop.NumeroFimEncomendas;
                            tmpOp.EliminarEncomendas      = valueop.EliminarEncomendas;
                            tmpOp.AlterarPrecoVenda       = valueop.AlterarPrecoVenda;
                            tmpOp.IntroduzComponentes     = valueop.IntroduzComponentes;
                            tmpOp.MostrarDataLinhas       = valueop.MostrarDataLinhas;
                            tmpOp.CriaLinhaEncomenda      = valueop.CriaLinhaEncomenda;
                            tmpOp.NomeVendedor            = valueop.NomeVendedor;
                            tmpOp.NumVendedor             = valueop.NumVendedor;
                            tmpOp.NumeroInicioClientes    = valueop.NumeroInicioClientes;
                            tmpOp.NumeroFimClientes       = valueop.NumeroFimClientes;
                            tmpOp.SincronizaCcNaoRegula   = valueop.SincronizaCcNaoRegula;
                            tmpOp.PhcNomeDossierInterno   = valueop.PhcNomeDossierInterno;
                            tmpOp.PhcNumDossierInterno    = valueop.PhcNumDossierInterno;
                            tmpOp.NumeroInicioClientes    = valueop.NumeroInicioClientes;
                            tmpOp.NumeroFimClientes       = valueop.NumeroFimClientes;
                            tmpOp.NumMaxDescontos         = valueop.NumMaxDescontos;
                            tmpOp.UsaPreco1       = valueop.UsaPreco1;
                            tmpOp.UsaPreco2       = valueop.UsaPreco2;
                            tmpOp.UsaPreco3       = valueop.UsaPreco3;
                            tmpOp.UsaPreco4       = valueop.UsaPreco4;
                            tmpOp.UsaPreco5       = valueop.UsaPreco5;
                            tmpOp.NumMaxDescontos = valueop.NumMaxDescontos;
                            tmpOp.IniciaisUs      = valueop.IniciaisUs;
                            //tmp.SaveChanges();
                        }
                    }
                    var tmpterminal = (from t in tmp.Terminais
                                       where t.IDTerminal == value.IDTerminal
                                       select t).SingleOrDefault();
                    if (tmpterminal != null)
                    {
                        tmpterminal.NumPda             = value.NumPda;
                        tmpterminal.MacAddress3G       = value.MacAddress3G;
                        tmpterminal.MacAddressWireless = value.MacAddressWireless;
                        tmpterminal.TerminalAccessKey  = value.TerminalAccessKey;
                    }

                    tmp.SaveChanges();
                }
            }
            catch (Exception e)
            {
                EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, e.Message));
            }
        }