private void fillTableAlteCategorii() { SqlCommand cmd = new SqlCommand("Select * From Categorii_Cursuri", con); SqlDataReader reader = cmd.ExecuteReader(); TableRow th = TabelPreferintePosibile.Rows[0]; TabelPreferintePosibile.Rows.Clear(); TabelPreferintePosibile.Rows.Add(th); while (reader.Read()) { if (hasNotSelected(reader.GetInt32(0)) == true) { TableRow row = new TableRow(); TableCell numeCategorie = new TableCell(); // Label1.Text = ((int)reader.GetInt32(0)).ToString(); numeCategorie.Text = reader.GetValue(1).ToString(); //Label1.Text = numeCategorie.Text; row.Cells.Add(numeCategorie); TableCell AdaugaPreferintaCell = new TableCell(); IntInfoBut Adauga = new IntInfoBut(); Adauga.Text = "Adauga Preferinta"; Adauga.Info = (int)reader.GetInt32(0); Adauga.Click += new EventHandler(AdaugaCursul); AdaugaPreferintaCell.Controls.Add(Adauga); row.Cells.Add(AdaugaPreferintaCell); TabelPreferintePosibile.Rows.Add(row); } } reader.Close(); }
private void fillTableCategoriiSelecate() { SqlCommand cmd = new SqlCommand("Select Categorie From Preferinte Where IdUser = "******"Sterge"; Delete.Info = (int)reader.GetInt32(0); Delete.Click += new EventHandler(StergeCursul); delPreferintaCell.Controls.Add(Delete); row.Cells.Add(delPreferintaCell); TabelPreferinteSelectate.Rows.Add(row); } reader.Close(); }
private void AdaugaCursul(object sender, EventArgs e) { IntInfoBut Adauga = (IntInfoBut)sender; try { con = DbConnection.GetSqlConnection(); con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO Preferinte VALUES( " + userId + " , " + Adauga.Info + ")", con); cmd.ExecuteNonQuery(); } catch { } finally { con.Close(); } Response.Redirect(Request.RawUrl); }
public void StergeCursul(object sender, EventArgs e) { IntInfoBut Delete = (IntInfoBut)sender; try { con = DbConnection.GetSqlConnection(); con.Open(); SqlCommand cmd = new SqlCommand("Delete From Preferinte Where Categorie = " + Delete.Info + " AND IdUser = " + userId, con); cmd.ExecuteNonQuery(); } catch { } finally { con.Close(); } Response.Redirect(Request.RawUrl); }