コード例 #1
0
ファイル: Form1.cs プロジェクト: AHronec7/Ch9Tutorial
        private void AddPhoneButton_Click(object sender, EventArgs e)
        {
            // create a cellphone object

            CellPhoneInventory myphone = new CellPhoneInventory();

            // get the phone data

            getdata(myphone);

            //Add the cell phone object to the list

            phoneList.Add(myphone);

            // add the entry to the list box

            PhoneListBox.Items.Add(myphone.Brand + " " + myphone.Model);

            // clear the contents of the textbox

            BrandTextBox.Clear();
            ModelTextBox.Clear();
            PriceTextBox.Clear();

            BrandTextBox.Focus();
        }
コード例 #2
0
 // Test input text to be only numbers, letters, spaces and dashes "-".
 private void ModelTextBox_TextChanged(object sender, EventArgs e)
 {
     if (!System.Text.RegularExpressions.Regex.IsMatch(ModelTextBox.Text, @"^[a-zA-Z0-9 -]*$"))
     {
         MessageBox.Show("This textbox accepts only alphabetical characters and numbers!");
         ModelTextBox.ResetText();
     }
 }
コード例 #3
0
 private void DiscardButton_Click(object sender, RoutedEventArgs e)
 {
     BrandComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget();
     ModelTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     Property1ComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget();
     Property2ComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget();
     PriceTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     StockTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     UpdatePropertyComboBoxProperties();
 }
コード例 #4
0
        private void createVehicleButton_Click(object sender, EventArgs e)
        {
            if (MakeTextBox.Text == null || ModelTextBox.Text == null || yearTextBox.Text == null || mileageTextBox.Text == null || comboBox1.Text == null)
            {
                MessageBox.Show("Fill in All Values", "ERROR");
            }

            else
            {
                string  Make       = MakeTextBox.Text;
                string  Model      = ModelTextBox.Text;
                string  year       = yearTextBox.Text;
                string  mileage    = mileageTextBox.Text;
                string  type       = comboBox1.Text;
                Vehicle newvehicle = new Vehicle(Model, Make, year, mileage, type);

                Form1.vehicles = Vehicle.loadVehicles();
                var local_vehicles = Form1.vehicles;
                local_vehicles.Add(newvehicle);

                //System.IO.StreamReader file = new System.IO.StreamReader(@"C:\\Users\\J Aldo\\source\\Car_Rental_Service\\Car_Rental_Service\\vehicle.txt");

                StreamWriter sw = new StreamWriter(@"C:\\Users\\J Aldo\\source\\Car_Rental_Service\\Car_Rental_Service\\vehicles.txt");
                string       outline;


                ////////////////////// Check /////////////////////////
                foreach (Vehicle vehicle in local_vehicles)
                {
                    bool refer = true;
                    outline = vehicle.make + ", " + vehicle.model + ", " + vehicle.year + ", " + vehicle.mileage + ", " + vehicle.type;


                    if (refer == true)
                    {
                        sw.WriteLine(outline);
                    }
                    else
                    {
                        MessageBox.Show("Invalid, vehicle duplicate");
                    }
                }



                sw.Close();
                MessageBox.Show("vehicle Added");
                MakeTextBox.Clear();
                ModelTextBox.Clear();
                yearTextBox.Clear();
                mileageTextBox.Clear();
            }
        }
コード例 #5
0
        //Writing method
        private void _SaveInfo()
        {
            //makes sure user is ready to save
            DialogResult UserResult = MessageBox.Show("Are You Sure?", "Confirm", MessageBoxButtons.YesNo);

            if (UserResult == DialogResult.Yes)
            {
                // Open a writer and Write to the file
                _writer = new StreamWriter("Product.txt", true);
                _writer.WriteLine(ProductIDTextbox.Text + _DELIMETER +
                                  ConditionTextbox.Text + _DELIMETER +
                                  CostTextbox.Text + _DELIMETER +
                                  PlatformTextBox.Text + _DELIMETER +
                                  ManufactuerTextbox.Text + _DELIMETER +
                                  OSTextbox.Text + _DELIMETER +
                                  ModelTextBox + _DELIMETER +
                                  MemoryTextBox.Text + _DELIMETER +
                                  LCDTextbox.Text + _DELIMETER +
                                  HDDTextbox.Text + _DELIMETER +
                                  CPUBrandTextbox.Text + _DELIMETER +
                                  CPUNumberTextbox.Text + _DELIMETER +
                                  CPUSpeedTextbox.Text + _DELIMETER +
                                  GPUTextbox.Text + _DELIMETER +
                                  WebcamTextbox.Text);

                //Close the file
                _writer.Close();

                // Resets all boxes
                ProductIDTextbox.Clear();
                ConditionTextbox.Clear();
                CostTextbox.Clear();
                PlatformTextBox.Clear();
                ManufactuerTextbox.Clear();
                OSTextbox.Clear();
                ModelTextBox.Clear();
                MemoryTextBox.Clear();
                LCDTextbox.Clear();
                HDDTextbox.Clear();
                CPUBrandTextbox.Clear();
                CPUNumberTextbox.Clear();
                CPUTypeTextbox.Clear();
                GPUTextbox.Clear();
                CPUSpeedTextbox.Clear();
                WebcamTextbox.Clear();
            }
        }
