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.

895 lines
42 KiB
C#

12 months 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.Xml.Linq;
using DSWeb.EntityDA;
using DSWeb.Models;
using JsonHelper;
using System.Xml;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
using DSWeb.Log;
namespace DSWeb.Shipping
{
public partial class SeaeOrderAudit : System.Web.UI.Page
{
CrmSeaeorderDA CrmSeaeorderDA = new CrmSeaeorderDA();
CrmSeaeorderEntity CrmSeaeorderEntity = new CrmSeaeorderEntity();
CrmSeaeorderctnDA CrmSeaeorderctnDA = new CrmSeaeorderctnDA();
TopSeaeEntity TopSeaeEntity = new TopSeaeEntity();
SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
RangeDA RangeDA = new RangeDA();
public string strUserID;//用户GID
private string strShowName;//用户登录名
private string strCompanyID;//分公司GID
private string strDeptName;//部门名称
//grid
private string strColumnVal;
private string strType = "14";//Grid模块号
//gridEnd
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 (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
//
//权限可视范围
this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modSeaeOrderAudit");//销售订舱审核
this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modSeaeOrderAudit");//销售订舱审核
this.hdRange.Value = "";
//if (this.hdRangeV.Value.Trim() != this.hdRangeO.Value.Trim())
//{
this.hdRange.Value = "";
if (this.hdRangeO.Value.Trim().Equals("4"))//无
{
this.btAudit.Disabled = true;
this.btRejected.Disabled = true;
}
//}
//grid
if (!IsPostBack)
{
}
if (hid_setting.Value.Trim() != "")
{
strColumnVal = hid_setting.Value.Trim();
SaveColumnSetting(strColumnVal);
hid_setting.Value = "";
}
if (hid_header.Value.Trim() != "")
{
strColumnVal = hid_header.Value.Trim();
SaveColumnSetting(strColumnVal);
hid_header.Value = "";
}
if (hd_ddlORSTATUS.Value.Trim() == "")
{
this.hd_ddlORSTATUS.Value = "1";
}
//分公司代码
DataSet ds = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, "select COMPANYID from user_company where USERID='" + strUserID.Trim() + "'");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
this.hdCOMPANYID.Value = ds.Tables[0].Rows[0]["COMPANYID"].ToString().Trim();
}
else
{
this.hdCOMPANYID.Value = "";
}
}
else
{
this.hdCOMPANYID.Value = "";
}
//
//gridEnd
}
protected void btDel_Click(object sender, EventArgs e)
{
if (this.hid_id.Value.Trim() != "")
{
DataSet ds = CrmSeaeorderDA.GetFieldAll(this.hid_id.Value.Trim());
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0][""].ToString().Trim().Equals("0"))
{
Response.Write("<script>alert('审核已通过,不允许删除!');history.back();</script>");
return;
}
}
else
{
Response.Write("<script>alert('删除出错!');history.back();</script>");
return;
}
}
else
{
Response.Write("<script>alert('删除出错!');history.back();</script>");
return;
}
//
string alt = CrmSeaeorderDA.GetCrmSeaeorderDel(this.hid_id.Value.Trim(), strUserID.Trim());
if (alt == "")
{
//Response.Write("<script>alert('删除成功!');history.back();</script>");
//return;
}
else
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
}
}
protected void btAudit1_Click(object sender, EventArgs e)
{
CrmSeaeorderEntity = CrmSeaeorderDA.GetID(this.hd_ORDNO.Value.Trim());
TopSeaeEntity.BSNO = CrmSeaeorderEntity.ORDNO.ToString().Trim();
if (CrmSeaeorderEntity.ORDNO != null)
{
//服务项目名读取
TopSeaeEntity.ISFUMIGATION = CrmSeaeorderEntity.ISFUMIGATION;
TopSeaeEntity.ISSTORAGE = CrmSeaeorderEntity.ISSTORAGE;
TopSeaeEntity.ISLAND = CrmSeaeorderEntity.ISLAND;
TopSeaeEntity.ISCUSTOMS = CrmSeaeorderEntity.ISCUSTOMS;
TopSeaeEntity.ISINSPECTION = CrmSeaeorderEntity.ISINSPECTION;
TopSeaeEntity.ISBOOKING = CrmSeaeorderEntity.ISBOOKING;
TopSeaeEntity.ISAGENT = CrmSeaeorderEntity.ISAGENT;
TopSeaeEntity.ISHBLNO = CrmSeaeorderEntity.ISHBLNO;
TopSeaeEntity.SERVICE9 = CrmSeaeorderEntity.SERVICE9;
TopSeaeEntity.SERVICE10 = CrmSeaeorderEntity.SERVICE10;
//
TopSeaeEntity.CUSTOMERNAME = CrmSeaeorderEntity.CUSTOMERNAME.ToString().Trim();
TopSeaeEntity.SALE = CrmSeaeorderEntity.SALE.ToString().Trim();
TopSeaeEntity.BLTYPE = CrmSeaeorderEntity.BLTYPE.ToString().Trim();
TopSeaeEntity.CARRIER = CrmSeaeorderEntity.CARRIER.ToString().Trim();
TopSeaeEntity.FORWARDER = CrmSeaeorderEntity.FORWARDER.ToString().Trim();
TopSeaeEntity.REMARK = CrmSeaeorderEntity.REMARK.ToString().Trim();
TopSeaeEntity.SHIPPERID = CrmSeaeorderEntity.SHIPPERID.ToString().Trim();
TopSeaeEntity.CONSIGNEEID = CrmSeaeorderEntity.CONSIGNEEID.ToString().Trim();
TopSeaeEntity.NOTIFYPARTYID = CrmSeaeorderEntity.NOTIFYPARTYID.ToString().Trim();
TopSeaeEntity.SHIPPER = CrmSeaeorderEntity.SHIPPER.ToString().Trim();
TopSeaeEntity.CONSIGNEE = CrmSeaeorderEntity.CONSIGNEE.ToString().Trim();
TopSeaeEntity.NOTIFYPARTY = CrmSeaeorderEntity.NOTIFYPARTY.ToString().Trim();
TopSeaeEntity.ETD = CrmSeaeorderEntity.ETD;
TopSeaeEntity.ISSUETYPE = CrmSeaeorderEntity.ISSUETYPE.ToString().Trim();
TopSeaeEntity.PORTLOADID = CrmSeaeorderEntity.PORTLOADID.ToString().Trim();
TopSeaeEntity.PORTLOAD = CrmSeaeorderEntity.PORTLOAD.ToString().Trim();
TopSeaeEntity.PORTDISCHARGEID = CrmSeaeorderEntity.PORTDISCHARGEID.ToString().Trim();
TopSeaeEntity.PORTDISCHARGE = CrmSeaeorderEntity.PORTDISCHARGE.ToString().Trim();
TopSeaeEntity.PKGS = CrmSeaeorderEntity.PKGS;
TopSeaeEntity.KINDPKGS = CrmSeaeorderEntity.KINDPKGS.ToString().Trim();
TopSeaeEntity.NOPKGS = CrmSeaeorderEntity.PKGS + " " + CrmSeaeorderEntity.KINDPKGS.ToString().Trim();
TopSeaeEntity.TOTALNO = CrmSeaeorderEntity.TOTALNO.ToString().Trim();
TopSeaeEntity.KGS = CrmSeaeorderEntity.KGS;
TopSeaeEntity.CBM = CrmSeaeorderEntity.CBM;
TopSeaeEntity.GROSSWEIGHT = CrmSeaeorderEntity.KGS.ToString().Trim();
TopSeaeEntity.MEASUREMENT = CrmSeaeorderEntity.CBM.ToString().Trim();
TopSeaeEntity.MARKS = CrmSeaeorderEntity.MARKS.ToString().Trim();
TopSeaeEntity.DESCRIPTION = CrmSeaeorderEntity.DESCRIPTION.ToString().Trim();
TopSeaeEntity.OP = CrmSeaeorderEntity.OP.ToString().Trim();
TopSeaeEntity.DOC = CrmSeaeorderEntity.DOC.ToString().Trim();
TopSeaeEntity.STLNAME = CrmSeaeorderEntity.STLNAME.ToString().Trim();
TopSeaeEntity.STLDATE = CrmSeaeorderEntity.STLDATE;
TopSeaeEntity.ISSUEDATE = CrmSeaeorderEntity.ETD;
TopSeaeEntity.ISSUEPLACE = CrmSeaeorderEntity.PORTDISCHARGE.ToString().Trim();
TopSeaeEntity.REMARK = CrmSeaeorderEntity.REMARK.ToString().Trim();
//
TopSeaeEntity.MASTERNO = CrmSeaeorderEntity.ORDNO.ToString().Trim();
TopSeaeEntity.BSSTATUS = false;//"接受委托";
TopSeaeEntity.FEESTATUS = false;//"未锁定";
TopSeaeEntity.ORDERTYPE = "销售订舱";
//TopSeaeEntity.BSDATE = DateTime.Today.Date;
string strdate = T_ALL_DA.GetStrSQL("strdate", "select getdate() as strdate");
TopSeaeEntity.ACCDATE = DateTime.Parse(strdate).Year.ToString().Trim() + "-" + DateTime.Parse(strdate).Month.ToString().Trim();
TopSeaeEntity.MBLNO = "";
TopSeaeEntity.HBLNO = getCodeRule("分提单号", "HBLNO");//调用编码规则
TopSeaeEntity.CUSTNO = getCodeRule("委托编号", "CUSTNO");//调用编码规则
TopSeaeEntity.TRANSNO = "";
TopSeaeEntity.AGENTID = "";
TopSeaeEntity.AGENT = "";
TopSeaeEntity.YARD = "";
TopSeaeEntity.VESSEL = "";
TopSeaeEntity.VOYNO = "";
TopSeaeEntity.PlACERECEIPTID = "";
TopSeaeEntity.PlACERECEIPT = "";
TopSeaeEntity.PLACEDELIVERYID = "";
TopSeaeEntity.PLACEDELIVERY = "";
TopSeaeEntity.DESTINATIONID = "";
TopSeaeEntity.DESTINATION = "";
TopSeaeEntity.NOBILL = "";
TopSeaeEntity.BLFRT = T_ALL_DA.GetStrSQL("BLFRT", "select BLFRT from subcomp_seae_def where CORPID=(select GID from company where GID='" + this.hdCOMPANYID.Value.Trim() + "' and ISDELETED=0)");
TopSeaeEntity.PREPARDAT = "";
TopSeaeEntity.PAYABLEAT = "";
TopSeaeEntity.SERVICE = T_ALL_DA.GetStrSQL("SERVICE", "select SERVICE from subcomp_seae_def where CORPID=(select GID from company where GID='" + this.hdCOMPANYID.Value.Trim() + "' and ISDELETED=0)");
TopSeaeEntity.CNTRSEALNO = "";
TopSeaeEntity.GOODSNAME = "";
TopSeaeEntity.CNTRNO = "";
TopSeaeEntity.CNTR1 = 0;
TopSeaeEntity.CNTR2 = 0;
TopSeaeEntity.CNTR3 = 0;
TopSeaeEntity.CNTR4 = 0;
TopSeaeEntity.CNTR5 = 0;
TopSeaeEntity.CNTR6 = 0;
TopSeaeEntity.CNTR7 = 0;
TopSeaeEntity.CNTR8 = 0;
TopSeaeEntity.CNTR9 = 0;
TopSeaeEntity.CNTR10 = 0;
TopSeaeEntity.OTCNTR = 0;
TopSeaeEntity.TEU = 0;
TopSeaeEntity.CNTRTOTAL = "";
TopSeaeEntity.INPUTBY = CrmSeaeorderEntity.INPUTBY.Trim();
TopSeaeEntity.LANE = T_ALL_DA.GetStrSQL("LANE", "SELECT code_lanes.LANE FROM code_lanes INNER JOIN code_disport ON code_lanes.GID = code_disport.LANEGID WHERE (code_disport.PORT = '" + TopSeaeEntity.PORTDISCHARGE.ToString().Trim() + "')");
TopSeaeEntity.CUSTOMSER = "";
TopSeaeEntity.TRUCKER = "";
TopSeaeEntity.INVNO = "";
TopSeaeEntity.CARGOID = "";
TopSeaeEntity.DCLASS = "";
TopSeaeEntity.DUNNO = "";
TopSeaeEntity.REEFERF = "";
TopSeaeEntity.TEMPID = "";
TopSeaeEntity.TEMPSET = "";
TopSeaeEntity.TEMPMAX = "";
TopSeaeEntity.TEMPMIN = "";
TopSeaeEntity.BSSOURCE = "";
TopSeaeEntity.BSSOURCEDETAIL = "";
TopSeaeEntity.CUSTOMSNUM = 0;
TopSeaeEntity.CONTRACTNO = "";
TopSeaeEntity.ORDTYPE = "";
TopSeaeEntity.ORDERNO = "";
TopSeaeEntity.INSURANCEER = "";
TopSeaeEntity.INSURANCENO = "";
TopSeaeEntity.INAMOUT = 0;
TopSeaeEntity.ISVOU = false;
TopSeaeEntity.VOUNO = "";
TopSeaeEntity.STATUS1 = false;
TopSeaeEntity.STATUS2 = false;
TopSeaeEntity.STATUS3 = false;
TopSeaeEntity.STATUS4 = false;
TopSeaeEntity.STATUS5 = false;
TopSeaeEntity.CUSTSERVICE = "";
TopSeaeEntity.PACKINGTYPE = "";
TopSeaeEntity.WAREHOUSE = "";
TopSeaeEntity.CORPID = "";
TopSeaeEntity.SALEDEPT = "";
TopSeaeEntity.MBLFRT = "";
//
TopSeaeEntity.OPERATOR = "";
TopSeaeEntity.OPERATORTEL = "";
TopSeaeEntity.OPERATORFAX = "";
TopSeaeEntity.OPERATOREMAIL = "";
TopSeaeEntity.FINANCIALSTAFF = "";
TopSeaeEntity.FINANCIALSTAFFTEL = "";
TopSeaeEntity.FINANCIALSTAFFFAX = "";
TopSeaeEntity.FINANCIALSTAFFEMAIL = "";
TopSeaeEntity.OPERATORCODE = "";
TopSeaeEntity.FINANCIALSTAFFCODE = "";
//
//int iResult = SeaExportInfoDA.InserInfo(TopSeaeEntity);
//获取订舱信息关联的费用信息
IList<CrmOrderFeeEntity> crmOrderFeeEntities = new List<CrmOrderFeeEntity>();
CrmOrderFeeDA crmOrderFeeDA = new CrmOrderFeeDA();
crmOrderFeeEntities = crmOrderFeeDA.GetFeeByBSNO(TopSeaeEntity.BSNO);
//将订舱信息和订舱费用分别插入海运出口委托表和费用表
int iResult = CrmSeaeorderDA.AuditPassCopyToOpSeae(TopSeaeEntity, crmOrderFeeEntities, strUserID);//SeaExportInfoDA.InserInfo(TopSeaeEntity);
if (iResult > 0)
{
/*
DataSet ds = CrmSeaeorderctnDA.GetFieldAll(" and ORDNO='" + this.hd_ORDNO.Value.Trim() + "'");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
string alt = T_ALL_DA.GetCTNCODEInsert(this.hd_ORDNO.Value.Trim(), strUserID.Trim(), myRow["CTNALL"].ToString().Trim(), int.Parse(myRow["CTNNUM"].ToString().Trim()), myRow["CTN_ID"].ToString().Trim(), myRow["REMARK"].ToString().Trim(), "", "");
if (alt != "")
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
}
}
}
}
//
int iii = CrmSeaeorderDA.UpdateInfoCNTRTOTAL("update crm_seaeorder set ORREASON='',ORSTATUS='0' where ORDNO='" + this.hd_ORDNO.Value.Trim() + "'", strUserID.Trim());
if (iii == 1)
{
bool bl = T_ALL_DA.GetExecuteSqlCommand("update crm_seaeorder set AUDITOPERATOR='" + strUserID.Trim() + "',AUDITDATE=getdate() where ORDNO='" + this.hd_ORDNO.Value.Trim() + "'");
return;
}
else
{
Response.Write("<script>alert('销售订舱状态改变出错!');history.back();</script>");
return;
}
*/
UserDA userDA = new UserDA();
UserEntity userEntity = new UserEntity();
userEntity = userDA.GetUserAllBySHOWNAME(CrmSeaeorderEntity.INPUTBY);
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
//插入消息提醒
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "SeaOrderAudit";
messageEntity.Description = "销售订舱审核通知";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 已批准通过您的 [销售订舱审核] 申请 ";
messageEntity.TaskID = "";
messageEntity.Receiver = userEntity.Gid;
messageEntity.TaskUrl = "shipping/SeaeOrderList.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.SEAORDERAUDIT);
messageEntity.RecvType = 3;//审核完成类型
messageEntities.Add(messageEntity);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.SEAORDERAUDIT, messageEntities);
}
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>ShowDetailFresh();</script>");
return;
}
else if (iResult == -3)
{
Response.Write("<script>alert('订舱信息写入委托表出错!');history.back();</script>");
return;
}
else if (iResult == -4)
{
Response.Write("<script>alert('插入订舱的费用!');history.back();</script>");
return;
}
else if (iResult == -5)
{
Response.Write("<script>alert('更新订舱费用ISSUBMIT2FEE字段出错');history.back();</script>");
return;
}
else if (iResult == -6)
{
Response.Write("<script>alert('更新委托的集装箱大写和TEU出错');history.back();</script>");
return;
}
else if (iResult == -7)
{
Response.Write("<script>alert('插入集装箱明细出错!');history.back();</script>");
return;
}
else if (iResult == -8)
{
Response.Write("<script>alert('更改销售订舱状态、审核人、审核时间!');history.back();</script>");
return;
}
else if (iResult == -9)
{
Response.Write("<script>alert('更新委托的集装箱大写和箱封号!');history.back();</script>");
return;
}
else
{
Response.Write("<script>alert('提交销售订舱委托出错!');history.back();</script>");
return;
}
}
}
/// <summary>
/// 提取规则编号
/// </summary>
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <returns></returns>
protected String getCodeRule(string strRULENAME, string strfield)
{
//调用编码规则
string strRULEYEAR = "";
string strRULECONTENT = "";
string strCODENAME = "";
string strDEPTNO = "";
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
string strCONTENT = "";
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=1");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
//getCodeRuleEnabled(strRULENAME, strfield);
//
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
{
if (TopSeaeEntity.ETD.ToString().Trim() == "")
{
return "";
}
DateTime dETD = System.Convert.ToDateTime(TopSeaeEntity.ETD.ToString().Trim());
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("会计期间"))
{
if (TopSeaeEntity.ACCDATE.ToString().Trim() == "")
{
return "";
}
else
{
DateTime dACCDATE = System.Convert.ToDateTime(TopSeaeEntity.ACCDATE.ToString().Trim() + "-01");
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dACCDATE.ToString("yyyy") + dACCDATE.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dACCDATE.ToString("yy") + dACCDATE.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dACCDATE.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dACCDATE.ToString("yy");
}
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
{
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy");
}
}
}
//
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
}
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
//
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
strCONTENT = strRULECONTENT + strRULEYEAR;
//获取分公司的票号头字符
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
strCONTENT = tempBANKSHEAD + strCONTENT;
//
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [op_seae] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + 1;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strCONTENT = strCONTENT + strRULENOLENGTH;
return strCONTENT;
}
}
}
return "";
}
#region Grid参数
private void SaveColumnSetting(string tempColumnVal)
{
JsonColumnGroupEntity jsonColumnGroupEntity = GetPostEntity(tempColumnVal);
List<JsonColumnEntity> jsonColumnEntities = new List<JsonColumnEntity>();
UserSettingDA userSettingDA = new UserSettingDA();
UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType);
if (userSettingEntity.GID != null)
{
userSettingEntity.ModifiedUser = strUserID;
GridEntity gridEntity = null;
List<GridColumnEntity> gridColumnEntities = new List<GridColumnEntity>();
gridEntity = GetSettingXml(userSettingEntity.Xml);
gridEntity.PagePreCount = jsonColumnGroupEntity.ShowCount;
foreach (JsonColumnEntity jColumn in jsonColumnGroupEntity.JsonColumnEntities)
{
foreach (GridColumnEntity gColumn in gridEntity.Columns)
{
if (gColumn.Description.Equals(jColumn.col3))
{
gColumn.Description = jColumn.col3;
gColumn.Width = jColumn.col5;
gColumn.Index = jColumn.col4;
if (jColumn.col6 != -1)
{
gColumn.VisibleState = jColumn.col6;
}
//gridColumnEntities.Add(gColumn);
break;
}
}
}
//Columns
//gridEntity.Columns = gridColumnEntities;
userSettingEntity.Xml = SaveUserSetting(gridEntity).OuterXml;
int iResult = userSettingDA.UpdateUserSetting(userSettingEntity);
}
else
{
if (jsonColumnGroupEntity != null)
{
userSettingEntity = new UserSettingEntity();
userSettingEntity.GID = Guid.NewGuid().ToString();
userSettingEntity.Name = "SeaeOrderAuditGridSetting";
userSettingEntity.Description = "销售订舱Grid设置";
userSettingEntity.UserID = strUserID;
userSettingEntity.Type = 1;//type值为1表示Grid
string strRequestUrl = Request.Url.ToString();
string strUrl = strRequestUrl.Substring(0, strRequestUrl.LastIndexOf("/"));
string strPage = strRequestUrl.Substring(strRequestUrl.LastIndexOf("/") + 1, strRequestUrl.Length - strRequestUrl.LastIndexOf("/") - 1);
userSettingEntity.Url = strUrl;
userSettingEntity.Page = strPage;
userSettingEntity.CreateUser = strUserID;
GridEntity gridEntity = new GridEntity();
gridEntity.GID = userSettingEntity.GID;
gridEntity.UserID = strUserID;
gridEntity.GroupBy = "";
gridEntity.DefaultPrePageCount = 15;
gridEntity.PagePreCount = jsonColumnGroupEntity.ShowCount;
List<GridColumnEntity> gridColumnEntities = new List<GridColumnEntity>();
foreach (JsonColumnEntity column in jsonColumnGroupEntity.JsonColumnEntities)
{
GridColumnEntity gridColumnEntity = new GridColumnEntity();
if (column.col6 != -1)
{
gridColumnEntity.Name = column.col2;
gridColumnEntity.VisibleState = column.col6;
}
else
{
switch (column.col3.Trim())
{
case "订舱状态":
gridColumnEntity.Name = "ORSTATUS";
break;
case "委托单位":
gridColumnEntity.Name = "CUSTOMERNAME";
break;
case "揽货人":
gridColumnEntity.Name = "SALE";
break;
case "操作":
gridColumnEntity.Name = "OP";
break;
case "单证":
gridColumnEntity.Name = "DOC";
break;
case "开船日期":
gridColumnEntity.Name = "ETD";
break;
case "集装箱":
gridColumnEntity.Name = "CNTRTOTAL";
break;
case "船公司":
gridColumnEntity.Name = "CARRIER";
break;
case "订舱代理":
gridColumnEntity.Name = "FORWARDER";
break;
case "录入人":
gridColumnEntity.Name = "INPUTBY";
break;
case "录入日期":
gridColumnEntity.Name = "BSDATE";
break;
case "审核人":
gridColumnEntity.Name = "AUDITOPERATOR";
break;
case "审核日期":
gridColumnEntity.Name = "AUDITDATE";
break;
}
gridColumnEntity.VisibleState = 0;
}
gridColumnEntity.Description = column.col3;
gridColumnEntity.Index = column.col4;
gridColumnEntity.Width = column.col5;
gridColumnEntities.Add(gridColumnEntity);
}
//Columns
gridEntity.Columns = gridColumnEntities;
userSettingEntity.Xml = SaveUserSetting(gridEntity).OuterXml;
int iResult = userSettingDA.InsertUserSetting(userSettingEntity);
dvSaveState.InnerHtml = iResult.ToString();
}
}
}
#region 获取列信息
/// <summary>
/// 获取列信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
private JsonColumnGroupEntity GetPostEntity(string tempValue)
{
JsonColumnGroupEntity tempColumnGroupEntity = new JsonColumnGroupEntity();
try
{
tempColumnGroupEntity = (JsonColumnGroupEntity)JSON.Instance.ToObject(tempValue);
}
catch (Exception error)
{
throw error;
}
return tempColumnGroupEntity;
}
#endregion
private XmlDocument SaveUserSetting(GridEntity gridEntity)
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement root = xmlDoc.CreateElement("user-settings");
//xmlDoc.AppendChild(root);
XmlElement xGid = xmlDoc.CreateElement("gid");
xGid.InnerText = gridEntity.GID;
root.AppendChild(xGid);
XmlElement xUserID = xmlDoc.CreateElement("userid");
xUserID.InnerText = gridEntity.UserID;
root.AppendChild(xUserID);
XmlElement xCreateTime = xmlDoc.CreateElement("create-time");
xCreateTime.InnerText = gridEntity.CreateTime.ToString();
root.AppendChild(xCreateTime);
XmlElement xColumns = xmlDoc.CreateElement("columns");
foreach (GridColumnEntity column in gridEntity.Columns)
{
XmlElement xColumn = xmlDoc.CreateElement("column");
XmlElement nName = xmlDoc.CreateElement("name");
nName.InnerText = column.Name;
xColumn.AppendChild(nName);
XmlElement nDescription = xmlDoc.CreateElement("description");
nDescription.InnerText = column.Description;
xColumn.AppendChild(nDescription);
XmlElement nIndex = xmlDoc.CreateElement("index");
nIndex.InnerText = column.Index.ToString();
xColumn.AppendChild(nIndex);
XmlElement nWidth = xmlDoc.CreateElement("width");
nWidth.InnerText = column.Width.ToString();
xColumn.AppendChild(nWidth);
XmlElement nVisible = xmlDoc.CreateElement("visible");
nVisible.InnerText = column.VisibleState.ToString();
xColumn.AppendChild(nVisible);
xColumns.AppendChild(xColumn);
}
root.AppendChild(xColumns);
XmlElement xGroupBy = xmlDoc.CreateElement("group-by");
xGroupBy.InnerText = gridEntity.GroupBy;
root.AppendChild(xGroupBy);
XmlElement xPage = xmlDoc.CreateElement("page");
XmlElement nPageDefault = xmlDoc.CreateElement("page-default");
nPageDefault.InnerText = gridEntity.DefaultPrePageCount.ToString();
xPage.AppendChild(nPageDefault);
XmlElement nPagePre = xmlDoc.CreateElement("page-pre");
nPagePre.InnerText = gridEntity.PagePreCount.ToString();
xPage.AppendChild(nPagePre);
root.AppendChild(xPage);
xmlDoc.AppendChild(root);
return xmlDoc;
}
private GridEntity GetSettingXml(string strXml)
{
XmlDocument xmlSettingDoc = new XmlDocument();
GridEntity gridEntity = new GridEntity();
try
{
xmlSettingDoc.LoadXml(strXml);
gridEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[0].InnerText.Trim();
gridEntity.UserID = xmlSettingDoc.ChildNodes[0].ChildNodes[1].InnerText.Trim();
gridEntity.CreateTime = DateTime.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[2].InnerText.Trim());
IList<GridColumnEntity> columnsEntities = new List<GridColumnEntity>();
int iColCount = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes.Count;
for (int i = 0; i < iColCount; i++)
{
GridColumnEntity columnEntity = new GridColumnEntity();
//columnEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[0].ToString();
columnEntity.Name = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[0].InnerText.Trim();
columnEntity.Description = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[1].InnerText.Trim();
columnEntity.Index = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[2].InnerText.Trim());
columnEntity.Width = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[3].InnerText.Trim());
columnsEntities.Add(columnEntity);
}
gridEntity.Columns = columnsEntities;
gridEntity.GroupBy = xmlSettingDoc.ChildNodes[0].ChildNodes[4].InnerText.Trim();
gridEntity.DefaultPrePageCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[0].InnerText.Trim());
gridEntity.PagePreCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[1].InnerText.Trim());
}
catch (Exception error)
{
throw (error);
}
return gridEntity;
}
public enum SqlName
{
NAME = 0,
LOGTYPE = 1,
LOGTIME = 2,
LOGCONTENT = 3,
USERNAME = 4
}
#endregion
}
}