Beispiel #1
0
        private void data()
        {
            var text = new Createdata();
            var data = text.OilTable.ToList();

            dataGridView1.DataSource = data;
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            OilTable data = new OilTable()
            {
                RefuelingDate = dateTimePicker1.Value,
                Liter         = decimal.ToInt32(numericUpDown1.Value),
                Kilometer     = decimal.ToInt32(numericUpDown2.Value)
            };

            try
            {
                Createdata record = new Createdata();
                record.OilTable.Add(data);
                record.SaveChanges();
                MessageBox.Show("存檔完成");
                ClearNum();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"發生錯誤{ex.ToString()}");
            }
        }