예제 #1
0
파일: FormMain.cs 프로젝트: fuzzy69/Praksa5
        private void btnEditEmployee_Click(object sender, EventArgs e)
        {
            List <MESTO>    cities       = db.MESTO.ToList();
            EmployeeAndCity employee     = GetSelectedEmployee();
            var             formEmployee = new frmEmployee();

            formEmployee.Text     = "Edit Employee";
            formEmployee.db       = db;
            formEmployee.cities   = cities;
            formEmployee.employee = employee;
            formEmployee.ShowDialog(this);
        }
예제 #2
0
파일: FormMain.cs 프로젝트: fuzzy69/Praksa5
        private EmployeeAndCity GetSelectedEmployee()
        {
            var             index = dgvEmployees.SelectedRows[0].Index;
            Int64           maticniBrojZaposlenog = Int64.Parse((string)dgvEmployees.Rows[index].Cells["Maticni_Broj_Zaposlenog"].Value);
            EmployeeAndCity employee = (
                from z in db.ZAPOSLENI
                join m in db.MESTO on z.Sifra_Mesto equals m.Sifra_Mesto
                where z.Maticni_Broj_Zaposlenog == maticniBrojZaposlenog
                select new EmployeeAndCity
            {
                Name = z.Ime_Zaposlenog,
                Surname = z.Prezime_Zaposlenog,
                JMBG = z.Maticni_Broj_Zaposlenog,
                ParentName = z.Ime_Jednog_Roditelja,
                Address = z.Adresa,
                City = m.Naziv_Mesto,
                CityZip = m.Sifra_Mesto,
                Email = z.Email
            }).First();

            return(employee);
        }
예제 #3
0
파일: FormMain.cs 프로젝트: fuzzy69/Praksa5
        private void btnDeleteEmployee_Click(object sender, EventArgs e)
        {
            EmployeeAndCity employee = GetSelectedEmployee();

            if (employee != null)
            {
                string       text   = String.Format("Are you sure to delete employee {0} {1}?", employee.Name, employee.Surname);
                DialogResult result = MessageBox.Show(text, "Confirm Employee Removal!", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    db.ZAPOSLENI.Remove(db.ZAPOSLENI.Single(x => x.Maticni_Broj_Zaposlenog == employee.JMBG));
                    int affectedRows = db.SaveChanges();
                    if (affectedRows > 0)
                    {
                        dgvPregledPodatakaRefresh();
                        MessageBox.Show(String.Format("Successfully deleted {0} employee(s)!", affectedRows), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select an employee!");
            }
        }