protected void Page_Load(object sender, EventArgs e) { if (Session["Usermanager"] == null) { Response.Redirect("~/Login.aspx"); } else { if (!IsPostBack) { //填充DropDownlist控件客户 this.ddlCustomer.DataSource = CusMan.GetAllCustomers(); this.ddlCustomer.DataTextField = "CusName"; this.ddlCustomer.DataValueField = "CusID"; ddlCustomer.DataBind(); //填充DropDownlist控件承运公司 this.ddlCompany.DataSource = ComMan.GetAllCarrieCompany(); this.ddlCompany.DataTextField = "CoName"; this.ddlCompany.DataValueField = "Cid"; ddlCompany.DataBind(); //控件窗体加载不显示 lblmessage.Visible = false; lblerror.Visible = false; //判断页面跳转传过来是否有Nid if (Request.QueryString["Nid"] == null) { if (Request.QueryString["rid"] != null) { txtBeginNo.Text = Request.QueryString["rid"]; txtEndNo.Text = Request.QueryString["rid"]; RegisterTB rt = new RegisterTB(); rt = regMan.GetAllRegisterTBByRid(Convert.ToInt64(Request.QueryString["rid"])); ddlCompany.SelectedValue = rt.Cid.ToString(); CarrieCompanyTB cct = new CarrieCompanyTB(); cct = ccm.GetCompanyByid(Convert.ToInt32(ddlCompany.SelectedValue)); txtmoney.Text = cct.Cmoney.ToString(); } else { txtDate.Visible = false; //清空所有的控件 txtBeginNo.Text = ""; txtEndNo.Text = ""; txtmoney.Text = ""; txtDate.Text = ""; txtRemark.Text = ""; } } else { //接受页面穿的值 int Nid = Convert.ToInt32(Request.QueryString["Nid"].ToString()); //实例化实体类 DisNoteTB disno = new DisNoteTB(); //调用方法查询记录 disno = DIsNtMan.GetByNidDisNoteTB(Nid); ddlCustomer.SelectedValue = disno.CusID.ToString(); ddlCompany.SelectedValue = disno.Cid.ToString(); txtBeginNo.Text = disno.BeginNo.ToString(); txtEndNo.Text = disno.EndNo.ToString(); txtDate.Text = disno.Dtime.ToString(); txtmoney.Text = disno.Sum.ToString(); if (disno.IsSet == "是") { rdoNo.Checked = true; } if (disno.IsSet == "否") { rdoNo.Checked = true; } txtRemark.Text = disno.Remark; } } } }