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/Shipping/OpStatusList.aspx.cs

435 lines
21 KiB
C#

using System;
using System.Collections;
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 DSWeb.Models;
using System.Collections.Generic;
using JsonHelper;
using DSWeb.EntityDA;
using DSWeb.Log;
namespace DSWeb.Shipping
{
public partial class OpStatusList : System.Web.UI.Page
{
private string recvJSON;
RangeDA RangeDA = new RangeDA();
public string strUserID;//用户GID
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 (Request.QueryString["id"] != null)
{
this.hid_associatedno.Value = Request.QueryString["id"].ToString().Trim();
#region 权限可视范围
//if (Request.QueryString["opstatus"] != null)
//{
// this.opstatus.Value = Request.QueryString["opstatus"].ToString().Trim();
//}
////权限可视范围
//if (this.opstatus.Value.Trim() == "op_seae")
//{
// 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";
// }
// }
// //
// 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_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
// {
// alt = RangeDA.GetOrderManagementDEPT(strUserID.Trim(), this.hid_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
// {
// alt = RangeDA.GetOrderManagementPerson(strUserID.Trim(), this.hid_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("4"))//无
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
//}
//else if (this.opstatus.Value.Trim() == "op_seai")
//{
// this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modSeaImportList");//海运进口委托管理列表
// this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modSeaImportList");//海运进口委托管理列表
// //页面是否只读
// if (Request.QueryString["hdenabled"] != null)
// {
// if (Request.QueryString["hdenabled"].ToString() == "false")
// {
// this.hdRangeO.Value = "4";
// }
// }
// //
// 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.GetSeaImportListCompany(strUserID.Trim(), this.hid_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
// {
// alt = RangeDA.GetSeaImportListDEPT(strUserID.Trim(), this.hid_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
// {
// alt = RangeDA.GetSeaImportListPerson(strUserID.Trim(), this.hid_associatedno.Value.Trim());
// if (alt == "")
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
// else if (this.hdRangeO.Value.Trim().Equals("4"))//无
// {
// divadd.Disabled = true;
// divsave.Disabled = true;
// divdel.Disabled = true;
// divrollback.Disabled = true;
// mygrid_container_recv.Disabled = true;
// }
// }
//}
#endregion
}
else
{
//this.hid_associatedno.Value = "";
//Response.Write("-1");
//Response.End();
}
//
//
recvJSON = "";
recvJSON = this.recvContainer.Value.Trim();
if (!recvJSON.Trim().Equals(""))
{
//应收账户保存
JsonOpStatusListGroupEntity OpStatusListGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonOpStatusListEntity> OpStatusListRecvEntities = new List<JsonOpStatusListEntity>();
OpStatusListRecvEntities = OpStatusListGroupRecvEntity.JsonOpStatusListEntities;
SaveRecvOpStatusList(OpStatusListGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvOpStatusList(JsonOpStatusListGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonOpStatusListEntity> OpStatusListEntities = new List<JsonOpStatusListEntity>();
OpStatusListEntities = tempGroupEntity.JsonOpStatusListEntities;
OpStatusListDA OpStatusListDA = new OpStatusListDA();
DataTable OpStatusListTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonOpStatusListEntities.Count > 0)
{
string BSNO = tempGroupEntity.JsonOpStatusListEntities[0].OpStatusList6.Trim();
strInitSql = " SELECT ST_ID,BSNO,STATUS,COMPTIME,COMPOP,REMARK FROM op_status WHERE 1=1 AND BSNO = '" + BSNO + "'";
}
else
{
return;
}
OpStatusListTable = OpStatusListDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < OpStatusListTable.Rows.Count; i++)
{
foreach (JsonOpStatusListEntity OpStatusList in OpStatusListEntities)
{
if (OpStatusListTable.Rows[i]["ST_ID"].ToString().Trim().Equals(OpStatusList.OpStatusList1.Trim()))//惟一编号
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//业务状态
string strSTATUS = OpStatusList.OpStatusList2.Trim().ToLower().Equals("null") ? "" : OpStatusList.OpStatusList2.Trim();
if (!OpStatusListTable.Rows[i]["STATUS"].ToString().Trim().Equals(strSTATUS))
{
strSql += String.Format(" STATUS = '{0}'", strSTATUS);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "业务状态", OpStatusListTable.Rows[i]["STATUS"].ToString().Trim(), strSTATUS);
}
//完成时间
string strCOMPTIME = OpStatusList.OpStatusList3.ToString().Trim().ToLower().Equals("null") ? "null" : OpStatusList.OpStatusList3.ToString().Trim();
if (!OpStatusListTable.Rows[i]["COMPTIME"].ToString().Trim().Equals(strCOMPTIME))
{
if (strCOMPTIME.Trim().Equals("null") || strCOMPTIME.Trim().Equals(""))
{
strSql += String.Format(",COMPTIME ={0}", strCOMPTIME);
}
else
{
strSql += String.Format(",COMPTIME = '{0}'", strCOMPTIME);
}
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "完成时间", OpStatusListTable.Rows[i]["COMPTIME"].ToString().Trim(), strCOMPTIME);
}
//完成人
string strCOMPOP = OpStatusList.OpStatusList4.Trim().ToLower().Equals("null") ? "" : OpStatusList.OpStatusList4.Trim();
if (!OpStatusListTable.Rows[i]["COMPOP"].ToString().Trim().Equals(strCOMPOP))
{
strSql += String.Format(",COMPOP = '{0}'", strCOMPOP);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "完成人", OpStatusListTable.Rows[i]["COMPOP"].ToString().Trim(), strCOMPOP);
}
//备注
string strREMARK = OpStatusList.OpStatusList5.Trim().ToLower().Equals("null") ? "" : OpStatusList.OpStatusList5.Trim();
if (!OpStatusListTable.Rows[i]["REMARK"].ToString().Trim().Equals(strREMARK))
{
strSql += String.Format(",REMARK = '{0}'", strREMARK);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", OpStatusListTable.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 ST_ID = '{2}'", "op_status", strSql, OpStatusList.OpStatusList1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新账户标识 {0} {1}", OpStatusList.OpStatusList1.Trim(), LogContent));
}
OpStatusListEntities.Remove(OpStatusList);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = OpStatusListDA.UpdateOpStatusListFromGrid(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 (OpStatusListEntities.Count > 0)
{
//插入新的应收费用信息
InsertOpStatusList(OpStatusListEntities, 1);
}
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="OpStatusListEntities">需要插入账户表的账户实体类</param>
/// <param name="iType">如果iType值为1则记录账户类型为收/否则记录为付</param>
public void InsertOpStatusList(List<JsonOpStatusListEntity> OpStatusListEntities, int iType)
{
ArrayList sqlInsertList = new ArrayList();
OpStatusListDA OpStatusListDA = new OpStatusListDA();
foreach (JsonOpStatusListEntity OpStatusList in OpStatusListEntities)
{
string strItemSql = "";
string strValueSql = "";
string strInsertSql = "";
//ST_ID
strItemSql += "ST_ID";
strValueSql += String.Format("'{0}'", OpStatusList.OpStatusList1.Trim().Equals("null") ? "" : OpStatusList.OpStatusList1.Trim());
//业务状态
strItemSql += ",STATUS";
strValueSql += String.Format(",'{0}'", OpStatusList.OpStatusList2.Trim().Equals("null") ? "" : OpStatusList.OpStatusList2.Trim());
//完成时间
string rq = OpStatusList.OpStatusList3.ToString().Trim().Equals("null") ? "null" : OpStatusList.OpStatusList3.ToString().Trim();
if (!rq.Trim().Equals("null") && !rq.Trim().Equals(""))
{
strItemSql += ",COMPTIME";
strValueSql += String.Format(",'{0}'", OpStatusList.OpStatusList3.ToString().Trim());
}
//完成人
strItemSql += ",COMPOP";
strValueSql += String.Format(",'{0}'", OpStatusList.OpStatusList4.Trim().Equals("null") ? "" : OpStatusList.OpStatusList4.Trim());
//备注
strItemSql += ",REMARK";
strValueSql += String.Format(",'{0}'", OpStatusList.OpStatusList5.Trim().Equals("null") ? "" : OpStatusList.OpStatusList5.Trim());
//业务编号
strItemSql += ",BSNO";
strValueSql += String.Format(",'{0}'", OpStatusList.OpStatusList6);
//录入人
strItemSql += ",INPUTBY";
strValueSql += String.Format(",'{0}'", strUserID.Trim());
//
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_status", strItemSql, strValueSql);
sqlInsertList.Add(strInsertSql);
}
}
if (sqlInsertList.Count > 0)
{
int iResult = OpStatusListDA.InsertOpStatusListFromGrid(sqlInsertList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
//if (iResult == 1)
//{
//}
}
}
#endregion
#region 获取账户客户保存的账户信息
/// <summary>
/// 获取账户客户保存的账户信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonOpStatusListGroupEntity GetPostEntity(string tempValue)
{
JsonOpStatusListGroupEntity OpStatusListGroupEntity = (JsonOpStatusListGroupEntity)JSON.Instance.ToObject(tempValue);
return OpStatusListGroupEntity;
}
#endregion
//
}
}