示例#1
0
        private void btnSaveTractorPDIReport_Click(object sender, RoutedEventArgs e)
        {
            tractorPurchase.TRACTOR_FIP_NO = txtFIPNo.Text;
            tractorPurchase.TRACTOR_ALTERNATE_MAKER = txtAlternateMaker.Text;
            tractorPurchase.TRACTOR_SELFSTARTMAKER = txtStarterMotorMake.Text;
            tractorPurchase.TRACTOR_PDI_HOURS = Convert.ToDecimal(txtPDIHours.Text);

            TRACTOR_PART tractorPart = null;
            int i = 0;

            gridTyreDetails.Children.OfType<TextBox>().All(s =>
            {
                switch (i++)
                {
                    case 0: tractorPart = new TRACTOR_PART() { PART_TYPE = data.GetMasterId((s.Name.Contains("Battery") ? CommonLayer.PARTTYPE.BATTERY : CommonLayer.PARTTYPE.TYRE).ToString()) };
                        tractorPart.PART_MAKER = s.Text;
                        break;
                    case 1: tractorPart.PART_SIZE = s.Text;
                        break;
                    case 2: tractorPart.PART_SERIAL_NO = s.Text;
                        break;
                    case 3: tractorPart.PART_REMARKS = s.Text;
                        tractorPurchase.TRACTOR_PARTs.Add(tractorPart);
                        i = 0;
                        break;
                }
                return true;
            });

            data.Update<TRACTOR_PURCHASE>();
            MessageBox.Show("Saved Sucessfully.");
        }
 partial void DeleteTRACTOR_PART(TRACTOR_PART instance);
 partial void UpdateTRACTOR_PART(TRACTOR_PART instance);
 partial void InsertTRACTOR_PART(TRACTOR_PART instance);
		private void detach_TRACTOR_PARTs(TRACTOR_PART entity)
		{
			this.SendPropertyChanging();
			entity.TRACTOR_PURCHASE = null;
		}
		private void attach_TRACTOR_PARTs(TRACTOR_PART entity)
		{
			this.SendPropertyChanging();
			entity.MASTER = this;
		}