Esempio n. 1
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 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 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);
	}
}
Esempio n. 5
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);
    }
}