コード例 #1
0
        private void AddMaterialBtn_Click(object sender, EventArgs e)
        {
            RawMaterial rawMaterial = new RawMaterial();

            if (Miscellaneous.Validation.MatchStringNumbers(materialNameTextBox.Text) && Miscellaneous.Validation.MatchStringWithDot(materialDescriptionTextBox.Text))
            {
                if (rawMaterial.AddRawMaterial(materialNameTextBox.Text, materialDescriptionTextBox.Text))
                {
                    MessageBox.Show("Material Successfully added!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    materialDescriptionTextBox.Text = "";
                    materialNameTextBox.Text        = "";
                    materialTextBox.Text            = "";
                }
                else
                {
                    MessageBox.Show("Sorry cannot add raw material", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Name and Description should only contain letters and white spaces.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
 private void MaterialSearchBtn_Click(object sender, EventArgs e)
 {
     if (searchRawMaterial.Text.Equals(" ") || searchRawMaterial.Text != null)
     {
         if (Miscellaneous.Validation.MatchString(searchRawMaterial.Text))
         {
             RawMaterial rawMaterial = RawMaterial.GetRawMaterial(searchRawMaterial.Text);
             if (rawMaterial != null)
             {
                 materialTextBox.Text            = rawMaterial.Materialid.ToString();
                 materialNameTextBox.Text        = rawMaterial.Name;
                 materialDescriptionTextBox.Text = rawMaterial.Description;
             }
         }
         else
         {
             MessageBox.Show("Raw materials should only contain letters and white spaces", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Please enter a valid name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }