Esempio n. 1
0
 //parameterized constructor 1
 public EditInventoryForm(InventoryDataForm parent)
 {
     InitializeComponent();
     parentForm          = parent;
     itemID_textBox.Text = (parentForm.LastItemNumber + 1).ToString();
     insert    = true;
     this.Text = "New Item";
 }
Esempio n. 2
0
 //parameterized constructor 2:
 public EditInventoryForm(InventoryDataForm parent, Record rec)
 {
     InitializeComponent();
     record                   = rec;
     parentForm               = parent;
     itemID_textBox.Text      = record.ID.ToString();
     itemName_textBox.Text    = record.Name;
     qtyRequired_textBox.Text = record.QtyReq.ToString();
     qty_textBox.Text         = record.Quantity.ToString();
 }
Esempio n. 3
0
        //event when open menu is clicked
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //create and show dialog box enabling user to open file
            DialogResult result;   //result of OpenFileDialog
            string       fileName; //name of file containing data

            using (OpenFileDialog fileChooser = new OpenFileDialog())
            {
                fileChooser.InitialDirectory = Directory.GetCurrentDirectory();
                //dialog filers for only "inv" files
                fileChooser.Filter           = "inv files (*.inv)|*.inv|All files (*.*)|*.*";
                fileChooser.RestoreDirectory = true;
                result   = fileChooser.ShowDialog();
                fileName = fileChooser.FileName; //get specified name
            }

            //ensure that user clicked "OK"
            if (result == DialogResult.OK)
            {
                //show error if user specified invalid file
                if (fileName == string.Empty)
                {
                    MessageBox.Show("Invalid File Name", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (OpenFiles.Contains(fileName))
                {
                    MessageBox.Show(this, "File is already open", "Quick Inventory",
                                    MessageBoxButtons.OK, MessageBoxIcon.None,
                                    MessageBoxDefaultButton.Button1);
                }
                else
                {
                    //open new MDI child
                    InventoryDataForm newMDIChildData = new InventoryDataForm(fileName, false, this);
                    //add file to list
                    OpenFiles.Add(fileName);
                    //set the parent Form of the child window.
                    newMDIChildData.MdiParent = this;
                    //display the new form.
                    newMDIChildData.Show();
                }
            }
        }
Esempio n. 4
0
 //Purpose: checks to see which child is active
 //Requires: none
 //Returns: none
 private void CheckActiveChild()
 {
     activeChild = (InventoryDataForm)this.ActiveMdiChild;
 }