Weeman Osekre

Weeman Osekre

  • NA
  • 56
  • 4k

Database with entity framework

Nov 3 2020 7:16 PM
I have a database(opos)which contains a table (unpaidchecks). I want to first all check if the data contains data and if it does I want to loop through it and compare the data from one of the columns (user) to libuser. Text , then if it’s the same I creat a dynamic button. The buttons are supposed to be created when the form loads
  1. loads unpaidcheck uk = new unpaidcheck();  
  2. oposEntities gg = new oposEntities();  
  3. private void Interface_Load(object sender, EventArgs e) {  
  4.   int i = 0;  
  5.   int x = 0;  
  6.   if (gg.unpaidchecks.Count() != 0) {  
  7.     foreach(DataRow item in gg.uk. {  
  8.       if (uk.user.Contains(this.libuser.Text)) {  
  9.         Button btn = new Button();  
  10.         btn.Location = new Point(3 + i, 14 + x);  
  11.         btn.Width = 160;  
  12.         btn.Height = 80;  
  13.         btn.BackColor = System.Drawing.Color.Red;  
  14.         btn.ForeColor = System.Drawing.Color.Yellow;  
  15.         btn.Text = "Tabel" + item["tabel_no_"].ToString();  
  16.         btn.Click += new EventHandler(btn_Click);  
  17.         this.panel3.Controls.Add(btn);  
  18.         i += 10;  
  19.         x += 10;  
  20.       }  
  21.     }  
 

Answers (4)