예제 #1
0
        public void Adicionar(Comando comando)
        {
            using (var conn = new NpgsqlConnection(connString))
            {
                conn.Open();

                using (var cmd = new NpgsqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = "INSERT INTO acesso.automacao_log (setor, equipamento, controle, comando) VALUES (@setor, @equipamento, @controle, @comando) RETURNING filedate, num";
                    cmd.Parameters.AddWithValue("setor", comando.Setor);
                    cmd.Parameters.AddWithValue("equipamento", comando.Equipamento);
                    cmd.Parameters.AddWithValue("controle", comando.Controle);
                    cmd.Parameters.AddWithValue("comando", comando.NomeComando);

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DataRow linha = NewRow();
                            linha["filedate"]    = reader["filedate"].ToString();
                            linha["num"]         = reader["num"].ToString();
                            linha["setor"]       = comando.Setor;
                            linha["equipamento"] = comando.Equipamento;
                            linha["controle"]    = comando.Controle;
                            Rows.Add(linha);
                        }


                        DefaultView.Sort = "num desc";
                        DefaultView.ToTable();
                    }
                }
            }
        }
예제 #2
0
 public bool Check()
 {
     if (Rows.Count > 2)
     {
         var newMarking = DefaultView.ToTable();
         for (var i = 1; i < newMarking.Rows.Count; i++)
         {
             var previousRow = newMarking.Rows[i - 1];
             var currentRow  = newMarking.Rows[i];
             if ((previousRow[_beginColumn.ColumnName] is DBNull) && (previousRow[_endColumn.ColumnName] is DBNull))
             {
                 return(false);
             }
             var begin = Convert.ToInt32(previousRow[_beginColumn.ColumnName]);
             var end   = Convert.ToInt32(previousRow[_endColumn.ColumnName]);
             if (begin - end > 0)
             {
                 return(false);
             }
             if (currentRow[_endColumn.ColumnName] is DBNull)
             {
                 return(false);
             }
             begin = Convert.ToInt32(currentRow[_beginColumn.ColumnName]);
             end   = Convert.ToInt32(previousRow[_endColumn.ColumnName]);
             if ((begin - end) != 1)
             {
                 return(false);
             }
         }
     }
     else
     {
         var begin = Convert.ToInt32(Rows[0][_beginColumn.ColumnName]);
         int end   = Convert.ToInt32(Rows[0][_endColumn.ColumnName]);
         if (begin - end > 0)
         {
             return(false);
         }
     }
     return(true);
 }