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/PriceCarrier/OpSailingDateInfo.aspx.cs

536 lines
23 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 JsonHelper;
using DSWeb.Log;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Text.RegularExpressions;
using DSWeb.Authority;
using System.Data.OleDb;
namespace DSWeb.PriceCarrier
{
public partial class OpSailingDateInfo : System.Web.UI.Page
{
OpSailingDateEntity OpSailingDateEntity = new OpSailingDateEntity();
OpSailingDateUrlEntity OpSailingDateUrlEntity = new OpSailingDateUrlEntity();
OpSailingDateDA OpSailingDateDA = new OpSailingDateDA();
public string strHandleType = String.Empty;
public string strUserID;//用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
this.hdUserID.Value = strUserID.Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
Session["strHandleType"] = Request.QueryString["handle"].ToString();//"edit";
strHandleType = Session["strHandleType"].ToString().Trim();
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
if (Request.QueryString["id"] != null)
{
Session["GID"] = Request.QueryString["id"].ToString();
this.hdGid.Value = Session["GID"].ToString().Trim();
}
//
switch (strHandleType)
{
case "add"://新增
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
break;
case "addfull"://新增
btISISSUE.Text = "取消发布";
//
OpSailingDateEntity = OpSailingDateDA.GetID(Session["GID"].ToString().Trim());
if (OpSailingDateEntity.GID != null)
{
tbTITLE.Text = OpSailingDateEntity.TITLE == null ? "" : OpSailingDateEntity.TITLE.ToString().Trim();
tbCONTENTS.Text = OpSailingDateEntity.CONTENTS == null ? "" : OpSailingDateEntity.CONTENTS.ToString().Trim();
//
Session["GID"] = getBSNO("Sail");
this.hdGid.Value = Session["GID"].ToString().Trim();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
else
{
Session["strHandleType"] = "add";
strHandleType = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
break;
case "edit"://录入
OpSailingDateEntity = OpSailingDateDA.GetID(Session["GID"].ToString().Trim());
if (OpSailingDateEntity.GID != null)
{
tbTITLE.Text = OpSailingDateEntity.TITLE == null ? "" : OpSailingDateEntity.TITLE.ToString().Trim();
tbCONTENTS.Text = OpSailingDateEntity.CONTENTS == null ? "" : OpSailingDateEntity.CONTENTS.ToString().Trim();
//
if (OpSailingDateEntity.ISISSUE)
{
getEnabled();
btISISSUE.Text = "取消发布";
this.hdISISSUE.Value = "1";
btISISSUE.Enabled = true;
}
else
{
getEnabledTrue();
btISISSUE.Text = "发布";
this.hdISISSUE.Value = "0";
}
}
else
{
Session["strHandleType"] = "add";
strHandleType = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
break;
}
}
else
{
}
}
//集装箱
if (Session["GID"] != null)
{
if (this.hdEnter.Value != "")
{
getEnter();
}
if (Session["GID"].ToString().Trim().Equals(""))
{
this.hdGid.Value = Session["GID"].ToString().Trim();
}
else
{
this.hdGid.Value = Session["GID"].ToString().Trim();
}
}
else
{
//Response.Write("-1");
//Response.End();
}
}
protected void getEnabled()
{
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
divibEnter.Disabled = true;
imgFresh.Disabled = true;
ibDel.Enabled = false;
btISISSUE.Enabled = false;
tbTITLE.Enabled = false;
tbCONTENTS.Enabled = false;
FileUpload1.Enabled = false;
this.btFU.Disabled = true;
this.imgDel.Disabled = true;
this.imgFresh.Disabled = true;
this.mygrid_container_log.Disabled = true;
}
protected void getEnabledTrue()
{
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
divibEnter.Disabled = false;
imgFresh.Disabled = false;
ibDel.Enabled = true;
btISISSUE.Enabled = true;
tbTITLE.Enabled = true;
tbCONTENTS.Enabled = true;
FileUpload1.Enabled = true;
this.btFU.Disabled = false;
this.imgDel.Disabled = false;
this.imgFresh.Disabled = false;
this.mygrid_container_log.Disabled = false;
}
protected String getBSNO(string strName)
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = strName + strBSNO;
return strBSNO;
}
protected void getaddnull()
{
getEnabledTrue();
//
btISISSUE.Text = "发布";
Session["GID"] = getBSNO("Sail");
this.hdGid.Value = Session["GID"].ToString().Trim();
//
tbTITLE.Text = "";
tbCONTENTS.Text = "";
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected string getFU()
{
if (FileUpload1.HasFile == true)//如果用户确实选择了上传控件的浏览按钮,浏览文件成功.
{
string fuName = FileUpload1.FileName.Replace(" ", "_");
string AbsPath = Server.MapPath("FTPFiles/");
string sPath = AbsPath + fuName;
//
//string s2 = Server.MapPath(Request.Path.ToString());
//int i2 = s2.LastIndexOf("DSWeb", s2.Length);
//
//string sPath = s2.Substring(0, i2 + 5).ToString() + "\\Temp\\" + fuName;
//string sPath = FileUpload1.PostedFile.FileName.Trim();
Int32 FileLength = 0;//有可能图片的大小会超出INT的范围所以声明为Int32,当然这和下面大小的判断有关系
FileLength = this.FileUpload1.PostedFile.ContentLength;//获取上传文件的字节大小
//取web中的最大限制数FTPMaxRequestLength
string strFTPMaxRequestLength = System.Configuration.ConfigurationSettings.AppSettings["FTPMaxRequestLength"].ToString() as string;
Int32 iFTPMaxRequestLength = 2091151;
if (strFTPMaxRequestLength == null)
{
iFTPMaxRequestLength = Int32.Parse(strFTPMaxRequestLength);
}
//
if (FileLength > iFTPMaxRequestLength)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('文件最大不能超过4M');</script>");
return "上传文件超过最大限制!";
}
if (File.Exists(sPath)) //判断文件是否寸在
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('文件上传FTP失败');</script>");
return "当前路径下已经存在同名文件!";
}
this.FileUpload1.SaveAs(sPath); //保存到服务器的目录,需要根据服务器具体情况修改FileUpload1.FileName会自动获取上传文件名.
//
//FTPDA FTPDA = new FTPDA();
//FTPDA.ErrorMsg = "";
////
//string OppPath = "xml";
//string xmlPath = s2.Substring(0, i2 + 5).ToString() + "\\Accounts\\"+OppPath;//Server.MapPath(OppPath);
//string xmlName = "SendFTP.xml";
//string strFTPSERVE = "";
//string strSENDER = "";
//string strPASSWORD = "";
////
//if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
//{
// //存在的情况下
// XmlDocument xmldoc = new XmlDocument();
// xmldoc.Load(xmlPath + "//" + xmlName);
// //更新文件
// XmlNode roots = xmldoc.SelectSingleNode("Data");//获取History节点的所有子节点
// foreach (XmlNode root in roots)//遍历所有子节点
// {
// XmlElement xe = (XmlElement)root;//将子节点类型转换为XmlElement类型
// if (xe.GetAttribute("id").ToString().Trim() == "1")//如果id属性值为“strCompanyID”
// {
// XmlNodeList bakss = xe.ChildNodes;//继续获取xe子节点的所有子节点
// foreach (XmlNode baks in bakss)//遍历
// {
// XmlElement bak = (XmlElement)baks;//转换类型
// if (bak.Name == "FTPSERVE")//如果找到
// {
// strFTPSERVE = bak.InnerText.Trim();//发件人邮箱服务器地址
// }
// else if (bak.Name == "SENDER")//如果找到
// {
// strSENDER = bak.InnerText.Trim();//发件人地址
// }
// else if (bak.Name == "PASSWORD")//发件人密码
// {
// strPASSWORD = bak.InnerText.Trim();
// }
// }
// break;
// }
// //
// }
//}
////
//FTPDA.Uri = new Uri(strFTPSERVE);//"ftp://223.7.22.167/"
//if (FTPDA.ErrorMsg.ToString().Trim() != "")
//{
// //Response.Write("<script>alert('" + FTPDA.ErrorMsg.ToString().Trim() + "');</script>");
// return FTPDA.ErrorMsg.ToString().Trim();
//}
//FTPDA.DirectoryPath = "//PriceCarrier//FTPFiles//";
//FTPDA.UserName = strSENDER;// "hmw028167";
//FTPDA.Password = strPASSWORD;// "hmw123456";
//bool bl = FTPDA.UploadFile(sPath, fuName, false);
//if (FTPDA.ErrorMsg.ToString().Trim() != "")
//{
// //Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('" + FTPDA.ErrorMsg.ToString().Trim() + "');</script>");
// return FTPDA.ErrorMsg.ToString().Trim();
//}
//if (!bl)
//{
// //Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('文件上传FTP失败');</script>");
// return "文件上传FTP失败";
//}
//
OpSailingDateUrlEntity.GID = getBSNO("SUrl");// 惟一编号
OpSailingDateUrlEntity.LINKGID = Session["GID"].ToString().Trim();// 关联编号
OpSailingDateUrlEntity.AFFIXNAME = fuName;// 附件名称
OpSailingDateUrlEntity.AFFIXURL = "../PriceCarrier/FTPFiles/" + fuName;// 附件地址
OpSailingDateUrlEntity.AFFIXSIZE = FileLength.ToString().Trim();// 附件大小
OpSailingDateUrlEntity.TABLENAME = "op_sailingdate";//
//
//File.Delete(sPath);
}
return "";
}
protected void getEnter()
{
bool bl = false;
strHandleType = Session["strHandleType"].ToString();
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
string strError = getFU();
if (strError.Trim() != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('" + strError.Trim() + "');</script>");
return;
}
//
if (strHandleType.Equals("add") || strHandleType.Equals("addfull"))//新增
{
OpSailingDateEntity.GID = Session["GID"].ToString().Trim();// 惟一编号
OpSailingDateEntity.TITLE = tbTITLE.Text.ToString().Trim();// 标题
OpSailingDateEntity.CONTENTS = tbCONTENTS.Text;// 内容
OpSailingDateEntity.CREATEUSER = strUserID;// 创建人
OpSailingDateEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
OpSailingDateEntity.DELETEUSER = strUserID; // 删除操作人
OpSailingDateEntity.CORPID = strCompanyID.Trim();
//
int iResult = OpSailingDateDA.InserInfo(OpSailingDateEntity, OpSailingDateUrlEntity);
if (iResult > 0)
{
bl = true;
}
else
{
bl = false;
}
}
else if (strHandleType.Equals("edit"))//录入
{
OpSailingDateEntity.GID = Session["GID"].ToString().Trim();// 惟一编号
OpSailingDateEntity.TITLE = tbTITLE.Text.ToString().Trim();// 标题
OpSailingDateEntity.CONTENTS = tbCONTENTS.Text;// 内容
OpSailingDateEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
//
int iResult = OpSailingDateDA.UpdateInfo(OpSailingDateEntity, OpSailingDateUrlEntity);
if (iResult > 0)
{
//Response.Write("<script>alert('成功提交!');window.opener.location.reload();history.back();</script>");
bl=true;
}
else
{
//Response.Write("<script>alert('出错,请重新填写!');history.back();</script>");
bl=false;
}
}
this.hdEnter.Value = "";
//
if (bl)
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//window.opener.location.reload();history.back();
//Response.Write("<script>alert('成功提交!');</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','" + Session["strHandleType"].ToString().Trim() + "');</script>");
return;
}
else
{
Response.Write("<script>alert('出错,请重新填写!');history.back();</script>");
return;
}
}
protected void ibFullAdd_Click(object sender, EventArgs e)
{
getEnabledTrue();
Session["strHandleType"] = "addfull";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
Session["GID"] = getBSNO("Sail");
this.hdGid.Value = Session["GID"].ToString().Trim();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected void ibAdd_Click(object sender, EventArgs e)
{
getEnabledTrue();
Session["strHandleType"] = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected void ibDel_Click(object sender, EventArgs e)
{
if (this.hdISISSUE.Value.Trim().Equals("1"))
{
Response.Write("<script>alert('业务已发布,不允许删除!');history.back();</script>");
return;
}
//
string alt = OpSailingDateDA.GetOpSailingDateDel(" or gid='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim());
if (alt != "")
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
//
getEnabledTrue();
Session["strHandleType"] = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
public bool IsNumeric(string s)
{
bool bReturn = true;
try
{
int inum = int.Parse(s);
}
catch
{
bReturn = false;
}
return bReturn;
}
protected void btISISSUE_Click(object sender, EventArgs e)
{
int iii = 0;
if (this.hdISISSUE.Value.Trim().Equals("0"))
{
iii = OpSailingDateDA.UpdateInfoCNTRTOTAL("update op_sailingdate set ISISSUE='1',BEGINTIME=getdate() where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim());
if (iii == 1)
{
btISISSUE.Text = "取消发布";
this.hdISISSUE.Value = "1";
getEnabled();
btISISSUE.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','" + Session["strHandleType"].ToString().Trim() + "');</script>");
return;
}
else
{
Response.Write("<script>alert('发布出错!');</script>");
return;
}
}
else
{
iii = OpSailingDateDA.UpdateInfoCNTRTOTAL("update op_sailingdate set ISISSUE='0',ENDTIME=getdate() where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim());
if (iii == 1)
{
btISISSUE.Text = "发布";
this.hdISISSUE.Value = "0";
getEnabledTrue();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','" + Session["strHandleType"].ToString().Trim() + "');</script>");
return;
}
else
{
Response.Write("<script>alert('取消发布出错!');</script>");
return;
}
}
}
}
}