Exemple #1
0
        private void Employees_Table_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            int selectedRow = e.RowIndex;

            if (e.RowIndex != -1)
            {
                employee_menu.Enabled = true;
                this.employees_table.ClearSelection();
                this.employees_table.Rows[selectedRow].Selected = true;
                selected_employee = db.Empoyee.Find(employees_table.Rows[selectedRow].Cells[0].Value);
            }
            else
            {
                employee_menu.Enabled = false;
            }
        }
Exemple #2
0
        private void Employee_Create(object sender, EventArgs e)
        {
            Empoyee new_employee = new Empoyee()
            {
                FirstName  = textBox1.Text,
                SurName    = textBox2.Text,
                Patronymic = textBox3.Text,
                Position   = textBox4.Text
            };

            new_employee.DateOfBirth = DateTime.Parse(maskedTextBox1.Text);
            new_employee.DocSeries   = maskedTextBox2.Text.Substring(0, 4);
            new_employee.DocNumber   = maskedTextBox2.Text.Substring(5, 6);
            new_employee.Department  = db.Department.Find(comboBox1.SelectedValue);
            db.Empoyee.Add(new_employee);
            db.SaveChanges();
            this.Close();
        }
Exemple #3
0
 public Employee_Form(TestDBContext db, Empoyee selected_employee)
 {
     InitializeComponent();
     this.db = db;
     this.selected_employee  = selected_employee;
     comboBox1.DataSource    = db.Department.ToList();
     comboBox1.DisplayMember = "Name";
     comboBox1.ValueMember   = "Id";
     comboBox1.SelectedItem  = selected_employee.Department;
     groupBox1.Text          = "Редактирование сотрудника";
     textBox1.Text           = selected_employee.FirstName;
     textBox2.Text           = selected_employee.SurName;
     textBox3.Text           = selected_employee.Patronymic;
     maskedTextBox1.Text     = selected_employee.DateOfBirth.ToShortDateString();
     maskedTextBox2.Text     = selected_employee.DocSeries + selected_employee.DocNumber;
     textBox4.Text           = selected_employee.Position;
     this.button1.Click     += new EventHandler(Employee_Save);
     this.button3.Click     += (sender, e) => { this.Close(); };
 }