Click here to Skip to main content
15,896,201 members
Articles / Programming Languages / C

BasicAdmin - Personal Organizer

Rate me:
Please Sign up or sign in to vote.
4.94/5 (14 votes)
1 Aug 2009CPOL6 min read 51K   5.6K   60  
Finance, contacts, notes organizer
#pragma once
#include <vector>

using namespace std;

enum TFieldType
{
	TFTypeText = 0,
	TFTypeNumeric = 1,
	TFTypeInteger = 2,
	TFTypeFloat = 3
};
class CField
{
	public:
		CString Name;
		TFieldType ftype;
		BOOL PK;
		CString getFieldDesc(TFieldType f)
		{
			switch (f)
			{
				case TFTypeText:	return "TEXT";
				case TFTypeNumeric: return "NUMERIC";
				case TFTypeInteger: return "INTEGER";
				case TFTypeFloat:	return "FLOAT";
			}
		}
		CString GetFieldCreate()
		{
			CString strres = "";
			strres.Append(Name);
			strres.Append(" ");
			strres.Append(getFieldDesc(ftype));
			if (PK)
				strres.Append(" PRIMARY KEY");
			return strres;
		}
};
class CTable
{
	public:
		CString Name;
		vector<CField> arrFields;
		CString GetCreate()
		{
			CString strres, strf="";
			strres.Format("CREATE TABLE %s", Name);
			vector<CField>::iterator itf;
			for(itf = arrFields.begin(); itf != arrFields.end(); ++itf)
			{
				strf.Append((*itf).GetFieldCreate());
				strf.Append(",");
			}
			strf = strf.Left(strf.GetLength() - 1);
			strres.AppendFormat("(%s)", strf);
			return strres;
		}
};
class CDataStructure
{
public:
	BOOL fieldexists(CString Tabla, CString Campo);
	void AddIfNotExists(CString Tabla, CString Campo, CString Tipo);
	void OpenCreateDB(CString NombreBase);
	void CreateAccounts();
	void CreateCurrencies();
	void CreateDailyInput();
	void CreateContactsCat();
	void CreateContacts();
	void CreateNotes();
	void CreateTaskData();
	/*CString encript(CString cad);
	CString decript(CString cad);*/
	vector<CTable> arrTables;
	void ProcessDB();
	void ProcessTable(CTable& t);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Argentina Argentina
System developer from Argentina.

Programmed in VB 5,6,.NET, C#, Java, PL-SQL, Transac-SQL, C, C++ and even some "calculator" language.

Love to build small, useful applications.
Usually building big and complicated apps based on solid, reliable components.

Hobbies: reading, photography, chess, paddle, running.

Comments and Discussions