protected void Button1_Click(object sender, EventArgs e) { data_conn cn = new data_conn(); DataSet ds = cn.mdb_ds("select * from TB_CollectPort where numID='" + strID.Value + "'", "t1"); if (ds.Tables["t1"].Rows.Count != 0) { DataSet ds2 = cn.mdb_ds("select * from TB_CollectPortRelation where StartPortID=" + DropDownList3.SelectedValue + " and EndPortID=" + ds.Tables["t1"].Rows[0]["id"].ToString(), "t2"); if (ds2.Tables["t2"].Rows.Count != 0) { this.MessageBox("", "编号已经存在"); } else { cn.mdb_exe("insert into TB_CollectPortRelation (StartPortID,EndPortID) values (" + DropDownList3.SelectedValue + "," + ds.Tables["t1"].Rows[0]["id"].ToString() + ")"); } } else { string id = cn.mdb_exe_return("insert into TB_CollectPort (location,EnglishName,numID,countryName,PortLocation) values ('" + strPortcn.Value + "','" + strPorten.Value + "','" + strID.Value + "','',1)"); cn.mdb_exe("insert into TB_CollectPortRelation (StartPortID,EndPortID) values (" + DropDownList3.SelectedValue + "," + id + ")"); } strPortcn.Value = ""; strPorten.Value = ""; strID.Value = ""; LoadList(); LoadList2(); LoadRecord("1"); }
protected void Button1_Click(object sender, EventArgs e) { data_conn cn = new data_conn(); DataSet ds = cn.mdb_ds("select * from TB_CollectPort where numID='" + strID.Value + "'", "t1"); if (DropDownList1.SelectedValue == "0") { if (ds.Tables["t1"].Rows.Count != 0) { this.MessageBox("", "编号已经存在"); } else { cn.mdb_exe("insert into TB_CollectPort (location,EnglishName,numID,countryName,PortLocation) values ('" + strPortcn.Value + "','" + strPorten.Value + "','" + strID.Value + "',''," + DropDownList1.SelectedValue + ")"); DropDownList3.Items.Clear(); DropDownList3.Items.Add(new ListItem("请选择", "0")); DataSet ds2 = cn.mdb_ds("select * from TB_CollectPort where PortLocation=0", "port"); for (int i = 0; i < ds2.Tables["port"].Rows.Count; i++) { DropDownList3.Items.Add(new ListItem(ds2.Tables["port"].Rows[i]["location"].ToString(), ds2.Tables["port"].Rows[i]["id"].ToString())); } } strPortcn.Value = ""; strPorten.Value = ""; strID.Value = ""; //strcountry.Value = ""; DropDownList1.SelectedValue = "0"; } else { if (ds.Tables["t1"].Rows.Count != 0) { DataSet ds2 = cn.mdb_ds("select * from TB_CollectPortRelation where StartPortID=" + DropDownList3.SelectedValue + " and EndPortID=" + ds.Tables["t1"].Rows[0]["id"].ToString(), "t2"); if (ds2.Tables["t2"].Rows.Count != 0) { this.MessageBox("", "编号已经存在"); } else { cn.mdb_exe("insert into TB_CollectPortRelation (StartPortID,EndPortID) values (" + DropDownList3.SelectedValue + "," + ds.Tables["t1"].Rows[0]["id"].ToString()+")"); } } else { string id = cn.mdb_exe_return("insert into TB_CollectPort (location,EnglishName,numID,countryName,PortLocation) values ('" + strPortcn.Value + "','" + strPorten.Value + "','" + strID.Value + "',''," + DropDownList1.SelectedValue + ")"); cn.mdb_exe("insert into TB_CollectPortRelation (StartPortID,EndPortID) values (" + DropDownList3.SelectedValue + "," + id + ")"); } strPortcn.Value = ""; strPorten.Value = ""; strID.Value = ""; } LoadList(); LoadList2(); LoadRecord("1"); }