private void btnAddTractor_Click(object sender, RoutedEventArgs e)
 {
     TRACTOR_PURCHASE tractor = new TRACTOR_PURCHASE();
     tractor.TRACTOR_MODEL = data.GetById<TRACTOR_MODEL>(s => s.TRACTOR_MODEL_ID == Convert.ToInt32(cmbTractorModel.SelectedValue));
     tractor.TRACTOR_SPECIFICATION = txtTractorSpecification.Text;
     tractor.TRACTOR_ENGINE_NO = txtEngineNo.Text;
     tractor.TRACTOR_CHASSIS_NO = txtChassisNo.Text;
     tractor.TRACTOR_PURCHASE_RATE = Convert.ToDecimal(txtUnitCost.Text);
     TractorInvoice.TRACTOR_PURCHASEs.Add(tractor);
     gridTractors.ItemsSource = TractorInvoice.TRACTOR_PURCHASEs.ToList();
     Common.ClearAllControls<TextBox>(gridTractorPurchase, 2);
     Common.ClearAllControls<DatePicker>(gridTractorPurchase, 1);
     Common.ClearAllControls<ComboBox>(gridTractorPurchase, 1);
     _total += tractor.TRACTOR_PURCHASE_RATE;
     ShowTotal();
     btnSaveTractor.IsEnabled = true;
 }
Пример #2
0
        private void cmbEngineNos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            tractorPurchase = lstTractorPurchases.Where(s => s.TRACTOR_ID == Convert.ToInt32(cmbEngineNos.SelectedValue)).Select(s => s).FirstOrDefault();

            if (tractorPurchase != null)
            {
                txtInvoiceNo.Text = tractorPurchase.INVOICE.INVOICE_NO;
                dateOfInvoice.SelectedDate = tractorPurchase.INVOICE.INVOICE_DATE;
                txtTractorModel.Text = tractorPurchase.TRACTOR_MODEL.TRACTOR_MODEL_NAME;
                txtTractorSpecification.Text = tractorPurchase.TRACTOR_SPECIFICATION;
                txtChassisNo.Text = tractorPurchase.TRACTOR_CHASSIS_NO;
                txtFIPNo.Text = tractorPurchase.TRACTOR_FIP_NO;
                txtAlternateMaker.Text = tractorPurchase.TRACTOR_ALTERNATE_MAKER;
                txtStarterMotorMake.Text = tractorPurchase.TRACTOR_SELFSTARTMAKER;
                txtPDIHours.Text = tractorPurchase.TRACTOR_PDI_HOURS.HasValue ? tractorPurchase.TRACTOR_PDI_HOURS.ToString() : string.Empty;
                TRACTOR_PART[] partsArray = null;
                if ((partsArray = tractorPurchase.TRACTOR_PARTs.ToArray()).Length > 0)
                {
                    int i = 0;
                    int j = 0;
                    gridTyreDetails.Children.OfType<TextBox>().All(s =>
                    {
                        switch (i++)
                        {
                            case 0: s.Text = partsArray[j].PART_MAKER;
                                break;
                            case 1: s.Text = partsArray[j].PART_SIZE;
                                break;
                            case 2: s.Text = partsArray[j].PART_SERIAL_NO;
                                break;
                            case 3: s.Text = partsArray[j++].PART_REMARKS;
                                i = 0;
                                break;
                        }
                        return true;
                    });
                }
                else
                {
                    gridTyreDetails.Children.OfType<TextBox>().All(s => { s.Text = string.Empty; return true; });
                }
                btnSaveTractorPDIReport.IsEnabled = true;
            }
        }
 partial void DeleteTRACTOR_PURCHASE(TRACTOR_PURCHASE instance);
 partial void UpdateTRACTOR_PURCHASE(TRACTOR_PURCHASE instance);
 partial void InsertTRACTOR_PURCHASE(TRACTOR_PURCHASE instance);
		private void detach_TRACTOR_PURCHASEs(TRACTOR_PURCHASE entity)
		{
			this.SendPropertyChanging();
			entity.TRACTOR_MODEL = null;
		}
		private void attach_TRACTOR_PURCHASEs(TRACTOR_PURCHASE entity)
		{
			this.SendPropertyChanging();
			entity.INVOICE = this;
		}