Exemple #1
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();
	}

	
}
Exemple #2
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);
	}

}
Exemple #4
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 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);
	}
}
Exemple #6
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);
    }
}
Exemple #7
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);
}
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);
}