Esempio n. 1
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            MyDataModel dm       = new MyDataModel();
            Employee    employee = new Employee(txtEmployeeName.Text);

            employee.Id              = Convert.ToInt32(txtEmployeeId.Text);
            employee.Age             = (int)nudEmployeeAge.Value;
            dm.Entry(employee).State = System.Data.Entity.EntityState.Modified;
            dm.SaveChanges();
        }
Esempio n. 2
0
        private void tvEmployees_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            MyDataModel dm = new MyDataModel();

            foreach (Employee employee in dm.Employees)
            {
                if (employee.Name == e.Node.Text)
                {
                    txtEmployeeId.Text   = employee.Id.ToString();
                    txtEmployeeName.Text = employee.Name;
                    nudEmployeeAge.Value = employee.Age;
                }
            }

            tabControl.SelectedTab = tabEditEmployee;
        }