private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { toolStripStatusLabel1.Text = "Unesite ime i prezime uposlenika"; toolStripStatusLabel1.ForeColor = Color.Red; } else { if (comboBox1.SelectedItem.ToString() == "Doktor") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; Decimal.TryParse(textBox2.Text, out plata); string pass = FormaMain.CreateMD5(textBox4.Text); FormaMain.klinika17736.listaDoktora.Add(new Doktor(textBox1.Text, d, plata, textBox3.Text, pass)); } else if (comboBox1.SelectedItem.ToString() == "Medicinski tehnicar") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); FormaMain.klinika17736.listaOsoblja.Add(new Zaposleni(textBox1.Text, d, plata, Posao.MedTehnicar, textBox3.Text, pass)); } else if (comboBox1.SelectedItem.ToString() == "Cistaci") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); FormaMain.klinika17736.listaOsoblja.Add(new Zaposleni(textBox1.Text, d, plata, Posao.Cistaci, textBox3.Text, pass)); } else if (comboBox1.SelectedItem.ToString() == "Tehnicko osoblje") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); FormaMain.klinika17736.listaOsoblja.Add(new Zaposleni(textBox1.Text, d, plata, Posao.TehAdmin, textBox3.Text, pass)); } else if (comboBox1.SelectedItem.ToString() == "Uprava") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); FormaMain.klinika17736.listaOsoblja.Add(new Zaposleni(textBox1.Text, d, plata, Posao.Uprava, textBox3.Text, pass)); } else { toolStripStatusLabel1.Text = "Odaberite tip uposlenika!"; toolStripStatusLabel1.ForeColor = Color.Red; return; } comboBox1.Text = null; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; toolStripStatusLabel1.Text = ""; } }
private int provjeriZaZaposlenika()// 0-greska, 1-doktor, 2-zaposleni { if (textBox1.Text == "") { toolStripStatusLabel1.Text = "Unesite ime i prezime uposlenika"; toolStripStatusLabel1.ForeColor = Color.Red; return(0); } else { if (comboBox1.SelectedItem.ToString() == "Doktor") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; Decimal.TryParse(textBox2.Text, out plata); string pass = FormaMain.CreateMD5(textBox4.Text); doc = new Doktor(textBox1.Text, d, plata, textBox3.Text, pass); return(1); } else if (comboBox1.SelectedItem.ToString() == "Medicinski tehnicar") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); zap = new Zaposleni(textBox1.Text, d, plata, Posao.MedTehnicar, textBox3.Text, pass); } else if (comboBox1.SelectedItem.ToString() == "Cistaci") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); zap = new Zaposleni(textBox1.Text, d, plata, Posao.Cistaci, textBox3.Text, pass); } else if (comboBox1.SelectedItem.ToString() == "Tehnicko osoblje") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); zap = new Zaposleni(textBox1.Text, d, plata, Posao.TehAdmin, textBox3.Text, pass); } else if (comboBox1.SelectedItem.ToString() == "Uprava") { DateTime d = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day); Decimal plata; string pass = FormaMain.CreateMD5(textBox4.Text); Decimal.TryParse(textBox2.Text, out plata); zap = new Zaposleni(textBox1.Text, d, plata, Posao.Uprava, textBox3.Text, pass); } else { toolStripStatusLabel1.Text = "Odaberite tip uposlenika!"; toolStripStatusLabel1.ForeColor = Color.Red; return(0); } comboBox1.Text = null; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; toolStripStatusLabel1.Text = ""; return(2); } }