示例#1
0
        private void LvwPartsList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //Make a list of parts not associated with a repair
            List <PartVM> partsVM = new List <PartVM>();

            foreach (PartVM part2 in parts)
            {
                if (part2.RepairLineItemID == 0)
                {
                    partsVM.Add(part2);
                }
            }

            //Get the selected part
            Part part;

            if (lvwPartsList.SelectedIndex != -1)
            {
                part = partsVM[lvwPartsList.SelectedIndex];
            }
            else
            {
                part = parts[0];
            }

            //Pass the part to a new form
            NewPart partForm = new NewPart(part);

            partForm.ShowDialog();

            //Delete the part if neccessary
            if (partForm.deleted)
            {
                try
                {
                    _partsManager.deletePart(part.getSerialNumber());
                }
                catch (Exception ex)
                {
                    lblStatusMessage.Content = ex.Message;
                }
            }
        }
示例#2
0
        private void BtnNewPart_Click(object sender, RoutedEventArgs e)
        {
            //Create the dialog
            NewPart partForm = new NewPart();

            partForm.ShowDialog();

            //Add the part to the database
            try
            {
                Part part = partForm.part;
                _partsManager.addNewPart(part);
                lblStatusMessage.Content = "Update success";
            }
            catch (Exception ex)
            {
                lblStatusMessage.Content = ex.Message;
            }
        }