protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { Polazak polazak = new Polazak(); Label lblID = (Label)GvRedVoznje.Rows[e.RowIndex].FindControl("lblID"); polazak.ID = Convert.ToInt32(lblID.Text); if (polazak.DeletePolazak()) { LblRedVoznje.Text = "Podatak je izbrisan"; } else { LblRedVoznje.Text = "Greska pri brisanju"; } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Polazak polazak = new Polazak(); Label lblID = (Label)GvRedVoznje.Rows[e.RowIndex].FindControl("lblID"); polazak.LinijaStajalisteID = Convert.ToInt32(lblID.Text); TextBox txtVreme = (TextBox)GvRedVoznje.Rows[e.RowIndex].FindControl("TextBox1"); polazak.Vreme = txtVreme.Text; if (polazak.UpdatePolazak()) { LblRedVoznje.Text = "Podatak je izmenjen"; } else { LblRedVoznje.Text = "Greska pri izmeni"; } GvRedVoznje.EditIndex = -1; GvRedVoznje.DataBind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Insert") { Polazak polazak = new Polazak(); TextBox txtVreme = (TextBox)GvRedVoznje.FooterRow.FindControl("txtVreme"); polazak.Vreme = txtVreme.Text; polazak.LinijaStajalisteID = Convert.ToInt32(LinijaStajaliste.Value); polazak.Dan = DdlDan.SelectedValue; if (polazak.InsertPolazak()) { LblRedVoznje.Text = "Uspesno ste uneli podatak"; } else { LblRedVoznje.Text = "Greska pri unosu"; } } }
private void BindRedVoznje() { Polazak polazak = new Polazak(); string linija; if (DdlLinije.SelectedValue == "") { linija = "5"; } else { linija = DdlLinije.SelectedValue; } List <Polazak> redVoznje = polazak.RedVoznje(linija, DdlSmer.SelectedValue, DdlDan.SelectedValue, -1, -1); if (redVoznje.Count != 0) { LinijaStajaliste.Value = redVoznje[0].LinijaStajalisteID.ToString(); } GvRedVoznje.DataSource = redVoznje; GvRedVoznje.DataBind(); }