コード例 #1
0
        private void buttonAddPost_Click(object sender, EventArgs e)
        {
            positionEmployee = new PositionEmployee();
            positionEmployee.DateOfAdopting = dateTimePickerAccept.Value;
            employeeTable = new EmployeeTable();
            var koll = from k in dataEntities.EmployeeTable select new { Name = k.Name, Surname = k.Surname, ID = k.id };

            foreach (var item in koll)
            {
                if (item.Name.ToString() == textBoxName.Text && item.Surname.ToString() == textBoxSurname.Text)
                {
                    idEmp = item.ID;
                }
            }
            positionEmployee.IDEmployee = idEmp;
            var kill = from l in dataEntities.Position select new { Title = l.Title, ID = l.id };

            foreach (var item in kill)
            {
                if (item.Title == comboBoxPost.SelectedItem.ToString())
                {
                    idEmp = item.ID;
                }
            }
            positionEmployee.IDPosition = idEmp;
            dataEntities.PositionEmployee.Add(positionEmployee);
            dataEntities.SaveChanges();
            this.Update();
        }
コード例 #2
0
        private void buttonSaveAnketa_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeeTable emp = null;
                if (emp == dataEntities.EmployeeTable.Find(id))
                {
                    emp.Name        = textBoxName.Text;
                    emp.Surname     = textBoxSurname.Text;
                    emp.Patronymic  = textBoxPatronymic.Text;
                    emp.DateOfBirth = dateTimePickerBirthday.Value;
                    emp.Address     = textBoxAdress.Text;
                    emp.Email       = textBoxEmail.Text;
                    emp.Phone       = textBoxPhone.Text;
                    emp.IDStatus    = 1; //1 if 1 = kandidat
                    emp.Photo       = bytes;
                    dataEntities.SaveChanges();
                    Updt(id);
                }
                else
                {
                    emp             = new EmployeeTable();
                    emp.Name        = textBoxName.Text;
                    emp.Surname     = textBoxSurname.Text;
                    emp.Patronymic  = textBoxPatronymic.Text;
                    emp.DateOfBirth = dateTimePickerBirthday.Value;
                    emp.Address     = textBoxAdress.Text;
                    emp.Phone       = textBoxPhone.Text;
                    emp.Email       = textBoxEmail.Text;
                    var temp = from k in dataEntities.Status
                               join s in dataEntities.EmployeeTable on k.id equals s.IDStatus
                               where s.Name.ToLower() == textBoxName.Text.ToLower() && s.Surname.ToLower() == textBoxName.Text.ToLower()
                               select k;
                    foreach (var item in temp)
                    {
                        if (item.Title.ToLower() == label9.Text.ToLower())
                        {
                            emp.IDStatus = item.id;
                            break;
                        }
                    }
                    emp.Photo = bytes;

                    dataEntities.EmployeeTable.Add(emp);
                    dataEntities.SaveChanges();
                    Updt(id);
                }

                MessageBox.Show("SAVE OK!");
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
コード例 #3
0
        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int  index     = dataGridViewWorkers.SelectedRows[0].Index;
            int  id        = 0;
            bool converted = Int32.TryParse(dataGridViewWorkers[0, index].Value.ToString(), out id);

            if (converted == false)
            {
                return;
            }
            EmployeeTable emp = dataEntities.EmployeeTable.Find(id);

            dataEntities.EmployeeTable.Remove(emp);
            dataEntities.SaveChanges();
            dataGridViewWorkers.DataSource = dataEntities.EmployeeTable.Local.ToList();
            MessageBox.Show("Object deleted");
        }