issuanceFreight.aspx.cs
Upload User: lusr621
Upload Date: 2022-01-11
Package Size: 1001k
Code Size: 4k
Development Platform:

VBScript

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class issuanceFreight : System.Web.UI.Page
  12. {
  13.     protected void Page_Load(object sender, EventArgs e)
  14.     {
  15.         if (!IsPostBack)
  16.         {
  17.             bindSf();
  18.         }
  19.     }
  20.     //绑定省份
  21.     public void bindSf()
  22.     { 
  23.         string sql="select distinct sf from tb_City";
  24.         //调用数据库操作类中的getDataset方法并接受返回的数据集
  25.         DataSet ds=dataOperate.getDataset(sql, "tb_City");
  26.         //绑定出发省的数据源
  27.         this.ddlcSf.DataSource = ds.Tables["tb_City"].DefaultView;
  28.         //绑定到达省的数据源
  29.         this.ddldSf.DataSource = ds.Tables["tb_City"].DefaultView;
  30.         //绑定出发省DropDownList控件的文本值
  31.         ddlcSf.DataTextField = "sf";
  32.         //绑定出发省DropDownList控件的值
  33.         ddlcSf.DataValueField = "sf";
  34.         ddldSf.DataTextField = "sf";
  35.         ddldSf.DataValueField = "sf";
  36.         this.ddlcSf.DataBind();
  37.         this.ddldSf.DataBind();
  38.     }
  39.     //联动出发点城市
  40.     protected void ddlcSf_SelectedIndexChanged(object sender, EventArgs e)
  41.     {   
  42.         //获取所选择省的值
  43.         string sf = ddlcSf.SelectedValue.ToString();
  44.         string sql = "select cs from tb_City where sf='" + sf+"'";
  45.         //调用数据库操作类中的getDataset方法并接受返回的数据集
  46.         DataSet ds = dataOperate.getDataset(sql, "tb_City");
  47.         this.ddlcCs.DataSource = ds.Tables["tb_City"].DefaultView;
  48.         //绑定出发市DropDownList控件的文本值
  49.         ddlcCs.DataTextField = "cs";
  50.         //绑定出发市DropDownList控件的值
  51.         ddlcCs.DataValueField = "cs";        
  52.         this.ddlcCs.DataBind();        
  53.     }   
  54.     //联动终点城市
  55.     protected void ddldSf_SelectedIndexChanged(object sender, EventArgs e)
  56.     {
  57.         string sf = ddldSf.SelectedValue.ToString();
  58.         string sql = "select cs from tb_City where sf='" + sf + "'";
  59.         DataSet ds = dataOperate.getDataset(sql, "tb_City");
  60.         this.ddldCs.DataSource = ds.Tables["tb_City"].DefaultView;
  61.         ddldCs.DataTextField = "cs";
  62.         ddldCs.DataValueField = "cs";
  63.         this.ddldCs.DataBind();
  64.     }
  65.     //发布货源
  66.     protected void btnIssuance_Click(object sender, EventArgs e)
  67.     {
  68.         string UserName = Session["UserName"].ToString();
  69.         string Start = ddlcSf.SelectedValue.ToString() + ddlcCs.SelectedValue.ToString();
  70.         string Terminal = ddldSf.SelectedValue.ToString() + ddldCs.SelectedValue.ToString();
  71.         string FreightType = this.txtFreightType.Text;
  72.         string FreightWeight = this.txtFreightWeight.Text;
  73.         string WeightUnit;
  74.         if (rdibtnDun.Checked)
  75.         {
  76.             WeightUnit = "吨";
  77.         }
  78.         else
  79.             if (rdibtnFan.Checked)
  80.             {
  81.                 WeightUnit = "方";
  82.             }
  83.             else
  84.             {
  85.                 WeightUnit = "件";
  86.             }
  87.         string Linkman = this.txtLinkman.Text;
  88.         string Phone = this.txtPhone.Text;
  89.         string Term = this.txtTerm.Text;
  90.         string Content = this.txtContent.Text;
  91.         string FBDate = DateTime.Now.ToString();
  92.         string UserType = Session["UserType"].ToString();
  93.         string sql = "insert into tb_Freight values('" + UserName + "','" + Start + "','" + Terminal + "','" + FreightType + "','" +
  94.             FreightWeight + "','" + WeightUnit + "','" + Linkman + "','" + Phone + "','" + Term + "','" + Content + "','" + FBDate + "','" + UserType + "','')";
  95.         if (dataOperate.execSQL(sql))
  96.         {
  97.             txtContent.Text = "";
  98.             txtFreightType.Text = "";
  99.             txtFreightWeight.Text = "";
  100.             txtLinkman.Text = "";
  101.             txtPhone.Text = "";
  102.             txtTerm.Text = "";
  103.             
  104.             RegisterStartupScript("true", "<script>alert('发布成功!')</script>");
  105.         }
  106.         else
  107.         {
  108.             RegisterStartupScript("false", "<script>alert('发布失败!')</script>");
  109.         }
  110.        
  111.     }
  112. }