protected void OpenAction(object sender, EventArgs e) { LinkButton lnkOpen = (LinkButton)sender; int rowIndex = int.Parse(lnkOpen.CommandArgument); t_basis_road road = new t_basis_road(); string txtId = GridView1.DataKeys[rowIndex].Values[0].ToString(); if (!string.IsNullOrEmpty(txtId)) { road.id = Convert.ToInt32(txtId); road.name = ((Label)GridView1.Rows[rowIndex].FindControl("lblName")).Text; road.comment = ((Label)GridView1.Rows[rowIndex].FindControl("lblComment")).Text; } Label lblRoadBaseName = Master.FindControl("lblRoadDatabaseName") as Label; lblRoadBaseName.Text = string.Format("当前打开的路网为:{0}", road.name); HiddenField lblRoadBaseId = Master.FindControl("lblRoadDatabaseId") as HiddenField; lblRoadBaseId.Value = road.id.ToString(); Common.Cookie.MyCookieHelper.SetCookie("road_id", road.id.ToString());//写入Cookie //using (ZZHMHN.IBase.I_Core.IScene sence = MyApp.Scene) //{ // sence.Context = new ZZHMHN.Web.Core.InvokeContext("", road.id.ToString()); // sence.Bll.Test.TestScence(); //} }
protected void AddNewAction(object sender, EventArgs e) { try { t_basis_road road = new t_basis_road(); road.name = ((TextBox)GridView1.FooterRow.FindControl("txtName")).Text; road.comment = ((TextBox)GridView1.FooterRow.FindControl("txtComment")).Text; if (MyApp.Bll.RoadDatabase.ExistRoad(new { name = road.name })) { ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "nameKey", "alert('路网数据库名称已经存在!');", true); return; } string datasource = MyApp.Bll.RoadDatabase.Add(road); MyApp.Dal.DatabaseManagerRepository.CopyData <ACTIVITY>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <CODEINFO>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <DTBRANCH>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <DTPARAM>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <MRPOLICY>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <MRPOLICYSET>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <PMSELTS>(datasource); MyApp.Dal.DatabaseManagerRepository.CopyData <PREF_ITEM>(datasource); AspNetPager1.RecordCount = (int)MyApp.Bll.RoadDatabase.GetRecordCount(); AspNetPager1.CurrentPageIndex = AspNetPager1.PageCount; List <t_basis_road> roads = GetData(); GridView1.DataSource = roads; GridView1.DataBind(); Label lblRoadBaseName = Master.FindControl("lblRoadDatabaseName") as Label; lblRoadBaseName.Text = string.Format("当前打开的路网为:{0}", road.name); HiddenField lblRoadBaseId = Master.FindControl("lblRoadDatabaseId") as HiddenField; lblRoadBaseId.Value = road.id.ToString(); } catch (Exception ex) { _logger.ErrorFormat("创建路网数据库失败!", ex.Message); ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "nameKey", "alert('创建路网数据库失败!');", true); } }
protected void UpdateAction(object sender, GridViewUpdateEventArgs e) { t_basis_road road = new t_basis_road(); string txtId = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); if (!string.IsNullOrEmpty(txtId)) { road.id = Convert.ToInt32(txtId); road.name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName")).Text; road.comment = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtComment")).Text; MyApp.Bll.RoadDatabase.Update(road); } List <t_basis_road> roads = GetData(); GridView1.EditIndex = -1; GridView1.DataSource = roads; GridView1.DataBind(); }