Ejemplo n.º 1
0
        private void buttonPutOne_Click(object sender, EventArgs e)
        {
            var part = LocalDataHolder.Part_Get(_selectedPartIndex);

            part.PushOne();
            FillPart(part);
        }
Ejemplo n.º 2
0
        private void buttonConvertPartToCode_Click(object sender, EventArgs e)
        {
            var sendingData = (string)null;

            if (_selectedPartIndex != -1)
            {
                var part = LocalDataHolder.Part_Get(_selectedPartIndex);
                sendingData = part.Id.ToString();
                sendingData = JsonConvert.SerializeObject(part);
            }



            ObjectWrapper returnable = new ObjectWrapper();
            ObjectWrapper sendable   = new ObjectWrapper(sendingData);

            var hexagonShowForm = new HexagonShowForm(returnable, sendable);
            var thr             = new Thread(() => { Application.Run(hexagonShowForm); });

            thr.SetApartmentState(ApartmentState.STA);
            thr.Start();
            this.Visible = false;
            while (!hexagonShowForm.IsDisposed)
            {
                Thread.Sleep(10);
            }

            this.Visible = true;
        }
Ejemplo n.º 3
0
        private void buttonConvertPartFromCode_Click(object sender, EventArgs e)
        {
            ObjectWrapper returnable = new ObjectWrapper();
            ObjectWrapper sendable   = new ObjectWrapper();

            var hexagonParseForm = new HexagonParseForm(returnable, sendable);
            var thr = new Thread(() => { Application.Run(hexagonParseForm); });

            thr.SetApartmentState(ApartmentState.STA);
            thr.Start();
            this.Visible = false;
            while (!hexagonParseForm.IsDisposed)
            {
                Thread.Sleep(10);
            }

            this.Visible = true;

            var parsedContent = (string)returnable.O;

            if (parsedContent != null)
            {
                var parsedId  = int.Parse(parsedContent);
                var itemIndex = LocalDataHolder.Part_SelectAll().FindIndex(t => t.Id == parsedId);
                if (itemIndex != -1)
                {
                    listBoxParts.SelectedIndex = itemIndex;
                }
            }
        }
Ejemplo n.º 4
0
        private void buttonInsertCountry_Click(object sender, EventArgs e)
        {
            if (!_editingCountry)
            {
                textBoxCountryId.Text = "0";

                buttonUpdateCountry.Enabled        = false;
                buttonInsertCountry.Text           = "Save";
                buttonCancelEditingCountry.Enabled = true;
                _editingCountry = true;
            }
            else
            {
                var id = int.Parse(textBoxCountryId.Text);

                var name = textBoxCountryName.Text;

                var country = new Country(id, name);

                LocalDataHolder.Country_Insert(country);

                ClearPartFields();

                FillData();

                buttonUpdateCountry.Enabled        = true;
                buttonInsertCountry.Text           = "Insert";
                buttonCancelEditingCountry.Enabled = false;

                _editingCountry = false;
            }
        }
Ejemplo n.º 5
0
        private void FillData()
        {
            listBoxParts.Items.Clear();
            listBoxCountries.Items.Clear();
            listBoxManufacturers.Items.Clear();

            LocalDataHolder.Part_SelectAll()
            .ForEach(part => listBoxParts.Items.Add($"{part.Id}: {part.Name}"));
            LocalDataHolder.Country_SelectAll()
            .ForEach(country => listBoxCountries.Items.Add($"{country.Id}: {country.Name}"));
            LocalDataHolder.Manufacturers_SelectAll().ForEach(manufacturer =>
                                                              listBoxManufacturers.Items.Add($"{manufacturer.Id}: {manufacturer.Name}"));

            comboBoxPartCountry.Items.Clear();
            comboBoxPartManufacturer.Items.Clear();

            var countries = LocalDataHolder.Country_SelectAll();

            countries.ForEach(country =>
                              comboBoxPartCountry.Items.Add($"{country.Id}: {country.Name}"));

            var manufacturers = LocalDataHolder.Manufacturers_SelectAll();

            manufacturers.ForEach(manufacturer =>
                                  comboBoxPartManufacturer.Items.Add($"{manufacturer.Id}: {manufacturer.Name}"));
        }
