protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CurrentSchoolBus != 0) { //BindData(); DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetSchoolBus(CurrentSchoolBus); if (ds.Tables[0].Rows.Count > 0) { uiTextBoxEnName.Text = ds.Tables[0].Rows[0]["ENLineName"].ToString(); uiTextBoxArName.Text = ds.Tables[0].Rows[0]["ArLineName"].ToString(); uiTextBoxENDriverName.Text = ds.Tables[0].Rows[0]["ENDriverName"].ToString(); uiTextBoxARDriverName.Text = ds.Tables[0].Rows[0]["ArDriverName"].ToString(); uiTextBoxDriverTele.Text = ds.Tables[0].Rows[0]["DriverTele"].ToString(); uiTextBoxENSupName.Text = ds.Tables[0].Rows[0]["ENSupervisorName"].ToString(); uiTextBoxARSupName.Text = ds.Tables[0].Rows[0]["ARSupervisorName"].ToString(); uiTextBoxSupTele.Text = ds.Tables[0].Rows[0]["SupervisorTele"].ToString(); uiTextBoxENNotes.Text = ds.Tables[0].Rows[0]["ENNotes"].ToString(); uiTextBoxARNotes.Text = ds.Tables[0].Rows[0]["ARNotes"].ToString(); } uiPanelCurrentSchoolBus.Visible = false; uiPanelCurrent.Visible = true; } else { uiPanelCurrentSchoolBus.Visible = true; uiPanelCurrent.Visible = false; BindData(); } } }
protected void uiGridViewSchoolBus_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditSchoolBus") { int id = Convert.ToInt32(e.CommandArgument.ToString()); CurrentSchoolBus = id; DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetSchoolBus(id); if (ds.Tables[0].Rows.Count > 0) { uiTextBoxEnName.Text = ds.Tables[0].Rows[0]["ENLineName"].ToString(); uiTextBoxArName.Text = ds.Tables[0].Rows[0]["ArLineName"].ToString(); uiTextBoxENDriverName.Text = ds.Tables[0].Rows[0]["ENDriverName"].ToString(); uiTextBoxARDriverName.Text = ds.Tables[0].Rows[0]["ArDriverName"].ToString(); uiTextBoxDriverTele.Text = ds.Tables[0].Rows[0]["DriverTele"].ToString(); uiTextBoxENSupName.Text = ds.Tables[0].Rows[0]["ENSupervisorName"].ToString(); uiTextBoxARSupName.Text = ds.Tables[0].Rows[0]["ARSupervisorName"].ToString(); uiTextBoxSupTele.Text = ds.Tables[0].Rows[0]["SupervisorTele"].ToString(); uiTextBoxENNotes.Text = ds.Tables[0].Rows[0]["ENNotes"].ToString(); uiTextBoxARNotes.Text = ds.Tables[0].Rows[0]["ARNotes"].ToString(); } uiPanelCurrentSchoolBus.Visible = false; uiPanelCurrent.Visible = true; } else if (e.CommandName == "DeleteSchoolBus") { int id = Convert.ToInt32(e.CommandArgument.ToString()); CurrentSchoolBus = id; DBLayer db = new DBLayer(); db.DeleteSchoolBus(id); uiPanelCurrentSchoolBus.Visible = true; uiPanelCurrent.Visible = false; BindData(); } }