private void button4_Click(object sender, EventArgs e) { try { //update button int yr = Convert.ToInt32(label19.Text); YearlyIncome yrDb = db.YearlyIncomes.SingleOrDefault(x => x.Id == yr); yrDb.year = Convert.ToInt32(textBox1.Text); yrDb.income = Convert.ToInt32(textBox2.Text); db.SubmitChanges(); MessageBox.Show("Data Updated"); //opening this window by refershing again Hide(); YearlyIncomeClass newObj = new YearlyIncomeClass(); newObj.whoLoggedIn = this.whoLoggedIn; newObj.Show(); } catch { MessageBox.Show("Invalid Input"); } }
private void YearlyIncomeClass_Load(object sender, EventArgs e) { ///first YearlyIncome first = db.YearlyIncomes.SingleOrDefault(x => x.Id == 1); label19.Text = first.Id.ToString(); textBox1.Text = first.year.ToString(); textBox2.Text = first.income.ToString(); ///second YearlyIncome second = db.YearlyIncomes.SingleOrDefault(x => x.Id == 2); label20.Text = second.Id.ToString(); textBox4.Text = second.year.ToString(); textBox3.Text = second.income.ToString(); ///third YearlyIncome third = db.YearlyIncomes.SingleOrDefault(x => x.Id == 3); label21.Text = third.Id.ToString(); textBox6.Text = third.year.ToString(); textBox5.Text = third.income.ToString(); ///forth YearlyIncome forth = db.YearlyIncomes.SingleOrDefault(x => x.Id == 4); label22.Text = forth.Id.ToString(); textBox8.Text = forth.year.ToString(); textBox7.Text = forth.income.ToString(); ///fifth YearlyIncome fifth = db.YearlyIncomes.SingleOrDefault(x => x.Id == 5); label23.Text = fifth.Id.ToString(); textBox10.Text = fifth.year.ToString(); textBox9.Text = fifth.income.ToString(); }
partial void UpdateYearlyIncome(YearlyIncome instance);
partial void DeleteYearlyIncome(YearlyIncome instance);
partial void InsertYearlyIncome(YearlyIncome instance);