예제 #1
0
        private void ButtonSaveStaff_Click(object sender, EventArgs e)
        {
            string[] requiredValues =
            {
                firstNameStaffTextBox.Text,
                middleNameStaffTextBox.Text,
                lastNameStaffTextBox.Text,
                phoneStaffTextBox.Text,
            };
            bool exitEmptyField = requiredValues.Any(s => String.IsNullOrEmpty(s.Trim()));

            if (exitEmptyField)
            {
                MessageBox.Show("Не выполнено!\nВсе поля со звездочкой обязательны к заполнению!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            dbDataSet.StaffRow worker = (staffBindingSource.Current as DataRowView).Row as dbDataSet.StaffRow;
            staffPositionsBindingSource.Position = staffPositionsBindingSource.Find("Name", staffPositionsComboBox.Text);
            dbDataSet.StaffPositionsRow position = (staffPositionsBindingSource.Current as DataRowView).Row as dbDataSet.StaffPositionsRow;
            worker.Position     = position.Id;
            worker.PositionName = position.Name;

            staffBindingSource.EndEdit();
            tableAdapterManager.UpdateAll(dbDataSet);
            staffLocalTableAdapter.Update(worker);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int          id   = Data.selectedEmployee == null ? 0 : Data.selectedEmployee.Id;
            Form         form = new EmployeeSelectForm(id);
            DialogResult res  = form.ShowDialog();

            if (res == DialogResult.OK)
            {
                dbDataSet.StaffRow data = Data.selectedEmployee;
                fullNameInput.Text = $"{data.LastName} {data.FirstName} {data.MiddleName}";
                labelPosition.Text = data.PositionName;
            }
        }
예제 #3
0
 private void staffDataGridView_SelectionChanged(object sender, EventArgs e)
 {
     if (staffDataGridView.SelectedRows.Count == 0)
     {
         panel12.Hide();
     }
     else
     {
         panel12.Show();
         dbDataSet.StaffRow worker = (staffBindingSource.Current as DataRowView).Row as dbDataSet.StaffRow;
         staffPositionsBindingSource.Position = staffPositionsBindingSource.Find("Name", worker.PositionName);
     }
 }
예제 #4
0
        private void ButtonDeleteWorder_Click(object sender, EventArgs e)
        {
            if (staffBindingSource.Count == 0)
            {
                return;
            }
            DialogResult res = MessageBox.Show("Вы уверены?\nОтменить данное действие будет невозможно!", "Подтвердите удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res != DialogResult.Yes)
            {
                return;
            }
            int pos = staffBindingSource.Position;

            dbDataSet.StaffRow worker = (staffBindingSource.Current as DataRowView).Row as dbDataSet.StaffRow;
            staffLocalTableAdapter.DeleteById(worker.Id);
            staffLocalTableAdapter.Fill(dbDataSet.Staff);
            staffBindingSource.Position = pos;
        }
예제 #5
0
 private void buttonStaffReset_Click(object sender, EventArgs e)
 {
     staffBindingSource.CancelEdit();
     dbDataSet.StaffRow worker = (staffBindingSource.Current as DataRowView).Row as dbDataSet.StaffRow;
     staffPositionsBindingSource.Position = staffPositionsBindingSource.Find("Name", worker.PositionName);
 }