コード例 #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);
        }
コード例 #2
0
        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);
 }