Ejemplo n.º 6
0
        private void buttonInsertPart_Click(object sender, EventArgs e)
        {
            if (!_editingPart)
            {
                textBoxPartId.Text = "0";

                buttonUpdatePart.Enabled        = false;
                buttonInsertPart.Text           = "Save";
                buttonCancelEditingPart.Enabled = true;
                _editingPart = true;
            }
            else
            {
                var id = int.Parse(textBoxPartId.Text);

                var countryId = LocalDataHolder.Country_Get(comboBoxPartCountry.SelectedIndex).Id;

                var manufacturerId = LocalDataHolder.Manufacturer_Get(comboBoxPartManufacturer.SelectedIndex).Id;

                var name = textBoxPartName.Text;

                string technicalData = "";

                try
                {
                    var technicalDataJson = JToken.Parse(richTextBoxPartTechnicalData.Text);
                    technicalData = technicalDataJson.ToString(Formatting.None);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error Parsing Technical Data JSON");
                    return;
                }


                var lifetime = int.Parse(textBoxPartLifetime.Text);

                var count = int.Parse(textBoxPartCount.Text);

                var part = new Part(id, countryId, manufacturerId, name, technicalData, lifetime, count);

                LocalDataHolder.Part_Insert(part);

                ClearPartFields();

                FillData();

                buttonUpdatePart.Enabled        = true;
                buttonInsertPart.Text           = "Insert";
                buttonCancelEditingPart.Enabled = false;

                _editingPart = false;
            }
        }
Ejemplo n.º 7
0
        private void buttonUpdateManufacturer_Click(object sender, EventArgs e)
        {
            if (!_editingManufacturer)
            {
                if (_selectedManufacturerIndex == -1)
                {
                    MessageBox.Show("Select Manufacturer");
                    return;
                }

                try
                {
                    var manufacturer = LocalDataHolder.Manufacturer_Get(_selectedManufacturerIndex);

                    textBoxManufacturerId.Text = manufacturer.Id.ToString();

                    textBoxManufacturerName.Text = manufacturer.Name;
                }
                catch (IndexOutOfRangeException)
                {
                    MessageBox.Show("No Local Manufacturer With Index " + _selectedManufacturerIndex + " Known");
                }

                buttonUpdateManufacturer.Text           = "Save";
                buttonInsertManufacturer.Enabled        = false;
                buttonCancelEditingManufacturer.Enabled = true;
                _editingManufacturer = true;
            }
            else
            {
                var id = int.Parse(textBoxManufacturerId.Text);

                var name = textBoxManufacturerName.Text;

                var manufacturer = new Manufacturer(id, name);

                LocalDataHolder.Manufacturer_Update(manufacturer);

                ClearManufacturerFields();

                FillData();

                buttonUpdateManufacturer.Text           = "Update";
                buttonInsertManufacturer.Enabled        = true;
                buttonCancelEditingManufacturer.Enabled = false;
                _editingManufacturer = false;
            }
        }
Ejemplo n.º 8
0
        private void buttonUpdateCountry_Click(object sender, EventArgs e)
        {
            if (!_editingCountry)
            {
                if (_selectedCountryIndex == -1)
                {
                    MessageBox.Show("Select Country");
                    return;
                }

                try
                {
                    var country = LocalDataHolder.Country_Get(_selectedCountryIndex);

                    textBoxCountryId.Text = country.Id.ToString();

                    textBoxCountryName.Text = country.Name;
                }
                catch (IndexOutOfRangeException)
                {
                    MessageBox.Show("No Local Country With Index " + _selectedCountryIndex + " Known");
                }

                buttonUpdateCountry.Text           = "Save";
                buttonInsertCountry.Enabled        = false;
                buttonCancelEditingCountry.Enabled = true;
                _editingCountry = true;
            }
            else
            {
                var id = int.Parse(textBoxCountryId.Text);

                var name = textBoxCountryName.Text;

                var country = new Country(id, name);

                LocalDataHolder.Country_Update(country);

                ClearCountryFields();

                FillData();

                buttonUpdateCountry.Text           = "Update";
                buttonInsertCountry.Enabled        = true;
                buttonCancelEditingCountry.Enabled = false;
                _editingCountry = false;
            }
        }
Ejemplo n.º 9
0
        private void buttonTakePart_Click(object sender, EventArgs e)
        {
            var part = LocalDataHolder.Part_Get(_selectedPartIndex);

            try
            {
                part.TakeOne();
                MessageBox.Show("Successfully Taken One");
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to Take One");
            }

            FillPart(part);
        }
Ejemplo n.º 10
0
        void FillPart(Part part)
        {
            textBoxPartId.Text = part.Id.ToString();

            var countries    = LocalDataHolder.Country_SelectAll();
            var countryIndex = countries.FindIndex(t => t.Id == part.CountryId);

            comboBoxPartCountry.SelectedIndex = countryIndex;

            var manufacturers     = LocalDataHolder.Manufacturers_SelectAll();
            var manufacturerIndex = manufacturers.FindIndex(t => t.Id == part.ManufacturerId);

            comboBoxPartManufacturer.SelectedIndex = manufacturerIndex;

            textBoxPartName.Text = part.Name;

            richTextBoxPartTechnicalData.Text = JToken.Parse(part.TechnicalData).ToString(Formatting.Indented);

            textBoxPartLifetime.Text = part.Lifetime.ToString();

            textBoxPartCount.Text = part.Count.ToString();
        }
Ejemplo n.º 11
0
 private void FormAdmin_Load(object sender, EventArgs e)
 {
     LocalDataHolder.RefreshLocalData();
     FillData();
 }