Esempio n. 1
0
        private void Test_button_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = selectedFolder;
            openFileDialog1.Filter           = "Report files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FileName         = "TEST data.txt";
            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.CheckPathExists  = false;
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                using (StreamReader reader = new StreamReader(selectedFolder + @"\TEST_data.txt"))
                {
                    string name;
                    while ((name = reader.ReadLine()) != null)
                    {
                        //string name = reader.ReadLine();
                        string   orderItem = reader.ReadLine();
                        decimal  cost      = Convert.ToDecimal(reader.ReadLine());
                        int      quantity  = Convert.ToInt32(reader.ReadLine());
                        DateTime orderdate = Convert.ToDateTime(reader.ReadLine());
                        Managment = new Managment(name, orderItem, cost, quantity, orderdate);
                        Managment.AddOrder();
                    }
                }
            }
            DisplayData();
        }
Esempio n. 2
0
        private void Add_button_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Name_textBox.Text) || string.IsNullOrEmpty(Item_textBox.Text) ||
                string.IsNullOrEmpty(Cost_textBox.Text) || string.IsNullOrEmpty(Quantity_textBox.Text))
            {
                MessageBox.Show("Please specify order information", "Unable to add", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Managment = new Managment(Name_textBox.Text, Item_textBox.Text, Convert.ToDecimal(Cost_textBox.Text),
                                      Convert.ToInt32(Quantity_textBox.Text), OrderDate);
            Managment.AddOrder();

            DisplayData();
        }