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.IO; using System.Text; using System.Text.RegularExpressions; using DSWeb.Authority; namespace DSCustomer.PriceCarrier { public partial class EBPricequeryList : System.Web.UI.Page { CrmPriceCarrierDA CrmPriceCarrierDA = new CrmPriceCarrierDA(); RangeDA RangeDA = new RangeDA(); public string strUserID;//用户GID //grid private string strColumnVal; private string strType = "27";//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 = ""; } // /* //权限可视范围 this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modEBPricequeryList"); this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modEBPricequeryList"); this.hdRange.Value = ""; //if (this.hdRangeV.Value.Trim() != this.hdRangeO.Value.Trim()) //{ this.hdRange.Value = ""; if (this.hdRangeO.Value.Trim().Equals("4"))//无 { this.imgAdd.Disabled = true; this.imgEdit.Disabled = true; this.imgDel.Disabled = true; } //} */ //grid if (!IsPostBack) { strUserID = strUserID.Trim(); } 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 = ""; } //gridEnd } protected void btDel_Click(object sender, EventArgs e) { if (this.hid_id.Value.Trim() != "") { CrmPriceCarrierEntity CrmPriceCarrierEntity = new CrmPriceCarrierEntity(); CrmPriceCarrierDA CrmPriceCarrierDA = new CrmPriceCarrierDA(); CrmPriceCarrierEntity = CrmPriceCarrierDA.GetID(this.hid_id.Value.Trim()); if (CrmPriceCarrierEntity.GID != null) { string alt = CrmPriceCarrierEntity.LOCKFLAG.ToString().Trim(); if (alt.Trim().Equals("1")) { Response.Write(""); return; } else { alt = CrmPriceCarrierDA.GetCrmPriceCarrierDel(this.hid_id.Value.Trim(), strUserID.Trim()); if (alt != "") { Response.Write(""); return; } else { return; } } } else { Response.Write(""); return; } } } protected void btSubmit_Click(object sender, EventArgs e) { string alt = ""; string[] sLOCKFLAGGID = this.hdLOCKFLAGGID.Value.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sLOCKFLAGGID.Length; i++) { alt += " or GID='" + sLOCKFLAGGID[i].ToString().Trim() + "'"; } int iii = 0; if (this.isLOCKFLAGGID.Value.Trim().Equals("0")) { iii = CrmPriceCarrierDA.UpdateInfoCNTRTOTAL("update crm_price_carrier set LOCKFLAG='0' where 1=0 " + alt, strUserID.Trim()); } else { iii = CrmPriceCarrierDA.UpdateInfoCNTRTOTAL("update crm_price_carrier set LOCKFLAG='1' where 1=0 " + alt, strUserID.Trim()); } if (iii == 1) { Response.Write(""); return; } else { Response.Write(""); return; } } protected void btIssue_Click(object sender, EventArgs e) { EBPricequeryDA EBPricequeryDA = new EBPricequeryDA(); EBPricequeryEntity EBPricequeryEntity1 = new EBPricequeryEntity(); IList EBPricequeryEntities = new List(); CrmPriceCarrierEntity CrmPriceCarrierEntity = new CrmPriceCarrierEntity(); CrmPriceCarrierDA CrmPriceCarrierDA = new CrmPriceCarrierDA(); T_ALL_DA T_ALL_DA = new T_ALL_DA(); string alt = ""; string strError = ""; string[] sISSUEGID = this.hdISSUEGID.Value.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sISSUEGID.Length; i++) { alt += " or LINKGID='" + sISSUEGID[i].ToString().Trim() + "'"; } int iii = 0; if (this.isISSUE.Value.Trim().Equals("0")) { strError = EBPricequeryDA.GetEBPricequeryDel(alt, strUserID.Trim()); } else { for (int i = 0; i < sISSUEGID.Length; i++) { EBPricequeryEntities = EBPricequeryDA.GetEBPricequeryByLINKGID(sISSUEGID[i].ToString().Trim()); CrmPriceCarrierEntity = CrmPriceCarrierDA.GetID(sISSUEGID[i].ToString().Trim()); string sSHOWNAME = T_ALL_DA.GetStrSQL("SHOWNAME", "select SHOWNAME from [user] where GID ='" + strUserID + "'"); // if (EBPricequeryEntities.Count > 0) { foreach (EBPricequeryEntity EBPricequeryEntity in EBPricequeryEntities) { if (EBPricequeryEntity.LEVEL.ToString().Trim().Equals("1")) { EBPricequeryEntity1.GID = EBPricequeryEntity.GID; EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP1; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP1; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ1; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ1; EBPricequeryEntity1.LEVEL = "1"; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; iii = EBPricequeryDA.UpdateInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",更新GID‘" + EBPricequeryEntity.GID.ToString() + "’"; } } else if (EBPricequeryEntity.LEVEL.ToString().Trim().Equals("2")) { EBPricequeryEntity1.GID = EBPricequeryEntity.GID; EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP2; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP2; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ2; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ2; EBPricequeryEntity1.LEVEL = "2"; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; iii = EBPricequeryDA.UpdateInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",更新GID‘" + EBPricequeryEntity.GID.ToString() + "’"; } } else if (EBPricequeryEntity.LEVEL.ToString().Trim().Equals("3")) { EBPricequeryEntity1.GID = EBPricequeryEntity.GID; EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP3; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP3; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ3; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ3; EBPricequeryEntity1.LEVEL = "3"; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; iii = EBPricequeryDA.UpdateInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",更新GID‘" + EBPricequeryEntity.GID.ToString() + "’"; } } } } else { EBPricequeryEntity1.GID = getBSNO(); EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP1; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP1; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ1; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ1; EBPricequeryEntity1.LEVEL = "1"; EBPricequeryEntity1.INPUTBY = sSHOWNAME; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; EBPricequeryEntity1.LINKGID = CrmPriceCarrierEntity.GID; iii = EBPricequeryDA.InserInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",插入GID‘" + EBPricequeryEntity1.GID.ToString() + "’"; } // EBPricequeryEntity1.GID = getBSNO(); EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP2; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP2; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ2; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ2; EBPricequeryEntity1.LEVEL = "2"; EBPricequeryEntity1.INPUTBY = sSHOWNAME; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; EBPricequeryEntity1.LINKGID = CrmPriceCarrierEntity.GID; iii = EBPricequeryDA.InserInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",插入GID‘" + EBPricequeryEntity1.GID.ToString() + "’"; } // EBPricequeryEntity1.GID = getBSNO(); EBPricequeryEntity1.PODLOAD = CrmPriceCarrierEntity.PODLOAD; EBPricequeryEntity1.PORTDISCHARGE = CrmPriceCarrierEntity.PORTDISCHARGE; EBPricequeryEntity1.DESTINATION = CrmPriceCarrierEntity.DESTINATION; EBPricequeryEntity1.VIA = CrmPriceCarrierEntity.VIA; EBPricequeryEntity1.POC = CrmPriceCarrierEntity.POC; EBPricequeryEntity1.LANE = CrmPriceCarrierEntity.LANE; EBPricequeryEntity1.CARRIERLANE = CrmPriceCarrierEntity.CARRIERLANE; EBPricequeryEntity1.CARRIE = CrmPriceCarrierEntity.CARRIE; EBPricequeryEntity1.FORWARDER = CrmPriceCarrierEntity.FORWARDER; EBPricequeryEntity1.ETD = CrmPriceCarrierEntity.ETD; EBPricequeryEntity1.TT = CrmPriceCarrierEntity.TT; EBPricequeryEntity1.SVC = CrmPriceCarrierEntity.SVC; EBPricequeryEntity1.SC = CrmPriceCarrierEntity.SC; EBPricequeryEntity1.NAMEAC = CrmPriceCarrierEntity.NAMEAC; EBPricequeryEntity1.SICUT = CrmPriceCarrierEntity.SICUT; EBPricequeryEntity1.CUSCLSG = CrmPriceCarrierEntity.CUSCLSG; EBPricequeryEntity1.CYCLSG = CrmPriceCarrierEntity.CYCLSG; EBPricequeryEntity1.OWS = CrmPriceCarrierEntity.OWS; EBPricequeryEntity1.COMMODITY = CrmPriceCarrierEntity.COMMODITY; EBPricequeryEntity1.D_20GP = CrmPriceCarrierEntity.D_20GP3; EBPricequeryEntity1.D_40GP = CrmPriceCarrierEntity.D_40GP3; EBPricequeryEntity1.D_40HQ = CrmPriceCarrierEntity.D_40HQ3; EBPricequeryEntity1.D_45HQ = CrmPriceCarrierEntity.D_45HQ3; EBPricequeryEntity1.LEVEL = "3"; EBPricequeryEntity1.INPUTBY = sSHOWNAME; EBPricequeryEntity1.MODIFIEDUSER = sSHOWNAME; EBPricequeryEntity1.LINKGID = CrmPriceCarrierEntity.GID; iii = EBPricequeryDA.InserInfo(EBPricequeryEntity1); if (iii < 1) { strError += ",插入GID‘" + EBPricequeryEntity1.GID.ToString() + "’"; } } } } if (strError.Trim().Equals("")) { Response.Write(""); return; } else { Response.Write(""); return; } } protected String getBSNO() { string strBSNO = Guid.NewGuid().ToString(); strBSNO = strBSNO.Replace("-", ""); strBSNO = "EBPQ" + strBSNO; return strBSNO; } protected void btSelect_Click(object sender, EventArgs e) { string alt = ""; if(!this.hd_comboPODLOAD.Value.Trim().Equals("")) { alt += ",起运港‘"+this.hd_comboPODLOAD.Value.Trim()+"’"; } if(!this.hd_comboPORTDISCHARGE.Value.Trim().Equals("")) { alt += ",卸货港‘"+this.hd_comboPORTDISCHARGE.Value.Trim()+"’"; } if(!this.hd_comboCARRIE.Value.Trim().Equals("")) { alt += ",船名‘"+this.hd_comboCARRIE.Value.Trim()+"’"; } if(!this.hd_comboLANE.Value.Trim().Equals("")) { alt += ",航线‘"+this.hd_comboLANE.Value.Trim()+"’"; } // if (alt.Trim() != "") { alt = alt.Trim().Substring(1); T_ALL_DA T_ALL_DA = new T_ALL_DA(); bool bl = T_ALL_DA.GetEBPricequeryListLOG(alt, strUserID); if (bl) { } else { } } } protected void btExcel1_Click(object sender, EventArgs e) { setExcelReport(); } protected void setExcelReport() { StringWriter sw = new StringWriter(); string sSQL = ""; //sw.WriteLine("结算单位\t委托编号\t主提单号\t分提单号\t船名\t航次\tETD\t目的港\t揽货人\t应收RMB\t实收RMB\t应收USD\t实收USD\t余额"); sw.WriteLine(this.hdNAMES.Value.Trim()); T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet DS = T_ALL_DA.GetAllSQL(this.hdSQL.Value.Trim()); foreach (DataTable myTable in DS.Tables) { foreach (DataRow myRow in myTable.Rows)//遍历表 { sSQL = ""; for (int i = 0; i < myTable.Columns.Count; i++) { if (sSQL.Trim() != "") { sSQL += "\t"; } if (myRow[i].ToString() == null || myRow[i].ToString() == "") { sSQL += ""; if (sSQL.Trim() == "") { sSQL += "\t"; } } else { sSQL += myRow[i].ToString().Trim(); } } sw.WriteLine(sSQL); } } // sw.Close(); switch ("MUEXCEL") { case "MUEXCEL": Response.AddHeader("Content-Disposition", "attachment; filename=report.xls"); Response.ContentType = "application/ms-excel"; break; case "MUTEXT": Response.AddHeader("Content-Disposition", "attachment; filename=report.txt"); Response.ContentType = "application/txt"; break; case "MUWORD": Response.AddHeader("Content-Disposition", "attachment; filename=report.doc"); Response.ContentType = "application/ms-word"; break; case "MUPDF": Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf"); Response.ContentType = "application/pdf"; break; case "MUXML": Response.AddHeader("Content-Disposition", "attachment; filename=report.xml"); Response.ContentType = "application/xml"; break; } Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.Write(sw); Response.End(); } #region Grid参数 private void SaveColumnSetting(string tempColumnVal) { JsonColumnGroupEntity jsonColumnGroupEntity = GetPostEntity(tempColumnVal); List jsonColumnEntities = new List(); UserSettingDA userSettingDA = new UserSettingDA(); UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType); if (userSettingEntity.GID != null) { userSettingEntity.ModifiedUser = strUserID; GridEntity gridEntity = null; List gridColumnEntities = new List(); 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 = "EBPricequeryListGridSetting"; 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 gridColumnEntities = new List(); 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 = "CARRIE"; break; case "起运港": gridColumnEntity.Name = "PODLOAD"; break; case "卸货港": gridColumnEntity.Name = "PORTDISCHARGE"; break; case "目的地": gridColumnEntity.Name = "DESTINATION"; break; case "中转港": gridColumnEntity.Name = "VIA"; break; case "ETD": gridColumnEntity.Name = "ETD"; break; case "航程": gridColumnEntity.Name = "TT"; break; case "航线": gridColumnEntity.Name = "LANE"; break; case "20GP": gridColumnEntity.Name = "D_20GP"; break; case "40GP": gridColumnEntity.Name = "D_40GP"; break; case "40HQ": gridColumnEntity.Name = "D_40HQ"; break; case "45HQ": gridColumnEntity.Name = "D_45HQ"; 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 获取列信息 /// /// 获取列信息 /// /// /// 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 columnsEntities = new List(); 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 } }