protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (DsBusWeb ds = new DsBusWeb()) { var dr = ds.Lines.NewLinesRow(); dr.LineID = int.Parse(((Button)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text); dr.LineName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text; using (var dao = BusWebDataService.GetServiceInstance()) { dao.UpdateLine(dr); } } GridView1.EditIndex = -1; Grid1Bind(); }
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (DsBusWeb ds = new DsBusWeb()) { var dr = ds.Stops.NewStopsRow(); dr.StopID = int.Parse(((TextBox)GridView2.Rows[e.RowIndex].Cells[0].Controls[0]).Text); dr.StopName = ((TextBox)GridView2.Rows[e.RowIndex].Cells[1].Controls[0]).Text; using (var dao = BusWebDataService.GetServiceInstance()) { dao.UpdateStop(dr); } } GridView2.EditIndex = -1; Grid2Bind(); }
protected void btnSend_Click(object sender, EventArgs e) { var gp = parseGMapUrl(txtGMapURL.Text); using (var dao = BusWebDataService.GetServiceInstance()) { DsBusWeb ds = new DsBusWeb(); int lineID = 0; if (!string.IsNullOrEmpty(txtNewLineName.Text)) { var dr = ds.Lines.NewLinesRow(); dr.LineName = txtNewLineName.Text; lineID = dao.InsertNewLine(dr); } else { lineID = int.Parse(ddlLine.SelectedValue); } var dr2 = ds.Stops.NewStopsRow(); dr2.StopName = txtNewStopName.Text; dr2.Latitude = gp.latitude; dr2.Longitude = gp.longitude; dr2.CreatorLatitude = 0d; dr2.CreatorLongitude = 0d; dr2.Owner = "SYSTEM"; dr2.StopID = dao.InsertNewStop(dr2); var dr3 = new DsBusWeb.Line2StopDataTable().NewLine2StopRow(); dr3.StopID = dr2.StopID; dr3.LineID = lineID; dao.InsertNewLine2StopRelation(dr3); } if (!string.IsNullOrEmpty(txtNewLineName.Text)) { refreshLineList(); } txtNewLineName.Text = string.Empty; ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script lang=jscript>alert('站點新增成功');</script>"); }