コード例 #1
0
        private void changeStatus(int parcelId)
        {
            var             par     = companyEntities.Parcel.Include(p => p.ParcelMoving).FirstOrDefault(p => p.id == parcelId);
            HistoryOfParcel history = new HistoryOfParcel()
            {
                idParcel    = par.id,
                idStatus    = par.idStatus,
                idWarehouse = Properties.Settings.Default.Warehouse,
                date        = DateTime.Now
            };

            companyEntities.HistoryOfParcel.Add(history);
            if (par.ParcelMoving.Count == 1 && documentType == EnumTypeOfDocument.PZ)
            {
                par.idStatus = (int)EnumParcelStatus.acceptedSender;
            }
            else if (par.ParcelMoving.Count == 1 && documentType == EnumTypeOfDocument.WZ)
            {
                par.idStatus = (int)EnumParcelStatus.beetwen;
            }
            else if (par.ParcelMoving.Count == 2 && documentType == EnumTypeOfDocument.PZ)
            {
                par.idStatus = (int)EnumParcelStatus.acceptedReciver;
            }
            else if (par.ParcelMoving.Count == 2 && documentType == EnumTypeOfDocument.WZ)
            {
                par.idStatus = (int)EnumParcelStatus.handed;
            }
        }
コード例 #2
0
        private void BtnChangeStatus_Click(object sender, RoutedEventArgs e)
        {
            var        parcelDetailsViewModel = (ParcelDetailsViewModel)DataContext;
            InfoWindow info = new InfoWindow();

            Parcel = CompanyEntities.Parcel
                     .Include(p => p.Status)
                     .Include(p => p.Region)
                     .Include(p => p.Region1)
                     .FirstOrDefault(p => p.id == parcelDetailsViewModel.Parcel.id);
            if (Parcel.idStatus >= parcelDetailsViewModel.StatusSelected.id)
            {
                info.ShowInfo("Wybrany status nie może być niższy niż aktualny", "", "Ok");
                info.Close();
                return;
            }
            HistoryOfParcel history = new HistoryOfParcel()
            {
                idParcel = Parcel.id,
                idStatus = Parcel.idStatus,
                date     = DateTime.Now
            };

            if (parcelDetailsViewModel.StatusSelected.id > (int)EnumParcelStatus.beetwen)
            {
                history.idWarehouse = Parcel.Region.idWarehouse;
            }
            else if (Parcel.Region1 != null)
            {
                history.idWarehouse = Parcel.Region1.idWarehouse;
            }
            else
            {
                history.idWarehouse = Properties.Settings.Default.Warehouse;
            }
            CompanyEntities.HistoryOfParcel.Add(history);
            Parcel.idStatus = parcelDetailsViewModel.StatusSelected.id;
            if (Parcel.idStatus == (int)EnumParcelStatus.delivered)
            {
                Parcel.dateOfDelivery = DateTime.Now;
            }
            CompanyEntities.SaveChanges();
            Counter = 0;
            AddDoc(Parcel);
            info.ShowInfo("Status został zmieniony pomyślnie", "", "Ok");
            info.Close();
        }