Example #1
0
        public void SalvarLog(string idLigacao)
        {
            Motorista Ligacao = LeDadosEntrega <SQLiteConnection, SQLiteDataAdapter>("Select * from Entregas where Id=" + idLigacao)[0];

            using (SQLiteConnection conn = new SQLiteConnection(conexao))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(conn))
                {
                    cmd.CommandText = "INSERT INTO LogLigacoes(Nome, Motorista, Horario, Data, ObsContato) " +
                                      "VALUES (@nome,@motorista,@hora,@data,@obs)";
                    cmd.Parameters.AddWithValue("@nome", Ligacao.QuemLigou);
                    cmd.Parameters.AddWithValue("@motorista", Ligacao.NomeMotorista);
                    cmd.Parameters.AddWithValue("@hora", DateTime.Now.TimeOfDay);
                    cmd.Parameters.AddWithValue("@data", DateTime.Now.Date);
                    cmd.Parameters.AddWithValue("@obs", Ligacao.Observacao);
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch
                    { }
                    finally
                    { conn.Close(); }
                }
            }
        }
Example #2
0
 public void InserirMotorista(Motorista novo)
 {
     using (SQLiteConnection conn = new SQLiteConnection(conexao))
     {
         conn.Open();
         using (SQLiteCommand cmd = new SQLiteCommand(conn))
         {
             cmd.CommandText = "INSERT INTO Entregas(Name,LastCall,Interval,Obs, NF, Supplier, Client, DateM) " +
                               "VALUES (@nome,@ultima,@intervalo,@obs,@nf,@sup,@cli,@datem)";
             cmd.Parameters.AddWithValue("@nome", novo.NomeMotorista);
             cmd.Parameters.AddWithValue("@ultima", DateTime.Today);
             cmd.Parameters.AddWithValue("@intervalo", 0);
             cmd.Parameters.AddWithValue("@obs", novo.Observacao);
             cmd.Parameters.AddWithValue("@nf", novo.NF);
             cmd.Parameters.AddWithValue("@cli", novo.Cliente);
             cmd.Parameters.AddWithValue("@datem", novo.DataManifesto);
             cmd.Parameters.AddWithValue("@sup", novo.Fornecedor);
             try
             {
                 cmd.ExecuteNonQuery();
             }
             catch
             { }
             finally
             {
                 conn.Close();
             }
         }
     }
 }
Example #3
0
        public void NovaDiaria(string idEntrega)
        {
            using (SQLiteConnection conn = new SQLiteConnection(conexao))
            {
                Motorista MotoDiaria = LeDadosEntrega <SQLiteConnection, SQLiteDataAdapter>("Select * from Entregas where Id=" + idEntrega)[0];

                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(conn))
                {
                    cmd.CommandText = "INSERT INTO Diarias (Name,Client,Supplier,Obs,NF) VALUES (@nome,@cliente,@fornecedor,@obs,@nf)";
                    cmd.Parameters.AddWithValue("@nome", MotoDiaria.NomeMotorista);
                    cmd.Parameters.AddWithValue("@obs", MotoDiaria.Observacao);
                    cmd.Parameters.AddWithValue("@cliente", MotoDiaria.Cliente);
                    cmd.Parameters.AddWithValue("@fornecedor", MotoDiaria.Fornecedor);
                    cmd.Parameters.AddWithValue("@nf", MotoDiaria.NF);
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch
                    { }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Example #4
0
 private void Registrar_Alteracao(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.EditAction == DataGridEditAction.Commit)     //caso a alteração seja confirmada
     {
         Motorista teste = e.Row.Item as Motorista;     //o item da coleção correspondente a linha alterada
         var       el    = e.EditingElement as TextBox; //o campo alterado
         d.AlterarEntrega(teste.Id, "Obs", el.Text);    //el.text é o novo valor do campo
     }
     isEditing = false;
 }
Example #5
0
        public bool GetFilteredView(object sourceObject)
        {
            Motorista linha = sourceObject as Motorista;

            if (FiltrarNome(linha) && FiltrarObservacao(linha))
            {
                return(true);
            }
            return(false);
        }
Example #6
0
        private void Registrar_Alteracao(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.EditAction == DataGridEditAction.Commit) //caso a alteração seja confirmada
            {
                //para descobrir qual propriedade esta ligada com a coluna alterada
                if (e.Column is DataGridBoundColumn column)
                {
                    var bindingPath = (column.Binding as Binding).Path.Path; //esse é o nome da propriedade

                    Motorista teste = e.Row.Item as Motorista;               //o item da coleção correspondente a linha alterada
                    var       el    = e.EditingElement as TextBox;           //o campo alterado
                    string    campo;
                    switch (bindingPath)
                    {
                    case "Intervalo":
                        campo = "Interval";
                        break;

                    case "Acao":
                        campo = "Action";
                        break;

                    case "NF":
                        campo = "NF";
                        break;

                    case "Fornecedor":
                        campo = "Supplier";
                        break;

                    case "Cliente":
                        campo = "Client";
                        break;

                    default:
                        campo = "Obs";
                        break;
                    }
                    d.AlterarEntrega(teste.Id, campo, el.Text);
                }
            }
            isEditing = false;
        }
Example #7
0
        public ObservableCollection <Motorista> LeDadosEntrega <S, T>(string query) where S : IDbConnection, new()
            where T : IDbDataAdapter, IDisposable, new()
        {
            var ListaDeMotoristas = new ObservableCollection <Motorista>();

            using (var conn = new S())
            {
                using (var da = new T())
                {
                    using (da.SelectCommand = conn.CreateCommand())
                    {
                        Motorista aux;
                        da.SelectCommand.CommandText = query;
                        da.SelectCommand.Connection.ConnectionString = conexao;
                        DataSet ds = new DataSet();
                        da.Fill(ds);
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            DateTime.TryParse(row["LastCall"].ToString(), out DateTime Ult);
                            DateTime.TryParse(row["DateM"].ToString(), out DateTime Manif);
                            aux = new Motorista(row["Id"].ToString(), row["Name"].ToString(), row["Obs"].ToString())
                            {
                                QuemLigou     = row["Caller"].ToString(),
                                Intervalo     = int.Parse(row["Interval"].ToString()),
                                UltimaLigacao = Ult,
                                NF            = row["NF"].ToString(),
                                Fornecedor    = row["Supplier"].ToString(),
                                Cliente       = row["Client"].ToString(),
                                Acao          = row["Action"].ToString(),
                                DataManifesto = Manif
                            };
                            aux.CalculaProxima();
                            ListaDeMotoristas.Add(aux);
                        }
                    }
                }
            }
            return(ListaDeMotoristas);
        }
Example #8
0
 private bool FiltrarObservacao(Motorista item)
 {
     return(item.Observacao.Contains(FiltroObservacao.Text));
 }
Example #9
0
 private bool FiltrarNome(Motorista item)
 {
     return(item.NomeMotorista.Contains(FiltroNomes.Text));
 }