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.

150 lines
7.8 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.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Data;
using System.Collections;
namespace DSWeb.UserSettings
{
public partial class GridSortSetting : System.Web.UI.Page
{
public string strUserID;//用户GID
private string strtableName;
public string strCompanyID;//公司GID
public string sSQL = String.Empty;
TopSeaeBillmanageEntity TopSeaeBillmanageEntity = new TopSeaeBillmanageEntity();
TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string[] strHeader = new string[] { "主提单号", "业务状态", "费用状态", "委托方式", "录入人", "录入日期", "船名", "航次", "开船日期", "发货人", "委托单位", "集装箱", "订舱代理", "揽货人", "操作", "单证", "客服", "航线", "装货港", "卸货港", "交货地", "目的地", "会计期间", "分提单号", "委托编号", "运单号", "装运方式", "场站", "截港日期", "预抵日期", "运输条款", "品名", "货物毛重", "货物尺码", "件数", "包装", "箱TEU", "船公司", "报关行", "承运车队", "发票号", "业务来源", "来源明细", "订舱类型", "订舱编号", "装箱类型", "仓库", "截单日期", "集港日期", "其他箱型" };
string[] strSortField = new string[] { "mblno", "bsstatus", "feestatus", "ordertype", "inputby", "bsdate", "vessel", "voyno", "etd", "shipperid", "customername", "cntrtotal", "forwarder", "sale", "op", "doc", "custservice", "lane", "portload", "portdischarge", "placedelivery", "destination", "accdate", "hblno", "custno", "transno", "bltype", "yard", "closingdate", "eta", "service", "goodsname", "kgs", "cbm", "pkgs", "kindpkgs", "teu", "carrier", "customser", "trucker", "invno", "bssource", "bssourcedetail", "ordtype", "orderno", "packingtype", "warehouse", "closedocdate", "intoportdate", "otcntr" };
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 (Request.QueryString["tablename"] != "")
{
strtableName = Request.QueryString["tablename"].ToString();
}
if (!IsPostBack)
{
//DataSet ds = T_ALL_DA.GetTableField(strtableName);
//foreach (DataTable myTable in ds.Tables)
//{
// foreach (DataRow myRow in myTable.Rows)//遍历表
// {
// string str = myRow["Explain"].ToString().Trim();
// int s = str.IndexOf(" ");
// if (s != -1)
// {
// str = str.Substring(0, s);
// }
// str = myRow["Field"].ToString().Trim() + " | " + str;
// ListBox2.Items.Add(new ListItem(str, myRow["Field"].ToString().Trim()));
// }
//}
for (int i = 0; i < strHeader.Length; i++)
{
string header = strHeader[i].ToString();
string sort = strSortField[i].ToString();
ListBox2.Items.Add(new ListItem(header,sort));
}
this.LoadDataHave();
}
}
/// <summary>
/// 加载数据库中的排列字段信息
/// </summary>
protected void LoadDataHave()
{
string strSQL = "SELECT CONTENT FROM [user_setting_gridsort] WHERE USERID='" + strUserID.Trim() + "' AND CORPID='" + strCompanyID.Trim() + "'";
string content = T_ALL_DA.GetStrSQL("CONTENT", strSQL);
ListBox3.Items.Clear();
if (content != "")
{
string[] contentArray = content.Trim().Split(',');
string orderType = "";
for (int i = 0; i < contentArray.Length; i++)
{
string conArSortVa1 = contentArray[i].ToString().ToLower().Split(' ')[0];
string orderSortVa2 = contentArray[i].ToString().ToLower().Split(' ')[1];
if (orderSortVa2.Trim() == "desc")
{
orderType = "倒序";
}
else if (orderSortVa2.Trim() == "asc")
{
orderType = "顺序";
}
for (int j = 0; j < strSortField.Length; j++)
{
if (conArSortVa1 == strSortField[j].ToLower().ToString())
{
ListBox3.Items.Add(new ListItem(strHeader[j].ToString() + " " + orderType, contentArray[i].ToString()));
}
}
}
}
}
protected void btnSaveSort_Click(object sender, EventArgs e)
{
string textvalue =this.hd_listbox3.Value;
//for (int i = 0; i < ListBox3.Rows; i++)
//{
// //if (ListBox3.Items[i].Selected)
// //{
// // ListBox2.Items.Remove(ListBox2.SelectedItem);//移除项==ListBox2.Items.RemoveAt(ListBox2.SelectedIndex);
// //}
// //textvalue += ListBox3.Items[i-1].Text + "&&";//获取所有项的值
//}
string strSQL = "SELECT * FROM [user_setting_gridsort] WHERE USERID='"+strUserID.Trim()+"' AND CORPID='"+strCompanyID.Trim()+"'";
string strSQLInsert = "INSERT [user_setting_gridsort](USERID,CORPID,TABLENAME,[CONTENT]) VALUES('" + strUserID.Trim() + "','" + strCompanyID.Trim() + "','"+strtableName.Trim()+"','"+textvalue+"') ";
string strSQLUpdate = "UPDATE [user_setting_gridsort] SET [CONTENT]='" + textvalue.Trim() + "' WHERE USERID='" + strUserID.Trim() + "' AND CORPID='" + strCompanyID.Trim() + "' ";
DataSet ds = T_ALL_DA.GetAllSQL(strSQL);//查看该操作人是否已经设置过该类信息,如果已存在则修改,如果不存在则添加
if (ds==null)
{
bool result = T_ALL_DA.GetExecuteSqlCommand(strSQLInsert);
if (result == true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>reloadParent();</script>");
//this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "<script>alert('保存成功!')</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('ok');</script>");
}
else
{
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "no", "<script>alert('保存失败,请重试!')</script>");
}
}
else
{
bool result = T_ALL_DA.GetExecuteSqlCommand(strSQLUpdate);
if (result == true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>reloadParent();</script>");
}
else
{
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "no", "<script>alert('保存失败,请重试!')</script>");
}
}
this.LoadDataHave();
}
}
}