Exemple #1
0
        public override void PopulateData(object data)
        {
            currentData   = (CustomerModel)data;
            addedJourneys = new List <JourneyModel>();
            if (currentData.Colour != 0)
            {
                this.txtColour.Color = Color.FromArgb(currentData.Colour);
            }

            addedJourneys                = currentData.Journeys;
            this.txtCustomerName.Text    = currentData.Name;
            this.txtDeliveryAddress.Text = currentData.DeliveryAddress;
            journeys = journeyService.GetJourneys();
            this.bindingSource1.DataSource = journeys;
            this.bsJourneys.DataSource     = addedJourneys;
            //this.hdnCustomerId.Text = customerModel.Id.ToString();
        }
Exemple #2
0
 public override void GetData()
 {
     Journeys = service.GetJourneys();
     dsCustomer.DataSource = Journeys;
 }
Exemple #3
0
        public override void PopulateData(object data)
        {
            DaybookModel currentData = (DaybookModel)data;

            var customers = _customerService.GetCustomers();
            var drivers   = _driverService.GetDrivers();

            journeys = _journeyService.GetJourneys();
            var trucks   = _driverService.GetTrucks();
            var trailers = _driverService.GetTrailers();


            cboCustomer.Items.Clear();
            cboDriver.Items.Clear();
            cboJourney.Items.Clear();
            cboTrailer.Items.Clear();
            cboTruck.Items.Clear();


            this.txtCustomerRef.Text  = string.Empty;
            this.txtAddress.Text      = string.Empty;
            this.txtbasePrice.Text    = string.Empty;
            this.txtArea.Text         = string.Empty;
            this.txtGeneralNotes.Text = string.Empty;
            this.txtMiscCode.Text     = string.Empty;
            this.txtInvoice.Text      = string.Empty;
            this.txtTime.Text         = string.Empty;
            this.txtJobRef.Text       = string.Empty;
            this.chkDulicate.Checked  = currentData.IsDuplicate;
            this.chkUseReturn.Checked = currentData.UseReturn;

            int index = 1;

            DWTComboBoxItem journeyItem = new DWTComboBoxItem {
                Text = "Select Journey", Value = 0
            };

            cboJourney.Items.Add(journeyItem);

            int selectedJourneyIndex = 0;

            foreach (var journey in journeys)
            {
                journeyItem = new DWTComboBoxItem {
                    Text = journey.Journey, Value = journey.ID
                };
                cboJourney.Items.Add(journeyItem);

                if (journey.Journey == currentData.Journey)
                {
                    selectedJourneyIndex = index;
                }
                index++;
            }

            int             importExport = Convert.ToInt32(currentData.Type) == 1 ? 0 : 1;
            DWTComboBoxItem customerItem = new DWTComboBoxItem {
                Text = "Select Customer", Value = 0
            };

            cboCustomer.Items.Add(customerItem);


            index = 1;
            int selectedCustomerIndex = 0;

            foreach (var customer in customers)
            {
                customerItem = new DWTComboBoxItem {
                    Text = customer.Name, Value = customer.CustID
                };
                cboCustomer.Items.Add(customerItem);
                if (customer.CustID == currentData.CustomerID)
                {
                    selectedCustomerIndex = index;
                }
                index++;
            }

            DWTComboBoxItem driverItem = new DWTComboBoxItem {
                Text = "Select Driver", Value = 0
            };

            cboDriver.Items.Add(driverItem);

            index = 1;
            int selectedDriverIndex = 0;

            foreach (var driver in drivers)
            {
                driverItem = new DWTComboBoxItem {
                    Text = string.Format("{0} {1}", driver.Name, driver.Surname), Value = driver.DriverID
                };
                cboDriver.Items.Add(driverItem);
                if (driver.DriverID == currentData.DriverID)
                {
                    selectedDriverIndex = index;
                }
                index++;
            }

            DWTComboBoxItem truckItem = new DWTComboBoxItem {
                Text = "Select Truck", Value = 0
            };

            cboTruck.Items.Add(truckItem);

            index = 1;
            int selectedTruckIndex = 0;

            foreach (var truck in trucks)
            {
                truckItem = new DWTComboBoxItem {
                    Text = string.Format("{0}-{1}", truck.Name, truck.TruckNumber), Value = truck.Id
                };
                cboTruck.Items.Add(truckItem);

                if (truck.Id == currentData.TruckId)
                {
                    selectedTruckIndex = index;
                }
                index++;
            }

            DWTComboBoxItem trailerItem = new DWTComboBoxItem {
                Text = "Select Trailer", Value = 0
            };

            cboTrailer.Items.Add(trailerItem);

            index = 1;
            int selectedTrailerIndex = 0;

            foreach (var trailer in trailers)
            {
                trailerItem = new DWTComboBoxItem {
                    Text = string.Format("{0}-{1}", trailer.Name, trailer.TrailerName), Value = trailer.Id
                };
                cboTrailer.Items.Add(trailerItem);

                if (trailer.Id == currentData.TrailerId)
                {
                    selectedTrailerIndex = index;
                }
                index++;
            }

            this.txtCustomerRef.Text  = currentData.CustRef;
            this.txtAddress.Text      = currentData.Address;
            this.txtbasePrice.Text    = currentData.BasePrice.ToString();
            this.txtArea.Text         = currentData.Area;
            this.txtGeneralNotes.Text = currentData.Notes;
            this.txtMiscCode.Text     = currentData.MiscCode;
            this.txtInvoice.Text      = currentData.InvoiceNo;

            TimeSpan timeSpan = currentData.Time != null?Convert.ToDateTime(currentData.Time).TimeOfDay : DateTime.Now.TimeOfDay;

            this.txtTime.EditValue = Utilities.ConvertTo12HourFormat(timeSpan);


            this.cboCustomer.SelectedIndex = selectedCustomerIndex;
            this.cboDriver.SelectedIndex   = selectedDriverIndex;
            this.cboTruck.SelectedIndex    = selectedTruckIndex;
            this.cboTrailer.SelectedIndex  = selectedTrailerIndex;

            if (cboJourney.Items.Count > 0 && selectedJourneyIndex < cboJourney.Items.Count)
            {
                this.cboJourney.SelectedIndex = selectedJourneyIndex;
            }

            if (cboImportExport.Items.Count > 0)
            {
                this.cboImportExport.SelectedIndex = importExport;
            }

            this.txtJobRef.Text    = currentData.JobRef;
            this.hdnJobId.Text     = currentData.JobID.ToString();
            this.dateFrom.DateTime = Convert.ToDateTime(currentData.dtFrom);
            this.dateTo.DateTime   = Convert.ToDateTime(currentData.dtTo);
            this.txtPin.Text       = currentData.PinNumber;



            var addresses = _dayBookService.GetAdresses();

            AutoCompleteStringCollection addressSuggestions = new AutoCompleteStringCollection();

            addresses.ForEach(add => addressSuggestions.Add(add));
            txtAddress.AutoCompleteCustomSource = addressSuggestions;
            txtAddress.AutoCompleteMode         = AutoCompleteMode.Suggest;
            txtAddress.AutoCompleteSource       = AutoCompleteSource.CustomSource;
        }