private void button2_Click(object sender, EventArgs e) { NurseForm form = new NurseForm(); form.ShowDialog(); dataGridView2.DataSource = ConnectDb.GetNurses(); }
private void button1_Click(object sender, EventArgs e) { if (v) { user = new Nurse(); user.Id = id; user.Name = txtName.Text.ToString(); user.Surname = txtSurname.Text.ToString(); user.PeselNo = txtPeselNo.Text.ToString(); user.Username = txtUsername.Text.ToString(); user.Password = txtPassword.Text.ToString(); user.Type = 1; ConnectDb.Updateusers(user); } else { user = new Nurse(); user.Id = id; user.Name = txtName.Text.ToString(); user.Surname = txtSurname.Text.ToString(); user.PeselNo = txtPeselNo.Text.ToString(); user.Username = txtUsername.Text.ToString(); user.Password = txtPassword.Text.ToString(); user.Type = 3; ConnectDb.Updateusers(user); } }
private void button1_Click(object sender, EventArgs e) { DoctorForm form = new DoctorForm(); form.ShowDialog(); dataGridView1.DataSource = ConnectDb.GetDoctors(); }
public Dashboard(int key) { InitializeComponent(); this.key = key; dtDoctors = new DataTable(); dtNurses = new DataTable(); dtDoctors = ConnectDb.GetDoctors(); dtNurses = ConnectDb.GetNurses(); dataGridView1.DataSource = dtDoctors; dataGridView2.DataSource = dtNurses; dataGridView2.Columns["Type"].Visible = false; dataGridView2.Columns["Password"].Visible = false; dataGridView1.Columns["Type"].Visible = false; dataGridView1.Columns["Password"].Visible = false; dataGridView2.Columns["PwzNo"].Visible = false; btnNewDoctor.Visible = false; btnNewNurse.Visible = false; btnNewAdmin.Visible = false; if (key == 1) { dataGridView1.ContextMenuStrip = contextMenuStrip1; dataGridView2.ContextMenuStrip = contextMenuStrip2; btnNewDoctor.Visible = true; btnNewNurse.Visible = true; btnNewAdmin.Visible = true; } }
private void Form1_Load(object sender, EventArgs e) { Role role = new Role(); role.InitializeTypes(); ConnectDb.fillUserTypes(comboBox1); ConnectDb.InsertUser(); }
private void Dashboard_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.S) { ConnectDb.UpdateDoctors(doctor); dataGridView1.DataSource = ConnectDb.GetDoctors(); } }
// For new roles public void InitializeTypes() { List <Role> types = new List <Role>(); types.Add(new Role("Admin")); types.Add(new Role("Doctor")); types.Add(new Role("Nurse")); ConnectDb.InsertUserType(types); }
private void button1_Click(object sender, EventArgs e) { doctor = new Doctor(); doctor.Id = Id; doctor.Name = txtName.Text.ToString(); doctor.Surname = txtSurname.Text.ToString(); doctor.PeselNo = txtPeselNo.Text.ToString(); doctor.PwzNo = txtPwzNo.Text.ToString(); doctor.Speciality = txtSpeciality.Text.ToString(); doctor.Username = txtUsername.Text.ToString(); doctor.Password = txtPassword.Text.ToString(); doctor.Type = 2; ConnectDb.UpdateDoctors(doctor); }
private void button1_Click_2(object sender, EventArgs e) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("doctors.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, ConnectDb.GetDoctors()); stream.Close(); formatter = new BinaryFormatter(); stream = new FileStream("nurses.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, dtNurses); stream.Close(); formatter = new BinaryFormatter(); stream = new FileStream("scedule.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, ConnectDb.getScedule()); stream.Close(); MessageBox.Show("Serialization successfull"); }
private void button1_Click(object sender, EventArgs e) { DutyScedule scedule; dtDoctors = new DataTable(); dtNurses = new DataTable(); dtDoctors = ConnectDb.GetDoctorsScedule(); dtNurses = ConnectDb.GetNursesScedule(); if (row.Cells["Type"].Value.ToString().Equals("2")) { if (dtDoctors.Rows.Count > 0) { var selectedRows = dtDoctors.AsEnumerable() .Where(row1 => (row1.Field <DateTime>("DutyDate") == DateTime.Parse(dateTimePicker1.Value.ToString("yyy-MM-dd"))) && (int.Parse(row.Cells["Id"].Value.ToString()) == row1.Field <int>("UserId"))).FirstOrDefault(); if (selectedRows != null) { MessageBox.Show("Scedule for specified date exists"); return; } var selectedRowsNex = dtDoctors.AsEnumerable() .Where(row1 => (row1.Field <DateTime>("DutyDate") == DateTime.Parse(dateTimePicker1.Value.AddDays(1).ToString("yyy-MM-dd"))) && (int.Parse(row.Cells["Id"].Value.ToString()) == row1.Field <int>("UserId"))).FirstOrDefault(); if (selectedRowsNex != null) { MessageBox.Show("Scedule for next day exists"); return; } var selectedRowsPrev = dtDoctors.AsEnumerable() .Where(row1 => (row1.Field <DateTime>("DutyDate") == DateTime.Parse(dateTimePicker1.Value.AddDays(-1).ToString("yyy-MM-dd"))) && (int.Parse(row.Cells["Id"].Value.ToString()) == row1.Field <int>("UserId"))).FirstOrDefault(); if (selectedRowsPrev != null) { MessageBox.Show("Scedule for previous date exists"); return; } DataTable dtFiltered = new DataTable(); try { dtFiltered = (from a in dtDoctors.AsEnumerable() where a.Field <DateTime>("DutyDate").Month == dateTimePicker1.Value.Month && a.Field <int>("UserId") == int.Parse(row.Cells["Id"].Value.ToString()) select a).CopyToDataTable(); } catch { } if (dtFiltered.Rows.Count >= 10) { MessageBox.Show("Maximum 10 24-hour on duty scedule are allowed"); return; } var selectedRowsDup = dtDoctors.AsEnumerable() .Where(row1 => (row1.Field <string>("Speciality") == row.Cells["Speciality"].Value.ToString()) && (DateTime.Parse(dateTimePicker1.Value.ToString("yyyy-MM-dd")) == row1.Field <DateTime>("DutyDate"))).FirstOrDefault(); if (selectedRowsDup != null) { MessageBox.Show("Only one doctor from speciality is allowed to be on 24 hour duty"); return; } scedule = new DutyScedule(); scedule.DutyDate = dateTimePicker1.Value; scedule.UserId = int.Parse(row.Cells["Id"].Value.ToString()); ConnectDb.insertScedule(scedule); MessageBox.Show("Scedule added successfully"); } else { scedule = new DutyScedule(); scedule.DutyDate = dateTimePicker1.Value; scedule.UserId = int.Parse(row.Cells["Id"].Value.ToString()); ConnectDb.insertScedule(scedule); MessageBox.Show("Scedule added successfully"); } } else if (row.Cells["Type"].Value.ToString().Equals("3")) { var selectedRows = dtDoctors.AsEnumerable() .Where(row1 => (row1.Field <DateTime>("DutyDate") == DateTime.Parse(dateTimePicker1.Value.ToString("yyyy-MM-dd"))) && (row1.Field <int>("UserId") == int.Parse(row.Cells["Id"].Value.ToString()))); if (selectedRows != null) { MessageBox.Show("Scedule for specified date exists"); return; } else { scedule = new DutyScedule(); scedule.DutyDate = dateTimePicker1.Value; scedule.UserId = int.Parse(row.Cells["Id"].Value.ToString()); ConnectDb.insertScedule(scedule); MessageBox.Show("Scedule added successfully"); } } }
public bool verifyLogin(Login login) { return(ConnectDb.Authentication(login)); }
private void SeeScedule_Load(object sender, EventArgs e) { dataGridView1.DataSource = ConnectDb.getScedule(); }