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.
DS7/DSWeb/Shipping/SeaExportInfoHBLAdd.aspx.cs

469 lines
23 KiB
C#

3 years ago
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;
namespace DSWeb.Shipping
{
public partial class SeaExportInfoHBLAdd : System.Web.UI.Page
{
public string sSQL = String.Empty;
public string gvid = String.Empty;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
MoneyConvert MoneyConvert = new MoneyConvert();
TopSeaeEntity TopSeaeEntity = new TopSeaeEntity();
SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA();
TopSeaeBillmanageEntity TopSeaeBillmanageEntity = new TopSeaeBillmanageEntity();
TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA();
RangeDA RangeDA = new RangeDA();
public string strUserID;//用户GID
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
}
//
if (!IsPostBack)
{
if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();
}
//
ViewState["BILLTYPE"] = "分票";
TopSeaeEntity = SeaExportInfoDA.GetID(ViewState["GID"].ToString().Trim());
//
if (Request.QueryString["asid"] != null)
{
Session["asid"] = Request.QueryString["asid"].ToString();
this.hdGid.Value = Request.QueryString["asid"].ToString();
}
//
if (Request.QueryString["handle"] != "edit")
{
Session["handle"] = Request.QueryString["handle"].ToString();
TopSeaeEntity = SeaExportInfoDA.GetID(ViewState["GID"].ToString().Trim());
if (TopSeaeEntity.BSNO != null)
{
tbMBLNO.Text = TopSeaeEntity.MBLNO.ToString().Trim();
tbHBLNO.Text = TopSeaeEntity.HBLNO.ToString().Trim();
tbSHIPPER.Text = TopSeaeEntity.SHIPPER.ToString().Trim();
tbCONSIGNEE.Text = TopSeaeEntity.CONSIGNEE.ToString().Trim();
tbNOTIFYPARTY.Text = TopSeaeEntity.NOTIFYPARTY.ToString().Trim();
tbAGENT.Text = TopSeaeEntity.AGENT.ToString().Trim();
ddlVESSEL.Text = TopSeaeEntity.VESSEL.ToString().Trim();
ddlVOYNO.Text = TopSeaeEntity.VOYNO.ToString().Trim();
//
if (TopSeaeEntity.ISSUEDATE.ToString().Trim().IndexOf("0001")>-1)
{
tbISSUEDATE.Text = "";
}
else
{
tbISSUEDATE.Text = TopSeaeEntity.ISSUEDATE.ToString("yyyy-MM-dd").Trim();
}
//
ddlPORTLOAD.Text = TopSeaeEntity.PORTLOAD.ToString().Trim();
ddlPORTDISCHARGE.Text = TopSeaeEntity.PORTDISCHARGE.ToString().Trim();
ddlPLACEDELIVERY.Text = TopSeaeEntity.PLACEDELIVERY.ToString().Trim();
ddlDESTINATION.Text = TopSeaeEntity.DESTINATION.ToString().Trim();
ddlNOBILL.Text = TopSeaeEntity.NOBILL.ToString().Trim();
tbISSUEPLACE.Text = TopSeaeEntity.ISSUEPLACE.ToString().Trim();
tbMARKS.Text = TopSeaeEntity.MARKS.ToString().Trim();
tbDESCRIPTION.Text = TopSeaeEntity.DESCRIPTION.ToString().Trim();
//
tbCNTRSEALNO.Text = "";// TopSeaeEntity.CNTRSEALNO.ToString().Trim();
//获取委托相关的集装箱信息
IList<TopCtnEntity> topCtnEntities = new List<TopCtnEntity>();
TopCtnDA topCtnDA = new TopCtnDA();
topCtnEntities = topCtnDA.GetID(TopSeaeEntity.BSNO.ToString().Trim());
if (topCtnEntities.Count > 0)
{
foreach (TopCtnEntity ctnEntity in topCtnEntities)
{
tbCNTRSEALNO.Text += ctnEntity.CNTRNO.ToString().Trim() + "/" + ctnEntity.SEALNO.ToString().Trim() + "/" + ctnEntity.CTNALL.ToString().Trim() + "\r\n";
}
}
//
tbNOPKGS.Text = TopSeaeEntity.PKGS.ToString().Trim() + TopSeaeEntity.KINDPKGS.ToString().Trim();
//
tbGROSSWEIGHT.Text = TopSeaeEntity.KGS.ToString().Trim();
tbMEASUREMENT.Text = TopSeaeEntity.CBM.ToString().Trim();
tbTOTALNO.Text = TopSeaeEntity.TOTALNO.ToString().Trim();
}
else
{
}
//
this.imgPrint.Disabled = true;
}
else
{
Session["handle"] = Request.QueryString["handle"].ToString();
if (Session["asid"] != null && Session["asid"].ToString().Trim() != "")
{
TopSeaeBillmanageEntity = TopSeaeBillmanageDA.GetID(Session["asid"].ToString().Trim());
if (TopSeaeBillmanageEntity.AS_ID != null)
{
ViewState["BILLTYPE"] = TopSeaeBillmanageEntity.BILLTYPE;
tbMBLNO.Text = TopSeaeBillmanageEntity.MBLNO.ToString().Trim();
tbHBLNO.Text = TopSeaeBillmanageEntity.HBLNO.ToString().Trim();
tbSHIPPER.Text = TopSeaeBillmanageEntity.SHIPPER.ToString().Trim();
tbCONSIGNEE.Text = TopSeaeBillmanageEntity.CONSIGNEE.ToString().Trim();
tbNOTIFYPARTY.Text = TopSeaeBillmanageEntity.NOTIFYPARTY.ToString().Trim();
tbAGENT.Text = TopSeaeBillmanageEntity.AGENT.ToString().Trim();
ddlVESSEL.Text = TopSeaeBillmanageEntity.VESSEL.ToString().Trim();
ddlVOYNO.Text = TopSeaeBillmanageEntity.VOYNO.ToString().Trim();
//
if (TopSeaeBillmanageEntity.ISSUEDATE.ToString().Trim().IndexOf("0001")>-1)
{
tbISSUEDATE.Text = "";
}
else
{
tbISSUEDATE.Text = TopSeaeEntity.ISSUEDATE.ToString("yyyy-MM-dd").Trim();
}
//
ddlPORTLOAD.Text = TopSeaeBillmanageEntity.PORTLOAD.ToString().Trim();
ddlPORTDISCHARGE.Text = TopSeaeBillmanageEntity.PORTDISCHARGE.ToString().Trim();
ddlPLACEDELIVERY.Text = TopSeaeBillmanageEntity.PLACEDELIVERY.ToString().Trim();
ddlDESTINATION.Text = TopSeaeBillmanageEntity.DESTINATION.ToString().Trim();
ddlNOBILL.Text = TopSeaeBillmanageEntity.NOBILL.ToString().Trim();
tbISSUEPLACE.Text = TopSeaeBillmanageEntity.ISSUEPLACE.ToString().Trim();
tbMARKS.Text = TopSeaeBillmanageEntity.MARKS.ToString().Trim();
tbDESCRIPTION.Text = TopSeaeBillmanageEntity.DESCRIPTION.ToString().Trim();
tbCNTRSEALNO.Text = TopSeaeBillmanageEntity.CNTRSEALNO.ToString().Trim();
tbGROSSWEIGHT.Text = TopSeaeBillmanageEntity.GROSSWEIGHT.ToString().Trim();
tbMEASUREMENT.Text = TopSeaeBillmanageEntity.MEASUREMENT.ToString().Trim();
tbTOTALNO.Text = TopSeaeBillmanageEntity.TOTALNO.ToString().Trim();
//
tbNOPKGS.Text = TopSeaeBillmanageEntity.NOPKGS.ToString().Trim();
}
else
{
}
}
//权限可视范围
string strV = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modOrderManagement");
string strO = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modOrderManagement");
//页面是否只读
if (Request.QueryString["hdenabled"] != null)
{
if (Request.QueryString["hdenabled"].ToString() == "false")
{
strO = "4";
}
}
//
string alt = "";
if (strV.Trim() != strO.Trim())
{
if (strO.Trim().Equals("0"))//全部
{
}
else if (strO.Trim().Equals("1"))//分公司
{
alt = RangeDA.GetOrderManagementCompany(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
else if (strO.Trim().Equals("2"))//部门
{
alt = RangeDA.GetOrderManagementDEPT(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
else if (strO.Trim().Equals("3"))//个人
{
alt = RangeDA.GetOrderManagementPerson(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
else if (strO.Trim().Equals("4"))//无
{
getEnabled();
}
}
//
}
}
}
protected void getEnabled()
{
ibEnter.Enabled = false;
this.imgPrint.Disabled = true;
//
tbMBLNO.Enabled = false;
tbHBLNO.Enabled = false;
tbSHIPPER.Enabled = false;
tbCONSIGNEE.Enabled = false;
tbNOTIFYPARTY.Enabled = false;
tbAGENT.Enabled = false;
ddlVESSEL.Enabled = false;
ddlVOYNO.Enabled = false;
ddlPORTLOAD.Enabled = false;
ddlPORTDISCHARGE.Enabled = false;
ddlDESTINATION.Enabled = false;
ddlPLACEDELIVERY.Enabled = false;
tbCNTRSEALNO.Enabled = false;
tbMARKS.Enabled = false;
tbNOPKGS.Enabled = false;
tbDESCRIPTION.Enabled = false;
tbGROSSWEIGHT.Enabled = false;
tbMEASUREMENT.Enabled = false;
tbTOTALNO.Enabled = false;
tbISSUEDATE.Enabled = false;
tbISSUEPLACE.Enabled = false;
ddlNOBILL.Enabled = false;
}
protected void btnEnter_Click(object sender, ImageClickEventArgs e)
{
if (Session["handle"].ToString().Trim() != "edit")
{
bool bl = getAdd();
if (bl)
{
this.imgPrint.Disabled = false;
Session["handle"] = "edit";
Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + Session["asid"].ToString().Trim() + "');</script>");
//System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('成功提交!');window.opener.location.reload();history.back();", true);
return;
}
else
{
System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport31", "alert('出错,请重新填写!');", true);
return;
}
}
else
{
if (Session["asid"] != null && Session["asid"].ToString().Trim() != "")
{
bool bl = getEdit();
if (bl)
{
System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('成功提交!');window.opener.location.reload();history.back();", true);
return;
}
else
{
System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport31", "alert('出错,请重新填写!');", true);
return;
}
}
}
}
protected void btnDel_Click(object sender, ImageClickEventArgs e)
{
}
protected bool getAdd()
{
TopSeaeBillmanageEntity.ETA = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.ETD = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.CLOSINGDATE = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.ISSUEDATE = DateTime.Parse("0001-1-1 0:00:00");
//
Session["asid"] = T_ALL_DA.getSQLID("HBL");
TopSeaeBillmanageEntity.AS_ID = Session["asid"].ToString().Trim();
TopSeaeBillmanageEntity.BSNO = ViewState["GID"].ToString().Trim();
TopSeaeBillmanageEntity.MBLNO = tbMBLNO.Text.Trim();
TopSeaeBillmanageEntity.HBLNO = tbHBLNO.Text.Trim();
TopSeaeBillmanageEntity.TEMPLATE = "";
if (ViewState["BILLTYPE"] != null)
{
TopSeaeBillmanageEntity.BILLTYPE = ViewState["BILLTYPE"].ToString().Trim();
}
TopSeaeBillmanageEntity.SHIPPERID = "";
TopSeaeBillmanageEntity.CONSIGNEEID = "";
TopSeaeBillmanageEntity.NOTIFYPARTYID = "";
TopSeaeBillmanageEntity.AGENTID = "";
TopSeaeBillmanageEntity.SHIPPER = tbSHIPPER.Text.Trim();
TopSeaeBillmanageEntity.CONSIGNEE = tbCONSIGNEE.Text.Trim();
TopSeaeBillmanageEntity.NOTIFYPARTY = tbNOTIFYPARTY.Text.Trim();
TopSeaeBillmanageEntity.AGENT = tbAGENT.Text.Trim();
TopSeaeBillmanageEntity.YARD = "";
TopSeaeBillmanageEntity.VESSEL = ddlVESSEL.Text.Trim();
TopSeaeBillmanageEntity.VOYNO = ddlVOYNO.Text.Trim();
if (tbISSUEDATE.Text.Trim() != "")
{
TopSeaeBillmanageEntity.ISSUEDATE = DateTime.Parse(tbISSUEDATE.Text.Trim());
}
//
TopSeaeBillmanageEntity.PlACERECEIPT = "";
TopSeaeBillmanageEntity.PORTLOAD = ddlPORTLOAD.Text.Trim();
TopSeaeBillmanageEntity.PORTDISCHARGE = ddlPORTDISCHARGE.Text.Trim();
TopSeaeBillmanageEntity.PLACEDELIVERY = ddlPLACEDELIVERY.Text.Trim();
TopSeaeBillmanageEntity.DESTINATION = ddlDESTINATION.Text.Trim();
TopSeaeBillmanageEntity.PORTLOADID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_loadport where PORT='" + ddlPORTLOAD.Text.Trim() + "'");//装货港代码;
TopSeaeBillmanageEntity.PORTDISCHARGEID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlPORTDISCHARGE.Text.Trim() + "'");//卸货港代码
TopSeaeBillmanageEntity.PLACEDELIVERYID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlPLACEDELIVERY.Text.Trim() + "'");//交货地代码
TopSeaeBillmanageEntity.DESTINATIONID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlDESTINATION.Text.Trim() + "'");//目的地代码
//
TopSeaeBillmanageEntity.NOBILL = ddlNOBILL.Text.Trim();
TopSeaeBillmanageEntity.ISSUETYPE = "";
TopSeaeBillmanageEntity.ISSUEPLACE = tbISSUEPLACE.Text.Trim();
TopSeaeBillmanageEntity.BLFRT = "";
TopSeaeBillmanageEntity.PREPARDAT = "";
TopSeaeBillmanageEntity.PAYABLEAT = "";
TopSeaeBillmanageEntity.SERVICE = "";
TopSeaeBillmanageEntity.MARKS = tbMARKS.Text.Trim();
TopSeaeBillmanageEntity.CNTRSEALNO = tbCNTRSEALNO.Text.Trim();
TopSeaeBillmanageEntity.NOPKGS = tbNOPKGS.Text.Trim();
TopSeaeBillmanageEntity.DESCRIPTION = tbDESCRIPTION.Text.Trim();
TopSeaeBillmanageEntity.GOODSNAME = "";
TopSeaeBillmanageEntity.GROSSWEIGHT = tbGROSSWEIGHT.Text.Trim();
TopSeaeBillmanageEntity.MEASUREMENT = tbMEASUREMENT.Text.Trim();
TopSeaeBillmanageEntity.PKGS = 0;
TopSeaeBillmanageEntity.KINDPKGS = "";
TopSeaeBillmanageEntity.KGS = 0;
TopSeaeBillmanageEntity.CBM = 0;
TopSeaeBillmanageEntity.TOTALNO = tbTOTALNO.Text.Trim();
TopSeaeBillmanageEntity.CNTRNO = "";
TopSeaeBillmanageEntity.CNTRTOTAL = "";
TopSeaeBillmanageEntity.INPUTBY = "";
int iResult = TopSeaeBillmanageDA.InserInfo(TopSeaeBillmanageEntity);
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
TopSeaeBillmanageEntity.ETA = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.ETD = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.CLOSINGDATE = DateTime.Parse("0001-1-1 0:00:00");
TopSeaeBillmanageEntity.ISSUEDATE = DateTime.Parse("0001-1-1 0:00:00");
//
TopSeaeBillmanageEntity.AS_ID = Session["asid"].ToString().Trim();
TopSeaeBillmanageEntity.BSNO = ViewState["GID"].ToString().Trim();
TopSeaeBillmanageEntity.MBLNO = tbMBLNO.Text.Trim();
TopSeaeBillmanageEntity.HBLNO = tbHBLNO.Text.Trim();
TopSeaeBillmanageEntity.TEMPLATE = "";
if (ViewState["BILLTYPE"] != null)
{
TopSeaeBillmanageEntity.BILLTYPE = ViewState["BILLTYPE"].ToString().Trim();
}
TopSeaeBillmanageEntity.SHIPPERID = "";
TopSeaeBillmanageEntity.CONSIGNEEID = "";
TopSeaeBillmanageEntity.NOTIFYPARTYID = "";
TopSeaeBillmanageEntity.AGENTID = "";
TopSeaeBillmanageEntity.SHIPPER = tbSHIPPER.Text.Trim();
TopSeaeBillmanageEntity.CONSIGNEE = tbCONSIGNEE.Text.Trim();
TopSeaeBillmanageEntity.NOTIFYPARTY = tbNOTIFYPARTY.Text.Trim();
TopSeaeBillmanageEntity.AGENT = tbAGENT.Text.Trim();
TopSeaeBillmanageEntity.YARD = "";
TopSeaeBillmanageEntity.VESSEL = ddlVESSEL.Text.Trim();
TopSeaeBillmanageEntity.VOYNO = ddlVOYNO.Text.Trim();
if (tbISSUEDATE.Text.Trim() != "")
{
TopSeaeBillmanageEntity.ISSUEDATE = DateTime.Parse(tbISSUEDATE.Text.Trim());
}
//
TopSeaeBillmanageEntity.PlACERECEIPT = "";
TopSeaeBillmanageEntity.PORTLOAD = ddlPORTLOAD.Text.Trim();
TopSeaeBillmanageEntity.PORTDISCHARGE = ddlPORTDISCHARGE.Text.Trim();
TopSeaeBillmanageEntity.PLACEDELIVERY = ddlPLACEDELIVERY.Text.Trim();
TopSeaeBillmanageEntity.DESTINATION = ddlDESTINATION.Text.Trim();
TopSeaeBillmanageEntity.PORTLOADID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_loadport where PORT='" + ddlPORTLOAD.Text.Trim() + "'");//装货港代码;
TopSeaeBillmanageEntity.PORTDISCHARGEID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlPORTDISCHARGE.Text.Trim() + "'");//卸货港代码
TopSeaeBillmanageEntity.PLACEDELIVERYID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlPLACEDELIVERY.Text.Trim() + "'");//交货地代码
TopSeaeBillmanageEntity.DESTINATIONID = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_disport where PORT='" + ddlDESTINATION.Text.Trim() + "'");//目的地代码
//
TopSeaeBillmanageEntity.NOBILL = ddlNOBILL.Text.Trim();
TopSeaeBillmanageEntity.ISSUETYPE = "";
TopSeaeBillmanageEntity.ISSUEPLACE = tbISSUEPLACE.Text.Trim();
TopSeaeBillmanageEntity.BLFRT = "";
TopSeaeBillmanageEntity.PREPARDAT = "";
TopSeaeBillmanageEntity.PAYABLEAT = "";
TopSeaeBillmanageEntity.SERVICE = "";
TopSeaeBillmanageEntity.MARKS = tbMARKS.Text.Trim();
TopSeaeBillmanageEntity.CNTRSEALNO = tbCNTRSEALNO.Text.Trim();
TopSeaeBillmanageEntity.NOPKGS = tbNOPKGS.Text.Trim();
TopSeaeBillmanageEntity.DESCRIPTION = tbDESCRIPTION.Text.Trim();
TopSeaeBillmanageEntity.GOODSNAME = "";
TopSeaeBillmanageEntity.GROSSWEIGHT = tbGROSSWEIGHT.Text.Trim();
TopSeaeBillmanageEntity.MEASUREMENT = tbMEASUREMENT.Text.Trim();
TopSeaeBillmanageEntity.PKGS = 0;
TopSeaeBillmanageEntity.KINDPKGS = "";
TopSeaeBillmanageEntity.KGS = 0;
TopSeaeBillmanageEntity.CBM = 0;
TopSeaeBillmanageEntity.TOTALNO = tbTOTALNO.Text.Trim();
TopSeaeBillmanageEntity.CNTRNO = "";
TopSeaeBillmanageEntity.CNTRTOTAL = "";
TopSeaeBillmanageEntity.INPUTBY = "";
int iResult = TopSeaeBillmanageDA.UpdateInfo(TopSeaeBillmanageEntity);
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
public bool IsNumeric(string s)
{
int inum = 0;
bool bReturn = true;
try
{
inum = int.Parse(s);
}
catch
{
inum = 0;
bReturn = false;
}
return bReturn;
}
//
}
}