Пример #1
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;
    }
Пример #2
0
void CoordMng::Window_Open(Win::Event& e)
{
	this->AlwaysOnTop(true);
	int dept;
	wstring cmd;
	//________________________________________________________ lvProfessor
	lvProfessor.Cols.Add(0, LVCFMT_LEFT, 250, L"Name");
	lvProfessor.Cols.Add(1, LVCFMT_RIGHT, 150, L"Email");
	lvProfessor.Cols.Add(2, LVCFMT_RIGHT, 80, L"Extension");
	//________________________________________________________ lvCourse
	lvCourse.Cols.Add(0, LVCFMT_LEFT, 150, L"Course Key");
	lvCourse.Cols.Add(1, LVCFMT_LEFT, 300, L"Course");
	try
	{
		Sql::SqlConnection conn;
		conn.OpenSession(DSN,USERNAME,PASSWORD);
		Sys::Format(cmd,L"SELECT department_id FROM program WHERE program_id=%d",career_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,p.extension 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",career_id);
		}
		else
		{
			Sys::Format(cmd,L"SELECT p.professor_id,p.last_name_p+' '+p.last_name_m+', '+p.name,p.email,p.extension FROM professor p ORDER BY p.last_name_p");
		}
		conn.ExecuteSelect(cmd, 100, lvProfessor);
		Sys::Format(cmd,L"SELECT c.course_id, c.course_key, c.descr FROM course c, prog_course pc, program p WHERE c.course_id=pc.course_id AND pc.program_id=p.program_id AND pc.program_id=%d",career_id);
		conn.ExecuteSelect(cmd, 100, lvCourse);
	}
Пример #3
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();
	}

	
}
void Deleteitem::deleteItem()
{
	Win::HourGlassCursor hgc(true);
	const int selectedIndex= lvItems.GetSelectedIndex();
	if(selectedIndex<0) return; //_____________________________Nothing is selected
	//_________________________________________________________Ask the user
	if(this->MessageBox(L"Are you sure you want to delete the selected item?", L"Delete item",
		MB_YESNO|MB_ICONQUESTION)!=IDYES) return;
	//________________________________________________________Delete;
	Sql::SqlConnection conn;
	wstring cmd;
	const int item_id= lvItems.Items[selectedIndex].Data; //Get the Primary Key; 
	int rows = 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"DELETE FROM item WHERE item_id= %d", item_id);
		rows = conn.ExecuteNonQuery(cmd);
		if (rows!=1)
		{
			this->MessageBox(Sys::Convert::ToString(rows), L"Error: number of deleted rows", MB_OK | MB_ICONERROR);
		}
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	fillListView();
}
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);
		}
	}
}
Пример #6
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();
	}
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);
	}
}
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();
}
Пример #9
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 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);
	}

}
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);
}
Пример #12
0
void CoordDlg::btOK_Click(Win::Event& e)
{
    //_____________________________________________________________ Validate
    tr1::wregex regextbxUsername(L"[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]+");
    if (tr1::regex_match(tbxUsername.Text, regextbxUsername) == false)
    {
        tbxUsername.ShowBalloonTip(L"Invalid Username", L"Please provide four or more alphanumeric characters (A-Z, a-z or 0-9)", TTI_ERROR);
        return;
    }
    tr1::wregex regextbxPass(L"[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]+");
    if (tr1::regex_match(tbxPass.Text, regextbxPass) == false)
    {
        tbxPass.ShowBalloonTip(L"Invalid Pass", L"Please provide three or more alphanumeric characters (A-Z, a-z or 0-9)", TTI_ERROR);
        return;
    }
    Sql::StringBuilder sb(L"coordinator", L"coordinator_id", coordinator_id);
    sb.Bind(L"professor_id", ddProfessor);
    sb.Bind(L"program_id", ddProgram);
    sb.Bind(L"username", tbxUsername);
    sb.Bind(L"pass", tbxPass);
    sb.Bind(L"isAdmin", ckIsadmin);
    Sql::SqlConnection conn;
    int rows = 0;
    try
    {
        conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
        //conn.OpenSession(hWnd, CONNECTION_STRING);
        rows = conn.ExecuteNonQuery(sb.GetString());
        if (rows!=1)
        {
            this->MessageBox(Sys::Convert::ToString(rows), L"Error: number of affected rows", MB_OK | MB_ICONERROR);
            return;
        }
    }
    catch (Sql::SqlException e)
    {
        this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
        return;
    }
    this->EndDialog(TRUE);
}
void TeethX::deleteItem()
{
	toolbMain.EnableButton(IDM_DELETE,false);
	Win::HourGlassCursor hgc(true);
	const int selectedIndex= lvMain.GetSelectedIndex();
	if(selectedIndex<0) return; //_____________________________Nothing is selected
	//_________________________________________________________Ask the user
	if(this->MessageBox(L"Are you sure you want to delete the selected item?", L"Delete item",
		MB_YESNO|MB_ICONQUESTION)!=IDYES) return;
	//________________________________________________________Delete;
	Sql::SqlConnection conn;
	wstring cmd;
	const int item_id= lvMain.Items[selectedIndex].Data; //Get the Primary Key; 
	int rows = 0;
	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)
			{Sys::Format(cmd, L"DELETE FROM patient WHERE patient_id= %d", item_id);}
		else if(tabSelection.SelectedData==1)
			{Sys::Format(cmd, L"DELETE FROM transactionz WHERE transactionz_id= %d", item_id);}
		else if(tabSelection.SelectedData==2)
			Sys::Format(cmd, L"DELETE FROM transactionz WHERE transactionz_id= %d", item_id);
		else if(tabSelection.SelectedData==3)
			{Sys::Format(cmd, L"DELETE FROM dental_procedure WHERE dental_procedure_id= %d", item_id);}
		else if(tabSelection.SelectedData==4)
			{Sys::Format(cmd, L"DELETE FROM userz WHERE userz_id= %d", item_id);}
		rows = conn.ExecuteNonQuery(cmd);
		if (rows!=1)
		{
			this->MessageBox(Sys::Convert::ToString(rows), L"ERROR: number of deleted rows", MB_OK | MB_ICONERROR);
		}
	}
	catch (Sql::SqlException ex)
	{
		this->MessageBox(ex.GetDescription(), L"ERROR", MB_OK | MB_ICONERROR);
	}
	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);
	}
}
void CategoryPage::btOk_Click(Web::HttpConnector& h)
{
	Sql::StringBuilder sb(L"category", L"category_id", category_id);
	sb.Bind(L"descr", tbxDescr);

	Sql::SqlConnection conn;
	int rows = 0;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(NULL, CONNECTION_STRING);
		rows = conn.ExecuteNonQuery(sb.GetString());
		if (rows!=1)
		{
			this->MessageBox(Sys::Convert::ToString(rows), L"Error -number of rows", MB_OK | MB_ICONERROR);
		}
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
	}
	h.NavigateTo(L"Index");
}
Пример #16
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 UserDlg::btOK_Click(Win::Event& e)
{
	//_____________________________________________________________ Validate
	tr1::wregex regextbxUsername(L"[A-Za-z0-9]+");
	if (tr1::regex_match(tbxUsername.Text, regextbxUsername) == false)
	{
		tbxUsername.ShowBalloonTip(L"Invalid Username", L"Please provide one or more characters", TTI_ERROR);
		return;
	}
	tr1::wregex regextbxFirst_name(L"[A-Za-z0-9]+");
	if (tr1::regex_match(tbxFirst_name.Text, regextbxFirst_name) == false)
	{
		tbxFirst_name.ShowBalloonTip(L"Invalid First name", L"Please provide one or more characters", TTI_ERROR);
		return;
	}
	tr1::wregex regextbxLast_name(L"[A-Za-z0-9]+");
	if (tr1::regex_match(tbxLast_name.Text, regextbxLast_name) == false)
	{
		tbxLast_name.ShowBalloonTip(L"Invalid Last name", L"Please provide one or more characters", TTI_ERROR);
		return;
	}
	tr1::wregex regextbxPasswordz(L"[A-Za-z0-9]+");
	if (tr1::regex_match(tbxPasswordz.Text, regextbxPasswordz) == false)
	{
		tbxPasswordz.ShowBalloonTip(L"Invalid Passwordz", L"Please provide one or more characters", TTI_ERROR);
		return;
	}
	tr1::wregex regextbxEmail(L".+@.+");
	if (tr1::regex_match(tbxEmail.Text, regextbxEmail) == false)
	{
		tbxEmail.ShowBalloonTip(L"Invalid Email", L"Please provide one or more characters", TTI_ERROR);
		return;
	}
	Sql::StringBuilder sb(L"userz", L"userz_id", userz_id);
	sb.Bind(L"username", tbxUsername);
	sb.Bind(L"first_name", tbxFirst_name);
	sb.Bind(L"last_name", tbxLast_name);
	sb.Bind(L"passwordz", tbxPasswordz);
	sb.Bind(L"email", tbxEmail);
	sb.Bind(L"is_active", ckIs_active);
	sb.Bind(L"has_access_patient_info", ckHas_access_patient_info);
	sb.Bind(L"has_access_users", ckHas_access_users);
	sb.Bind(L"has_access_payments", ckHas_access_payments);
	sb.Bind(L"has_access_patient_chart", ckHas_access_patient_chart);
	sb.Bind(L"has_access_dental_procedure_setup", ckHas_access_dental_procedure_setup);
	Sql::SqlConnection conn;
	int rows = 0;
	try
	{
		//conn.OpenSession(DSN, USERNAME, PASSWORD); //Control Panel>Administrative Tools>Data Sources (ODBC)>Create dsn_myDatabase
		conn.OpenSession(hWnd, CONNECTION_STRING);
		rows = conn.ExecuteNonQuery(sb.GetString());
		if (rows!=1)
		{
			this->MessageBox(Sys::Convert::ToString(rows), L"Error: number of affected rows", MB_OK | MB_ICONERROR);
			return;
		}
	}
	catch (Sql::SqlException e)
	{
		this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
		return;
	}
	this->EndDialog(TRUE);
}
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);
}
Пример #19
0
void AddCourseUD::btAccept_Click(Win::Event& e)
{
	if(isEditing!=1)
	{
		int course_id=ddCourse.GetSelectedData();
		int professor_id=ddProfessor.GetSelectedData();
		int classroom_id=ddClassroom.GetSelectedData();
		int week_id=ddClassdays.GetSelectedIndex()+1;
		int classtime_id=ddClasstime.GetSelectedData();
		if(course_id>1 || professor_id>1 || classroom_id>1 || week_id >1 || classtime_id >1)
		{
			this->MessageBox(L"You haven't selected all the required data", L"Error", MB_OK | MB_ICONERROR);
			return;
		}
		wstring cmd;
		char group='A';
		Sql::SqlConnection conn;
		int no_groups;
		try
		{
			conn.OpenSession(DSN, USERNAME, PASSWORD);
			Sys::Format(cmd,L"SELECT COUNT(*) FROM schedule WHERE course_id=%d AND period_id=%d AND week_day_id BETWEEN 1 AND 2",course_id, current_period);
			no_groups=conn.GetInt(cmd);
			group+=no_groups;

			if(week_id==1)
			{
				Sys::Format(cmd, L"INSERT INTO schedule(period_id,professor_id,course_id,grupo,classroom_id,classtime_id,week_day_id)VALUES(%d,%d,%d,'%c',%d,%d,1)",current_period,professor_id,course_id,group, classroom_id,classtime_id);
				conn.ExecuteNonQuery(cmd);
				Sys::Format(cmd, L"INSERT INTO schedule(period_id,professor_id,course_id,grupo,classroom_id,classtime_id,week_day_id)VALUES(%d,%d,%d,'%c',%d,%d,3)",current_period,professor_id,course_id,group, classroom_id,classtime_id);
				conn.ExecuteNonQuery(cmd);
				Sys::Format(cmd, L"INSERT INTO schedule(period_id,professor_id,course_id,grupo,classroom_id,classtime_id,week_day_id)VALUES(%d,%d,%d,'%c',%d,%d,5)",current_period,professor_id,course_id,group, classroom_id,classtime_id);
				conn.ExecuteNonQuery(cmd);
			}
			else
			{
				Sys::Format(cmd, L"INSERT INTO schedule(period_id,professor_id,course_id,grupo,classroom_id,classtime_id,week_day_id)VALUES(%d,%d,%d,'%c',%d,%d,2)",current_period,professor_id,course_id,group, classroom_id,classtime_id);
				conn.ExecuteNonQuery(cmd);
				Sys::Format(cmd, L"INSERT INTO schedule(period_id,professor_id,course_id,grupo,classroom_id,classtime_id,week_day_id)VALUES(%d,%d,%d,'%c',%d,%d,4)",current_period,professor_id,course_id,group, classroom_id,classtime_id);
				conn.ExecuteNonQuery(cmd);
			}
			conn.CloseSession();
		}
		catch (Sql::SqlException e)
		{
			this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
		}
	}
	else
	{
		classroom_id=ddClassroom.GetSelectedData();
		classtime_id=ddClasstime.GetSelectedData();
		wstring cmd;
		int rows=0;
		Sql::SqlConnection conn;
		try
		{
			conn.OpenSession(DSN, USERNAME, PASSWORD);
			Sys::Format(cmd, L"SELECT COUNT(*) FROM schedule WHERE professor_id=%d AND classtime_id=%d",professor_id,classtime_id);
			rows=conn.GetInt(cmd);
			if(rows>0)
			{
				this->MessageBoxW(L"This Professor is already teaching at this hour", L"Error", MB_OK | MB_ICONERROR);
				return;
			}

			Sys::Format(cmd, L"SELECT COUNT(*) FROM schedule WHERE classroom_id=%d AND classtime_id=%d",classroom_id,classtime_id);
			rows=conn.GetInt(cmd);
			if(rows>0)
			{
				this->MessageBoxW(L"This CLassroom is already occupied", L"Error", MB_OK | MB_ICONERROR);
				return;
			}


			Sys::Format(cmd, L"SELECT isbase FROM professor WHERE professor_id=%d",professor_id);
			rows=conn.GetInt(cmd);
			if(rows==1 && classtime_id>=5)
			{
				this->MessageBoxW(L"This Professor is fulltime", L"Error", MB_OK | MB_ICONERROR);
				return;
			}

			Sys::Format(cmd, L"UPDATE schedule SET classroom_id=%d WHERE course_id=%d AND grupo='%c'",classroom_id,course_id,grupo);
			conn.ExecuteNonQuery(cmd);

			Sys::Format(cmd, L"UPDATE schedule SET classtime_id=%d WHERE course_id=%d AND grupo='%c'",classtime_id,course_id,grupo);
			conn.ExecuteNonQuery(cmd);

			conn.CloseSession();
		}
		catch (Sql::SqlException e)
		{
			this->MessageBox(e.GetDescription(), L"Error", MB_OK | MB_ICONERROR);
		}

	}
	this->EndDialog(TRUE);
}