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.
HENGCHENG/DSWeb/Shipping/SeaExportInfoBlissueSur.asp...

755 lines
33 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 DSWeb.Log;
namespace DSWeb.Shipping
{
public partial class SeaExportInfoBlissueSur : System.Web.UI.Page
{
TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
RangeDA RangeDA = new RangeDA();
//grid
private string recvJSON;
//private string strColumnVal;
public string strUserID = "";//"04eaeac5-f271-45d1-b17b-ad4ccbab63d0";
private string strType = "9";//Grid模块号
//gridEnd
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
}
else
{
//Session["USERID"] = "1BEC90E1-9780-472F-90C2-0C6390C044A4";
//strUserID = Session["USERID"].ToString().Trim();
Server.Transfer("~/Error/FriendError.aspx");
return;
}
//
//grid
if (!IsPostBack)
{
if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString().Trim() != "") //if (Request.QueryString["id"] != null)
{
this.hid_BSNO.Value = Request.QueryString["id"].ToString().Trim();
}
else
{
this.hid_BSNO.Value = "Crm07662c4ad6c8413c9f288c2c237ab364";//Crm38af2a417b1243c291022cf43bd88021
}
}
//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
//
//权限可视范围
this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modOrderManagement");
this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modOrderManagement");
//页面是否只读
if (Request.QueryString["hdenabled"] != null)
{
if (Request.QueryString["hdenabled"].ToString() == "false")
{
this.hdRangeO.Value = "4";
this.hdEnabled.Value = "false";
}
}
string alt = "";
if (this.hdRangeV.Value.Trim() != this.hdRangeO.Value.Trim())
{
if (this.hdRangeO.Value.Trim().Equals("0"))//全部
{
}
else if (this.hdRangeO.Value.Trim().Equals("1"))//分公司
{
alt = RangeDA.GetOrderManagementCompany(strUserID.Trim(), this.hid_BSNO.Value.Trim());
if (alt == "")
{
this.imgApply.Disabled = true;
this.imgAdd.Disabled = true;
this.hdqx.Value = "0";
//
this.divadd.Disabled = true;
this.divsave.Disabled = true;
this.divdel.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
{
alt = RangeDA.GetOrderManagementDEPT(strUserID.Trim(), this.hid_BSNO.Value.Trim());
if (alt == "")
{
this.imgApply.Disabled = true;
this.imgAdd.Disabled = true;
this.hdqx.Value = "0";
//
this.divadd.Disabled = true;
this.divsave.Disabled = true;
this.divdel.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
{
alt = RangeDA.GetOrderManagementPerson(strUserID.Trim(), this.hid_BSNO.Value.Trim());
if (alt == "")
{
this.imgApply.Disabled = true;
this.imgAdd.Disabled = true;
this.hdqx.Value = "0";
//
this.divadd.Disabled = true;
this.divsave.Disabled = true;
this.divdel.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("4"))//无
{
this.imgApply.Disabled = true;
this.imgAdd.Disabled = true;
this.hdqx.Value = "0";
//
this.divadd.Disabled = true;
this.divsave.Disabled = true;
this.divdel.Disabled = true;
}
}
//
recvJSON = "";
recvJSON = this.recvContainer.Value.Trim();
//
if (!recvJSON.Trim().Equals(""))
{
//应收账户保存
JsonOpBlissueGroupEntity OpBlissueGroupRecvEntity = GetPostEntity1(recvJSON);
List<JsonOpBlissueEntity> OpBlissueRecvEntities = new List<JsonOpBlissueEntity>();
OpBlissueRecvEntities = OpBlissueGroupRecvEntity.JsonOpBlissueEntities;
SaveRecvOpBlissue(OpBlissueGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvOpBlissue(JsonOpBlissueGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonOpBlissueEntity> OpBlissueEntities = new List<JsonOpBlissueEntity>();
OpBlissueEntities = tempGroupEntity.JsonOpBlissueEntities;
OpBlissueDA OpBlissueDA = new OpBlissueDA();
DataTable OpBlissueTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonOpBlissueEntities.Count > 0)
{
string BSNO = tempGroupEntity.JsonOpBlissueEntities[0].OpBlissue8.Trim();
strInitSql = " SELECT id,BLSTATUS,OPNAME,OPTIME,DElFLAG,ISADD,REMARK FROM op_blissue WHERE 1=1 AND BSNO = '" + BSNO + "'";
}
else
{
return;
}
OpBlissueTable = OpBlissueDA.GetOpBlissueByCondition(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < OpBlissueTable.Rows.Count; i++)
{
foreach (JsonOpBlissueEntity OpBlissue in OpBlissueEntities)
{
if (OpBlissueTable.Rows[i]["ID"].ToString().Trim().Equals(OpBlissue.OpBlissue1.Trim()))//惟一编号
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//处理状态
string strBLSTATUS = OpBlissue.OpBlissue2.Trim().ToLower().Equals("null") ? "" : OpBlissue.OpBlissue2.Trim();
if (!OpBlissueTable.Rows[i]["BLSTATUS"].ToString().Trim().Equals(strBLSTATUS))
{
strSql += String.Format(" BLSTATUS = '{0}'", strBLSTATUS);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "处理状态", OpBlissueTable.Rows[i]["BLSTATUS"].ToString().Trim(), strBLSTATUS);
}
//处理时间
string strOPTIME = OpBlissue.OpBlissue3.ToString().Trim().ToLower().Equals("null") ? "null" : OpBlissue.OpBlissue3.ToString().Trim();
if (!OpBlissueTable.Rows[i]["OPTIME"].ToString().Trim().Equals(strOPTIME))
{
if (strOPTIME.Trim().Equals("null") || strOPTIME.Trim().Equals(""))
{
strSql += String.Format(",OPTIME ={0}", strOPTIME);
}
else
{
strSql += String.Format(",OPTIME = '{0}'", strOPTIME);
}
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "处理时间", OpBlissueTable.Rows[i]["OPTIME"].ToString().Trim(), strOPTIME);
}
//处理人
string strOPNAME = OpBlissue.OpBlissue4.Trim().ToLower().Equals("null") ? "" : OpBlissue.OpBlissue4.Trim();
if (!OpBlissueTable.Rows[i]["OPNAME"].ToString().Trim().Equals(strOPNAME))
{
strSql += String.Format(",OPNAME = '{0}'", strOPNAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "处理人", OpBlissueTable.Rows[i]["OPNAME"].ToString().Trim(), strOPNAME);
}
//备注
string strREMARK = OpBlissue.OpBlissue7.Trim().ToLower().Equals("null") ? "" : OpBlissue.OpBlissue7.Trim();
if (!OpBlissueTable.Rows[i]["REMARK"].ToString().Trim().Equals(strREMARK))
{
strSql += String.Format(",REMARK = '{0}'", strREMARK);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", OpBlissueTable.Rows[i]["REMARK"].ToString().Trim(), strREMARK);
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
string strUpdateSql = String.Format("UPDATE {0} SET {1} WHERE ID = '{2}'", "op_blissue", strSql, OpBlissue.OpBlissue1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新账户标识 {0} {1}", OpBlissue.OpBlissue1.Trim(), LogContent));
}
OpBlissueEntities.Remove(OpBlissue);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = OpBlissueDA.UpdateOpBlissueFromGrid(sqlList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
#region 日志记录操作
// INSERT-"INSERT INTO {0} ({1}) VALUES ({2})" @{0}-所要插入记录的表;{1}记录字段值;{2}-记录新值@
//if (logList.Count > 0)
//{
// for (int i = 0; i < logList.Count; i++)
// {
// LogEntity logEntity = new LogEntity();
// logEntity.GID = Guid.NewGuid().ToString();
// logEntity.Name = "更新账户信息列表";
// logEntity.LogType = "UPDATE 更新操作";
// logEntity.CreateUserID = strUserID.Trim();//测试使用数据,正式发布请删除
// logEntity.LogContent = logList[i].ToString();
// log.WriteLog(logEntity);
// }
//}
#endregion
}
}
//如果遍历完所有费用表数据,没有相对应的费用信息,则将剩余的费用信息插入到费用表中
if (OpBlissueEntities.Count > 0)
{
//插入新的应收费用信息
InsertOpBlissue(OpBlissueEntities, 1);
}
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="OpBlissueEntities">需要插入账户表的账户实体类</param>
/// <param name="iType">如果iType值为1则记录账户类型为收/否则记录为付</param>
public void InsertOpBlissue(List<JsonOpBlissueEntity> OpBlissueEntities, int iType)
{
ArrayList sqlInsertList = new ArrayList();
OpBlissueDA OpBlissueDA = new OpBlissueDA();
foreach (JsonOpBlissueEntity OpBlissue in OpBlissueEntities)
{
string strItemSql = "";
string strValueSql = "";
string strInsertSql = "";
//ID
strItemSql += "ID";
strValueSql += String.Format("'{0}'", OpBlissue.OpBlissue1.Trim().Equals("null") ? "" : OpBlissue.OpBlissue1.Trim());
//处理状态
strItemSql += ",BLSTATUS";
strValueSql += String.Format(",'{0}'", OpBlissue.OpBlissue2.Trim().Equals("null") ? "" : OpBlissue.OpBlissue2.Trim());
//处理时间
string rq = OpBlissue.OpBlissue3.ToString().Trim().Equals("null") ? "null" : OpBlissue.OpBlissue3.ToString().Trim();
if (!rq.Trim().Equals("null") && !rq.Trim().Equals(""))
{
strItemSql += ",OPTIME";
strValueSql += String.Format(",'{0}'", OpBlissue.OpBlissue3.ToString().Trim());
}
//处理人
strItemSql += ",OPNAME";
strValueSql += String.Format(",'{0}'", OpBlissue.OpBlissue4.Trim().Equals("null") ? "" : OpBlissue.OpBlissue4.Trim());
//备注
strItemSql += ",REMARK";
strValueSql += String.Format(",'{0}'", OpBlissue.OpBlissue7.Trim().Equals("null") ? "" : OpBlissue.OpBlissue7.Trim());
//业务编号
strItemSql += ",BSNO";
strValueSql += String.Format(",'{0}'", OpBlissue.OpBlissue8);
//撤销标志(撤销正本)
strItemSql += ",DElFLAG";
strValueSql += ",'False'";
//是否自由添加状态
strItemSql += ",ISADD";
strValueSql += ",'True'";
//
if (!strItemSql.Trim().Equals("") && !strValueSql.Trim().Equals(""))
{
if (strItemSql.Trim().StartsWith(","))
{
strItemSql = strItemSql.Trim().Substring(1);
}
if (strValueSql.Trim().StartsWith(","))
{
strValueSql = strValueSql.Trim().Substring(1);
}
strInsertSql = String.Format("INSERT INTO {0} ({1}) VALUES({2})", "op_blissue", strItemSql, strValueSql);
sqlInsertList.Add(strInsertSql);
}
}
if (sqlInsertList.Count > 0)
{
int iResult = OpBlissueDA.InsertOpBlissueFromGrid(sqlInsertList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
//if (iResult == 1)
//{
//}
}
}
#endregion
#region 获取账户客户保存的账户信息
/// <summary>
/// 获取账户客户保存的账户信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonOpBlissueGroupEntity GetPostEntity1(string tempValue)
{
JsonOpBlissueGroupEntity OpBlissueGroupEntity = (JsonOpBlissueGroupEntity)JSON.Instance.ToObject(tempValue);
return OpBlissueGroupEntity;
}
#endregion
protected void btSQDF_Click(object sender, EventArgs e)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string strOPNAME = T_ALL_DA.GetSHOWNAME(strUserID);
//
OpBlissueDA OpBlissueDA = new OpBlissueDA();
OpBlissueEntity OpBlissueEntity = new OpBlissueEntity();
OpBlissueEntity.BSNO = this.hid_BSNO.Value;
OpBlissueEntity.BLNO = "";//单证编号
OpBlissueEntity.BLNAME = "提单";//单证名称
OpBlissueEntity.BLSTATUS = "申请电放";//处理状态
OpBlissueEntity.BLORDERNO = "";//单证流水号
OpBlissueEntity.ISSUETYPE = "电放";//签单方式
OpBlissueEntity.OPNAME = strOPNAME;//处理人
//OpBlissueEntity.OPTIME;//处理时间
OpBlissueEntity.BSINKNO = "";//关联编号
OpBlissueEntity.REMARK = "";//备注
OpBlissueEntity.DElFLAG = false;//撤销标志
OpBlissueEntity.EXPRESSCORP = "";//快递公司
OpBlissueEntity.EXPRESSNO = "";//快递号
OpBlissueEntity.ISADD = false;//
OpBlissueEntity.PUTSINGLETIME = DateTime.Parse("0001-1-1 0:00:00");//
OpBlissueEntity.PUTSINGLE = "";//
OpBlissueEntity.PAYTIME = DateTime.Parse("0001-1-1 0:00:00");//
OpBlissueEntity.PAYRMB = 0;//
OpBlissueEntity.PAYUSD = 0;//
//
TopSeaeEntity TopSeaeEntity = new TopSeaeEntity();
SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA();
TopSeaeEntity = SeaExportInfoDA.GetID(this.hid_BSNO.Value.Trim());
if (TopSeaeEntity.BSNO != null)
{
OpBlissueEntity.BLNO = TopSeaeEntity.MBLNO;//单证编号
OpBlissueEntity.ISSUETYPE = TopSeaeEntity.ISSUETYPE;//签单方式
}
//
int iResult = OpBlissueDA.InserInfo(OpBlissueEntity);
if (iResult > 0)
{
//64784D94-420F-46D2-BDC1-471437278965 提单电放审核
UserActionDA UserActionDA = new UserActionDA();
IList<UserActionEntity> UserActionEntities = new List<UserActionEntity>();
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
//
UserActionEntities = UserActionDA.GetUserActionByActionIDALL("64784D94-420F-46D2-BDC1-471437278965", strUserID);//ActionID
//查看是否此用户相关的行为信息
if (UserActionEntities.Count > 0)
{
foreach (UserActionEntity userActionEntity in UserActionEntities)
{
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "BLISSUESUR";//英文名称自定义
messageEntity.Description = "申请电放审核";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strOPNAME + " 向您申请提单电放,提单号为:" + OpBlissueEntity.BLNO.ToString() + "";//消息内容
messageEntity.TaskID = OpBlissueEntity.BSNO.ToString();//bsno
messageEntity.Receiver = userActionEntity.UserID;//收件人id
messageEntity.TaskUrl = messageEntity.TaskUrl = "Shipping/SeaExportInfoBlissueSurAudit.aspx";//审核页面的地址
messageEntity.Type = messageDA.GetMessageType(MessageType.BLISSUESUR);
messageEntities.Add(messageEntity);
}
}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.BLISSUESUR, messageEntities);
}
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('操作成功!');ShowDetailFresh();</script>");
return;
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('操作失败!');</script>");
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 = "SeaExportInfoBlissueSurGridSetting";
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 = "BLSTATUS";
break;
case "处理人":
gridColumnEntity.Name = "OPNAME";
break;
case "处理时间":
gridColumnEntity.Name = "OPTIME";
break;
case "撤销状态":
gridColumnEntity.Name = "DElFLAG";
break;
case "备注":
gridColumnEntity.Name = "REMARK";
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
}
}