Exemplo n.º 1
0
        private void add_btn_Click(object sender, RoutedEventArgs e)
        {
            AddStaffWindow addStaffWindow = new AddStaffWindow();

            if (addStaffWindow.ShowDialog() == true)
            {
                if (addStaffWindow.titleBox.Text == "" || addStaffWindow.IdBox.Text == "" || addStaffWindow.depBox.Text == "" || addStaffWindow.quanBox.SelectedItem == null ||
                    addStaffWindow.nowBox.SelectedItem == null || addStaffWindow.tariffBox.Text == "")

                {
                    MessageBox.Show("Set all new staff's data...");
                }

                else
                {
                    MyStaffTable sSt = new MyStaffTable
                    {
                        IdPosFor = addStaffWindow.IdBox.Text,
                        DepFor   = addStaffWindow.depBox.SelectedItem.ToString(),
                        Quantity = (int)addStaffWindow.quanBox.SelectedItem,
                        Now      = (int)addStaffWindow.nowBox.SelectedItem,
                    };
                    client?.AddStaff(sSt);
                    MyPosition sPs = new MyPosition

                    {
                        PosId     = addStaffWindow.IdBox.Text,
                        PosTitle  = addStaffWindow.titleBox.Text,
                        PosTariff = Convert.ToDouble(addStaffWindow.tariffBox.Text),
                    };
                    client?.AddPosition(sPs);
                    RefreshTwo();
                }
            }
        }
Exemplo n.º 2
0
        private void del_btn_Click(object sender, RoutedEventArgs e)
        {
            MyStaffTable selectedStaffRow = dataGrid1.SelectedItem as MyStaffTable;

            if (dataGrid1.SelectedItem != null)
            {
                // Получение id редактируемого объекта
                string selectedId = selectedStaffRow.IdPosFor;
                var    num_emp    = client?.GetEmployeesByPosId(selectedId);

                if (num_emp == 0)
                {
                    client?.DeleteStaff(selectedId);
                    RefreshTwo();
                }
                else
                {
                    MessageBox.Show("You can't delete this staff (it still has employees)...");
                }
            }
            else
            {
                MessageBox.Show("You are didn't select staff...");
            }
        }
Exemplo n.º 3
0
        private void edit_btn_Click(object sender, RoutedEventArgs e)
        {
            EditStaffWindow editStaffWindow = new EditStaffWindow();
            MyStaffTable    selectedStRow   = dataGrid1.SelectedItem as MyStaffTable;

            if (dataGrid1.SelectedItem != null)
            {
                // Получение id редактируемого объекта
                string selectedId = selectedStRow.IdPosFor;

                editStaffWindow.IdBox.Text           = selectedStRow.IdPosFor.ToString();
                editStaffWindow.quanBox.SelectedItem = selectedStRow.Quantity;
                editStaffWindow.nowBox.SelectedItem  = selectedStRow.Now;

                if (editStaffWindow.ShowDialog() == true)
                {
                    if (editStaffWindow.quanBox.SelectedItem == null || editStaffWindow.nowBox.SelectedItem == null)
                    {
                        MessageBox.Show("Set all staff's data...");
                    }

                    else
                    {
                        selectedStRow.IdPosFor = editStaffWindow.IdBox.Text;
                        selectedStRow.Quantity = (int)editStaffWindow.quanBox.SelectedItem;
                        selectedStRow.Now      = (int)editStaffWindow.nowBox.SelectedItem;

                        client?.EditStaff(selectedStRow);
                        RefreshTwo();
                    }
                }
            }
            else
            {
                MessageBox.Show("You are didn't select position...");
            }
        }