private void pbBack_Click(object sender, EventArgs e) { FAdminMenu fam = new FAdminMenu(); fam.Show(); this.Hide(); }
private void pbSave_Click(object sender, EventArgs e) { if (txtSpecialist.Text == "" || txtFare.Text == "") { MessageBox.Show("Please fill in the data"); } else { FileStream fs1 = new FileStream("Data\\specialist.txt", FileMode.Open, FileAccess.Read); StreamReader sr1 = new StreamReader(fs1); string cek; bool test = false; while ((cek = sr1.ReadLine()) != null) { if (cek.Contains(txtSpecialist.Text)) { test = true; MessageBox.Show("Specialist already available"); } } sr1.Close(); fs1.Close(); if (test == false) { //sr1.Close(); //fs1.Close(); if (txtIdSpecialist.Text == "full") { MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning); FAdminMenu fam = new FAdminMenu(); fam.Show(); this.Hide(); } else { DialogResult result = MessageBox.Show("Do you want to save record " + txtIdSpecialist.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { FileStream fs = new FileStream("Data\\specialist.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(txtIdSpecialist.Text + "#" + txtSpecialist.Text + "#" + txtFare.Text + "#"); sw.Flush(); sw.Close(); MessageBox.Show("Data saved"); txtIdSpecialist.Clear(); txtFare.Clear(); txtSpecialist.Clear(); datagridview(); txtIdSpecialist.Text = agspecialist(); txtSpecialist.Focus(); } } } } }
private void pbSave_Click(object sender, EventArgs e) { if (txtDrugName.Text == "" || txtPrice.Text == "") { MessageBox.Show("Please fill in the data"); } else { if (txtIdDrug.Text == "full") { MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning); FAdminMenu fam = new FAdminMenu(); fam.Show(); this.Hide(); } else { DialogResult result = MessageBox.Show("Do you want to save record " + txtIdDrug.Text + " drug name " + txtDrugName.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { FileStream fs = new FileStream("Data\\drug.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string drugtype = cbDrugType.SelectedItem.ToString(); sw.WriteLine(txtIdDrug.Text + "#" + txtDrugName.Text + "#" + drugtype + "#" + txtStock.Text + "#" + txtExpDate.Text + "#" + txtPrice.Text + "#"); sw.Flush(); sw.Close(); MessageBox.Show("Data saved"); cbDrugType.SelectedIndex = -1; txtStock.Clear(); txtExpDate.Clear(); txtPrice.Clear(); txtIdDrug.Clear(); txtDrugName.Clear(); txtDrugName.Focus(); isicombobox(); txtIdDrug.Text = agdrug(); } } } }
private void pbLogin_Click(object sender, EventArgs e) { string username, password, user, pass; username = txtUser.Text; password = txtPass.Text; using (StreamReader sr = new StreamReader(File.Open("Data\\adminlogin.txt", FileMode.Open))) { user = sr.ReadLine(); pass = sr.ReadLine(); sr.Close(); } if (username == user && password == pass) { MessageBox.Show("Welcome, " + username + ". Have a nice day :)", "Login Success", MessageBoxButtons.OK, MessageBoxIcon.Information); FAdminMenu fam = new FAdminMenu(); fam.Show(); this.Hide(); } else { counter += 1; if (counter < 3) { lblError.Visible = true; txtUser.Focus(); txtUser.Clear(); txtPass.Clear(); } else { MessageBox.Show("Unauthorized Access. Aborting..."); this.Close(); } } }
private void pbAdd_Click(object sender, EventArgs e) { if (txtDoctorName.Text == "" || cbSpecialist.SelectedIndex == -1) { MessageBox.Show("Please fill in the data"); } else { if (txtIdDoctor.Text == "full") { MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning); FAdminMenu fam = new FAdminMenu(); fam.Show(); this.Hide(); } else { string gender = ""; if (rbMale.Checked) { gender = rbMale.Text; } else if (rbFemale.Checked) { gender = rbFemale.Text; } if (validategender() == 0) { DialogResult result = MessageBox.Show("Do you want to save record " + txtIdDoctor.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { FileStream fs = new FileStream("Data\\doctor.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string specialist = cbSpecialist.SelectedItem.ToString(); sw.WriteLine(txtIdDoctor.Text + "#" + txtDoctorName.Text + "#" + txtDOB.Text + "#" + gender + "#" + txtPhoneNumber.Text + "#" + txtAddress.Text + "#" + specialist + "#"); sw.Flush(); sw.Close(); MessageBox.Show("Data saved"); txtDoctorName.Clear(); txtDOB.Clear(); rbMale.Checked = false; rbFemale.Checked = false; txtPhoneNumber.Clear(); txtAddress.Clear(); cbSpecialist.SelectedIndex = -1; txtIdDoctor.Clear(); txtDoctorName.Focus(); datagridview(); txtIdDoctor.Text = agdoctor(); } } else { MessageBox.Show("Correct The Error(s)"); } } } }