Exemple #1
0
 public void Dispose()
 {
     Kernel         = null;
     Current        = null;
     BaseSelectList = null;
     Position       = 0;
 }
Exemple #2
0
        /// <summary>
        /// Зчитати
        /// </summary>
        /// <returns></returns>
        public bool Select(DateTime periodStart, DateTime periodEnd, string[] typeDocSelect = null)
        {
            Position = 0;
            Current  = null;
            BaseSelectList.Clear();

            Kernel.DataBase.SelectJournalDocumentPointer(Tables, TypeDocuments, BaseSelectList, periodStart, periodEnd, typeDocSelect);

            return(Count() > 0);
        }
Exemple #3
0
        public void SelectJournalDocumentPointer(string[] tables, string[] typeDocument, List <JournalDocument> listJournalDocument,
                                                 DateTime periodStart, DateTime periodEnd, string[] typeDocSelect = null)
        {
            string query   = "";
            int    counter = 0;

            foreach (string table in tables)
            {
                //if (typeDocSelect != null)
                //{
                //	bool existTypeDoc = false;

                //	foreach (string typeDoc in typeDocSelect)
                //		if (typeDocument[counter] == typeDoc)
                //		{
                //			existTypeDoc = true;
                //			break;
                //		}

                //	if (!existTypeDoc)
                //	{
                //		counter++;
                //		continue;
                //	}
                //}

                query += (counter > 0 ? "\nUNION " : "") +
                         $"(SELECT uid, docname, docdate, docnomer, spend, spend_date, '{typeDocument[counter]}' AS type_doc FROM {table} \n" +
                         "WHERE docdate >= @periodstart AND docdate <= @periodend)";

                counter++;
            }

            query += "\nORDER BY docdate";

            //Console.WriteLine(query);

            NpgsqlCommand nCommand = new NpgsqlCommand(query, Connection);

            nCommand.Parameters.Add(new NpgsqlParameter("periodstart", periodStart));
            nCommand.Parameters.Add(new NpgsqlParameter("periodend", periodEnd));

            NpgsqlDataReader reader = nCommand.ExecuteReader();

            while (reader.Read())
            {
                JournalDocument document = new JournalDocument()
                {
                    UnigueID     = new UnigueID((Guid)reader["uid"], ""),
                    DocName      = reader["docname"].ToString(),
                    DocDate      = reader["docdate"].ToString(),
                    DocNomer     = reader["docnomer"].ToString(),
                    Spend        = (bool)reader["spend"],
                    SpendDate    = (DateTime)reader["spend_date"],
                    TypeDocument = reader["type_doc"].ToString()
                };

                listJournalDocument.Add(document);
            }
            reader.Close();
        }