コード例 #6
0
 // reset the form;
 private void ResetForm()
 {
     ProductIDTextBox.Clear();
     ConditionTextBox.Clear();
     CostTextBox.Clear();
     PlatformTextBox.Clear();
     OSTextBox.Clear();
     ManufacturerTextBox.Clear();
     ModelTextBox.Clear();
     MemoryTextBox.Clear();
     LCDSizeTextBox.Clear();
     HDDTextBox.Clear();
     CPUBrandTextBox.Clear();
     CPUNumberTextBox.Clear();
     GPUTypeTextBox.Clear();
     CPUTypeTextBox.Clear();
     CPUSpeedTextBox.Clear();
     WebCamTextBox.Clear();
 }
コード例 #7
0
 private void ResetForm()
 {
     ProductTextBox.Clear();
     ConditionTextBox.Clear();
     CostTextBox.Clear();
     PlatFormTextBox.Clear();
     OsTextBox.Clear();
     ManuFacTextBox.Clear();
     ModelTextBox.Clear();
     MemoryTextBox.Clear();
     LCDTextBox.Clear();
     HDDTextBox.Clear();
     CPUBTextBox.Clear();
     CPUNumTextBox.Clear();
     GPUTTextBox.Clear();
     CPUTTextBox.Clear();
     CPUspeedTextBox.Clear();
     WebCamTextBox.Clear();
 }
コード例 #8
0
        //============================================================================*
        // cBulletTypeform() - Constructor
        //============================================================================*

        public cBulletTypeForm(string strTypeString, cDataFiles DataFiles)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;

            //----------------------------------------------------------------------------*
            // Initialize Event Handlers
            //----------------------------------------------------------------------------*

            ModelTextBox.TextChanged += OnTextChanged;

            CustomTextBox.TextChanged += OnTextChanged;

            LeadRadioButton.Click     += OnLeadButtonClicked;
            CastRadioButton.Click     += OnCastButtonClicked;
            SwagedRadioButton.Click   += OnSwagedButtonClicked;
            GasCheckRadioButton.Click += OnGasCheckButtonClicked;

            PlatedRadioButton.Click      += OnPlatedButtonClicked;
            ShortJacketRadioButton.Click += OnShortJacketButtonClicked;
            JacketedRadioButton.Click    += OnJacketedButtonClicked;
            FMJRadioButton.Click         += OnFMJButtonClicked;
            TMJRadioButton.Click         += OnTMJButtonClicked;

            RoundNoseRadioButton.Click     += OnRoundNoseButtonClicked;
            HollowPointRadioButton.Click   += OnHollowPointButtonClicked;
            WadCutterRadioButton.Click     += OnWadCutterButtonClicked;
            SemiWadCutterRadioButton.Click += OnSemiWadCutterButtonClicked;
            FlatNoseRadioButton.Click      += OnFlatNoseButtonClicked;
            FlatPointRadioButton.Click     += OnFlatPointButtonClicked;
            SpirePointRadioButton.Click    += OnSpirePointButtonClicked;
            TruncatedConeRadioButton.Click += OnTruncatedConeButtonClicked;

            BevelBaseRadioButton.Click  += OnBevelBaseButtonClicked;
            BoatTailRadioButton.Click   += OnBoatTailButtonClicked;
            FlatBaseRadioButton.Click   += OnFlatBaseButtonClicked;
            HollowBaseRadioButton.Click += OnHollowBaseButtonClicked;

            MatchCheckBox.Click        += OnCheckBoxClicked;
            CombatTargetCheckBox.Click += OnCheckBoxClicked;
            VarmintCheckBox.Click      += OnCheckBoxClicked;
            HornetCheckBox.Click       += OnCheckBoxClicked;
            CannelureCheckBox.Click    += OnCheckBoxClicked;

            SetClientSizeCore(GeneralGroupBox.Location.X + GeneralGroupBox.Width + 10, BulletTypeCancelButton.Location.Y + BulletTypeCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Parse the strTypeString parameter
            //----------------------------------------------------------------------------*

            foreach (object Object in Controls)
            {
                if (Object is GroupBox)
                {
                    foreach (object Control in (Object as GroupBox).Controls)
                    {
                        if (Control is RadioButton)
                        {
                            if (strTypeString.Contains((string)(Control as RadioButton).Tag))
                            {
                                (Control as RadioButton).Checked = true;
                            }
                        }
                    }
                }

                if (Object is RadioButton)
                {
                    if (strTypeString.Contains((string)(Object as RadioButton).Tag))
                    {
                        (Object as RadioButton).Checked = true;
                    }
                }
            }

            //----------------------------------------------------------------------------*
            // Setup Starting Data
            //----------------------------------------------------------------------------*

            BuildResultString();

            SetStaticToolTips();

            //----------------------------------------------------------------------------*
            // Set Focus to the Model TextBox
            //----------------------------------------------------------------------------*

            ModelTextBox.Focus();
        }