|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpSeaePre;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpSeaePreDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsOpSeaePreDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
static public List<MsOpSeaePre> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
// GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",(select top 1 showname from [user] where GID=op_seae_pre.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_seae_pre.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],BSLOCK FROM op_seae_pre ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",(select top 1 showname from [user] where GID=op_seae_pre.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_seae_pre.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATETIME],[MODIFIEDTIME],BSLOCK FROM op_seae_pre ";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsOpSeaePre GetData(string condition)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],BSLOCK FROM op_seae_pre ";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + condition;
|
|
|
|
|
}
|
|
|
|
|
var list=SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
|
}
|
|
|
|
|
return new MsOpSeaePre();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public List<MsOpSeaePre> GetHisDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
// GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",(select top 1 showname from [user] where GID=op_seae_pre_his.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_seae_pre_his.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],0 BSLOCK FROM op_seae_pre_his ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetHisDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],0 BSLOCK FROM op_seae_pre_his ";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsOpSeaePre GetHisData(string condition)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT [BSNO],[MASTERNO],[CUSTOMERNAME],[MBLNO],[CONTRACTNO],[VESSEL],[VOYNO],[ETD],[CLOSINGDATE],[CLOSEDOCDATE],[ETA]"
|
|
|
|
|
+ ",CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR"
|
|
|
|
|
+ ",[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[LANE],[CARRIER],[FORWARDER],[BSSTATUS],[CNTRTOTAL],[OP],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],0 BSLOCK FROM op_seae_pre_his ";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + condition;
|
|
|
|
|
}
|
|
|
|
|
var list = SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
|
}
|
|
|
|
|
return new MsOpSeaePre();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsOpSeaePre> SetData(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsOpSeaePre>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsOpSeaePre data = new MsOpSeaePre();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");
|
|
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
|
|
data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);
|
|
|
|
|
data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);
|
|
|
|
|
data.LANE = Convert.ToString(reader["LANE"]);
|
|
|
|
|
data.CARRIER = Convert.ToString(reader["CARRIER"]);
|
|
|
|
|
data.FORWARDER = Convert.ToString(reader["FORWARDER"]);
|
|
|
|
|
data.BSSTATUS = Convert.ToString(reader["BSSTATUS"]);
|
|
|
|
|
data.CNTRTOTAL = Convert.ToString(reader["CNTRTOTAL"]);
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
|
|
|
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
|
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);
|
|
|
|
|
if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
|
|
|
data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期
|
|
|
|
|
if (reader["CLOSEDOCDATE"] != DBNull.Value)
|
|
|
|
|
data.CLOSEDOCDATE = Convert.ToDateTime(reader["CLOSEDOCDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期
|
|
|
|
|
if (reader["CNTR1"] != DBNull.Value)
|
|
|
|
|
data.CNTR1 = Convert.ToInt32(reader["CNTR1"]);//箱型1
|
|
|
|
|
if (reader["CNTR2"] != DBNull.Value)
|
|
|
|
|
data.CNTR2 = Convert.ToInt32(reader["CNTR2"]);//箱型2
|
|
|
|
|
if (reader["CNTR3"] != DBNull.Value)
|
|
|
|
|
data.CNTR3 = Convert.ToInt32(reader["CNTR3"]);//箱型3
|
|
|
|
|
if (reader["CNTR4"] != DBNull.Value)
|
|
|
|
|
data.CNTR4 = Convert.ToInt32(reader["CNTR4"]);//箱型4
|
|
|
|
|
if (reader["CNTR5"] != DBNull.Value)
|
|
|
|
|
data.CNTR5 = Convert.ToInt32(reader["CNTR5"]);//箱型5
|
|
|
|
|
if (reader["CNTR6"] != DBNull.Value)
|
|
|
|
|
data.CNTR6 = Convert.ToInt32(reader["CNTR6"]);//箱型6
|
|
|
|
|
if (reader["CNTR7"] != DBNull.Value)
|
|
|
|
|
data.CNTR7 = Convert.ToInt32(reader["CNTR7"]);//箱型7
|
|
|
|
|
if (reader["CNTR8"] != DBNull.Value)
|
|
|
|
|
data.CNTR8 = Convert.ToInt32(reader["CNTR8"]);//箱型8
|
|
|
|
|
if (reader["CNTR9"] != DBNull.Value)
|
|
|
|
|
data.CNTR9 = Convert.ToInt32(reader["CNTR9"]);//箱型9
|
|
|
|
|
if (reader["CNTR10"] != DBNull.Value)
|
|
|
|
|
data.CNTR10 = Convert.ToInt32(reader["CNTR10"]);//箱型10
|
|
|
|
|
if (reader["OTCNTR"] != DBNull.Value)
|
|
|
|
|
data.OTCNTR = Convert.ToInt32(reader["OTCNTR"]);//其他箱型
|
|
|
|
|
if (!string.IsNullOrEmpty(data.ETD) && (data.BSSTATUS == "船公司已放舱未使用"))
|
|
|
|
|
{
|
|
|
|
|
if ((Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(2))>=(Convert.ToDateTime(data.ETD))) {
|
|
|
|
|
data.LISTSTATUS = "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else data.LISTSTATUS = "0";
|
|
|
|
|
if (reader["BSLOCK"] != DBNull.Value)
|
|
|
|
|
data.BSLOCK = Convert.ToBoolean(reader["BSLOCK"]);//箱型3
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 批量修改
|
|
|
|
|
|
|
|
|
|
public static DBResult UnBsLock(List<MsOpSeaePre> bodyList, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
string errstr = "";
|
|
|
|
|
int i = 0;
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("update op_seae_pre set BSLOCK=0 ");
|
|
|
|
|
strSql.Append(" where BSNO=@BSNO ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate =
|
|
|
|
|
db.GetSqlStringCommand(strSql.ToString());
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "取消锁定成功";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static DBResult Modify(List<MsOpSeaePre> bodyList, MsOpSeaePre modifydata, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
string errstr = "";
|
|
|
|
|
int i = 0;
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("update op_seae_pre set bsno=bsno ");
|
|
|
|
|
if (modifydata.CARRIER != "" && modifydata.CARRIER != null)
|
|
|
|
|
strSql.Append(",CARRIER=@CARRIER");
|
|
|
|
|
if (modifydata.FORWARDER != "" && modifydata.FORWARDER != null)
|
|
|
|
|
strSql.Append(",FORWARDER=@FORWARDER");
|
|
|
|
|
if (modifydata.CUSTOMERNAME != "" && modifydata.CUSTOMERNAME != null)
|
|
|
|
|
strSql.Append(",CUSTOMERNAME=@CUSTOMERNAME");
|
|
|
|
|
if (modifydata.LANE != "" && modifydata.LANE != null)
|
|
|
|
|
strSql.Append(",LANE=@LANE");
|
|
|
|
|
if (modifydata.PORTLOAD != "" && modifydata.PORTLOAD != null)
|
|
|
|
|
strSql.Append(",PORTLOAD=@PORTLOAD");
|
|
|
|
|
|
|
|
|
|
if (modifydata.PORTDISCHARGE != "" && modifydata.PORTDISCHARGE != null)
|
|
|
|
|
strSql.Append(",PORTDISCHARGE=@PORTDISCHARGE");
|
|
|
|
|
if (modifydata.VESSEL != "" && modifydata.VESSEL != null)
|
|
|
|
|
strSql.Append(",VESSEL=@VESSEL");
|
|
|
|
|
if (modifydata.VOYNO != "" && modifydata.VOYNO != null)
|
|
|
|
|
strSql.Append(",VOYNO=@VOYNO");
|
|
|
|
|
if (modifydata.ETD != "" && modifydata.ETD != null)
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(",ETD=@ETD");
|
|
|
|
|
}
|
|
|
|
|
if (modifydata.CLOSINGDATE != "" && modifydata.CLOSINGDATE != null)
|
|
|
|
|
strSql.Append(",CLOSINGDATE=@CLOSINGDATE");
|
|
|
|
|
if (modifydata.CLOSEDOCDATE != "" && modifydata.CLOSEDOCDATE != null)
|
|
|
|
|
strSql.Append(",CLOSEDOCDATE=@CLOSEDOCDATE");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" where BSNO=@BSNO ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate =
|
|
|
|
|
db.GetSqlStringCommand(strSql.ToString());
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
var opseae = GetData("BSNO='" + enumValue.BSNO + "'");
|
|
|
|
|
|
|
|
|
|
var isPost = true;
|
|
|
|
|
|
|
|
|
|
//if (opseae.BSSTATUS)
|
|
|
|
|
//{
|
|
|
|
|
// if (errstr == "")
|
|
|
|
|
// errstr = enumValue.CUSTNO + "此票所在业务已业务锁定";
|
|
|
|
|
// else
|
|
|
|
|
// errstr = errstr + "," + enumValue.CUSTNO + "此票所在业务已业务锁定";
|
|
|
|
|
// isPost = false;
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
//if (!string.IsNullOrEmpty(opseae.ETD) && !string.IsNullOrEmpty(modifydata.CLOSINGDATE))
|
|
|
|
|
//{
|
|
|
|
|
// if (Convert.ToDateTime(opseae.ETD + " 23:59:59") < Convert.ToDateTime(modifydata.CLOSINGDATE))
|
|
|
|
|
// {
|
|
|
|
|
// isPost = false;
|
|
|
|
|
// errstr = errstr + "," + "截港日期不允许大于开船日期";
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//if (!string.IsNullOrEmpty(opseae.ETD) && !string.IsNullOrEmpty(modifydata.CLOSEDOCDATE))
|
|
|
|
|
//{
|
|
|
|
|
// if (Convert.ToDateTime(opseae.ETD + " 23:59:59") < Convert.ToDateTime(modifydata.CLOSEDOCDATE))
|
|
|
|
|
// {
|
|
|
|
|
// isPost = false;
|
|
|
|
|
// errstr = errstr + "," + "截单日期不允许大于开船日期";
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isPost)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
|
|
|
|
|
if (modifydata.CARRIER != "" && modifydata.CARRIER != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@CARRIER", DbType.String, modifydata.CARRIER);
|
|
|
|
|
if (modifydata.FORWARDER != "" && modifydata.FORWARDER != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@FORWARDER", DbType.String, modifydata.FORWARDER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (modifydata.CUSTOMERNAME != "" && modifydata.CUSTOMERNAME != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@CUSTOMERNAME", DbType.String, modifydata.CUSTOMERNAME);
|
|
|
|
|
if (modifydata.LANE != "" && modifydata.LANE != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@LANE", DbType.String, modifydata.LANE);
|
|
|
|
|
if (modifydata.PORTLOAD != "" && modifydata.PORTLOAD != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@PORTLOAD", DbType.String, modifydata.PORTLOAD);
|
|
|
|
|
|
|
|
|
|
if (modifydata.PORTDISCHARGE != "" && modifydata.PORTDISCHARGE != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@PORTDISCHARGE", DbType.String, modifydata.PORTDISCHARGE);
|
|
|
|
|
if (modifydata.VESSEL != "" && modifydata.VESSEL != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@VESSEL", DbType.String, modifydata.VESSEL);
|
|
|
|
|
|
|
|
|
|
if (modifydata.VOYNO != "" && modifydata.VOYNO != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@VOYNO", DbType.String, modifydata.VOYNO);
|
|
|
|
|
if (modifydata.ETD != "" && modifydata.ETD != null)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdupdate, "@ETD", DbType.String, modifydata.ETD);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (modifydata.CLOSINGDATE != "" && modifydata.CLOSINGDATE != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@CLOSINGDATE", DbType.String, modifydata.CLOSINGDATE);
|
|
|
|
|
if (modifydata.CLOSEDOCDATE != "" && modifydata.CLOSEDOCDATE != null)
|
|
|
|
|
db.AddInParameter(cmdupdate, "@CLOSEDOCDATE", DbType.String, modifydata.CLOSEDOCDATE);
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
i = i + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "修改出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "修改成功" + i.ToString() + "票";
|
|
|
|
|
if (errstr != "")
|
|
|
|
|
{
|
|
|
|
|
result.Message = result.Message + "(其中" + errstr + " 无法修改)";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult ShenModify(MsOpSeaePre oldData, MsOpSeaePre newdata,string userid,string companyid,string rq)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
var headData = newdata;
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
|
|
headData.ModelUIStatus = "E";
|
|
|
|
|
//
|
|
|
|
|
headData.MODIFIEDUSER =userid;//最后一次操作人
|
|
|
|
|
headData.MODIFIEDTIME = DateTime.Parse(rq);//最后一次操作时间
|
|
|
|
|
|
|
|
|
|
var ctndataList = MsCodeOpServiceDAL.MsCodeOpServiceDAL.GetDataCtnList("OPTYPE='1'");
|
|
|
|
|
var ctnstr = "";
|
|
|
|
|
if (headData.CNTR1 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR1")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR1.ToString();
|
|
|
|
|
else
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR1.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (headData.CNTR2 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR2")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR2.ToString();
|
|
|
|
|
else
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR2.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR3 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR3")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR3.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR3.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR4 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR4")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR4.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR4.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR5 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR5")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR5.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR5.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR6 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR6")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR6.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR6.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR7 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR7")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR7.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR7.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR8 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR8")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR8.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR8.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR9 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR9")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR9.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR9.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headData.CNTR10 != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctncode in ctndataList)
|
|
|
|
|
{
|
|
|
|
|
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR10")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(ctnstr))
|
|
|
|
|
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR10.ToString();
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR10.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
headData.CNTRTOTAL = ctnstr;
|
|
|
|
|
if (headData.ETD == "") headData.ETD = null;
|
|
|
|
|
if (headData.CLOSINGDATE == "") headData.CLOSINGDATE = null;
|
|
|
|
|
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
|
|
result = modb.Save(headData);
|
|
|
|
|
if (result.Success) {
|
|
|
|
|
var oldhis = new MsOpSeaePreHis();
|
|
|
|
|
oldhis.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
oldhis.MASTERNO = headData.BSNO;
|
|
|
|
|
oldhis.LOSTNO = oldhis.BSNO;
|
|
|
|
|
oldhis.TYPE = 1;
|
|
|
|
|
oldhis.MODIFIEDUSER = userid;//最后一次操作人
|
|
|
|
|
oldhis.MODIFIEDTIME = DateTime.Parse(rq);//最后一次操作时间
|
|
|
|
|
oldhis.BSSTATUS = oldData.BSSTATUS;
|
|
|
|
|
oldhis.CUSTOMERNAME = oldData.CUSTOMERNAME;
|
|
|
|
|
oldhis.MBLNO = oldData.MBLNO;
|
|
|
|
|
oldhis.CONTRACTNO = oldData.CONTRACTNO;
|
|
|
|
|
oldhis.VESSEL = oldData.VESSEL;
|
|
|
|
|
oldhis.VOYNO = oldData.VOYNO;
|
|
|
|
|
oldhis.ETD = oldData.ETD;
|
|
|
|
|
oldhis.CLOSINGDATE = oldData.CLOSINGDATE;
|
|
|
|
|
oldhis.CLOSEDOCDATE = oldData.CLOSEDOCDATE;
|
|
|
|
|
oldhis.PORTLOAD = oldData.PORTLOAD;
|
|
|
|
|
oldhis.PORTDISCHARGE = oldData.PORTDISCHARGE;
|
|
|
|
|
oldhis.LANE = oldData.LANE;
|
|
|
|
|
oldhis.CARRIER = oldData.CARRIER;
|
|
|
|
|
oldhis.FORWARDER = oldData.FORWARDER;
|
|
|
|
|
oldhis.OP = oldData.OP;
|
|
|
|
|
oldhis.REMARK = oldData.REMARK;
|
|
|
|
|
oldhis.CNTR1 = oldData.CNTR1;
|
|
|
|
|
oldhis.CNTR2 = oldData.CNTR2;
|
|
|
|
|
oldhis.CNTR3 = oldData.CNTR3;
|
|
|
|
|
oldhis.CNTR4 = oldData.CNTR4;
|
|
|
|
|
oldhis.CNTR5 = oldData.CNTR5;
|
|
|
|
|
oldhis.CNTR6 = oldData.CNTR6;
|
|
|
|
|
oldhis.CNTR7 = oldData.CNTR7;
|
|
|
|
|
oldhis.CNTR8 = oldData.CNTR8;
|
|
|
|
|
oldhis.CNTR9 = oldData.CNTR9;
|
|
|
|
|
oldhis.CNTR10 = oldData.CNTR10;
|
|
|
|
|
if (oldhis.ETD == "") oldhis.ETD = null;
|
|
|
|
|
if (oldhis.CLOSINGDATE == "") oldhis.CLOSINGDATE = null;
|
|
|
|
|
if (oldhis.CLOSEDOCDATE == "") oldhis.CLOSEDOCDATE = null;
|
|
|
|
|
modb.Save(oldhis);
|
|
|
|
|
var newhis = new MsOpSeaePreHis();
|
|
|
|
|
newhis.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
newhis.MASTERNO = headData.BSNO;
|
|
|
|
|
newhis.LOSTNO = oldhis.BSNO;
|
|
|
|
|
newhis.TYPE = 2;
|
|
|
|
|
newhis.MODIFIEDUSER = userid;//最后一次操作人
|
|
|
|
|
newhis.MODIFIEDTIME = DateTime.Parse(rq);//最后一次操作时间
|
|
|
|
|
newhis.BSSTATUS = newdata.BSSTATUS;
|
|
|
|
|
newhis.CUSTOMERNAME = newdata.CUSTOMERNAME;
|
|
|
|
|
newhis.MBLNO = newdata.MBLNO;
|
|
|
|
|
newhis.CONTRACTNO = newdata.CONTRACTNO;
|
|
|
|
|
newhis.VESSEL = newdata.VESSEL;
|
|
|
|
|
newhis.VOYNO = newdata.VOYNO;
|
|
|
|
|
newhis.ETD = newdata.ETD;
|
|
|
|
|
newhis.CLOSINGDATE = newdata.CLOSINGDATE;
|
|
|
|
|
newhis.CLOSEDOCDATE = newdata.CLOSEDOCDATE;
|
|
|
|
|
newhis.PORTLOAD = newdata.PORTLOAD;
|
|
|
|
|
newhis.PORTDISCHARGE = newdata.PORTDISCHARGE;
|
|
|
|
|
newhis.LANE = newdata.LANE;
|
|
|
|
|
newhis.CARRIER = newdata.CARRIER;
|
|
|
|
|
newhis.FORWARDER = newdata.FORWARDER;
|
|
|
|
|
newhis.OP = newdata.OP;
|
|
|
|
|
newhis.REMARK = newdata.REMARK;
|
|
|
|
|
newhis.CNTR1 = newdata.CNTR1;
|
|
|
|
|
newhis.CNTR2 = newdata.CNTR2;
|
|
|
|
|
newhis.CNTR3 = newdata.CNTR3;
|
|
|
|
|
newhis.CNTR4 = newdata.CNTR4;
|
|
|
|
|
newhis.CNTR5 = newdata.CNTR5;
|
|
|
|
|
newhis.CNTR6 = newdata.CNTR6;
|
|
|
|
|
newhis.CNTR7 = newdata.CNTR7;
|
|
|
|
|
newhis.CNTR8 = newdata.CNTR8;
|
|
|
|
|
newhis.CNTR9 = newdata.CNTR9;
|
|
|
|
|
newhis.CNTR10 = newdata.CNTR10;
|
|
|
|
|
if (newhis.ETD == "") newhis.ETD = null;
|
|
|
|
|
if (newhis.CLOSINGDATE == "") newhis.CLOSINGDATE = null;
|
|
|
|
|
if (newhis.CLOSEDOCDATE == "") newhis.CLOSEDOCDATE = null;
|
|
|
|
|
modb.Save(newhis);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断编码是否有重复
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" Count(BSNO) AS CT ");
|
|
|
|
|
strSql.Append(" from op_other ");
|
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
var ct=0;
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return ct;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断是否有FEE
|
|
|
|
|
public static bool GetFeeCount(string BSNO)
|
|
|
|
|
{
|
|
|
|
|
var isfee = false;
|
|
|
|
|
String strSql = "Select count(*) as count from ch_fee where BSNO='" + BSNO + "'";
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
|
|
|
if (evData > 0) { isfee = true; };
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return isfee;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Rang权限范围
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID");
|
|
|
|
|
strSql.Append(" from VW_User_Authority");
|
|
|
|
|
strSql.Append(" where [NAME]='modOpOtherList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR CREATEUSER='" + userid + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR CREATEUSER='" + userid + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")
|
|
|
|
|
{
|
|
|
|
|
var rangeDa = new RangeDA();
|
|
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
|
|
str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
|
|
|
|
|
+ " OR CREATEUSER in (select GID from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "' or op_other.SALECORPID='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "5")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
str = "";
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
if (str == "")
|
|
|
|
|
{
|
|
|
|
|
str = " (op_other.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or op_other.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or op_other.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or op_other.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
str = str + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "6")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var opstr = "";
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opstr == "")
|
|
|
|
|
{
|
|
|
|
|
opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opstr != "") opstr = opstr + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (opstr == "") opstr = "('" + username + "')";
|
|
|
|
|
str = " (OP in " + opstr + " or CREATEUSER in " + opstr + " or CUSTSERVICE IN " + opstr + " or SALE IN " + opstr + " )";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (visiblerange == "0")
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|