You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

293 lines
13 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using System.Web.Mail;
using System.IO;
using System.Data.OleDb;
using JsonHelper;
using DSWeb.Log;
namespace DSWeb.ParameterSet
{
public partial class CodeDisportSetInfo : System.Web.UI.Page
{
public string strHandleType = String.Empty;
public string sSQL = String.Empty;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
public string strUserID;//用户GID
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
hdUserID.Value = strUserID;
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
//hdUserID.Value = strUserID;
}
//
if (ViewState["GID"] != null)
{
if (this.hdEnter.Value != "")
{
getEnter();
}
}
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null) //if (Request.QueryString["handle"] != null)
{
ViewState["strHandleType"] = Request.QueryString["handle"].ToString();
this.hdHandleType.Value = Request.QueryString["handle"].ToString();
strHandleType = Request.QueryString["handle"].ToString();
if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
}
switch (strHandleType)
{
case "add"://新增
ViewState["GID"] = getBSNO();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
getClear();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
break;
case "edit"://录入
getDataSet("select *,LANE=(select LANE from code_lanes where GID=code_disport.LANEGID) from code_disport where PORTID='" + ViewState["GID"].ToString().Trim() + "'");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
break;
}
}
else
{
}
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboCOUNTRY();initComboCHAU();initComboLANEGID();</script>");
}
protected void getClear()
{
tbPORT.Text = "";
tbCNAME.Text = "";
ddlPORTTYPE.Text = "";
this.hd_comboCOUNTRY.Value = "";
tbCOUNTRYID.Text = "";
this.hd_comboCHAU.Value = "";
this.hd_comboLANEGID.Value = "";
tbEXPLAIN.Text = "";
tbEDICODE.Text = "";
}
protected void getDataSet(string str)
{
DataSet ds = T_ALL_DA.GetAllSQL(str);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
ViewState["GID"] = ds.Tables[0].Rows[0]["PORTID"].ToString().Trim();
tbPORT.Text = ds.Tables[0].Rows[0]["PORT"].ToString().Trim();
tbCNAME.Text = ds.Tables[0].Rows[0]["CNAME"].ToString().Trim();
ddlPORTTYPE.Text = ds.Tables[0].Rows[0]["PORTTYPE"].ToString().Trim();
this.hd_comboCOUNTRY.Value = ds.Tables[0].Rows[0]["COUNTRY"].ToString().Trim();
tbCOUNTRYID.Text = ds.Tables[0].Rows[0]["COUNTRYID"].ToString().Trim();
this.hd_comboCHAU.Value = ds.Tables[0].Rows[0]["CHAU"].ToString().Trim();
tbEXPLAIN.Text = ds.Tables[0].Rows[0]["EXPLAIN"].ToString().Trim();
tbEDICODE.Text = ds.Tables[0].Rows[0]["EDICODE"].ToString().Trim();
this.hd_comboLANEGID.Value = ds.Tables[0].Rows[0]["LANEGID"].ToString().Trim();
this.hd_comboLANE.Value = ds.Tables[0].Rows[0]["LANE"].ToString().Trim();
}
else
{
getClear();
}
}
else
{
getClear();
}
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "Port" + strBSNO;
return strBSNO;
}
protected bool getAdd()
{
string strEXPLAIN = tbEXPLAIN.Text.Trim();
strEXPLAIN = strEXPLAIN.Replace("'", "");
sSQL = "insert into code_disport(PORTID,PORT,CNAME,COUNTRY,CHAU,EXPLAIN,PORTTYPE,COUNTRYID,LANEGID,EDICODE) values('" + ViewState["GID"].ToString().Trim() + "','" + tbPORT.Text.Trim() + "','" + tbCNAME.Text.Trim() + "','" + this.hd_comboCOUNTRY.Value.Trim() + "','" + this.hd_comboCHAU.Value.Trim() + "','" + strEXPLAIN.Trim() + "','" + ddlPORTTYPE.Text.Trim() + "','" + tbCOUNTRYID.Text.Trim() + "','" + this.hd_comboLANEGID.Value.Trim() + "','" + tbEDICODE.Text.Trim() + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
string strEXPLAIN=tbEXPLAIN.Text.Trim();
strEXPLAIN = strEXPLAIN.Replace("'","");
sSQL = "update code_disport set PORT='" + tbPORT.Text.Trim() + "',CNAME='" + tbCNAME.Text.Trim() + "',COUNTRY='" + this.hd_comboCOUNTRY.Value.Trim() + "',CHAU='" + this.hd_comboCHAU.Value.Trim() + "',EXPLAIN='" + strEXPLAIN.Trim() + "',PORTTYPE='" + ddlPORTTYPE.Text.Trim() + "',COUNTRYID='" + tbCOUNTRYID.Text.Trim() + "',LANEGID='" + this.hd_comboLANEGID.Value.Trim() + "',EDICODE='" + tbEDICODE.Text.Trim() + "' where PORTID='" + ViewState["GID"].ToString().Trim() + "'";
string ddd = this.hd_comboLANE.Value.Trim();
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
return true;
}
else
{
return false;
}
}
protected void getEnter()
{
if (tbPORT.Text.Trim() == "" || tbCNAME.Text.Trim() == "")
{
Response.Write("<script>alert('港口英文名称或中文名称不允许为空!');</script>");
return;
}
//
string strls = "";
bool bl = false;
strHandleType = this.hdHandleType.Value.Trim(); //ViewState["strHandleType"].ToString();//this.hdHandleType.Value.Trim();
if (strHandleType.Equals("add"))//新增
{
//
strls = T_ALL_DA.GetStrSQL("PORT", "select PORT from code_disport where PORT='" + tbPORT.Text.Trim() + "'");
if (strls.Trim() != "")
{
Response.Write("<script>alert('港口英文名称不允许重复!');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('港口英文名称不允许重复!');</script>");
return;
}
//
strls = T_ALL_DA.GetStrSQL("CNAME", "select [CNAME] from code_disport where [CNAME]='" + tbCNAME.Text.Trim() + "'");
if (strls.Trim() != "")
{
Response.Write("<script>alert('港口中文名称不允许重复!');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('港口中文名称不允许重复!');</script>");
return;
}
//
bl = getAdd();
}
else if (strHandleType.Equals("edit"))//录入
{
//
strls = T_ALL_DA.GetStrSQL("PORT", "select PORT from code_disport where PORT='" + tbPORT.Text.Trim() + "' and PORTID<>'" + ViewState["GID"].ToString().Trim() + "'");
if (strls.Trim() != "")
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('港口英文名称不允许重复!');</script>");
Response.Write("<script>alert('港口英文名称不允许重复!');</script>");
return;
}
//
strls = T_ALL_DA.GetStrSQL("CNAME", "select [CNAME] from code_disport where [CNAME]='" + tbCNAME.Text.Trim() + "' and PORTID<>'" + ViewState["GID"].ToString().Trim() + "'");
if (strls.Trim() != "")
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('港口名称不允许重复!');</script>");
Response.Write("<script>alert('港口中文名称不允许重复!');</script>");
return;
}
//
bl = getEdit();
}
//
if (bl)
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + strHandleType .Trim()+ "');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
//Response.Write("<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
return;
}
else
{
Response.Write("<script>alert('出错,请重新填写!');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>alert('出错,请重新填写!');</script>");
return;
}
}
protected void ibAdd_Click(object sender, EventArgs e)
{
ViewState["strHandleType"] = "add";
this.hdHandleType.Value = "add";
ViewState["GID"] = getBSNO();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
getClear();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
}
protected void ibDel_Click(object sender, EventArgs e)
{
bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from code_disport where PORTID='" + ViewState["GID"].ToString().Trim() + "'");
if (bl)
{
ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
getDataSet("select top 1 *,LANE=(select LANE from code_lanes where GID=code_disport.LANEGID) from code_disport order by PORT");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','del');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", "<script>alert('删除成功!');window.opener.location.reload();history.back();</script>");
//Response.Write("<script>alert('删除成功!');window.opener.location.reload();history.back();</script>");
return;
}
else
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('删除出错!');</script>");
Response.Write("<script>alert('删除出错!');</script>");
return;
}
}
}
}