Student Training Institute: Source Code
Student Training Institute: Source Code
Source Code:-
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Assignment_3
{
/// <summary>
/// </summary>
public partial class MainWindow : Window
{
bool check = false;
TraningInstitute__dbmsEntities db = new TraningInstitute__dbmsEntities();
public MainWindow()
{
InitializeComponent();
var std = from s in db.Students //Assign Students data in database
select new
{
firstName = s.FirstName,
lastName = s.LastNmae,
dateofBirth = s.DateofBirth,
registrationNo = s.RegistrationNo,
photo = s.Photo,
code = s.Phone_Code,
contactNo = s.ContactNo,
address = s.Address,
email = s.Email
};
this.stdgrid.ItemsSource = std.ToList();// attach data to grid from
database
};
this.trainerGrid.ItemsSource = trainer.ToList();
};
this.course_grid.ItemsSource = cource.ToList();
}
}
private void student_entity_Click(object sender, RoutedEventArgs e)
{
selection_Grid.Visibility = Visibility.Hidden;
// btn for show and Hide grids
Student_Grid.Visibility = Visibility.Visible;
};
db.Students.Add(stdobj);
this.fname_txtbox_std.Clear(); // clear fields
this.lname_txtbox_std.Clear();
this.DoB_txtbox.Clear();
this.regNo_txtbox.Clear();
this.code_txtbox_std.Clear();
this.contact_txtbox_std.Clear();
this.address_txtbox_std.Clear();
this.email_txtbox_std.Clear();
check = false;
this.img_dp.Width = 0;
db.SaveChanges();
}
}
private void UpgradeStudent_btn_Click(object sender, RoutedEventArgs e)
// upgrade record of student
{
var result = from std in db.Students
where std.Id == updatedkey
select std;
}
private int updatedkey = 0;
img_select.Width = 200;
}
}
this.stdgrid.ItemsSource = std.ToList();
this.stdgrid.Columns[10].Visibility = Visibility.Hidden;
}
this.trainerGrid.ItemsSource = trainer.ToList();
this.trainerGrid.Columns[11].Visibility = Visibility.Hidden;
db.SaveChanges();
}
this.fname_txtbox_trainer.Clear();
this.lname_txtbox_trainer.Clear();
this.designation_txtbox.Clear();
this.dept_txtbox.Clear();
this.contact_txtbox_trainer.Clear();
this.code_txtbox_trainer.Clear();
this.address_txtbox_trainer.Clear();
this.email_txtbox_trainer.Clear();
this.salaray_txtbox.Clear();
this.img_select1.Width = 0;
this.img_dp1.Width = 0;
}
private void DeleteTrainer_btn_Click(object sender, RoutedEventArgs e)
{
var result = from trainer in db.Trainers
where trainer.Id == updatedkey
select trainer;
db.SaveChanges();
}
}
this.fname_txtbox_trainer.Text = trainer.FirstName;
this.lname_txtbox_trainer.Text = trainer.LastName;
this.designation_txtbox.Text = trainer.Designation;
this.dept_txtbox.Text = trainer.Department;
this.salaray_txtbox.Text = trainer.Salary.ToString();
this.address_txtbox_trainer.Text = trainer.Address;
this.email_txtbox_trainer.Text = trainer.Email;
this.code_txtbox_trainer.Text = trainer.Phone_code;
this.contact_txtbox_trainer.Text = trainer.ContactNo;
this.updatedkey = trainer.Id;
}
img_select1.Width = 200;
}
}
}
if (openFile.ShowDialog() == true)
this.img_dp.Source = new BitmapImage(new Uri(openFile.FileName));
img_dp.Width = 200;
img_select.Width = 0;
check = true;
if (openFile.ShowDialog() == true)
this.img_dp1.Source = new BitmapImage(new Uri(openFile.FileName));
img_dp1.Width = 200;
img_select1.Width = 0;
//check = true;
}
this.course_grid.ItemsSource = course.ToList();
//this.course_grid.Columns[4].Visibility = Visibility.Hidden;
this.course_grid.Columns[5].Visibility = Visibility.Hidden;
this.course_grid.Columns[6].Visibility = Visibility.Hidden;
Code = this.code_txtbox.Text,
Title = this.title_txtbox.Text,
Description = this.description_txtbox.Text
};
db.Courses.Add(Cobj);
this.code_txtbox.Clear();
this.title_txtbox.Clear();
this.description_txtbox.Clear();
db.SaveChanges();
}
private void UpdateCources_btn_Click(object sender, RoutedEventArgs
e)
{
var result = from course in db.Courses
where course.Id == updatedkey
select course;
this.updatedkey = course.Id;
}
}
}
}
this.RegNo_Combo.ItemsSource = regno;
List<string> coursecode = new List<string>();// show courses in listbox
var res = from c in db.Courses
select c;
this.CourseCode_listbox.ItemsSource = coursecode;
};
this.std_cource_Grid.ItemsSource = query.ToList();
this.unassigned_regno_listbox.ItemsSource = regnostd.ToList();
}
}
Student_Course obj = new Student_Course();
obj.CourseID = selected_courseID;
obj.C_StudentID = selected_regnoID;
db.Student_Course.Add(obj);
db.SaveChanges();
}
private void Load_course_std_btn_Click(object sender, RoutedEventArgs
e)
{
var query = from s in db.Students // load btn to see the changes in data
grid
join sc in db.Student_Course on s.Id equals sc.C_StudentID
join c in db.Courses on sc.CourseID equals c.Id
select new
{
StudentID = sc.C_StudentID,
Student_RegNo = s.RegistrationNo,
Student_Name = s.FirstName + " " + s.LastNmae,
sc.CourseID,
Course_Title = c.Title,
Course_Code = c.Code
};
this.std_cource_Grid.ItemsSource = query.ToList();
};
foreach (var item in Studentsnot)
{
if (item.CourseID == null)
{
regnostd.Add(item.RegistrationNo);
}
}
this.unassigned_regno_listbox.ItemsSource = regnostd.ToList();
}
this.Trainer_Combo.ItemsSource = trainers_List;
{
if(item.TrainerID==null)
courses.Add(item.Code);
this.Trainer_Course_listbox.ItemsSource = courses;
};
foreach (var item in Trainers_not_assigned)
{
if (item.Trainer_ID.Equals(null))
{
trainersinfo.Add(item.Trainer_ID.ToString()+"
"+item.Trainer_Name);
}
}
this.unassigned_trainer_listbox.ItemsSource = trainersinfo.ToList();
};
this.TranerCourse_grid.ItemsSource = query.ToList();
}
db.SaveChanges();
}
private void Load_course_trainer_btn_Click(object sender,
RoutedEventArgs e)
{
};
this.TranerCourse_grid.ItemsSource = query.ToList();
{
if (item.TrainerID == null)
courses.Add(item.Code);
this.Trainer_Course_listbox.ItemsSource = courses;
};
foreach (var item in Trainers_not_assigned)
{
if (item.Trainer_ID.Equals(null))
{
trainersinfo.Add(item.Trainer_ID.ToString() + " " +
item.Trainer_Name);
}
}
this.unassigned_trainer_listbox.ItemsSource = trainersinfo.ToList();
}
}
ScreenShots:-
ERD Diagram
Student Record
Trainer Record
Course Record
Assign Courses to Students
Assign Courses to Trainers