Exemplo n.º 1
0
void AddCourseUD::loadByCareer(void)
{
	int program=ddCareer.GetSelectedData();
	Sql::SqlConnection conn;
	wstring cmd;
	ddCourse.Items.DeleteAll();
	ddProfessor.Items.DeleteAll();
	int dept;
	Sys::Format(cmd,L"SELECT c.course_id, c.descr\
						FROM course c, prog_course pg, program p\
						WHERE c.course_id=pg.course_id\
							AND pg.program_id=p.program_id\
							AND p.program_id=%d", program);
	try
	{
		conn.OpenSession(DSN,USERNAME,PASSWORD);
		conn.ExecuteSelect(cmd, 100, ddCourse);
		Sys::Format(cmd,L"SELECT department_id FROM program WHERE program_id=%d",program);
		dept=conn.GetInt(cmd);
		if(dept!=1)
		{
			Sys::Format(cmd,L"SELECT p.professor_id, p.last_name_p+' '+p.last_name_m+', '+p.name\
					  FROM professor p, department d, program pg\
					  WHERE p.department_id=d.department_id AND pg.department_id=d.department_id AND pg.program_id=%d\
					  ORDER BY p.last_name_p",program);
		}
		else
		{
			Sys::Format(cmd,L"SELECT p.professor_id, p.last_name_p+' '+p.last_name_m+', '+p.name\
						    FROM professor p ORDER BY p.last_name_p");
		}
        conn.ExecuteSelect(cmd, 100, ddProfessor);
		conn.CloseSession();
	}
Exemplo n.º 2
0
void AddCourseUD::Window_Open(Win::Event& e)
{
	this->Text=L"Add new coourse";
	wstring cmd;
	Sql::SqlConnection conn;
	try
	{
		Sys::Format(cmd, L"SELECT program_id, descr");
		conn.OpenSession(DSN,USERNAME,PASSWORD);
		conn.ExecuteSelect(L"SELECT program_id, career_name FROM program",100, ddCareer);
		conn.ExecuteSelect(L"SELECT classroom_id, descr FROM classroom",100,ddClassroom);
		conn.ExecuteSelect(L" SELECT classtime_id, CONVERT(varchar(15),begin_time,100) + ' - ' + CONVERT(varchar(15),end_time,100) FROM classtime ", 100, ddClasstime);
		conn.CloseSession();
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	ddClassdays.Items.Add(L"Lun-Mie-Vie");
	ddClassdays.Items.Add(L"Mar-Jue");
	if(isEditing==1)
	{
		editingCourse();
	}
	else
	{
		ddClassdays.SelectedIndex=0;
		ddCareer.SelectedIndex=0;
		ddClassroom.SelectedIndex=0;
		ddClasstime.SelectedIndex=0;
		loadByCareer();
	}

	
}
Exemplo n.º 3
0
void CourseDlg::Window_Open(Win::Event& e)
{
	int lab_id=0,hours=0;
	bool tables;
	this->Text=L"Course";
	Sql::SqlConnection conn;
	wstring cmd;
	try
	{
		conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		//conn.OpenSession(hWnd, CONNECTION_STRING);
		conn.ExecuteSelect(L"SELECT lab_id, descr FROM laboratories", 100, ddLab);
		clProgram.Cols.Add(0, LVCFMT_LEFT, 200, L"Program");
		conn.ExecuteSelect(L"SELECT program_id, career_name FROM program ORDER BY program_id", 200, clProgram);
		if (course_id < 0)
		{
			ddLab.SelectedIndex=lab_id;
			return;
		}
		Sys::Format(cmd, L"SELECT course_key, descr, lab_id, need_tables, week_hours FROM course WHERE course_id=%d", course_id);
		conn.ExecuteSelect(cmd);
		//tbxCourse_key.MaxText = 11;
		conn.BindColumn(1, tbxCourse_key, 128);
		//tbxDescr.MaxText = 80;
		conn.BindColumn(2, tbxDescr, 128);
		conn.BindColumn(3, lab_id);
		conn.BindColumn(4, tables);
		tbxWeek_hours.Number=true;
		conn.BindColumn(5, hours);
		if (conn.Fetch() == false)
		{
			this->MessageBox(L"No data was returned", L"Error", MB_OK);
		}

		int id;
		Sys::Format(cmd, L"SELECT program_id FROM prog_course WHERE course_id=%d",course_id);
		conn.ExecuteSelect(cmd);
		conn.BindColumn(1,id);
		while(conn.Fetch())
		{
			clProgram.Items[id-1].Checked=true;
		}
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	ddLab.SelectedIndex=lab_id-1;
	if(tables)ckNeed_tables.Checked=true;
	tbxWeek_hours.SetText(Sys::Convert::ToString(hours));
}
void CategoryPage::Window_Open(Web::HttpConnector& h)
{
	category_id= Sys::Convert::ToInt(hdCategoryID.Data);
	if(category_id<0) return; //if INSERT, just return

	if(h.FirstTime==true)
	{
		Sql::SqlConnection conn;
		wstring cmd;
		Sys::Format(cmd, L"SELECT descr FROM category WHERE category_id= %d", category_id);

		try
		{
			//conn.OpenSession(DNS,USERNAME,PASSWORD);
			conn.OpenSession(NULL, CONNECTION_STRING);
			conn.ExecuteSelect(cmd);
			conn.BindColumn(1,tbxDescr,64);
			if(conn.Fetch()==false) this->MessageBox(L"No data was returned", L"ERROR", MB_OK|MB_ICONERROR);
		}
		catch(Sql::SqlException ex)
		{
			this->MessageBox(ex.GetDescription(),L"ERROR", MB_OK|MB_ICONERROR);
		}
	}
}
void BrandManager::updateListview()
{
	//if(lvBrand.GetSelectedIndex<0) return;
	//int selectedIndex;
	//const int brand_id= lvBrand.Items[selectedIndex].Data;

	Sql::SqlConnection conn;
	Win::HourGlassCursor hgc(true);
	wstring cmd;
	try
	{
		toolbMain.EnableButton(IDM_EDIT, false);
		lvBrand.SetRedraw(false);
		lvBrand.Items.DeleteAll();
		//
		conn.OpenSession(hWnd, CONNECTION_STRING);
		Sys::Format(cmd, L"SELECT brand_id, descr FROM brand");
		conn.ExecuteSelect(cmd, 100, lvBrand);
		//
		lvBrand.SetRedraw(true);
	}
	catch(Sql::SqlException ex)
	{
		this->MessageBox(ex.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
}
Exemplo n.º 6
0
void CoordDlg::UpdateddProf()
{
    ddProfessor.SetRedraw(false);
    ddProfessor.Items.DeleteAll();
    wstring cmd;
    int program_id,dept;
    program_id=ddProgram.SelectedData;

    Sql::SqlConnection conn;
    try
    {
        conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
        //conn.OpenSession(hWnd, CONNECTION_STRING);
        Sys::Format(cmd,L"SELECT department_id FROM program WHERE program_id=%d",program_id);
        dept=conn.GetInt(cmd);
        if(dept!=1)
        {
            Sys::Format(cmd,L"SELECT p.professor_id,p.last_name_p+' '+p.last_name_m+', '+p.name,p.email FROM professor p, program pr, department d \
						 WHERE p.department_id=d.department_id AND d.department_id=pr.department_id AND pr.program_id=%d ORDER BY p.last_name_p",program_id);
        }
        else
        {
            Sys::Format(cmd,L"SELECT p.professor_id,p.last_name_p+' '+p.last_name_m+', '+p.name FROM professor p ORDER BY p.last_name_p");
        }
        conn.ExecuteSelect(cmd, 100, ddProfessor);
        ddProfessor.SelectedIndex=0;
    }
void TeethX::fillTabSelection()
{
	//____________________________________________________Get Access info from the userz table
	bool is_active= false;
	bool has_acceess_patient_info= false;
	bool has_access_users= false;
	bool has_access_payments= false;
	bool has_access_patient_chart= false;
	bool has_access_dental_procedure_setup= false;
	
	Sql::SqlConnection conn;
	wstring cmd;
	int employee_id=0;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(hWnd, CONNECTION_STRING);
		Sys::Format(cmd, L"SELECT is_active, has_access_patient_info, has_access_users, has_access_payments, has_access_patient_chart, has_access_dental_procedure_setup FROM userz WHERE userz_id= %d", userz_id);
		conn.ExecuteSelect(cmd);
		conn.BindColumn(1, is_active);
		conn.BindColumn(2, has_acceess_patient_info);
		conn.BindColumn(3, has_access_users);
		conn.BindColumn(4, has_access_payments);
		conn.BindColumn(5, has_access_patient_chart);
		conn.BindColumn(6, has_access_dental_procedure_setup);
		if(conn.Fetch()!=true)
		{
			this->MessageBox(L"Unable to get user access.", L"TeethX", MB_OK|MB_ICONERROR);
			this->Destroy();
			return;
		}
	}
	catch(Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(),L"TeethX", MB_OK|MB_ICONERROR);
	}
	if(is_active==false)
	{
		this->MessageBox(L"This account is not active.", L"TeethX", MB_OK|MB_ICONERROR);
		this->Destroy();
		return;
	}
	//____________________________________________________Tab Selection
	int index= 0;
	if(has_acceess_patient_info==true) tabSelection.Items.Add(index++, L"Patient", TAB_PATIENT);
	if(has_access_payments==true) tabSelection.Items.Add(index++, L"Payment", TAB_PAYMENT);
	if(has_access_patient_chart==true) tabSelection.Items.Add(index++, L"Patient Chart", TAB_PATIENT_CHART);
	if(has_access_dental_procedure_setup==true) tabSelection.Items.Add(index++, L"Procedure Setup", TAB_PROCEDURE_SETUP);
	if(has_access_users==true) tabSelection.Items.Add(index++, L"Users", TAB_USERS);
	tabSelection.SelectedIndex= 0;
	fillListView();
}
void CategoryDropList::Window_Open(Win::Event& e)
{	
	Sql::SqlConnection conn;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(NULL, CONNECTION_STRING);
		conn.ExecuteSelect(L"SELECT category_id, descr FROM category", 100, ddCategory);
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}

}
Exemplo n.º 9
0
void CoordDlg::Window_Open(Win::Event& e)
{
    this->Text=L"Coordinator Insert/Edit";

    int prof_id;
    wstring cmd;
    Sql::SqlConnection conn;
    try
    {
        conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
        //conn.OpenSession(hWnd, CONNECTION_STRING);
        conn.ExecuteSelect(L"SELECT program_id, career_name FROM program", 100, ddProgram);
        ddProgram.SelectedIndex=0;
        UpdateddProf();
        if (coordinator_id < 0) return;
        Sys::Format(cmd, L"SELECT professor_id, program_id, username, pass, isAdmin FROM coordinator WHERE coordinator_id=%d", coordinator_id);
        conn.ExecuteSelect(cmd);
        conn.BindColumn(1, ddProfessor);
        conn.BindColumn(2, ddProgram);
        conn.BindColumn(3, tbxUsername, 128);
        conn.BindColumn(4, tbxPass, 128);
        conn.BindColumn(5, ckIsadmin);
        if (conn.Fetch() == false)
        {
            this->MessageBox(L"No data was returned", L"Error", MB_OK);
        }
        UpdateddProf();
        Sys::Format(cmd, L"SELECT professor_id FROM coordinator WHERE coordinator_id=%d", coordinator_id);
        prof_id=conn.GetInt(cmd);
        ddProfessor.SelectedData=prof_id;
    }
    catch (Sql::SqlException e)
    {
        this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
    }
}
void Deleteitem::fillListView()
{
	lvItems.SetRedraw(false);
	lvItems.Items.DeleteAll();

	Sql::SqlConnection conn;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(hWnd, CONNECTION_STRING);
		conn.ExecuteSelect(L"SELECT item_id, [item descr], model, [brand descr], [category descr] FROM vw_Item", 100, lvItems);
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	lvItems.SetRedraw(true);
	toolbMain.EnableButton(IDM_DELETE,false);
}
void UserDlg::Window_Open(Win::Event& e)
{
	this->Text=L"Userz";
	Sql::SqlConnection conn;
	wstring cmd;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(hWnd, CONNECTION_STRING);
		if (userz_id < 0) return;
		Sys::Format(cmd, L"SELECT username, first_name, last_name, passwordz, email, is_active, has_access_patient_info, has_access_users, has_access_payments, has_access_patient_chart, has_access_dental_procedure_setup FROM userz WHERE userz_id=%d", userz_id);
		conn.ExecuteSelect(cmd);
		tbxUsername.MaxText = 16;
		conn.BindColumn(1, tbxUsername, 128);
		tbxFirst_name.MaxText = 32;
		conn.BindColumn(2, tbxFirst_name, 128);
		tbxLast_name.MaxText = 32;
		conn.BindColumn(3, tbxLast_name, 128);
		tbxPasswordz.MaxText = 16;
		conn.BindColumn(4, tbxPasswordz, 128);
		tbxEmail.MaxText = 32;
		conn.BindColumn(5, tbxEmail, 128);
		conn.BindColumn(6, ckIs_active);
		conn.BindColumn(7, ckHas_access_patient_info);
		conn.BindColumn(8, ckHas_access_users);
		conn.BindColumn(9, ckHas_access_payments);
		conn.BindColumn(10, ckHas_access_patient_chart);
		conn.BindColumn(11, ckHas_access_dental_procedure_setup);
		if (conn.Fetch() == false)
		{
			this->MessageBox(L"No data was returned", L"Error", MB_OK);
		}
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
}
void TeethX::fillListView()
{
	/*lvMain.SetRedraw(false);
	lvMain.Cols.DeleteAll();
	lvMain.Items.DeleteAll();*/

	Sql::SqlConnection conn;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(hWnd, CONNECTION_STRING);
		if(tabSelection.SelectedData==0)//Patient
		{
			lvMain.SetRedraw(false);
			lvMain.Cols.DeleteAll();
			lvMain.Items.DeleteAll();
			//
			lvMain.Cols.Add(0, LVCFMT_LEFT, 200, L"Last Name");
			lvMain.Cols.Add(1, LVCFMT_LEFT, 200, L"First Name");
			lvMain.Cols.Add(2, LVCFMT_LEFT, 100, L"Birthdate");
			lvMain.Cols.Add(3, LVCFMT_LEFT, 250, L"Email");
			if(patient_id==-1)
			{
				conn.ExecuteSelect(L"SELECT patient_id, last_name, first_name, birth_date, email FROM patient", 100, lvMain);
			}
			else
			{
				wstring cmd_s;
				Sys::Format(cmd_s, L"SELECT patient_id, last_name, first_name, birth_date, email FROM patient WHERE patient_id= %d", patient_id);
				conn.ExecuteSelect(cmd_s, 100, lvMain);
			}
		}
		else if(tabSelection.SelectedData==1)//Payment
		{
			lvMain.SetRedraw(false);
			lvMain.Cols.DeleteAll();
			lvMain.Items.DeleteAll();
			//
			lvMain.Cols.Add(0, LVCFMT_LEFT, 200, L"Patient");
			lvMain.Cols.Add(1, LVCFMT_LEFT, 100, L"Date");
			lvMain.Cols.Add(2, LVCFMT_LEFT, 100, L"Procedure");
			lvMain.Cols.Add(3, LVCFMT_LEFT, 70, L"Tooth");
			lvMain.Cols.Add(4, LVCFMT_LEFT, 100, L"Type");
			lvMain.Cols.Add(5, LVCFMT_LEFT, 100, L"Username");
			lvMain.Cols.Add(6, LVCFMT_LEFT, 100, L"Amount");
			if(patient_id==-1)
			{
				conn.ExecuteSelect(L"SELECT transaction_id, patient_name, transaction_date, dental_procedure, tooth_code, transaction_type, username, amount FROM vw_transaction WHERE transaction_type_id=2", 100, lvMain);
			}
			else
			{
				wstring cmd_s;
				Sys::Format(cmd_s, L"SELECT transaction_id, patient_name, transaction_date, dental_procedure, tooth_code, transaction_type, username, amount FROM vw_transaction WHERE transaction_type_id=2 AND patient_id= %d", patient_id);
				conn.ExecuteSelect(cmd_s, 100, lvMain);
			}
		}
		else if(tabSelection.SelectedData==2)//Dental Procedure
		{
			lvMain.SetRedraw(false);
			lvMain.Cols.DeleteAll();
			lvMain.Items.DeleteAll();
			//
			lvMain.Cols.Add(0, LVCFMT_LEFT, 200, L"Patient");
			lvMain.Cols.Add(1, LVCFMT_LEFT, 100, L"Date");
			lvMain.Cols.Add(2, LVCFMT_LEFT, 100, L"Procedure");
			lvMain.Cols.Add(3, LVCFMT_LEFT, 100, L"Tooth");
			lvMain.Cols.Add(4, LVCFMT_LEFT, 150, L"Type");
			lvMain.Cols.Add(5, LVCFMT_LEFT, 100, L"Username");
			lvMain.Cols.Add(6, LVCFMT_LEFT, 100, L"Amount");
			if(patient_id==-1)
			{
				conn.ExecuteSelect(L"SELECT transaction_id, patient_name, transaction_date, dental_procedure, tooth_code, transaction_type, username, amount FROM vw_transaction WHERE transaction_type_id=1", 100, lvMain);
			}
			else
			{
				wstring cmd_s;
				Sys::Format(cmd_s, L"SELECT transaction_id, patient_name, transaction_date, dental_procedure, tooth_code, transaction_type, username, amount FROM vw_transaction WHERE transaction_type_id=1 AND patient_id= %d", patient_id);
				conn.ExecuteSelect(cmd_s, 100, lvMain);
			}
		}
		else if(tabSelection.SelectedData==3)//Procedure Setup
		{
			lvMain.SetRedraw(false);
			lvMain.Cols.DeleteAll();
			lvMain.Items.DeleteAll();
			//
			lvMain.Cols.Add(0, LVCFMT_LEFT, 100, L"Description");
			lvMain.Cols.Add(1, LVCFMT_RIGHT, 100, L"Est. Cost");
			lvMain.Cols.Add(2, LVCFMT_CENTER, 150, L"Body line color");
			lvMain.Cols.Add(3, LVCFMT_CENTER, 150, L"Body fill color");
			lvMain.Cols.Add(4, LVCFMT_CENTER, 150, L"Root line color");
			lvMain.Cols.Add(5, LVCFMT_CENTER, 150, L"Root fill color");
			conn.ExecuteSelect(L"SELECT dental_procedure_id, descr, ROUND(estimated_cost,2), body_line_color, body_fill_color, root_line_color, root_fill_color FROM vw_dental_procedure", 100, lvMain);
		}
		else if(tabSelection.SelectedData==4)//Users
		{
			lvMain.SetRedraw(false);
			lvMain.Cols.DeleteAll();
			lvMain.Items.DeleteAll();
			//
			lvMain.Cols.Add(0, LVCFMT_LEFT, 150, L"Username");
			lvMain.Cols.Add(1, LVCFMT_LEFT, 150, L"Password");
			lvMain.Cols.Add(2, LVCFMT_LEFT, 150, L"Last name");
			lvMain.Cols.Add(3, LVCFMT_LEFT, 150, L"First name");
			lvMain.Cols.Add(4, LVCFMT_LEFT, 100, L"Active");
			lvMain.Cols.Add(5, LVCFMT_LEFT, 100, L"Patient info");
			lvMain.Cols.Add(6, LVCFMT_LEFT, 100, L"Users");
			lvMain.Cols.Add(7, LVCFMT_LEFT, 100, L"Transactions");
			lvMain.Cols.Add(8, LVCFMT_LEFT, 100, L"Pacient Chart");
			lvMain.Cols.Add(9, LVCFMT_LEFT, 100, L"Proc. Setup");
			conn.ExecuteSelect(L"SELECT userz_id, username, passwordz, last_name, first_name, dbo.f_to_yesno(is_active) AS is_active, dbo.f_to_access(has_access_patient_info) AS has_access_patient_info, dbo.f_to_access(has_access_users) AS has_access_users, dbo.f_to_access(has_access_payments) AS has_access_payments, dbo.f_to_access(has_access_patient_chart) AS has_access_patient_chart, dbo.f_to_access(has_access_dental_procedure_setup) AS has_access_dental_procedure_setup FROM userz", 100, lvMain);
		}
		else return;
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	lvMain.SetRedraw(true);
}