Esempio n. 1
0
 private void button4_Click(object sender, EventArgs e)
 {
     // ustaw employment jako nowy lub aktywny istniejący
     if (listView1.SelectedItems.Count > 0)
     {
         var selectedEmployee = ((List <Model.Models.Employee>)_employeesDTO.Employees)[listView1.Items.IndexOf(listView1.SelectedItems[0])];
         if (selectedEmployee.ActiveEmployments != null && selectedEmployee.ActiveEmployments.Count > 0)
         {
             _employmentForm.Employment = _employmentController.GetEmploymentById(selectedEmployee.ActiveEmployments[0].Id);
         }
         else
         {
             _employmentForm.Employment = new Model.Models.Employment();
         }
         _employmentForm.Employee = selectedEmployee;// _employeeController.GetEmployeeById(selectedEmployee.Id);
         _employmentForm.ShowDialog();
     }
 }
Esempio n. 2
0
        private bool SendData(out Parcel addedParcel)
        {
            int?senderApartment, recieverApartment;
            int senderAp, recieverAp;

            if (int.TryParse(senderApartmentNumberTextBox.Text, out senderAp))
            {
                senderApartment = senderAp;
            }
            else
            {
                senderApartment = null;
            }

            if (int.TryParse(recieverApartmentNumberTextBox.Text, out recieverAp))
            {
                recieverApartment = senderAp;
            }
            else
            {
                recieverApartment = null;
            }

            int?storePlace = _employmentController.GetEmploymentById(_employeeController.GetLoggedEmployee().Id).StorePlaceId;

            Parcel parcelToAdd = new Parcel
            {
                SenderData = new PersonalData
                {
                    FirstName       = senderFirstNameTextBox.Text,
                    LastName        = senderLastNameTextBox.Text,
                    PhoneNumber     = senderPhoneNumberTextBox.Text,
                    PersonalAddress = new Address
                    {
                        City            = senderCityTextBox.Text,
                        PostCode        = senderPostalCodeTextBox.Text,
                        Street          = senderStreetTextBox.Text,
                        HomeNumber      = senderHouseNumberTextBox.Text,
                        ApartmentNumber = senderApartment
                    }
                },
                ReceiverData = new PersonalData
                {
                    FirstName       = recieverFirstNameTextBox.Text,
                    LastName        = recieverLastNameTextBox.Text,
                    PhoneNumber     = recieverPhoneNumberTextBox.Text,
                    PersonalAddress = new Address
                    {
                        City            = recieverCityTextBox.Text,
                        PostCode        = recieverPostalCodeTextBox.Text,
                        Street          = recieverStreetTextBox.Text,
                        HomeNumber      = recieverHouseNumberTextBox.Text,
                        ApartmentNumber = recieverApartment
                    }
                },
                ParcelHeight = float.Parse(parcelDimensionsXTextBox.Text),
                ParcelWidth  = float.Parse(parcelDimensionsYTextBox.Text),
                ParcelLength = float.Parse(parcelDimensionsZTextBox.Text),
                ParcelType   = parcelType,
                ParcelWeight = float.Parse(parcelWeightTextBox.Text),
                Priority     = parcelPriorityComboBox.SelectedIndex,
                StorePlaceId = storePlace,
            };

            addedParcel = parcelToAdd;
            return(_parcelController.PostParcel(parcelToAdd));
        }