Simple database: Difference between revisions

Content added Content deleted
Line 378: Line 378:
{
{
//
//
// For appropriate use of this program
// For appropriate use of this program
// use standard Windows Command Processor or cmd.exe
// use standard Windows Command Processor or cmd.exe
//
//
Line 389: Line 389:
// To start cmd just double click at cmd.bat file.
// To start cmd just double click at cmd.bat file.
//
//
//
//
//
//
// Console application command line start command
// Console application command line start command
Line 422: Line 422:
//
//
//
//
//
//
//
//
// Command line example
// Command line example
Line 438: Line 439:
//
//
// Brackets and space between arguments and parameters are necessary.
// Brackets and space between arguments and parameters are necessary.
// Quotes must be used when parameters have more than one word.
// Quotes must be used when parameters have more than one word.
//
//
// If not used as shown in examples, program will show error message.
// If not used as shown in examples, program will show error message.
//
//
Line 488: Line 489:
// Check parameters
// Check parameters
//
//
bool parameters_ok = true;
foreach (string a in args)
{
if(!a.StartsWith("[") || !a.EndsWith("]"))
{
parameters_ok = !parameters_ok;
break;
}
}
//
//
// Minimum one parameter, category
// Add new entry to Data base document
//
//
if(parameters_ok)
if(args.Length==1)
{
{
//
//
//
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" Parameters are ok..... ");
Console.WriteLine(" Missing Parameters Error..... ");
Console.WriteLine();
Console.WriteLine();
}
Console.WriteLine(" Writing new entry to database..... ");
//
else
{
// Create new Data base entry
bool parameters_ok = true;
//
args[0] = string.Empty;
string line = string.Empty;
foreach (string a in args)
foreach (string a in args)
{
{
if(!a.StartsWith("[") || !a.EndsWith("]"))
line+=a;
{
parameters_ok = !parameters_ok;
break;
}
}
}
line+="[" + DateTime.Now.ToString() + "]";
args[0] = "[" + DateTime.Now.ToString() + "]";
//
//
// Write entry to Data base
// Add new entry to Data base document
//
StreamWriter w = new StreamWriter("Data base.txt",true);
w.WriteLine(line);
//
//
if(parameters_ok)
// Close and dispose stream writer
//
{
w.Close();
//
w.Dispose();
//
//
//
Console.WriteLine();
//
Console.WriteLine(" Parameters are ok..... ");
//
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" New entry is written to database. ");
Console.WriteLine(" Writing new entry to database..... ");
//
// Create new Data base entry
//
args[0] = string.Empty;
string line = string.Empty;
foreach (string a in args)
{
line+=a;
}
line+="[" + DateTime.Now.ToString() + "]";
args[0] = "[" + DateTime.Now.ToString() + "]";
//
// Write entry to Data base
//
StreamWriter w = new StreamWriter("Data base.txt",true);
w.WriteLine(line);
//
// Close and dispose stream writer
//
w.Close();
w.Dispose();
//
//
//
Console.WriteLine();
Console.WriteLine(" New entry is written to database. ");


Create_Print_Documents(args);
Create_Print_Documents(args);
//
//
//
//
//
//
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" Add new entry command executed. ");
Console.WriteLine(" Add new entry command executed. ");
//
//
//
//
//
//
}
}
else
else
{
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" ! Parameters are not ok ! ");
Console.WriteLine(" ! Parameters are not ok ! ");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" Add new entry command is not executed. ");
Console.WriteLine(" Add new entry command is not executed. ");
Console.WriteLine();
Console.WriteLine();
}
}
}
}
}