首先是page_load:
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- cmdSubmit.Attributes.Add("onClick","return confirm('确认要提交吗?');");
- //参数传入
- include.PublicClass pc=new spark.include.PublicClass();
- try
- {
- TEWarrantyID=Request.QueryString.Get ("TEWarrantyID").Trim ();
- if(TEWarrantyID == "")
- {
- TEWarrantyID = "0" ;
- }
- TEServerStationID = Session["SessionServerStationID"].ToString() ;
- }
- catch
- {
- pc.GotoErrorPage("取得参数时出错。如果您是通过正常的途径来到这里,请与软件开发商联系。");
- }
- //Response.Write("<INPUT type=hidden value=" + TEWarrantyID + " name=TEWarrantyID>");
- if(TEWarrantyID == "0"){cmdAddOrder.Disabled = true ;}
- //------判断权限
- include.Purview pv=new spark.include.Purview();
- bool canView = pv.CheckSecurity("3","001006003"); //如果是没有查看权限
- bool canSave = pv.CheckSecurity2("3","001006001");
- bool canSubmit = pv.CheckSecurity2("3","001006002");
- if(!Page.IsPostBack)
- {
- if(TEWarrantyID!="0")
- {
- get_warranty(TEWarrantyID) ; //取相关信息,页面的布局是上面显示基本信息,下面是datagrid列表。
- }
- else
- {
- txtSubmitDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;
- txtStartTranDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;
- txtChgStartDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;
- txtChgEndDate.Text = System.DateTime.Now.ToString("yyyy-MM-dd") ;
- }
- //排序
- ViewState["Sort"]="TAMain.MainStatus";
- }
- DataGridBind() ; //绑定
- }
- ///
- 下面是DataGridBind:
- include.ConDataBase cdb=new spark.include.ConDataBase ();
- DataSet ds=new DataSet ();
- string sql="********************" ; ///sql语句
- sql+=" order by ";
- sql+=ViewState["Sort"].ToString();
- //Response.Write(sql);
- ds=cdb.reDataSet (sql);
- DataGrid1.DataSource =ds.Tables [0];
- DataGrid1.DataBind ();
- ///
- ///最后是删除:
- public void Grid_DeleteOrder(Object sender,System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- include.ConDataBase cdb=new spark.include.ConDataBase ();
- DataSet ds= new DataSet ();
- spark.settle.warranties theWarranty = new spark.settle.warranties() ;
- string strSql ;
- string strMainStatus ;
- string TAMainID ;
- TAMainID = e.Item.Cells[0].Text ;
- strSql = "select * from TAMain where TAMainID = " + TAMainID ;
- ds = cdb.reDataSet(strSql) ;
- strMainStatus = ds.Tables[0].Rows[0]["MainStatus"].ToString();
- if(strMainStatus == "30")
- {
- cdb.ExecuteSQL("删除sql where TAMainID = "+ TAMainID );
- theWarranty.fresh(TEWarrantyID) ;
- }
- else
- {
- Response.Write("<SCRIPT language=javascript>alert('不能编辑此状态的索赔批次单。');</SCRIPT>") ;
- }
- DataGridBind();
- Response.Redirect("warrantyShow.aspx?TEWarrantyID="+TEWarrantyID); 返回本页,本页的文件名即为WarrantyShow.aspx
- }