コード例 #1
0
        private void lstRawMaterials_SelectedIndexChanged(object sender, EventArgs e)
        {
            //get the reference to the material from listbox and cast it to RawMaterial object
            objRawMat = (RawMaterials)lstRawMaterials.SelectedItem;

            //update the text box wit the RawMaterial value
            txtRawMaterialName.Text = objRawMat.material;
        }
コード例 #2
0
        private void btnAddNewMaterial_Click(object sender, EventArgs e)
        {
            try
            {
                string materialName = txtRawMaterialName.Text.Trim(' ');
                objRawMat = new RawMaterials(materialName);

                if (rawMaterials.Contains(objRawMat))
                {
                    MessageBox.Show(objRawMat.ToString());
                }


                if (!objRawMat.ContainsMaterialName(rawMaterials, objRawMat.material))
                {
                    addedRawMaterials.Add(objRawMat);

                    toolStripStatusLabel1.Text = "The material " + materialName + " was added to the list.";

                    lstRawMaterials.Items.Clear();
                    lstRawMaterials.Items.AddRange(rawMaterials.ToArray());
                    lstRawMaterials.Items.AddRange(addedRawMaterials.ToArray());

                    objDatabaseManager.InsertToRMTable(addedRawMaterials);
                }
                else
                {
                    MessageBox.Show("First input the name of a new material.");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err + "Error adding material to the list.");
                throw;
            }
        }