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.

5936 lines
276 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.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsOpAuditDetail;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using HcUtility.Comm;
using DSWeb.Areas.Dispatch.Helper;
using Newtonsoft.Json;
using System.Configuration;
using DSWeb.Areas.CommMng.DAL;
using System.IO;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.MvcContainer.DAL.MsOpCtnApply;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
using DSWeb.Areas.Account.Models.MsOpBill;
using DSWeb.MvcShipping.DAL.Chfee_AuditDAL;
using DSWeb.MvcShipping.DAL.MsOpSeaiDAL;
using DSWeb.MvcContainer.DAL.MsOpCtnBsCard;
using DSWeb.MvcShipping.Models.MsChFee;
using DSWeb.MvcContainer.DAL.MsCodeCtnTk;
using DSWeb.Areas.CommMng.Models;
namespace DSWeb.Areas.MvcShipping.DAL
{
public class MsOpAuditDetailDAL
{
#region Inquery DataList
static public List<MsOpAuditDetail> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("ADID,BSNO,SORT,ERRDATA,OPREMARK,ERRMSG,CREATEUSER,CREATETIME,AUDITTYPE,AUDITDETAILID");
strSql.Append(" from op_audit_detail ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by SORT ");
}
return SetData(strSql);
}
static public MsOpAuditDetail GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new MsOpAuditDetail();
}
private static List<MsOpAuditDetail> SetData(StringBuilder strSql)
{
var headList = new List<MsOpAuditDetail>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAuditDetail data = new MsOpAuditDetail();
#region Set DB data to Object
data.ADID = Convert.ToString(reader["ADID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
if (reader["SORT"] != DBNull.Value)
data.SORT = Convert.ToInt32(reader["SORT"]);
data.ERRDATA = Convert.ToString(reader["ERRDATA"]);
data.OPREMARK = Convert.ToString(reader["OPREMARK"]);
data.ERRMSG = Convert.ToString(reader["ERRMSG"]);
data.AUDITTYPE = Convert.ToString(reader["AUDITTYPE"]);
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
if (reader["CREATETIME"] != DBNull.Value)
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
data.AUDITDETAILID= Convert.ToString(reader["AUDITDETAILID"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 业务状态保存,删除
public static DBResult SaveUpdate(List<MsOpAuditDetail> bodyList, string BsNo, string username)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_detail (ADID,BSNO,SORT,ERRDATA,OPREMARK,ERRMSG,AUDITTYPE,CREATEUSER,CREATETIME,AUDITDETAILID)
values (@ADID,@BSNO,@SORT,@ERRDATA,@OPREMARK,@ERRMSG,@AUDITTYPE,@CREATEUSER,@CREATETIME,@AUDITDETAILID) ");
var cmdUpdate =
db.GetSqlStringCommand(
@"update op_audit_detail set ERRDATA=@ERRDATA,OPREMARK=@OPREMARK,ERRMSG=@ERRMSG where ADID=@ADID ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.BSNO == "*")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, enumValue.SORT);
db.AddInParameter(cmdInsert, "@ERRDATA", DbType.String, enumValue.ERRDATA);
db.AddInParameter(cmdInsert, "@OPREMARK", DbType.String, enumValue.OPREMARK);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, enumValue.ERRMSG);
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, enumValue.AUDITTYPE);
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdInsert, "@AUDITDETAILID", DbType.String, enumValue.AUDITDETAILID);
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
cmdUpdate.Parameters.Clear();
//db.AddInParameter(cmdUpdate, "@ST_ID", DbType.String, enumValue.ST_ID);
db.AddInParameter(cmdUpdate, "@ADID", DbType.String, enumValue.ADID);
db.AddInParameter(cmdUpdate, "@ERRDATA", DbType.String, enumValue.ERRDATA);
db.AddInParameter(cmdUpdate, "@OPREMARK", DbType.String, enumValue.OPREMARK);
db.AddInParameter(cmdUpdate, "@ERRMSG", DbType.String, enumValue.ERRMSG);
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功" + result.Message;
return result;
}
public static DBResult AddAudit( List<MsOpAuditDetail> bodyList,string BsNo,string username,bool issubmit)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
if (issubmit)
{
var cmdDelete = db.GetSqlStringCommand(
@"delete from op_audit_detail where bsno='" + BsNo + "' ");
db.ExecuteNonQuery(cmdDelete);
}
else
{
var cmdDelete = db.GetSqlStringCommand(
@"delete from op_audit_detail where bsno='" + BsNo + "' and CREATEUSER='" + username + "'");
db.ExecuteNonQuery(cmdDelete);
}
var auditlist = GetDataList("BSNO='"+ BsNo + "'");
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_detail (ADID,BSNO,SORT,ERRDATA,OPREMARK,ERRMSG,AUDITTYPE,CREATEUSER,CREATETIME,AUDITDETAILID)
values (@ADID,@BSNO,@SORT,@ERRDATA,@OPREMARK,@ERRMSG,@AUDITTYPE,@CREATEUSER,@CREATETIME,@AUDITDETAILID) ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var isfind = false;
auditlist.ForEach(i =>
{
if (i.AUDITDETAILID == enumValue.AUDITDETAILID && i.ERRDATA == enumValue.ERRDATA&& i.ERRMSG == enumValue.ERRMSG)
{
isfind = true;
}
if (string.IsNullOrEmpty(i.AUDITDETAILID) && i.ERRDATA == enumValue.ERRDATA && i.ERRMSG == enumValue.ERRMSG)
{
isfind = true;
}
});
if (!isfind)
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, enumValue.SORT);
db.AddInParameter(cmdInsert, "@ERRDATA", DbType.String, enumValue.ERRDATA);
db.AddInParameter(cmdInsert, "@OPREMARK", DbType.String, enumValue.OPREMARK);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, enumValue.ERRMSG);
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, enumValue.AUDITTYPE);
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdInsert, "@AUDITDETAILID", DbType.String, enumValue.AUDITDETAILID);
db.ExecuteNonQuery(cmdInsert, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功" + result.Message;
return result;
}
//public static DBResult SavePiliangUpdate(List<MsOpAuditDetail> billList, List<MsOpAuditDetail> bodyList, string username)
//{
// var result = new DBResult();
// Database db = DatabaseFactory.CreateDatabase();
// using (var conn = db.CreateConnection())
// {
// conn.Open();
// var tran = conn.BeginTransaction();
// try
// {
// var cmdInsert =
// db.GetSqlStringCommand(
// @"insert into op_status (ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,COMPOP,REMARK,INPUTBY,INPUTTIME,ORDNO,STATUS_OPSEAE,ISOPEN)
// values (@ST_ID,@BSNO,@STATUS,@ISCOMP,@COMPTIME,@COMPOP,@REMARK,@INPUTBY,@INPUTTIME,@ORDNO,@STATUS_OPSEAE,@ISOPEN) ");
// if (billList != null)
// {
// foreach (var enumbillValue in billList)
// {
// if (bodyList != null)
// {
// foreach (var enumValue in bodyList)
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@ST_ID", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumbillValue.BSNO);
// db.AddInParameter(cmdInsert, "@ORDNO", DbType.Int32, enumValue.ORDNO);
// db.AddInParameter(cmdInsert, "@STATUS", DbType.String, enumValue.STATUS);
// db.AddInParameter(cmdInsert, "@ISCOMP", DbType.String, enumValue.ISCOMP);
// db.AddInParameter(cmdInsert, "@COMPTIME", DbType.String, enumValue.COMPTIME);
// db.AddInParameter(cmdInsert, "@COMPOP", DbType.String, enumValue.COMPOP);
// db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
// db.AddInParameter(cmdInsert, "@INPUTBY", DbType.String, username);
// db.AddInParameter(cmdInsert, "@INPUTTIME", DbType.String, DateTime.Now.ToShortDateString());
// db.AddInParameter(cmdInsert, "@STATUS_OPSEAE", DbType.String, enumValue.STATUS_OPSEAE);
// db.AddInParameter(cmdInsert, "@ISOPEN", DbType.String, enumValue.ISOPEN);
// db.ExecuteNonQuery(cmdInsert, tran);
// }
// }
// }
// }
// tran.Commit();
// }
// catch (Exception)
// {
// tran.Rollback();
// result.Success = false;
// result.Message = "保存出现错误,请重试或联系系统管理员";
// return result;
// }
// }
// result.Success = true;
// result.Message = "保存成功" + result.Message;
// return result;
//}
public static DBResult DeleteStatus(List<MsOpAuditDetail> bodyList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"delete from op_audit_detail where ADID=@ADID ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADID", DbType.String, enumValue.ADID);
db.ExecuteNonQuery(cmdInsert, tran);
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "删除成功" + result.Message;
return result;
}
#endregion
#region 审核日志
static public List<MsOpAuditLog> GetAuditLogList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("[ADLGID],[BSNO],[SORT],[ERRMSG],[ERROP],ERRCUST,AUDITTYPE,[AUDITREMARK],[ISAMEND],[AUDITUSER],[AUDITTIME]");
strSql.Append(",(select ShowName from [user] where GID=op_audit_log.AUDITUSER) as AUDITUSERREF,PRREASON");
strSql.Append(" from op_audit_log ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by AUDITTIME ");
return SetAuditLogData(strSql);
}
private static List<MsOpAuditLog> SetAuditLogData(StringBuilder strSql)
{
var headList = new List<MsOpAuditLog>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAuditLog data = new MsOpAuditLog();
#region Set DB data to Object
data.ADLGID = Convert.ToString(reader["ADLGID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
if (reader["SORT"] != DBNull.Value)
data.SORT = Convert.ToInt32(reader["SORT"]);
data.ERRMSG = Convert.ToString(reader["ERRMSG"]);
data.ERROP = Convert.ToString(reader["ERROP"]);
data.ERRCUST = Convert.ToString(reader["ERRCUST"]);
data.AUDITTYPE = Convert.ToString(reader["AUDITTYPE"]);
data.AUDITREMARK = Convert.ToString(reader["AUDITREMARK"]);
if (reader["ISAMEND"] != DBNull.Value)
data.ISAMEND = Convert.ToBoolean(reader["ISAMEND"]);
data.AUDITUSER = Convert.ToString(reader["AUDITUSER"]);
if (reader["AUDITTIME"] != DBNull.Value)
data.AUDITTIME = Convert.ToDateTime(reader["AUDITTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
data.AUDITUSERREF = Convert.ToString(reader["AUDITUSERREF"]);
data.PRREASON = Convert.ToString(reader["PRREASON"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public int GetAuditLogCount(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT Count(1) AS CT from op_audit_log (NOLOCK) ");
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
private static string GetUserNameWithUserId(string userid)
{
string sql = "select showname from [user] where gid = '" + userid + "' ";
Database db = DatabaseFactory.CreateDatabase();
return db.ExecuteScalar(CommandType.Text, sql).ToString();
}
public static DBResult SubmitBL(string BsNo, string oplb, string isamend,string audit,bool isdetail, string userid, string username)
{
var result = new DBResult();
var auditdetaillist = GetDataList("BSNO='" + BsNo + "' AND AUDITTYPE='1' AND ISNULL(OPREMARK,'')='' ");
if (auditdetaillist != null && auditdetaillist.Count != 0)
{
result.Success = false;
result.Message = "未匹配信息,错误说明不能为空!";
return result;
}
var OPBILL = MsOpBillDAL.GetData("BSNO='"+BsNo+"'");
if (OPBILL.FEESTATUS) {
result.Success = false;
result.Message="已费用锁定,不允许提交账单审核!";
return result;
}
string auditName = GetUserNameWithUserId(audit);
var logcount = GetAuditLogCount(" BSNO='"+BsNo+"'");
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, logcount+1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String,"");
db.AddInParameter(cmdInsert, "@ERROP", DbType.String,"");
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String,"");
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, "提交审核");
//if (isamend == "1")
// db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, true);
//else
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.ExecuteNonQuery(cmdInsert, tran);
if (isamend == "1")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
var cmdInsertTaskState = db.GetSqlStringCommand(
@"insert into op_task_state (GID,TASKNO,TASKSTATUS,OP,OPTIME) values (newid(),'" + BsNo + "','已完成','" + username + "',GETDATE()) ");
cmdInsertTaskState.Parameters.Clear();
db.AddInParameter(cmdInsertTaskState, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdInsertTaskState, tran);
var cmdInsertTask = db.GetSqlStringCommand(
@"update op_task set ISCOMPLETE=1,TASKSTATUS='已完成',COMPLETETYPE='人工',COMPLETETIME=GETDATE(),OP='" + username + "' where TASKNO='" + BsNo + "' ");
cmdInsertTask.Parameters.Clear();
db.AddInParameter(cmdInsertTask, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdInsertTask, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
var cmdInsertTask2 = db.GetSqlStringCommand(
@"update op_task set ISCOMPLETE=1,TASKSTATUS='已完成',COMPLETETYPE='人工',COMPLETETIME=GETDATE(),OP='" + username + "' where BSNO='" + BsNo + "' and TASKSTATUS='未开始' ");
cmdInsertTask2.Parameters.Clear();
db.AddInParameter(cmdInsertTask2, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdInsertTask2, tran);
if (!isdetail)
{
if (isamend == "1")
{
var cmdUpdate = db.GetSqlStringCommand(
@"if (select bsno from op_close where bsno='" + BsNo + "') is null insert into op_close values(newid(),'" + BsNo + "',null,'','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "','" + auditName + "',0,0,0) else update op_close set FEECLOSETIME ='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "',FEECLOSEOP='" + auditName + "' where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
}
else
{
var cmdUpdate = db.GetSqlStringCommand(
@"if (select bsno from op_close where bsno='" + BsNo + "') is null insert into op_close values(newid(),'" + BsNo + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + auditName + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "','" + auditName + "',0,0,0) else update op_close set BSCLOSETIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',FEECLOSETIME ='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "',BSCLOSEOP='" + auditName + "',FEECLOSEOP='" + auditName + "' where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
}
//if (isamend == "1")
//{
// var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE OP_AMEND SET FEESTATUS=1 WHERE BSNO=@BSNO ");
// cmdUpdateamend.Parameters.Clear();
// db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
// db.ExecuteNonQuery(cmdUpdateamend, tran);
//}
//else
//{
// var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE " + oplb + " SET BSSTATUS=1,FEESTATUS=1 WHERE BSNO=@BSNO ");
// cmdUpdateamend.Parameters.Clear();
// db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
// db.ExecuteNonQuery(cmdUpdateamend, tran);
//}
}
var cmdUpdateAudit = db.GetSqlStringCommand(
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,'"+audit+"','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"
+ "0) else update op_audit set AUDITUSER='"+audit+ "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',ISFINISH=0 where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdateAudit, tran);
if (isamend == "1")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET FEESTATUS=1 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
var cmdUpdate = db.GetSqlStringCommand(
@"update " + oplb + " set REMARK=ISNULL(REMARK,'')+CHAR(13)+CHAR(10)+isnull((SELECT TOP 1 REMARK FROM op_amend_remark WHERE BSNO='"+BsNo+"'),'') where bsno='" + OPBILL.PARENTID + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BSSTATUS=1,FEESTATUS=1 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
tran.Commit();
result.Success = true;
SetBsLock(BsNo,oplb,isamend,userid,username);
}
catch (Exception e)
{
result.Success = false;
result.Message = e.Message;
tran.Rollback();
}
}
return result;
}
public static DBResult SetBsLock(string BsNo, string oplb, string isamend,string userid, string username)
{
var result = new DBResult();
var strbsno = BsNo;
if (isamend == "1")
{
var opamend = MsChFeeDAL.GetAmendData("BSNO='" + BsNo + "'");
strbsno = opamend.PARENTID;
}
if (oplb.ToUpper() == "OP_SEAE")
{
var OPSEAE = MsOpSeaeDAL.GetData("BSNO='" + strbsno + "'", userid);
if (!string.IsNullOrEmpty(OPSEAE.APPLYNO))
{
var applynostr = "'" + OPSEAE.APPLYNO + "'";
if (OPSEAE.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = OPSEAE.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db.GetSqlStringCommand(
@"update op_ctnbscard set ISBSLOCK=1 where APPLYNO IN (" + applynostr + ") ");
db.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
}
else if (oplb.ToUpper() == "OP_SEAI")
{
var OPSEAE = MsOpSeaiDAL.GetData("BSNO='" + strbsno + "'");
var applynostr = "'" + OPSEAE.APPLYNO + "'";
if (OPSEAE.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = OPSEAE.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
var OPCTNAPPLYLIST = MsOpCtnApplyDAL.GetDataList("BSNO IN (" + applynostr + ")");
var ctnnum = 0;
foreach (var OPCTNAPPLY in OPCTNAPPLYLIST)
{
ctnnum = ctnnum + OPCTNAPPLY.CTNNUM;
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList("APPLYNO='" + OPCTNAPPLY.BSNO + "'");
foreach (var opctnbscard in opctnbscardlist)
{
if (opctnbscard.CUSTNO == OPSEAE.CUSTNO) {
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db.GetSqlStringCommand(
@"update op_ctnbscard set ISSEAILOCK=1 where GID='"+ opctnbscard.GID+ "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
else if (opctnbscard.I_CUSTNO == OPSEAE.CUSTNO)
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db.GetSqlStringCommand(
@"update op_ctnbscard set ISRELOCK=1 where GID='" + opctnbscard.GID + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
else if (opctnbscard.D_CUSTNO == OPSEAE.CUSTNO)
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db.GetSqlStringCommand(
@"update op_ctnbscard set ISDBLOCK=1 where GID='" + opctnbscard.GID + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
}
}
}
return result;
}
public static DBResult AuditBL(string BsNo,string oplb,string optype, string isamend,string amendop,string audit,string auditremark, string isfinish,string errmsg,string errop, string errcust, string op, string userid, string username, string prreason,string bssourcedetail)
{
if (string.IsNullOrEmpty(amendop)) amendop = username;
var logcount = GetAuditLogCount(" BSNO='" + BsNo + "'");
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,ERRCUST,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE,PRREASON)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@ERRCUST,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE,@PRREASON) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32,logcount+1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, errmsg);
db.AddInParameter(cmdInsert, "@ERROP", DbType.String, errop);
db.AddInParameter(cmdInsert, "@ERRCUST", DbType.String, errcust);
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String,auditremark);
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String,"审核");
if (isamend=="1")
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean,true);
else db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean,false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdInsert, "@PRREASON", DbType.String, prreason);
db.ExecuteNonQuery(cmdInsert, tran);
var strisfinish = isfinish;
if (string.IsNullOrEmpty(isfinish)) strisfinish = "0";
if (string.IsNullOrEmpty(audit)) audit = userid;
var cmdUpdateAudit = db.GetSqlStringCommand(
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,'" + audit + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"
+ strisfinish+ ") else update op_audit set AUDITUSER='" + audit + "',SORT=SORT+1,AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',ISFINISH="+ strisfinish + " where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdateAudit, tran);
if (isfinish == "1") {
if (optype == "更改单")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET BillFeeStatus=2 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
else
{
if (!string.IsNullOrEmpty(bssourcedetail))
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=2,BSSOURCEDETAIL='"+ bssourcedetail + "' WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=2 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
}
if (isamend == "1") {
if (optype == "更改单")
{
var cmdUpdateBL =
db.GetSqlStringCommand(
@"INSERT INTO [op_task] (GID,[TASKNO] ,[PTASKNO],[TASKTYPE],[TASKSOURCE],[TASKSTATUS],[TASKTITLE] "
+ ",[CREATEUSER] ,[CREATETIME] ,[TASKBEGINDATE] ,[COMPLETETYPE] ,[COMPLETETIME] ,[KPI],[MBLNO],[FILENO],[MAILNO],[FILEPATH],[ISPUBLIC],[OP],[BSNO],ISCOMPLETE)"
+ " SELECT NEWID(),NEWID() as [任务编号],null as [上级任务号], '生成更改单' as [任务类型], '账单审核' as [任务来源], '未开始' as [任务状态], '审核意见:" + auditremark + "' as [任务说明],"
+ "'" + username + "' as [发起人],GETDATE() as [录入日期],GETDATE() as[任务开始时间], '手动' as [完成方式],null as [完成时间] ,null as [KPI值] , '' as [提单号], "
+ " null as [文件编号], '' as [邮件编号], '' as [电子档案路径], 0 as 是否公共,'" + amendop + "',PARENTID as 编号,0 from OP_AMEND where BSNO='" + BsNo+"'");
db.ExecuteNonQuery(cmdUpdateBL, tran);
}
else
{
var cmdUpdateBL =
db.GetSqlStringCommand(
@"INSERT INTO [op_task] (GID,[TASKNO] ,[PTASKNO],[TASKTYPE],[TASKSOURCE],[TASKSTATUS],[TASKTITLE] "
+ ",[CREATEUSER] ,[CREATETIME] ,[TASKBEGINDATE] ,[COMPLETETYPE] ,[COMPLETETIME] ,[KPI],[MBLNO],[FILENO],[MAILNO],[FILEPATH],[ISPUBLIC],[OP],[BSNO],ISCOMPLETE)"
+ " SELECT NEWID(),NEWID() as [任务编号],null as [上级任务号], '生成更改单' as [任务类型], '账单审核' as [任务来源], '未开始' as [任务状态], '审核意见:" + auditremark + "' as [任务说明],"
+ "'" + username + "' as [发起人],GETDATE() as [录入日期],GETDATE() as[任务开始时间], '手动' as [完成方式],null as [完成时间] ,null as [KPI值] , '' as [提单号], "
+ " null as [文件编号], '' as [邮件编号], '' as [电子档案路径], 0 as 是否公共,'" + amendop + "','" + BsNo + "' as 编号,0");
db.ExecuteNonQuery(cmdUpdateBL, tran);
}
}
}
tran.Commit();
result.Success = true;
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message ="审核过程出现错误"+e.Message;
}
}
return result;
}
public static DBResult AuditBackBL(string BsNo, string oplb, string isamend, string reason,string op, string userid, string username)
{
var result = new DBResult();
var auditlogList = MsOpAuditDetailDAL.GetAuditLogList("BSNO='" + BsNo + "' and AUDITTYPE='提交审核'");
if (auditlogList != null)
{
if (auditlogList.Count > 0)
{
op = auditlogList[0].AUDITUSER;
}
}
var logcount = GetAuditLogCount(" BSNO='" + BsNo + "'");
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, logcount+1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String,"");
db.AddInParameter(cmdInsert, "@ERROP", DbType.String,"");
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String,"审核驳回:"+reason);
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, "审核驳回");
if (isamend == "1")
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, true);
else db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.ExecuteNonQuery(cmdInsert, tran);
var cmdUpdateAudit = db.GetSqlStringCommand(
@"delete from op_audit where bsno='" + BsNo + "'");
db.ExecuteNonQuery(cmdUpdateAudit, tran);
if (isamend == "1")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET BillFeeStatus=4,FEESTATUS=0 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
var cmdUpdateclose = db.GetSqlStringCommand(
@"UPDATE op_close SET FEECLOSETIME=null,FEECLOSEOP='' WHERE BSNO=@BSNO ");
cmdUpdateclose.Parameters.Clear();
db.AddInParameter(cmdUpdateclose, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateclose, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=4,FEESTATUS=0,BSSTATUS=0 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
var cmdUpdateclose = db.GetSqlStringCommand(
@"UPDATE op_close SET BSCLOSETIME=null,BSCLOSEOP='',FEECLOSETIME=null,FEECLOSEOP='' WHERE BSNO=@BSNO ");
cmdUpdateclose.Parameters.Clear();
db.AddInParameter(cmdUpdateclose, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateclose, tran);
}
var cmdUpdatetask = db.GetSqlStringCommand(
@"UPDATE op_task SET TASKSTATUS='已取消',ISCOMPLETE=1,COMPLETETYPE='人工',COMPLETETIME=GETDATE() WHERE BSNO=@BSNO ");
cmdUpdatetask.Parameters.Clear();
db.AddInParameter(cmdUpdatetask, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdatetask, tran);
var cmdUpdateBL =
db.GetSqlStringCommand(
@"INSERT INTO [op_task] (GID,[TASKNO] ,[PTASKNO],[TASKTYPE],[TASKSOURCE],[TASKSTATUS],[TASKTITLE] "
+ ",[CREATEUSER] ,[CREATETIME] ,[TASKBEGINDATE] ,[COMPLETETYPE] ,[COMPLETETIME] ,[KPI],[MBLNO],[FILENO],[MAILNO],[FILEPATH],[ISPUBLIC],[OP],[BSNO],ISCOMPLETE)"
+ " SELECT NEWID(),NEWID() as [任务编号],null as [上级任务号], '账单审核驳回' as [任务类型], '账单审核' as [任务来源], '未开始' as [任务状态], '驳回原因:" + reason + "' as [任务说明],"
+ "'" + username + "' as [发起人],GETDATE() as [录入日期],GETDATE() as[任务开始时间], '手动' as [完成方式],null as [完成时间] ,null as [KPI值] , '' as [提单号], "
+ " null as [文件编号], '' as [邮件编号], '' as [电子档案路径], 0 as 是否公共,'"+op+"' as 客服员,'" + BsNo + "' as 编号,0");
db.ExecuteNonQuery(cmdUpdateBL, tran);
tran.Commit();
result.Success = true;
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "审核过程出现错误" + e.Message;
}
}
return result;
}
public static DBResult CloseAuditBL(string BsNo, string oplb, string isamend, string userid, string username)
{
var result = new DBResult();
//var auditlogList = MsOpAuditDetailDAL.GetAuditLogList("BSNO='" + BsNo + "' and AUDITTYPE='提交审核'");
//if (auditlogList != null)
//{
// if (auditlogList.Count > 0)
// {
// op = auditlogList[0].AUDITUSER;
// }
//}
var logcount = GetAuditLogCount(" BSNO='" + BsNo + "'");
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, logcount+1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, "");
db.AddInParameter(cmdInsert, "@ERROP", DbType.String, "");
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String, "");
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, "整票审核撤销");
if (isamend == "1")
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, true);
else db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.ExecuteNonQuery(cmdInsert, tran);
var cmdUpdateAudit = db.GetSqlStringCommand(
@"update op_audit set ISFINISH=0 where bsno='" + BsNo + "'");
db.ExecuteNonQuery(cmdUpdateAudit, tran);
if (isamend == "1")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET BillFeeStatus=1 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=1 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
tran.Commit();
result.Success = true;
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "审核过程出现错误" + e.Message;
}
}
return result;
}
public static bool CheckHasNoAuditFeeWithBsno(string bsno)
{
Database db = DatabaseFactory.CreateDatabase();
int rst = 0;
string sql = "select count(*) from ch_fee where bsno ='" + bsno + "' and (CUSTOMERNAME='' OR FEESTATUS=1 OR FEESTATUS=2 or FEESTATUS=3 or FEESTATUS=4)";
rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
if (rst > 0) {
return false;
} else {
return true;
}
}
public static DBResult IsAutoAudit(string BsNo, string oplb, string isamend, string userid, string username, string companyid,bool issubmit)
{
var result = new DBResult();
var auditlist = new List<MsOpAuditDetail>();
var sort = 0;
var strbsno = BsNo;
if (issubmit)
{
var opbs = Chfee_AuditDAL.GetBLData("B.BSNO='" + BsNo + "'");
if (opbs.BillFeeStatus == "1" || opbs.BillFeeStatus == "2")
{
result.Success = false;
result.Message = "已提交审核或审核通过,不允许重复提交!";
return result;
}
if (oplb.ToUpper() == "OP_SEAE")
{
if (string.IsNullOrEmpty(opbs.ETD))
{
result.Success = false;
result.Message = "开船日期为空,不允许提交!";
return result;
}
if (Convert.ToDateTime(opbs.ETD) > DateTime.Now)
{
result.Success = false;
result.Message = "开船日期之前,不允许提交!";
return result;
}
}
//if (isamend == "1") {
// var opamend = MsChFeeDAL.GetAmendData("BSNO='"+BsNo+"'");
// strbsno = opamend.PARENTID;
// var bgndate = Convert.ToDateTime(opamend.CREATETIME).AddDays(4);
// if (bgndate < DateTime.Now)
// {
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.ERRMSG = "晚于时间要求!";
// audit.ERRDATA = "更改单生成日期:" + opamend.CREATETIME + "后4个工作日起算";
// auditlist.Add(audit);
// }
//}
if (!CheckHasNoAuditFeeWithBsno(BsNo))
{
result.Success = false;
result.Message = "费用中存在录入、提交审核、申请修改、申请删除状态的费用,不允许提交账单审核!";
return result;
}
}
Database db = DatabaseFactory.CreateDatabase();
if (isamend == "1" && oplb.ToUpper() == "OP_SEAE")
{
var opseaeremark = "";
var optask = MsOpTaskDAL.GetData("t.TASKNO='" + BsNo + "'");
if (issubmit && !string.IsNullOrEmpty(optask.CREATETIME))
{
//var bgndate = Convert.ToDateTime(optask.CREATETIME).AddDays(4);
//if (bgndate < DateTime.Now)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITDETAILID = "SEAAMEND0001";
// audit.AUDITTYPE = "1";
// audit.ERRMSG = "晚于时间要求!";
// audit.ERRDATA = "更改单任务生成日期:" + optask.CREATETIME + "后4个工作日起算";
// auditlist.Add(audit);
//}
//else {
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITDETAILID = "SEAAMEND0002";
// audit.AUDITTYPE = "0";
// audit.ERRMSG = "账单符合时间要求!";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
}
var opamend = MsOpBillDAL.GetData("BSNO='" + BsNo + "'");
var OPSEAE = MsOpSeaeDAL.GetData("BSNO='" + opamend.PARENTID + "'", userid);
var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + opamend.PARENTID + "'");
var FeeList = MsChFeeDAL.GetDataList(" BSNO IN (SELECT BSNO FROM V_OP_BILL WHERE PARENTID IN (SELECT PARENTID FROM op_amend WHERE BSNO='" + BsNo + "'))", 2, "", userid, username, companyid);
if (!string.IsNullOrEmpty(opamend.APPLYNO))
{
var applynostr = "'" + opamend.APPLYNO + "'";
if (opamend.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = opamend.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (!string.IsNullOrEmpty(applyno))
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
}
var opctnnum = 0;
var ctnnostr = "";
var issame = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else
opctnnum = opctnnum + ctn.CTNNUM;
if (!string.IsNullOrEmpty(ctn.CNTRNO))
{
var CtnGId = "'" + ctn.CNTRNO + "'";
if (ctnnostr == "")
{
ctnnostr = CtnGId;
}
else
{
ctnnostr = ctnnostr + "," + CtnGId;
}
}
if (ctn.PKGS != ctn.CTNNUM) issame = false;
}
}
if (OPSEAE.ISFUMIGATION)
{
if (Convert.ToInt32(OPSEAE.PKGS) != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAAMEND000101";
audit.AUDITTYPE = "1";
audit.ERRMSG = "整箱业务箱量和件数不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAAMEND000102";
audit.AUDITTYPE = "0";
audit.ERRMSG = "整箱业务箱量和件数一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
decimal CTNTOTAL = 0;
decimal APPLYCTNTOTAL = 0;
var isfind = false;
bool isysgxf = false;
decimal YSGXF = 0;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
{
CTNTOTAL = CTNTOTAL + FEE.Amount;
}
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
YSGXF = YSGXF + FEE.Amount;
isysgxf = true;
}
}
var ctnapplyremark = "";
var opcntapplysql = "BSNO IN (" + applynostr + ")";
var opctnbscardsqlstr = "APPLYNO IN (" + applynostr + ")";
if (!string.IsNullOrEmpty(ctnnostr)) opctnbscardsqlstr = opctnbscardsqlstr + " AND CTNNO IN (" + ctnnostr + ")";
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList(opctnbscardsqlstr);
var OPCTNAPPLYLIST = MsOpCtnApplyDAL.GetDataList(opcntapplysql);
foreach (var OPCTNAPPLY in OPCTNAPPLYLIST)
{
ctnapplyremark = OPCTNAPPLY.LOAD_FREE_USECTNE_DAY + "/" + OPCTNAPPLY.LOAD_OVER_USECTNE_RATE + "+" + OPCTNAPPLY.DEST_FREE_USECTNE_DAY + "/" + OPCTNAPPLY.DEST_OVER_USECTNE_RATE;
if (OPCTNAPPLY.MNGAUDITSTATUS != "审核通过" || OPCTNAPPLY.COSTAUDITSTATUS == "申请修改") {
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND00031";
audit.ERRMSG = "成本核算不匹配!";
audit.ERRDATA = "成本核算未审核或申请修改";
auditlist.Add(audit);
}
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
//YSGXF = YSGXF + FEE.Amount;
if (opctnbscardlist.Count!=0&&FEE.Currency != OPCTNAPPLY.CURRENCY || FEE.CustomerName != OPCTNAPPLY.OWNERCTN)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND0003";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:币别" + FEE.Currency + " 结算单位:" + FEE.CustomerName + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 币别:" + OPCTNAPPLY.CURRENCY + " 结算单位:" + OPCTNAPPLY.OWNERCTN;
auditlist.Add(audit);
isysgxf = false;
}
}
if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
{
if (FEE.Currency == OPCTNAPPLY.CURRENCY && (FEE.CustomerName == OPCTNAPPLY.OWNERCTN || FEE.CustomerName == "恒成"))
{
isfind = true;
}
}
}
var applyctnlist = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("b.LINKGID='" + OPCTNAPPLY.GID + "'");
foreach (var applyctn in applyctnlist)
{
if (ctnlist.Find(x => x.CNTRNO == applyctn.CTNNO) != null)
APPLYCTNTOTAL = APPLYCTNTOTAL + OPCTNAPPLY.CTN_PRICE;
}
//APPLYCTNTOTAL = APPLYCTNTOTAL + OPCTNAPPLY.CTN_PRICE * opctnnum;
}
foreach (var opctnbscard in opctnbscardlist)
{
var ctnbscardremark = "";
foreach (var ctn in ctnlist)
{
if (ctn.CNTRNO == opctnbscard.CTNNO)
{
ctnbscardremark = "罐号:" + opctnbscard.CTNNO + " 提箱:" + opctnbscard.PORTLOAD_CNT_TIME + " 开船:" + opctnbscard.ETD + " " + Convert.ToInt32(opctnbscard.PORTLOAD_FREE_DAYS).ToString() + "/USD" + opctnbscard.PORTLOAD_OVER_DAYS_FEE.ToString().Replace(".0000", ".00") + "+" + Convert.ToInt32(opctnbscard.DESTPORT_FREE_DAYS).ToString() + "/USD" + opctnbscard.DESTPORT_OVER_DAYS_FEE.ToString().Replace(".0000", ".00");
if (opctnbscard.PORTLOAD_OVER_DAYS_AMT == 0)
{
ctnbscardremark = ctnbscardremark + " 不超期";
}
else
{
ctnbscardremark = ctnbscardremark + " 起运港超期天数" + Convert.ToInt32(opctnbscard.PORTLOAD_OVER_DAYS).ToString() + "天起运港箱使费USD" + opctnbscard.PORTLOAD_OVER_DAYS_AMT.ToString().Replace(".0000", ".00");
}
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
if (opctnbscard.ETD != opamend.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "与业务卡开船日期不一致!";
audit.ERRDATA = "开船日期:" + opamend.ETD + "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.ETD;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.ERRMSG = "与业务卡开船日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.ETD;
auditlist.Add(audit);
}
var opctnFeeList = MsChFeeDAL.GetDataList("BsNo='" + opctnbscard.GID + "' and (FEENAME='出口起运港-箱使费' or FEENAME='起运港箱使费') AND FEETYPE=1 ", 1, "", userid, username, companyid);
if (opctnFeeList != null && opctnFeeList.Count != 0)
{
decimal qygxsf = 0;
string qygxsfcurr = "";
foreach (var FEE in opctnFeeList)
{
if (FEE.FeeName == "出口起运港-箱使费" || FEE.FeeName == "起运港箱使费")
{
qygxsf = qygxsf + FEE.Amount;
qygxsfcurr = FEE.Currency;
}
if (!string.IsNullOrEmpty(FEE.WmsOutBsNo))
{
foreach (var OPFEE in FeeList)
{
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount != OPFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "费用名称" + FEE.FeeName + ",金额和引入的费用不一致";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 引入不一致!";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN && FEE.Currency == OPFEE.Currency)
{
result.Success = false;
result.Message = "起运港箱使费不匹配不允许提交!";
return result;
}
}
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount == OPFEE.Amount || FEE.Currency == OPFEE.Currency))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.ERRMSG = FEE.FeeName + ",操作与业务卡金额和引入的费用一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "业务卡:" + FEE.FeeName + "未引入操作模块";
audit.AUDITTYPE = "1";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 未引入操作模块";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN)
{
result.Success = false;
result.Message = "起运港箱使费不匹配不允许提交!";
return result;
}
}
//}
}
if (qygxsf != opctnbscard.PORTLOAD_OVER_DAYS_AMT)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "起运港箱使费不一致,不允许提交!";
audit.AUDITTYPE = "1";
audit.ERRDATA = "";
auditlist.Add(audit);
if (qygxsfcurr == "USD" && !opctnbscard.ISSHORTRENTCTN)
{
result.Success = false;
result.Message = "业务卡起运港箱使费不匹配不允许提交!";
return result;
}
}
}
else
{
if (opctnbscard.PORTLOAD_OVER_DAYS_AMT == 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.ERRMSG = "起运港箱使费匹配一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "起运港箱使费匹配不一致,业务卡费用未生成";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
if (isysgxf)
{
if (opctnbscardlist.Count!=0&&YSGXF != 0 && YSGXF != APPLYCTNTOTAL)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND0004";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费合计:" + YSGXF + "--用箱申请 罐箱费:" + APPLYCTNTOTAL.ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAAMEND0005";
audit.ERRMSG = "应收罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (isfind)
{
if (opctnbscardlist.Count == 0 && CTNTOTAL == APPLYCTNTOTAL)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAAMEND0006";
audit.ERRMSG = "应付罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND0007";
audit.ERRMSG = "应付罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:" + CTNTOTAL + "用箱申请:" + APPLYCTNTOTAL;
auditlist.Add(audit);
}
}
else
{
if (opctnbscardlist.Count != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND0008";
audit.ERRMSG = "应付罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "用箱申请:" + APPLYCTNTOTAL;
auditlist.Add(audit);
}
}
if (OPSEAE.ISAGENT)
{
if (Convert.ToInt64(opctnnum) != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAAMEND0009";
audit.ERRMSG = "服务项目为仅账单,箱数必须为0";
audit.ERRDATA = "现箱数为:" + opctnnum;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAAMEND0010";
audit.ERRMSG = "箱数符合要求";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//if (OPSEAE.TEU != 0)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.AUDITDETAILID = "SEAAMEND0011";
// audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
// audit.ERRDATA = "现箱量为:" + (OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR).ToString();
// auditlist.Add(audit);
//}
}
else
{
//sort = sort + 1;
//var audit3 = new MsOpAuditDetail();
//audit3.SORT = sort;
//audit3.AUDITTYPE = "0";
//audit3.ERRMSG = "件数符合要求(服务项目为仅账单,件数必须为0)";
//audit3.ERRDATA = "";
//auditlist.Add(audit3);
var isctnremark = false;
if (opseaeremark == "") isctnremark = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else
opctnnum = opctnnum + ctn.CTNNUM;
if (isctnremark)
{
var ctnbscardremark = "";
ctnbscardremark = "罐号:" + ctn.CNTRNO + ctnapplyremark;
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
//if (ctnnum != opctnnum)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.ERRMSG = "箱量与用箱申请箱量不一致!";
// audit.ERRDATA = "箱量:" + opctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
// auditlist.Add(audit);
//}
//else
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.ERRMSG = "箱量与用箱申请箱量一致!";
// audit.ERRDATA = "箱量:" + opctnnum.ToString();
// auditlist.Add(audit);
//}
}
}
else
{
//var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + OPSEAE.BSNO + "'");
var opctnnum = 0;
var isctnremark = false;
if (opseaeremark == "") isctnremark = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else
opctnnum = opctnnum + ctn.CTNNUM;
if (isctnremark)
{
var ctnbscardremark = "";
ctnbscardremark = "罐号:" + ctn.CNTRNO;
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
}
if (!string.IsNullOrEmpty(opseaeremark) && issubmit)
{
Database db2 = DatabaseFactory.CreateDatabase();
using (var conn = db2.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db2.GetSqlStringCommand(
@"delete from op_amend_remark where bsno='" + opamend.BSNO + "' insert into op_amend_remark(BSNO,REMARK) values('" + opamend.BSNO + "','第" + opamend.SLNO + "次更改 " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "'+CHAR(13)+CHAR(10)+'" + opseaeremark + "') ");
db2.ExecuteNonQuery(cmdUpdate, tran);
//var cmdUpdate = db2.GetSqlStringCommand(
// @"update op_seae set REMARK=ISNULL(REMARK,'')+CHAR(13)+CHAR(10)+'第"+ opamend.SLNO + "次更改 "+DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")+ "'+CHAR(13)+CHAR(10)+'" + opseaeremark + "' where bsno='" + opamend.PARENTID + "' ");
//db2.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception e)
{
tran.Rollback();
}
}
}
}
if (isamend != "1" && oplb.ToUpper() == "OP_SEAE")
{
var OPSEAE = MsOpSeaeDAL.GetData("BSNO='" + strbsno + "'", userid);
var opseaeremark = "";
decimal OPFEECOUNT = 0;
decimal OPCOUNT = 0;
var opctnnum = 0;
bool isbscard = false;
bool island = false;
if (issubmit&&OPSEAE.ISLAND) {
island = true;
if (!string.IsNullOrEmpty(OPSEAE.DELIVERYDATE))
{
// var bgndate = Convert.ToDateTime(OPSEAE.DELIVERYDATE).AddDays(7);
// if (bgndate < DateTime.Now)
var workday = GetWorkDay(Convert.ToDateTime(OPSEAE.DELIVERYDATE).ToString("yyyy-MM-dd"),DateTime.Now.ToString("yyyy-MM-dd"))-1;
if (workday>5)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAEL001";
audit.ERRMSG = "晚于时间要求!";
audit.ERRDATA = "海运出口送货日期:" + OPSEAE.DELIVERYDATE + "后五个工作日起算";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAEL002";
audit.AUDITTYPE = "0";
audit.ERRMSG = "符合时间要求(送货日期)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
else {
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAEL003";
audit.AUDITTYPE = "1";
audit.ERRMSG = "晚于时间要求!";
audit.ERRMSG = "海运出口送货日期为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (isamend != "1" && !string.IsNullOrEmpty(OPSEAE.ETD))
{
//var bgndate = Convert.ToDateTime(OPSEAE.ETD).AddDays(8);
var workday = GetWorkDay(Convert.ToDateTime(OPSEAE.ETD).ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"))-1;
if (issubmit&&(!island))
{
if (workday > 5)
//if (bgndate < DateTime.Now)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE001";
audit.ERRMSG = "晚于时间要求!";
audit.ERRDATA = "海运出口开船日期:" + OPSEAE.ETD + "开船后五个工作日起算";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAE002";
audit.AUDITTYPE = "0";
audit.ERRMSG = "符合时间要求";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (Convert.ToDateTime(OPSEAE.ETD).ToString("yyyy-MM") != OPSEAE.ACCDATE)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE003";
audit.ERRMSG = "海运出口开船日期与会计期间不一致";
audit.ERRDATA = "海运出口开船日期:" + OPSEAE.ETD + " 会计期间:" + OPSEAE.ACCDATE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE004";
audit.ERRMSG = "海运出口开船日期与会计期间一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.SALEDEPT == "市场部")
{
var opgain = MsChFeeDAL.GetHCGainList("BSNO='" + BsNo + "'");
if (opgain != null && opgain.Count != 0)
{
if (opgain[0].TTLHYFCR > (opgain[0].PR * 10))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE005";
audit.ERRMSG = "市场部应付HYF的金额大于毛利润的10倍";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//else {
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.ERRMSG = "市场部应付HYF的金额小于毛利润的10倍";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
if (opgain[0].TTLHYFCR != 0 && (opgain[0].TTLDR - opgain[0].TTLCR) < 700)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE006";
audit.ERRMSG = "市场部应付已录HYF毛利润小于等于100美金";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//else
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.ERRMSG = "市场部应付已录HYF毛利润小于等于50美金";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
if (opgain[0].PR < 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE007";
audit.ERRMSG = "市场部毛利润小于等于0";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
}
if (string.IsNullOrEmpty(OPSEAE.MBLNO))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE008";
audit.ERRMSG = "海运出口主提单号不能为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE009";
audit.ERRMSG = "海运出口主提单号不能为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var FeeList = MsChFeeDAL.GetDataList(" BSNO IN (SELECT BSNO FROM V_OP_BILL WHERE PARENTID='" + BsNo + "')", 2, "", userid, username, companyid);
var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + OPSEAE.BSNO + "'");
if (!string.IsNullOrEmpty(OPSEAE.APPLYNO))
{
var applynostr = "'" + OPSEAE.APPLYNO + "'";
if (OPSEAE.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = OPSEAE.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (!string.IsNullOrEmpty(applyno))
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
}
sort = sort + 1;
var audit1 = new MsOpAuditDetail();
audit1.SORT = sort;
audit1.AUDITTYPE = "0";
audit1.ERRMSG = "放箱申请单号符合要求!";
audit1.ERRDATA = "";
auditlist.Add(audit1);
var isfind = false;
decimal CTNTOTAL = 0;
decimal YSGXF = 0;
decimal APPLYYSGXF = 0;
bool isysgxf = false;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
YSGXF = YSGXF + FEE.Amount;
isysgxf = true;
}
if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
{
CTNTOTAL = CTNTOTAL + FEE.Amount;
}
}
var OPCTNAPPLYLIST = MsOpCtnApplyDAL.GetDataList("BSNO IN (" + applynostr + ")");
var ctnnum = 0;
var ctnapplyremark = "";
opctnnum = 0;
var ctnnostr = "";
var issame = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
//if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
// opctnnum = opctnnum + 1;
//else
opctnnum = opctnnum + ctn.CTNNUM;
if (!string.IsNullOrEmpty(ctn.CNTRNO))
{
var CtnGId = "'" + ctn.CNTRNO + "'";
if (ctnnostr == "")
{
ctnnostr = CtnGId;
}
else
{
ctnnostr = ctnnostr + "," + CtnGId;
}
}
if (ctn.PKGS != ctn.CTNNUM) issame = false;
}
}
if (OPSEAE.ISFUMIGATION)
{
if (Convert.ToInt32(OPSEAE.PKGS) != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEA000101";
audit.AUDITTYPE = "1";
audit.ERRMSG = "整箱业务箱量和件数不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEA000102";
audit.AUDITTYPE = "0";
audit.ERRMSG = "整箱业务箱量和件数一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
foreach (var OPCTNAPPLY in OPCTNAPPLYLIST)
{
ctnapplyremark = OPCTNAPPLY.LOAD_FREE_USECTNE_DAY + "/" + OPCTNAPPLY.LOAD_OVER_USECTNE_RATE + "+" + OPCTNAPPLY.DEST_FREE_USECTNE_DAY + "/" + OPCTNAPPLY.DEST_OVER_USECTNE_RATE;
if (OPCTNAPPLY.MNGAUDITSTATUS != "审核通过" || OPCTNAPPLY.COSTAUDITSTATUS == "申请修改")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEA00031";
audit.ERRMSG = "成本核算不匹配!";
audit.ERRDATA = "成本核算未审核或申请修改";
auditlist.Add(audit);
}
if (OPSEAE.MBLNO.IndexOf(".") > 0)
{
if (OPSEAE.CUSTOMERNAME != "恒成")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE010";
audit.ERRMSG = "委托单位匹配不一致!";
audit.ERRDATA = "主提单号含.委托单位必须为恒成";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE011";
audit.ERRMSG = "委托单位匹配一致!";
audit.ERRDATA = "主提单号含.委托单位必须为恒成";
auditlist.Add(audit);
}
}
else
{
if (OPSEAE.CUSTOMERNAME != OPCTNAPPLY.CUSTOMERNAME)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE012";
audit.ERRMSG = "与用箱申请委托单位不一致!";
audit.ERRDATA = "委托单位:" + OPSEAE.CUSTOMERNAME + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 委托单位:" + OPCTNAPPLY.CUSTOMERNAME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE013";
audit.ERRMSG = "与用箱申请委托单位一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (OPSEAE.SALE != OPCTNAPPLY.SALE)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE014";
audit.ERRMSG = "与用箱申请揽货人不一致!";
audit.ERRDATA = "揽货人:" + OPSEAE.SALE + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 揽货人:" + OPCTNAPPLY.SALE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE015";
audit.ERRMSG = "与用箱申请揽货人一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTLOAD != OPCTNAPPLY.PORTLOAD)
{
if (OPCTNAPPLY.PORTLOAD == "QINGDAO,CHINA" && OPSEAE.PORTLOADID == "CNTAO")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港一致!";
audit.AUDITDETAILID = "SEAE016";
audit.AUDITTYPE = "0";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE017";
audit.ERRDATA = "起运港:" + OPSEAE.PORTLOAD + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 起运港:" + OPCTNAPPLY.PORTLOAD;
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE018";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTDISCHARGE != OPCTNAPPLY.PORTDISCHARGE)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请卸货港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE019";
audit.ERRDATA = "卸货港:" + OPSEAE.PORTDISCHARGE + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 卸货港:" + OPCTNAPPLY.PORTDISCHARGE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请卸货港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE020";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.GOODSNAME != OPCTNAPPLY.GOODSNAME)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE021";
audit.ERRMSG = "与用箱申请品名不一致!";
audit.ERRDATA = "品名:" + OPSEAE.GOODSNAME + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 品名:" + OPCTNAPPLY.GOODSNAME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE022";
audit.ERRMSG = "与用箱申请品名一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
//YSGXF = YSGXF + FEE.Amount;
if (FEE.Currency != OPCTNAPPLY.CURRENCY)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE023";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:" + FEE.UnitPrice + "*" + FEE.Quantity + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 单价:" + OPCTNAPPLY.CTN_PRICE;
auditlist.Add(audit);
isysgxf = false;
}
}
if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
{
if (FEE.Currency == OPCTNAPPLY.CURRENCY && FEE.CustomerName == OPCTNAPPLY.OWNERCTN)
{
isfind = true;
//CTNTOTAL = CTNTOTAL + FEE.Amount;
}
}
}
var applyctnlist = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("b.LINKGID='" + OPCTNAPPLY.GID + "'");
foreach (var applyctn in applyctnlist)
{
if (ctnlist.Find(x => x.CNTRNO == applyctn.CTNNO) != null)
APPLYYSGXF = APPLYYSGXF + OPCTNAPPLY.CTN_PRICE;
}
//APPLYYSGXF = APPLYYSGXF + OPCTNAPPLY.CTN_PRICE * opctnnum;
ctnnum = ctnnum + OPCTNAPPLY.CTNNUM;
var bscardstr = "APPLYNO='" + OPCTNAPPLY.BSNO + "'";
if (!string.IsNullOrEmpty(ctnnostr)) bscardstr = bscardstr + " AND CTNNO IN (" + ctnnostr + ")";
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList(bscardstr);
foreach (var opctnbscard in opctnbscardlist)
{
var ctnbscardremark = "";
isbscard = true;
foreach (var ctn in ctnlist)
{
if (ctn.CNTRNO == opctnbscard.CTNNO)
{
ctnbscardremark = "罐号:" + opctnbscard.CTNNO + " 提箱:" + opctnbscard.PORTLOAD_CNT_TIME + " 开船:" + opctnbscard.ETD + " " + Convert.ToInt32(opctnbscard.PORTLOAD_FREE_DAYS).ToString() + "/USD" + opctnbscard.PORTLOAD_OVER_DAYS_FEE.ToString().Replace(".0000", ".00") + "+" + Convert.ToInt32(opctnbscard.DESTPORT_FREE_DAYS).ToString() + "/USD" + opctnbscard.DESTPORT_OVER_DAYS_FEE.ToString().Replace(".0000", ".00");
if (opctnbscard.PORTLOAD_OVER_DAYS_AMT == 0)
{
ctnbscardremark = ctnbscardremark + " 不超期";
}
else
{
ctnbscardremark = ctnbscardremark + " 起运港超期天数" + Convert.ToInt32(opctnbscard.PORTLOAD_OVER_DAYS).ToString() + "天起运港箱使费USD" + opctnbscard.PORTLOAD_OVER_DAYS_AMT.ToString().Replace(".0000", ".00");
}
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
if (string.IsNullOrEmpty(opctnbscard.PORTLOAD_CNT_TIME))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE024";
audit.ERRMSG = "业务卡起运港提箱日期为空,不允许提交!";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "]";
auditlist.Add(audit);
result.Success = false;
result.Message = "业务卡起运港提箱日期为空,不允许提交!";
return result;
}
if (opctnbscard.ETD != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE025";
audit.ERRMSG = "与业务卡开船日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.ETD;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE026";
audit.ERRMSG = "与业务卡开船日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.ETD;
auditlist.Add(audit);
}
if (OPSEAE.GOODSNAME != opctnbscard.GOODSNAME)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE027";
audit.ERRMSG = "与业务卡品名不一致!";
audit.ERRDATA = "品名:" + OPSEAE.GOODSNAME + "--业务卡[" + opctnbscard.BSNO + "] 品名:" + opctnbscard.GOODSNAME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE028";
audit.ERRMSG = "与业务卡品名一致!";
audit.ERRDATA = "品名:" + OPSEAE.GOODSNAME + "--业务卡[" + opctnbscard.BSNO + "] 品名:" + opctnbscard.GOODSNAME;
auditlist.Add(audit);
}
if (OPSEAE.MBLNO.IndexOf("年检") > 0)
{
var dataList = MsCodeCtnTkDAL.GetCodeCtnTkInspectItemsData("BSNO IN (SELECT GID FROM code_ctntk WHERE CTNNO='" + opctnbscard.CTNNO + "')");
if (dataList != null && dataList.Count != 0)
{
if (dataList[0].DEPOT != opctnbscard.DESTPORT_STATOIN)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE029";
audit.ERRMSG = "罐箱年检信息与业务卡目的港场站不一致!";
audit.ERRDATA = "场站:" + dataList[0].DEPOT + "--业务卡[" + opctnbscard.BSNO + "] 目的港场站:" + opctnbscard.DESTPORT_STATOIN;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE030";
audit.ERRMSG = "罐箱年检信息与业务卡目的港场站一致!";
audit.ERRDATA = "场站:" + dataList[0].DEPOT + "--业务卡[" + opctnbscard.BSNO + "] 目的港场站:" + opctnbscard.DESTPORT_STATOIN;
auditlist.Add(audit);
}
if (dataList[0].DEPOTDATE != opctnbscard.DEST_RTCNT_TIME)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE031";
audit.ERRMSG = "罐箱年检信息与业务卡目的港还箱日期不一致!";
audit.ERRDATA = "入场时间:" + dataList[0].DEPOTDATE + "--业务卡[" + opctnbscard.BSNO + "] 目的港还箱:" + opctnbscard.DEST_RTCNT_TIME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE032";
audit.ERRMSG = "罐箱年检信息与业务卡目的港还箱日期一致!";
audit.ERRDATA = "入场时间:" + dataList[0].DEPOTDATE + "--业务卡[" + opctnbscard.BSNO + "] 目的港还箱:" + opctnbscard.DEST_RTCNT_TIME;
auditlist.Add(audit);
}
}
}
var opctnFeeList = MsChFeeDAL.GetDataList("BsNo='" + opctnbscard.GID + "' and (FEENAME='出口起运港-箱使费' or FEENAME='起运港箱使费') AND FEETYPE=1 ", 1, "", userid, username, companyid);
if (opctnFeeList != null && opctnFeeList.Count != 0)
{
decimal qygxsf = 0;
string qygxsfcurr = "";
foreach (var FEE in opctnFeeList)
{
if (FEE.FeeName == "出口起运港-箱使费" || FEE.FeeName == "起运港箱使费")
{
qygxsf = qygxsf + FEE.Amount;
qygxsfcurr = FEE.Currency;
}
if (!string.IsNullOrEmpty(FEE.WmsOutBsNo))
{
foreach (var OPFEE in FeeList)
{
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount != OPFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE033";
audit.ERRMSG = "费用名称" + FEE.FeeName + ",金额和引入的费用不一致";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 引入不一致!";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN && FEE.Currency == OPFEE.Currency)
{
result.Success = false;
result.Message = "起运港箱使费不匹配不允许提交!";
return result;
}
}
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount == OPFEE.Amount || FEE.Currency == OPFEE.Currency))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE034";
audit.ERRMSG = FEE.FeeName + ",操作与业务卡金额和引入的费用一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "业务卡:" + FEE.FeeName + "未引入操作模块";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE035";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 未引入操作模块";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN)
{
result.Success = false;
result.Message = "起运港箱使费不匹配不允许提交!";
return result;
}
}
//}
}
if (qygxsf != opctnbscard.PORTLOAD_OVER_DAYS_AMT)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "起运港箱使费不一致,不允许提交!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE036";
audit.ERRDATA = "";
auditlist.Add(audit);
if (qygxsfcurr == "USD" && !opctnbscard.ISSHORTRENTCTN)
{
result.Success = false;
result.Message = "业务卡起运港箱使费不匹配不允许提交!";
return result;
}
}
}
else
{
if (opctnbscard.PORTLOAD_OVER_DAYS_AMT == 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE037";
audit.ERRMSG = "起运港箱使费匹配一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE038";
audit.ERRMSG = "起运港箱使费匹配不一致,业务卡费用未生成";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
}
}
}
if (isysgxf)
{
if (YSGXF != 0 && YSGXF != APPLYYSGXF)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE039";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费合计:" + YSGXF + "--用箱申请 罐箱费:" + APPLYYSGXF.ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE040";
audit.ERRMSG = "应收罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (isfind)
{
if (CTNTOTAL == APPLYYSGXF)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE041";
audit.ERRMSG = "应付罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE042";
audit.ERRMSG = "应付罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:" + CTNTOTAL + "用箱申请:" + APPLYYSGXF;
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE043";
audit.ERRMSG = "应付罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "用箱申请:" + APPLYYSGXF.ToString();
auditlist.Add(audit);
}
if ((OPSEAE.SERVICE.IndexOf("-DOOR") > 0 || OPSEAE.SERVICE.IndexOf("-DR") > 0) && string.IsNullOrEmpty(OPSEAE.DESTINATION))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE044";
audit.ERRMSG = "到门业务目的港不能为空!";
audit.ERRDATA = "运输条款:" + OPSEAE.SERVICE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE045";
audit.ERRMSG = "目的港符合要求(TO DOOR业务目的港不能为空)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.ISAGENT)
{
if (Convert.ToInt64(OPSEAE.PKGS) != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE046";
audit.ERRMSG = "服务项目为仅账单,件数必须为0";
audit.ERRDATA = "现件数为:" + OPSEAE.PKGS;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE047";
audit.ERRMSG = "件数符合要求";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.TEU != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE048";
audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
audit.ERRDATA = "现箱量为:" + (OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR).ToString();
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit3 = new MsOpAuditDetail();
audit3.SORT = sort;
audit3.AUDITTYPE = "0";
audit3.AUDITDETAILID = "SEAE049";
audit3.ERRMSG = "件数符合要求(服务项目为仅账单,件数必须为0)";
audit3.ERRDATA = "";
auditlist.Add(audit3);
opctnnum = 0;
var isctnremark = false;
if (opseaeremark == "") isctnremark = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else
opctnnum = opctnnum + ctn.CTNNUM;
if (isctnremark)
{
var ctnbscardremark = "";
ctnbscardremark = "罐号:" + ctn.CNTRNO + ctnapplyremark;
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
if (ctnnum != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE050";
audit.ERRMSG = "箱量与用箱申请箱量不一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE051";
audit.ERRMSG = "箱量与用箱申请箱量一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString();
auditlist.Add(audit);
}
}
}
else
{
//var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + OPSEAE.BSNO + "'");
opctnnum = 0;
var isctnremark = false;
if (opseaeremark == "") isctnremark = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else
opctnnum = opctnnum + ctn.CTNNUM;
if (isctnremark)
{
var ctnbscardremark = "";
ctnbscardremark = "罐号:" + ctn.CNTRNO;
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
}
if (OPSEAE.ISAGENT)
{
var issamectn = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNNUM != 0 || ctn.PKGS != 1) issamectn = false;
}
if (!issamectn)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE052";
audit.ERRMSG = "仅帐单业务箱量件数不正确(箱量必须为0件数为1)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE053";
audit.ERRMSG = "仅帐单业务箱量和件数正确!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (OPSEAE.ISFUMIGATION || OPSEAE.ISINSPECTION)
{
var isfindctnno = true;
foreach (var ctn in ctnlist)
{
if (string.IsNullOrEmpty(ctn.CNTRNO)) isfindctnno = false;
}
if (!isfindctnno)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE054";
audit.ERRMSG = "集装箱信息的箱号为空!";
audit.ERRDATA = "服务项目是整箱、报关拖车调拨";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE055";
audit.ERRMSG = "集装箱信息的箱号不为空!";
audit.ERRDATA = "服务项目是整箱、报关拖车调拨";
auditlist.Add(audit);
}
}
if (OPSEAE.ISFUMIGATION)
{
OPFEECOUNT = opctnnum;
OPCOUNT = 0.5M;
if (isbscard) OPCOUNT = 1;
}
else if (OPSEAE.ISCUSTOMS)
{
OPFEECOUNT = 1;
OPCOUNT = 0.5M;
}
else if (OPSEAE.ISINSPECTION)
{
OPFEECOUNT = 0.5M;
OPCOUNT = 0.5M;
}
else if (OPSEAE.ISAGENT)
{
OPFEECOUNT = 0;
OPCOUNT = 0.5M;
}
else if (OPSEAE.ISLAND)
{
OPFEECOUNT = 0.2M * opctnnum;
OPCOUNT = 0.2M * opctnnum;
}
if (!string.IsNullOrEmpty(OPSEAE.FORWARDER))
{
if (FeeList != null && FeeList.Count != 0)
{
var FeeDrList = new List<MsChFee>();
var FeeCrList = new List<MsChFee>();
var isnotsame = false;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 2 && (FEE.FeeName == "出口海运费" || FEE.FeeName == "代理海运费") && FEE.CustomerName != OPSEAE.FORWARDER)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE056";
audit.ERRMSG = "海运费结算对象与订舱代理不一致!";
audit.ERRDATA = "海运费结算对象:" + FEE.CustomerName + "--订舱代理:" + OPSEAE.FORWARDER;
auditlist.Add(audit);
isnotsame = true;
}
if (FEE.FeeType == 1 && FEE.Currency != "RMB")
{
FeeDrList.Add(FEE);
}
if (FEE.FeeType == 2 && FEE.Currency != "RMB")
{
FeeCrList.Add(FEE);
}
}
if (!isnotsame)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE057";
audit.ERRMSG = "海运费结算对象与订舱代理一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
isnotsame = false;
foreach (var FEE in FeeDrList)
{
if (FEE.BsNo == OPSEAE.BSNO)
{
foreach (var CRFEE in FeeCrList)
{
if (FEE.BsNo == CRFEE.BsNo && FEE.Currency == CRFEE.Currency && FEE.ExChangerate != CRFEE.ExChangerate)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE058";
audit.ERRMSG = "应收应付汇率不一致!";
audit.ERRDATA = "应收汇率:" + FEE.ExChangerate + "--应付汇率:" + CRFEE.ExChangerate;
auditlist.Add(audit);
isnotsame = true;
}
}
}
}
if (!isnotsame)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAE059";
audit.ERRMSG = "应收应付汇率一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
else
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAE060";
audit.ERRMSG = "订舱代理为空无法匹配海运费费用对象";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (issubmit)
{
if (!string.IsNullOrEmpty(opseaeremark))
{
Database db2 = DatabaseFactory.CreateDatabase();
using (var conn = db2.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db2.GetSqlStringCommand(
@"update op_seae set REMARK='" + opseaeremark + "',OPFEECOUNT=" + OPFEECOUNT + ",OPCOUNT=" + OPCOUNT + " where bsno='" + BsNo + "' ");
db2.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
else
{
Database db2 = DatabaseFactory.CreateDatabase();
using (var conn = db2.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db2.GetSqlStringCommand(
@"update op_seae set OPFEECOUNT=" + OPFEECOUNT + ",OPCOUNT=" + OPCOUNT + " where bsno='" + BsNo + "' ");
db2.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
}
}
else if (isamend != "1" && oplb.ToUpper() == "OP_SEAI")
{
var OPSEAE = MsOpSeaiDAL.GetData("BSNO='" + strbsno + "'");
var opctnnum = 0;
var cntrnostr = "";
var ctnlist = MsOpSeaiDAL.GetBodyListHc("BSNO='" + OPSEAE.BSNO + "'", OPSEAE.APPLYNO);
var opseaeremark = "";
var issame = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
//if (ctn.CTNNUM==0&&!string.IsNullOrEmpty(ctn.CNTRNO))
// opctnnum = opctnnum +1;
//else
opctnnum = opctnnum + ctn.CTNNUM;
if (cntrnostr == "")
{
cntrnostr = "'" + ctn.CNTRNO + "'";
}
else
{
cntrnostr = cntrnostr + "," + "'" + ctn.CNTRNO + "'";
}
if (ctn.PKGS != ctn.CTNNUM) issame = false;
}
}
if (OPSEAE.ISFUMIGATION)
{
if (Convert.ToInt32(OPSEAE.PKGS) != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAAMEND000101";
audit.AUDITTYPE = "1";
audit.ERRMSG = "整箱业务箱量和件数不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAAMEND000102";
audit.AUDITTYPE = "0";
audit.ERRMSG = "整箱业务箱量和件数一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (!string.IsNullOrEmpty(OPSEAE.MBLNO))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI001";
audit.ERRMSG = "主提单号不能为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI002";
audit.ERRMSG = "主提单号为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.CUSTOMERNAME == "恒成" && OPSEAE.SALE == "恒成")
{
if (OPSEAE.CUSTNO.IndexOf("HE5") > 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI003";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI004";
audit.ERRMSG = "委托编号匹配不一致!";
audit.ERRDATA = "恒成:委托编号" + OPSEAE.CUSTNO;
auditlist.Add(audit);
}
}
else
if (OPSEAE.SALE == "陈成")
{
if (OPSEAE.CUSTNO.IndexOf("CC5") > 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI005";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI006";
audit.ERRMSG = "委托编号匹配不一致!";
audit.ERRDATA = "揽货人:陈成;委托编号" + OPSEAE.CUSTNO;
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI007";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if ((OPSEAE.SERVICE.IndexOf("-DOOR") > 0 || OPSEAE.SERVICE.IndexOf("-DR") > 0) && string.IsNullOrEmpty(OPSEAE.DESTINATION))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI008";
audit.ERRMSG = "到门业务目的港不能为空!";
audit.ERRDATA = "运输条款:" + OPSEAE.SERVICE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI009";
audit.ERRMSG = "目的港符合要求(TO DOOR业务目的港不能为空)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var iszd = false;
//if (OPSEAE.ISFUMIGATION)
//{
//}
var txsj = "";
foreach (var ctn in ctnlist)
{
if (!string.IsNullOrEmpty(ctn.SJRGSJ))
{
if (string.IsNullOrEmpty(txsj))
txsj = ctn.SJRGSJ;
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(ctn.SJRGSJ)) txsj = ctn.SJRGSJ;
}
}
}
if (!string.IsNullOrEmpty(OPSEAE.ETD))
{
if (OPSEAE.ISAGENT)
{
//if (Convert.ToInt64(OPSEAE.PKGS) != 0)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.ERRMSG = "服务项目为仅账单,件数必须为0";
// audit.ERRDATA = "现件数为:" + OPSEAE.PKGS;
// auditlist.Add(audit);
//}
if (OPSEAE.TEU != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0012";
audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
audit.ERRDATA = "现箱量为:" + (OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR).ToString();
auditlist.Add(audit);
}
}
}
var FeeList = MsChFeeDAL.GetDataList("BSNO IN (SELECT BSNO FROM V_OP_BILL WHERE PARENTID='" + BsNo + "')", 2, "", userid, username, companyid);
if (!string.IsNullOrEmpty(OPSEAE.APPLYNO))
{
var applynostr = "'" + OPSEAE.APPLYNO + "'";
if (OPSEAE.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = OPSEAE.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (!string.IsNullOrEmpty(applyno))
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
}
decimal YSGXF = 0;
decimal APPLYYSGXF = 0;
var isgxf = false;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
YSGXF = YSGXF + FEE.Amount;
}
//if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
//{
// if (FEE.Currency == OPCTNAPPLY.CURRENCY && FEE.CustomerName == OPCTNAPPLY.OWNERCTN)
// {
// CTNTOTAL = CTNTOTAL + FEE.Amount;
// }
//}
}
var opseaelist = MsOpBillDAL.GetDataList("APPLYNO IN (" + applynostr + ") AND OPLBNAME='海运出口' and OPTYPE='普通货'", "", "", "");
foreach (var item in opseaelist)
{
//if (item.MBLNO == OPSEAE.MBLNO)
//{
if (OPSEAE.ORDERNO.IndexOf(item.CUSTNO) < 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0013";
audit.ERRMSG = "与原出口账单中的委托编号不一致!";
audit.ERRDATA = "海运出口委托编号:" + item.CUSTNO;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0014";
audit.ERRMSG = "与原出口账单中的委托编号一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (item.CUSTOMERNAME != OPSEAE.ENTERP)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0015";
audit.ERRMSG = "经营单位与原出口账单中的委托单位不一致!";
audit.ERRDATA = "海运出口委托单位:" + item.CUSTOMERNAME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0016";
audit.ERRMSG = "经营单位与原出口账单中的委托单位一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//}
}
var OPCTNAPPLYLIST = MsOpCtnApplyDAL.GetDataList("BSNO IN (" + applynostr + ")");
var ctnnum = 0;
foreach (var OPCTNAPPLY in OPCTNAPPLYLIST)
{
if (OPCTNAPPLY.MNGAUDITSTATUS != "审核通过" || OPCTNAPPLY.COSTAUDITSTATUS == "申请修改")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI00031";
audit.ERRMSG = "成本核算不匹配!";
audit.ERRDATA = "成本核算未审核或申请修改";
auditlist.Add(audit);
}
if ((OPSEAE.BSSOURCEDETAIL != "空返") && (OPSEAE.BSSOURCEDETAIL != "调拨"))
{
if (OPSEAE.PORTLOAD != OPCTNAPPLY.PORTLOAD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港不一致!";
audit.AUDITDETAILID = "SEAI0017";
audit.AUDITTYPE = "1";
audit.ERRDATA = "起运港:" + OPSEAE.PORTLOAD + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 起运港:" + OPCTNAPPLY.PORTLOAD;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0018";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTDISCHARGE != OPCTNAPPLY.PORTDISCHARGE)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请卸货港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0019";
audit.ERRDATA = "卸货港:" + OPSEAE.PORTDISCHARGE + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 卸货港:" + OPCTNAPPLY.PORTDISCHARGE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请卸货港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0020";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
//var isfind = false;
//decimal CTNTOTAL = 0;
//decimal YSGXF = 0;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
//YSGXF = YSGXF + FEE.Amount;
if (FEE.Currency != OPCTNAPPLY.CURRENCY)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0021";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:" + FEE.UnitPrice + "*" + FEE.Quantity + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 单价:" + OPCTNAPPLY.CTN_PRICE;
auditlist.Add(audit);
isgxf = true;
}
}
//if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
//{
// if (FEE.Currency == OPCTNAPPLY.CURRENCY && FEE.CustomerName == OPCTNAPPLY.OWNERCTN)
// {
// isfind = true;
// CTNTOTAL = CTNTOTAL + FEE.Amount;
// }
//}
}
var applyctnlist = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("b.LINKGID='" + OPCTNAPPLY.GID + "'");
foreach (var applyctn in applyctnlist)
{
if (ctnlist.Find(x => x.CNTRNO == applyctn.CTNNO) != null)
APPLYYSGXF = APPLYYSGXF + OPCTNAPPLY.CTN_PRICE;
}
var bscardstr = "APPLYNO='" + OPCTNAPPLY.BSNO + "'";
if (!string.IsNullOrEmpty(cntrnostr)) bscardstr = bscardstr + " and CTNNO IN(" + cntrnostr + ") ";
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList(bscardstr);
foreach (var opctnbscard in opctnbscardlist)
{
var portload = opctnbscard.PORTLOAD;
var portdischarge = opctnbscard.DESTPORT;
if (OPSEAE.BSSOURCEDETAIL == "空返")
{
var dgrq = "";
portload = opctnbscard.I_PORTLOAD;
portdischarge = opctnbscard.I_DESTPORT;
if (!string.IsNullOrEmpty(opctnbscard.I_DEST_RTCNT_TIME))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.I_DEST_RTCNT_TIME;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.I_DEST_RTCNT_TIME)) txsj = opctnbscard.I_DEST_RTCNT_TIME;
}
}
else if (!string.IsNullOrEmpty(opctnbscard.I_ETA))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.I_ETA;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.I_ETA)) txsj = opctnbscard.I_ETA;
}
}
//if (OPSEAE.ETA != opctnbscard.I_ETD)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.AUDITDETAILID = "SEAI0031";
// audit.ERRMSG = "空返的开船日期与业务不一致!";
// audit.ERRDATA = "空返开船日期:" + opctnbscard.I_ETD + "--海运进口开船日期:" + OPSEAE.ETD;
// auditlist.Add(audit);
//}
//else {
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.AUDITDETAILID = "SEAI0031";
// audit.ERRMSG = "空返的开船日期与业务匹配一致!";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
}
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
portload = opctnbscard.D_PORTLOAD;
portdischarge = opctnbscard.D_DESTPORT;
var dgrq = "";
if (!string.IsNullOrEmpty(opctnbscard.D_DEST_RTCNT_TIME))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.D_DEST_RTCNT_TIME;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.D_DEST_RTCNT_TIME)) txsj = opctnbscard.D_DEST_RTCNT_TIME;
}
}
else if (!string.IsNullOrEmpty(opctnbscard.D_ETA))
{
txsj = opctnbscard.D_ETA;
}
//if (OPSEAE.ETD != opctnbscard.D_ETA)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.AUDITDETAILID = "SEAI0032";
// audit.ERRMSG = "调拨的到港日期与业务不一致!";
// audit.ERRDATA = "空返开船日期:" + opctnbscard.I_ETD + "--海运进口开船日期:" + OPSEAE.ETD;
// auditlist.Add(audit);
//}
//else
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.AUDITDETAILID = "SEAI0031";
// audit.ERRMSG = "空返的开船日期与业务匹配一致!";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
}
if (OPSEAE.PORTLOAD!= portload)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡起运港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0022";
audit.ERRDATA = "起运港:" + OPSEAE.PORTLOAD + "--业务卡[" + opctnbscard.BSNO + "] 起运港:" + portload;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡起运港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0023";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTDISCHARGE != portdischarge)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡卸货港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0024";
audit.ERRDATA = "卸货港:" + OPSEAE.PORTDISCHARGE + "--业务卡[" + opctnbscard.BSNO + "] 卸货港:" + portdischarge;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡卸货港一致!";
audit.AUDITTYPE = "0";
audit.ERRDATA = "";
audit.AUDITDETAILID = "SEAI0025";
auditlist.Add(audit);
}
if (opctnbscard.CUSTNO == OPSEAE.CUSTNO)
{
if (opctnbscard.ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0026";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0027";
audit.ERRMSG = "与业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
}
if (OPSEAE.BSSOURCEDETAIL == "空返")
{
if (opctnbscard.I_ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0028";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "空返到港日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.I_ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0029";
audit.ERRMSG = "与空返业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.I_ETA;
auditlist.Add(audit);
}
}
else
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
if (opctnbscard.D_ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0030";
audit.ERRMSG = "调拨业务与业务卡调拨到港日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.D_ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0031";
audit.ERRMSG = "调拨业务与业务卡调拨到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.D_ETA;
auditlist.Add(audit);
}
}
else
{
if (opctnbscard.ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0032";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0033";
audit.ERRMSG = "与业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
}
ctnnum = ctnnum + 1;
var opctnFeeList = MsChFeeDAL.GetDataList("BsNo='" + opctnbscard.GID + "'", 1, "", userid, username, companyid);
decimal qygxsf = 0;
string qygxsfcurr = "";
if (opctnFeeList != null && opctnFeeList.Count != 0)
{
foreach (var FEE in opctnFeeList)
{
if (FEE.FeeName == "箱使费")
{
qygxsf = qygxsf + FEE.Amount;
qygxsfcurr = FEE.Currency;
}
if (!string.IsNullOrEmpty(FEE.WmsOutBsNo)&&(OPSEAE.BSSOURCEDETAIL!="箱使费"))
{
foreach (var OPFEE in FeeList)
{
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount != OPFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0034";
audit.ERRMSG = "费用名称" + FEE.FeeName + ",金额和引入的费用不一致";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 引入不一致!";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN && FEE.Currency == OPFEE.Currency)
{
//result.Success = false;
//result.Message = "起运港箱使费不匹配不允许提交!";
//return result;
}
}
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount == OPFEE.Amount || FEE.Currency == OPFEE.Currency))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0035";
audit.ERRMSG = FEE.FeeName + ",操作与业务卡金额和引入的费用一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
else
{
if (OPSEAE.BSSOURCEDETAIL != "箱使费")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "业务卡:" + FEE.FeeName + "未引入操作模块";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0036";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 未引入操作模块";
auditlist.Add(audit);
}
//if (!opctnbscard.ISSHORTRENTCTN)
//{
// result.Success = false;
// result.Message = "业务卡费用未引入操作模块不允许提交!";
// return result;
//}
}
//}
}
}
else
{
}
if (qygxsf != opctnbscard.DESTPORT_OVER_DAYS_AMT)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "目的港箱使费不一致,不允许提交!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0037";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 目的港箱使费:" + opctnbscard.DESTPORT_OVER_DAYS_AMT.ToString();
auditlist.Add(audit);
//if (qygxsfcurr == "USD" && !opctnbscard.ISSHORTRENTCTN)
//{
//result.Success = false;
//result.Message = "业务卡目的港箱使费不匹配不允许提交!";
//return result;
//}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "目的港箱使费一致";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0038";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var ctnbscardremark = "";
foreach (var ctn in ctnlist)
{
if (ctn.CNTRNO == opctnbscard.CTNNO)
{
ctnbscardremark = "罐号:" + opctnbscard.CTNNO + " 到港:" + opctnbscard.ETA + " 还箱:" + opctnbscard.DEST_RTCNT_TIME + " " + Convert.ToInt32(opctnbscard.DESTPORT_FREE_DAYS).ToString() + "/USD" + opctnbscard.DESTPORT_OVER_DAYS_FEE.ToString().Replace(".0000", ".00");
if (opctnbscard.DESTPORT_OVER_DAYS_AMT == 0)
{
ctnbscardremark = ctnbscardremark + " 不超期";
}
else
{
ctnbscardremark = ctnbscardremark + " 目的港超期天数" + Convert.ToInt32(opctnbscard.DESTPORT_OVER_DAYS).ToString() + "天目的港箱使费USD" + opctnbscard.DESTPORT_OVER_DAYS_AMT.ToString().Replace(".0000", ".00");
}
if (OPSEAE.BSSOURCEDETAIL == "空返")
{
ctnbscardremark = ctnbscardremark + " 空返到港:" + opctnbscard.I_ETA + "," + " 空返还箱:" + opctnbscard.I_DEST_RTCNT_TIME;
}
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
ctnbscardremark = ctnbscardremark + " 调拨到港:" + opctnbscard.D_ETA + "," + " 调拨还箱:" + opctnbscard.D_DEST_RTCNT_TIME;
}
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
}
if (!isgxf )
{
if (YSGXF != (APPLYYSGXF))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0039";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费合计:" + YSGXF + "--用箱申请 罐箱费:" + (APPLYYSGXF).ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0040";
audit.ERRMSG = "应收罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (OPSEAE.BSSOURCEDETAIL != "箱使费")
{
if (ctnnum != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0041";
audit.ERRMSG = "箱量与用箱申请箱量不一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0042";
audit.ERRMSG = "箱量与用箱申请箱量一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString();
auditlist.Add(audit);
}
}
if (!string.IsNullOrEmpty(txsj))
{
if (issubmit)
{
var workday = GetWorkDay(Convert.ToDateTime(txsj).ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"))-1;
if (workday > 7)
// var bgndate = Convert.ToDateTime(txsj).AddDays(10);
//if (bgndate < DateTime.Now)
{
iszd = true;
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0010";
audit.ERRMSG = "晚于时间要求!";
audit.ERRDATA = OPSEAE.BSSOURCEDETAIL+"还箱日期:" + txsj + "后七个工作日起算";
auditlist.Add(audit);
}
}
}
if (!iszd)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0011";
audit.ERRMSG = "未晚出账单,符合账单晚于时间要求!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.ISAGENT)
{
if (Convert.ToInt64(OPSEAE.PKGS) != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0043";
audit.ERRMSG = "服务项目为仅账单,件数必须为0";
audit.ERRDATA = "现件数为:" + OPSEAE.PKGS;
auditlist.Add(audit);
}
if (OPSEAE.TEU != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0044";
audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
audit.ERRDATA = "现箱量为:" + OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR;
auditlist.Add(audit);
}
}
else
{
//var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + OPSEAE.BSNO + "'");
//var opctnnum = 0;
//foreach (var ctn in ctnlist)
//{
// if (ctn.CTNALL.IndexOf("TK") > 0)
// {
// opctnnum = opctnnum + ctn.CTNNUM;
// }
//}
//if (ctnnum != opctnnum)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.ERRMSG = "箱量与用箱申请箱量不一致!";
// audit.ERRDATA = "箱量:" + ctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
// auditlist.Add(audit);
//}
}
}
else
{
if (OPSEAE.ISINSPECTION)
{
if ((OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR) == opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0045";
audit.ERRMSG = "箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0046";
audit.ERRMSG = "调拨业务箱量匹配不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0047";
audit.ERRMSG = "箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var issamectn = true;
if (OPSEAE.ISAGENT)
{
foreach (var ctn in ctnlist)
{
if (ctn.CTNNUM != 0 || ctn.PKGS != 1) issamectn = false;
}
if (!issamectn)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0048";
audit.ERRMSG = "仅帐单业务箱量件数不正确(箱量必须为0件数为1)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0049";
audit.ERRMSG = "仅帐单业务箱量件数正确!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
else if (OPSEAE.ISFUMIGATION || OPSEAE.ISINSPECTION)
{
foreach (var ctn in ctnlist)
{
if (ctn.CTNNUM != 1 || ctn.PKGS != 1) issamectn = false;
}
if (!issamectn)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0050";
audit.ERRMSG = "整箱或报关拖车调拨业务箱量件数匹配不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0051";
audit.ERRMSG = "整箱或报关拖车调拨业务箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
if (FeeList != null && FeeList.Count != 0)
{
var FeeDrList = new List<MsChFee>();
var FeeCrList = new List<MsChFee>();
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1)
{
FeeDrList.Add(FEE);
}
if (FEE.FeeType == 2)
{
FeeCrList.Add(FEE);
}
}
var isnotsame = false;
var isnotsameyj = false;
var isfindyjdr = false;
var isfindyjcr = false;
foreach (var FEE in FeeDrList)
{
if (FEE.FeeName == "押金") isfindyjdr = true;
if (FEE.BsNo == OPSEAE.BSNO)
{
foreach (var CRFEE in FeeCrList)
{
if (FEE.Currency == CRFEE.Currency && FEE.ExChangerate != CRFEE.ExChangerate)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0052";
audit.ERRMSG = "应收应付汇率不一致!";
audit.ERRDATA = "应收汇率:" + FEE.ExChangerate + "--应付汇率:" + CRFEE.ExChangerate;
auditlist.Add(audit);
isnotsame = true;
}
if (CRFEE.FeeName == "押金") isfindyjcr = true;
if (FEE.FeeName == "押金" && CRFEE.FeeName == "押金" && (FEE.CustomerName != CRFEE.CustomerName || FEE.Currency != CRFEE.Currency || FEE.Amount != CRFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0053";
audit.ERRMSG = "押金应收应付不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
isnotsameyj = true;
}
}
}
}
if (!isfindyjdr)
{
foreach (var CRFEE in FeeCrList)
{
if (CRFEE.FeeName == "押金") isfindyjcr = true;
}
}
if (!isnotsame)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0054";
audit.ERRMSG = "应收应付汇率一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (isfindyjdr != isfindyjcr)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAI0055";
audit.ERRMSG = "押金应收应付不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
if (!isnotsameyj)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAI0056";
audit.ERRMSG = "押金应收应付一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (!string.IsNullOrEmpty(opseaeremark) && issubmit)
{
Database db2 = DatabaseFactory.CreateDatabase();
using (var conn = db2.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db2.GetSqlStringCommand(
@"update op_seai set REMARK='" + opseaeremark + "' where bsno='" + BsNo + "' ");
db2.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
//if (!string.IsNullOrEmpty(OPSEAE.FORWARDER))
//{
//}
}
else if (isamend == "1" && oplb.ToUpper() == "OP_SEAI")
{
var opctnnum = 0;
var cntrnostr = "";
var opamend = MsOpBillDAL.GetData("BSNO='" + BsNo + "'");
var OPSEAE = MsOpSeaiDAL.GetData("BSNO='" + opamend.PARENTID + "'");
var ctnlist = MsOpSeaiDAL.GetBodyListHc("BSNO='" + OPSEAE.BSNO + "'", OPSEAE.APPLYNO);
var FeeList = MsChFeeDAL.GetDataList(" BSNO IN (SELECT BSNO FROM V_OP_BILL WHERE PARENTID IN (SELECT PARENTID FROM op_amend WHERE BSNO='" + BsNo + "'))", 2, "", userid, username, companyid);
var opseaeremark = "";
var issame = true;
foreach (var ctn in ctnlist)
{
if (ctn.CTNALL.IndexOf("TK") > 0)
{
if (ctn.CTNNUM == 0 && !string.IsNullOrEmpty(ctn.CNTRNO))
opctnnum = opctnnum + 1;
else opctnnum = opctnnum + ctn.CTNNUM;
if (cntrnostr == "")
{
cntrnostr = "'" + ctn.CNTRNO + "'";
}
else
{
cntrnostr = cntrnostr + "," + "'" + ctn.CNTRNO + "'";
}
}
if (ctn.PKGS != ctn.CTNNUM) issame = false;
}
if (OPSEAE.ISFUMIGATION)
{
if (Convert.ToInt32(OPSEAE.PKGS) != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAIAMEND000101";
audit.AUDITTYPE = "1";
audit.ERRMSG = "整箱业务箱量和件数不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAIAMEND000102";
audit.AUDITTYPE = "0";
audit.ERRMSG = "整箱业务箱量和件数一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (!string.IsNullOrEmpty(OPSEAE.MBLNO))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND001";
audit.ERRMSG = "主提单号不能为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND002";
audit.ERRMSG = "主提单号为空!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.CUSTOMERNAME == "恒成" && OPSEAE.SALE == "恒成")
{
if (OPSEAE.CUSTNO.IndexOf("HE5") > 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND003";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "委托编号匹配不一致!";
audit.AUDITDETAILID = "SEAIAMEND004";
audit.ERRDATA = "恒成:委托编号" + OPSEAE.CUSTNO;
auditlist.Add(audit);
}
}
else
if (OPSEAE.SALE == "陈成")
{
if (OPSEAE.CUSTNO.IndexOf("CC5") > 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND005";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "委托编号匹配不一致!";
audit.AUDITDETAILID = "SEAIAMEND006";
audit.ERRDATA = "揽货人:陈成;委托编号" + OPSEAE.CUSTNO;
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND007";
audit.ERRMSG = "委托单号匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if ((OPSEAE.SERVICE.IndexOf("-DOOR") > 0 || OPSEAE.SERVICE.IndexOf("-DR") > 0) && string.IsNullOrEmpty(OPSEAE.DESTINATION))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND008";
audit.ERRMSG = "到门业务目的港不能为空!";
audit.ERRDATA = "运输条款:" + OPSEAE.SERVICE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND009";
audit.ERRMSG = "目的港符合要求(TO DOOR业务目的港不能为空)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var iszd = false;
//if (OPSEAE.ISFUMIGATION)
//{
//}
var txsj = "";
foreach (var ctn in ctnlist)
{
if (!string.IsNullOrEmpty(ctn.SJRGSJ))
{
if (string.IsNullOrEmpty(txsj))
txsj = ctn.SJRGSJ;
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(ctn.SJRGSJ)) txsj = ctn.SJRGSJ;
}
}
}
//if (!string.IsNullOrEmpty(txsj))
//{
// if (issubmit)
// {
// var bgndate = Convert.ToDateTime(txsj).AddDays(10);
// if (bgndate < DateTime.Now)
// {
// iszd = true;
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.AUDITDETAILID = "SEAIAMEND010";
// audit.ERRMSG = "晚于时间要求!";
// audit.ERRDATA = "整箱还箱日期:" + txsj + "后九个工作日起算";
// auditlist.Add(audit);
// }
// }
//}
//if (issubmit&&!iszd)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "0";
// audit.AUDITDETAILID = "SEAIAMEND011";
// audit.ERRMSG = "未晚出账单,符合账单晚于时间要求!";
// audit.ERRDATA = "";
// auditlist.Add(audit);
//}
if (!string.IsNullOrEmpty(OPSEAE.ETD))
{
if (OPSEAE.ISAGENT)
{
//if (Convert.ToInt64(OPSEAE.PKGS) != 0)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.AUDITTYPE = "1";
// audit.ERRMSG = "服务项目为仅账单,件数必须为0";
// audit.ERRDATA = "现件数为:" + OPSEAE.PKGS;
// auditlist.Add(audit);
//}
if (OPSEAE.TEU != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND012";
audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
audit.ERRDATA = "现箱量为:" + OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR;
auditlist.Add(audit);
}
}
}
if (!string.IsNullOrEmpty(OPSEAE.APPLYNO))
{
var applynostr = "'" + OPSEAE.APPLYNO + "'";
if (OPSEAE.APPLYNO.IndexOf(",") > 0)
{
applynostr = "";
var applynolist = OPSEAE.APPLYNO.Split(',');
foreach (var applyno in applynolist)
{
if (!string.IsNullOrEmpty(applyno))
{
if (applynostr == "")
{
applynostr = "'" + applyno + "'";
}
else
{
applynostr = applynostr + "," + "'" + applyno + "'";
}
}
}
}
decimal YSGXF = 0;
decimal APPLYYSGXF = 0;
var isgxf = false;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
YSGXF = YSGXF + FEE.Amount;
}
//if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
//{
// if (FEE.Currency == OPCTNAPPLY.CURRENCY && FEE.CustomerName == OPCTNAPPLY.OWNERCTN)
// {
// CTNTOTAL = CTNTOTAL + FEE.Amount;
// }
//}
}
var opseaelist = MsOpBillDAL.GetDataList("APPLYNO IN (" + applynostr + ") AND OPLBNAME='海运出口' and OPTYPE='普通货'", "", "", "");
foreach (var item in opseaelist)
{
//if (item.MBLNO == OPSEAE.MBLNO)
//{
if (OPSEAE.ORDERNO.IndexOf(item.CUSTNO) < 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND013";
audit.ERRMSG = "与原出口账单中的委托编号不一致!";
audit.ERRDATA = "海运出口委托编号:" + item.CUSTNO;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND014";
audit.ERRMSG = "与原出口账单中的委托编号一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (item.CUSTOMERNAME != OPSEAE.ENTERP)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND015";
audit.ERRMSG = "经营单位与原出口账单中的委托单位不一致!";
audit.ERRDATA = "海运出口委托单位:" + item.CUSTOMERNAME;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND016";
audit.ERRMSG = "经营单位与原出口账单中的委托单位一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//}
}
var OPCTNAPPLYLIST = MsOpCtnApplyDAL.GetDataList("BSNO IN (" + applynostr + ")");
var ctnnum = 0;
foreach (var OPCTNAPPLY in OPCTNAPPLYLIST)
{
if (OPCTNAPPLY.MNGAUDITSTATUS != "审核通过" || OPCTNAPPLY.COSTAUDITSTATUS == "申请修改")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEA00031";
audit.ERRMSG = "成本核算不匹配!";
audit.ERRDATA = "成本核算未审核或申请修改";
auditlist.Add(audit);
}
if ((OPSEAE.BSSOURCEDETAIL != "空返") && (OPSEAE.BSSOURCEDETAIL != "调拨"))
{
if (OPSEAE.PORTLOAD != OPCTNAPPLY.PORTLOAD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请起运港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND017";
audit.ERRDATA = "起运港:" + OPSEAE.PORTLOAD + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 起运港:" + OPCTNAPPLY.PORTLOAD;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAIAMEND018";
audit.ERRMSG = "与用箱申请起运港一致!";
audit.AUDITTYPE = "0";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTDISCHARGE != OPCTNAPPLY.PORTDISCHARGE)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与用箱申请卸货港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND019";
audit.ERRDATA = "卸货港:" + OPSEAE.PORTDISCHARGE + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 卸货港:" + OPCTNAPPLY.PORTDISCHARGE;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAIAMEND020";
audit.ERRMSG = "与用箱申请卸货港一致!";
audit.AUDITTYPE = "0";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
//var isfind = false;
//decimal CTNTOTAL = 0;
//decimal YSGXF = 0;
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1 && FEE.FeeName == "罐箱费")
{
//YSGXF = YSGXF + FEE.Amount;
if (FEE.Currency != OPCTNAPPLY.CURRENCY)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND021";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费:" + FEE.UnitPrice + "*" + FEE.Quantity + "--用箱申请[" + OPCTNAPPLY.BSNO + "] 单价:" + OPCTNAPPLY.CTN_PRICE;
auditlist.Add(audit);
isgxf = true;
}
}
//if (FEE.FeeType == 2 && FEE.FeeName == "罐箱费")
//{
// if (FEE.Currency == OPCTNAPPLY.CURRENCY && FEE.CustomerName == OPCTNAPPLY.OWNERCTN)
// {
// isfind = true;
// CTNTOTAL = CTNTOTAL + FEE.Amount;
// }
//}
}
var applyctnlist = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("b.LINKGID='" + OPCTNAPPLY.GID + "'");
foreach (var applyctn in applyctnlist)
{
if (ctnlist.Find(x => x.CNTRNO == applyctn.CTNNO) != null)
APPLYYSGXF = APPLYYSGXF + OPCTNAPPLY.CTN_PRICE;
}
var bscardstr = "APPLYNO='" + OPCTNAPPLY.BSNO + "'";
if (!string.IsNullOrEmpty(cntrnostr)) bscardstr = bscardstr + " and CTNNO IN(" + cntrnostr + ") ";
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList(bscardstr);
foreach (var opctnbscard in opctnbscardlist)
{
var portload = opctnbscard.PORTLOAD;
var portdischarge = opctnbscard.DESTPORT;
if (OPSEAE.BSSOURCEDETAIL == "空返") {
portload = opctnbscard.I_PORTLOAD;
portdischarge = opctnbscard.I_DESTPORT;
var dgrq = "";
if (!string.IsNullOrEmpty(opctnbscard.I_DEST_RTCNT_TIME))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.I_DEST_RTCNT_TIME;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.I_DEST_RTCNT_TIME)) txsj = opctnbscard.I_DEST_RTCNT_TIME;
}
}
if (string.IsNullOrEmpty(txsj))
{
if (!string.IsNullOrEmpty(opctnbscard.I_ETA))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.I_ETA;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.I_ETA)) txsj = opctnbscard.I_ETA;
}
}
}
}
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
portload = opctnbscard.D_PORTLOAD;
portdischarge = opctnbscard.D_DESTPORT;
var dgrq = "";
if (!string.IsNullOrEmpty(opctnbscard.D_DEST_RTCNT_TIME))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.D_DEST_RTCNT_TIME;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.D_DEST_RTCNT_TIME)) txsj = opctnbscard.D_DEST_RTCNT_TIME;
}
}
if (string.IsNullOrEmpty(txsj))
{
if (!string.IsNullOrEmpty(opctnbscard.D_ETA))
{
if (string.IsNullOrEmpty(txsj))
{
txsj = opctnbscard.D_ETA;
}
else
{
if (Convert.ToDateTime(txsj) < Convert.ToDateTime(opctnbscard.D_ETA)) txsj = opctnbscard.D_ETA;
}
}
}
}
if (OPSEAE.PORTLOAD != portload)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡起运港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND022";
audit.ERRDATA = "起运港:" + OPSEAE.PORTLOAD + "--业务卡[" + opctnbscard.BSNO + "] 起运港:" + portload;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡起运港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND023";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (OPSEAE.PORTDISCHARGE != portdischarge)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡卸货港不一致!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND024";
audit.ERRDATA = "卸货港:" + OPSEAE.PORTDISCHARGE + "--业务卡[" + opctnbscard.BSNO + "] 卸货港:" + portdischarge;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "与业务卡卸货港一致!";
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND025";
audit.ERRDATA = "";
auditlist.Add(audit);
}
//var ETA = opctnbscard.ETA;
//if (OPSEAE.BSSOURCEDETAIL == "空返")
//{
// ETA = opctnbscard.I_ETA;
//}
//if (OPSEAE.BSSOURCEDETAIL == "调拨")
//{
// ETA = opctnbscard.D_ETA;
//}
if (opctnbscard.CUSTNO == OPSEAE.CUSTNO)
{
if (opctnbscard.ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND026";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND027";
audit.ERRMSG = "与业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
}
if (OPSEAE.BSSOURCEDETAIL == "空返")
{
if (opctnbscard.I_ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND028";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "到港日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.I_ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND029";
audit.ERRMSG = "与业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.I_ETA;
auditlist.Add(audit);
}
}
else
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
if (opctnbscard.D_ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND030";
audit.ERRMSG = "与业务卡开船日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.D_ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND031";
audit.ERRMSG = "与业务卡开船日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 开船日期:" + opctnbscard.D_ETA;
auditlist.Add(audit);
}
}
else
{
if (opctnbscard.ETA != OPSEAE.ETD)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND032";
audit.ERRMSG = "与业务卡到港日期不一致!";
audit.ERRDATA = "开船日期:" + OPSEAE.ETD + "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND033";
audit.ERRMSG = "与业务卡到港日期一致!";
audit.ERRDATA = "--业务卡[" + opctnbscard.BSNO + "] 到港日期:" + opctnbscard.ETA;
auditlist.Add(audit);
}
}
ctnnum = ctnnum + 1;
var opctnFeeList = MsChFeeDAL.GetDataList("BsNo='" + opctnbscard.GID + "'", 1, "", userid, username, companyid);
decimal qygxsf = 0;
string qygxsfcurr = "";
if (opctnFeeList != null && opctnFeeList.Count != 0)
{
foreach (var FEE in opctnFeeList)
{
if (FEE.FeeName == "箱使费")
{
qygxsf = qygxsf + FEE.Amount;
qygxsfcurr = FEE.Currency;
}
if (!string.IsNullOrEmpty(FEE.WmsOutBsNo))
{
foreach (var OPFEE in FeeList)
{
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount != OPFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND034";
audit.ERRMSG = "费用名称" + FEE.FeeName + ",金额和引入的费用不一致";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 引入不一致!";
auditlist.Add(audit);
if (!opctnbscard.ISSHORTRENTCTN && FEE.Currency == OPFEE.Currency)
{
//result.Success = false;
//result.Message = "起运港箱使费不匹配不允许提交!";
//return result;
}
}
if (FEE.WmsOutBsNo == OPFEE.GId && (FEE.Amount == OPFEE.Amount || FEE.Currency == OPFEE.Currency))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND035";
audit.ERRMSG = FEE.FeeName + ",操作与业务卡金额和引入的费用一致";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
else
{
if (OPSEAE.BSSOURCEDETAIL != "箱使费")
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "业务卡:" + FEE.FeeName + "未引入操作模块";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND036";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 费用名称:" + FEE.FeeName + " 未引入操作模块";
auditlist.Add(audit);
}
}
//}
}
}
else
{
}
if (qygxsf != opctnbscard.DESTPORT_OVER_DAYS_AMT)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.ERRMSG = "目的港箱使费不一致,不允许提交!";
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND037";
audit.ERRDATA = "业务卡[" + opctnbscard.BSNO + "] 目的港箱使费:" + opctnbscard.DESTPORT_OVER_DAYS_AMT.ToString();
auditlist.Add(audit);
//if (qygxsfcurr == "USD" && !opctnbscard.ISSHORTRENTCTN)
//{
//result.Success = false;
//result.Message = "业务卡目的港箱使费不匹配不允许提交!";
//return result;
//}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITDETAILID = "SEAIAMEND038";
audit.ERRMSG = "目的港箱使费一致";
audit.AUDITTYPE = "0";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var ctnbscardremark = "";
foreach (var ctn in ctnlist)
{
if (ctn.CNTRNO == opctnbscard.CTNNO)
{
ctnbscardremark = "罐号:" + opctnbscard.CTNNO + " 到港:" + opctnbscard.ETA + " 还箱:" + opctnbscard.DEST_RTCNT_TIME + " " + Convert.ToInt32(opctnbscard.DESTPORT_FREE_DAYS).ToString() + "/USD" + opctnbscard.DESTPORT_OVER_DAYS_FEE.ToString().Replace(".0000", ".00");
if (opctnbscard.DESTPORT_OVER_DAYS_AMT == 0)
{
ctnbscardremark = ctnbscardremark + " 不超期";
}
else
{
ctnbscardremark = ctnbscardremark + " 目的港超期天数" + Convert.ToInt32(opctnbscard.DESTPORT_OVER_DAYS).ToString() + "天目的港箱使费USD" + opctnbscard.DESTPORT_OVER_DAYS_AMT.ToString().Replace(".0000", ".00");
}
if (OPSEAE.BSSOURCEDETAIL == "空返")
{
ctnbscardremark = ctnbscardremark + " 空返到港:" + opctnbscard.I_ETA + "," + " 空返还箱:" + opctnbscard.I_DEST_RTCNT_TIME;
}
if (OPSEAE.BSSOURCEDETAIL == "调拨")
{
ctnbscardremark = ctnbscardremark + " 调拨到港:" + opctnbscard.D_ETA + "," + " 调拨还箱:" + opctnbscard.D_DEST_RTCNT_TIME;
}
if (opseaeremark == "") opseaeremark = ctnbscardremark; else opseaeremark = opseaeremark + Environment.NewLine + ctnbscardremark;
}
}
}
}
if (!isgxf)
{
if (YSGXF != (APPLYYSGXF))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND039";
audit.ERRMSG = "应收罐箱费与用箱罐箱费不一致!";
audit.ERRDATA = "罐箱费合计:" + YSGXF + "--用箱申请 罐箱费:" + (APPLYYSGXF).ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND040";
audit.ERRMSG = "应收罐箱费与用箱罐箱费一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (OPSEAE.BSSOURCEDETAIL != "箱使费")
{
if (ctnnum != opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND041";
audit.ERRMSG = "箱量与用箱申请箱量不一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND042";
audit.ERRMSG = "箱量与用箱申请箱量一致!";
audit.ERRDATA = "箱量:" + opctnnum.ToString();
auditlist.Add(audit);
}
}
if (OPSEAE.ISAGENT)
{
if (Convert.ToInt64(OPSEAE.PKGS) != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND043";
audit.ERRMSG = "服务项目为仅账单,件数必须为0";
audit.ERRDATA = "现件数为:" + OPSEAE.PKGS;
auditlist.Add(audit);
}
if (OPSEAE.TEU != 0)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND044";
audit.ERRMSG = "服务项目为仅账单,箱量必须为0";
audit.ERRDATA = "现箱量为:" + OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR;
auditlist.Add(audit);
}
}
else
{
//var ctnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + OPSEAE.BSNO + "'");
//var opctnnum = 0;
//foreach (var ctn in ctnlist)
//{
// if (ctn.CTNALL.IndexOf("TK") > 0)
// {
// opctnnum = opctnnum + ctn.CTNNUM;
// }
//}
//if (ctnnum != opctnnum)
//{
// sort = sort + 1;
// var audit = new MsOpAuditDetail();
// audit.SORT = sort;
// audit.ERRMSG = "箱量与用箱申请箱量不一致!";
// audit.ERRDATA = "箱量:" + ctnnum.ToString() + "--用箱申请[" + OPSEAE.APPLYNO + "] 箱量:" + ctnnum.ToString();
// auditlist.Add(audit);
//}
}
}
else
{
if (OPSEAE.ISINSPECTION)
{
if ((OPSEAE.CNTR1 + OPSEAE.CNTR2 + OPSEAE.CNTR3 + OPSEAE.CNTR4 + OPSEAE.CNTR5 + OPSEAE.CNTR6 + OPSEAE.CNTR7 + OPSEAE.CNTR8 + OPSEAE.CNTR9 + OPSEAE.CNTR10 + OPSEAE.OTCNTR) == opctnnum)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND045";
audit.ERRMSG = "箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND046";
audit.ERRMSG = "调拨业务箱量匹配不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND047";
audit.ERRMSG = "箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
var issamectn = true;
if (OPSEAE.ISAGENT)
{
foreach (var ctn in ctnlist)
{
if (ctn.CTNNUM != 0 || ctn.PKGS != 1) issamectn = false;
}
if (!issamectn)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND048";
audit.ERRMSG = "仅帐单业务箱量件数不正确(箱量必须为0件数为1)";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND049";
audit.ERRMSG = "仅帐单业务箱量件数正确!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
else if (OPSEAE.ISFUMIGATION || OPSEAE.ISINSPECTION)
{
foreach (var ctn in ctnlist)
{
if (ctn.CTNNUM != 1 || ctn.PKGS != 1) issamectn = false;
}
if (!issamectn)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND050";
audit.ERRMSG = "整箱或报关拖车调拨业务箱量件数匹配不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND051";
audit.ERRMSG = "整箱或报关拖车调拨业务箱量匹配一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
}
if (FeeList != null && FeeList.Count != 0)
{
var FeeDrList = new List<MsChFee>();
var FeeCrList = new List<MsChFee>();
foreach (var FEE in FeeList)
{
if (FEE.FeeType == 1)
{
FeeDrList.Add(FEE);
}
if (FEE.FeeType == 2)
{
FeeCrList.Add(FEE);
}
}
var isnotsame = false;
var isnotsameyj = false;
var isfindyjdr = false;
var isfindyjcr = false;
foreach (var FEE in FeeDrList)
{
if (FEE.FeeName == "押金") isfindyjdr = true;
if (FEE.BsNo == opamend.BSNO)
{
foreach (var CRFEE in FeeCrList)
{
//if (opamend.ACCDATE == OPSEAE.ACCDATE)
//{
if (FEE.BsNo == CRFEE.BsNo && FEE.Currency == CRFEE.Currency && FEE.ExChangerate != CRFEE.ExChangerate)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.ERRMSG = "应收应付汇率不一致!";
audit.AUDITDETAILID = "SEAIAMEND052";
audit.ERRDATA = "应收汇率:" + FEE.ExChangerate + "--应付汇率:" + CRFEE.ExChangerate;
auditlist.Add(audit);
isnotsame = true;
}
//}
if (FEE.BsNo == CRFEE.BsNo && CRFEE.FeeName == "押金") isfindyjcr = true;
if (FEE.BsNo == CRFEE.BsNo && FEE.FeeName == "押金" && CRFEE.FeeName == "押金" && (FEE.CustomerName != CRFEE.CustomerName || FEE.Currency != CRFEE.Currency || FEE.Amount != CRFEE.Amount))
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND053";
audit.ERRMSG = "押金应收应付不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
isnotsameyj = true;
}
}
}
}
foreach (var CRFEE in FeeCrList)
{
if (CRFEE.FeeName == "押金") isfindyjcr = true;
}
if (!isnotsame)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND054";
audit.ERRMSG = "应收应付汇率一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
if (isfindyjdr != isfindyjcr)
{
sort = sort + 1;
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "1";
audit.AUDITDETAILID = "SEAIAMEND055";
audit.ERRMSG = "押金应收应付不一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
else
if (!isnotsameyj)
{
var audit = new MsOpAuditDetail();
audit.SORT = sort;
audit.AUDITTYPE = "0";
audit.AUDITDETAILID = "SEAIAMEND056";
audit.ERRMSG = "押金应收应付一致!";
audit.ERRDATA = "";
auditlist.Add(audit);
}
}
if (!string.IsNullOrEmpty(opseaeremark) && issubmit)
{
Database db2 = DatabaseFactory.CreateDatabase();
using (var conn = db2.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdUpdate = db2.GetSqlStringCommand(
@"delete from op_amend_remark where bsno='" + opamend.BSNO + "' insert into op_amend_remark(BSNO,REMARK) values('" + opamend.BSNO + "','第" + opamend.SLNO + "次更改 " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "'+CHAR(13)+CHAR(10)+'" + opseaeremark + "') ");
db2.ExecuteNonQuery(cmdUpdate, tran);
//var cmdUpdate = db2.GetSqlStringCommand(
// @"update op_seai set REMARK=ISNULL(REMARK,'')+CHAR(13)+CHAR(10)+'第" + opamend.SLNO + "次更改 " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "'+CHAR(13)+CHAR(10)+'" + opseaeremark + "' where bsno='" + opamend.PARENTID + "' ");
//db2.ExecuteNonQuery(cmdUpdate, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
//if (!string.IsNullOrEmpty(OPSEAE.FORWARDER))
//{
//}
}
if (auditlist.Count > 0)
{
result.Success = true;
result.Message = "保存成功" + result.Message;
AddAudit(auditlist,BsNo,username,issubmit);
//Database db = DatabaseFactory.CreateDatabase();
if (issubmit)
{
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
if (isamend == "1")
{
var cmdUpdate = db.GetSqlStringCommand(
@"if (select bsno from op_close where bsno='" + BsNo + "') is null insert into op_close values(newid(),'" + BsNo + "',null,'','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "','" + username + "',0,0,0) else update op_close set FEECLOSETIME ='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "',FEECLOSEOP='" + username + "' where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
}
else
{
var cmdUpdate = db.GetSqlStringCommand(
@"if (select bsno from op_close where bsno='" + BsNo + "') is null insert into op_close values(newid(),'" + BsNo + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "','" + username + "',0,0,0) else update op_close set BSCLOSETIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',FEECLOSETIME ='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ "',BSCLOSEOP='" + username + "',FEECLOSEOP='" + username + "' where BSNO='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
}
}
else
{
result.Success = true;
result.Message = "保存成功" + result.Message;
}
return result;
}
public static DBResult CancelAuditBL(string BsNo, string oplb, string isamend, string userid, string username)
{
var result = new DBResult();
var auditlist = new List<MsOpAuditDetail>();
var sort = 0;
var strbsno = BsNo;
var auditlogList = MsOpAuditDetailDAL.GetAuditLogList("BSNO='"+BsNo+ "' and AUDITTYPE<>'提交审核' and AUDITTYPE<>'撤销提交' and AUDITTYPE<>'审核驳回'");
if (auditlogList != null) {
if (auditlogList.Count > 0) {
result.Success = false;
result.Message = "已部分审核,不允许撤销审核!" ;
return result;
}
}
var logcount = GetAuditLogCount(" BSNO='" + BsNo + "'");
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, logcount+1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, "");
db.AddInParameter(cmdInsert, "@ERROP", DbType.String, "");
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String, "");
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, "撤销提交");
if (isamend == "1")
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, true);
else db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.ExecuteNonQuery(cmdInsert, tran);
if (isamend == "1")
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE OP_AMEND SET BillFeeStatus=0,BILLFEESTATUSTIME=null WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
else
{
var cmdUpdateamend = db.GetSqlStringCommand(
@"UPDATE " + oplb + " SET BillFeeStatus=0,BILLFEESTATUSTIME=null,FEESTATUS=0,BSSTATUS=0 WHERE BSNO=@BSNO ");
cmdUpdateamend.Parameters.Clear();
db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, BsNo);
db.ExecuteNonQuery(cmdUpdateamend, tran);
}
var cmdUpdate = db.GetSqlStringCommand(
@"delete from op_audit_detail where bsno='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate, tran);
var cmdUpdate2 = db.GetSqlStringCommand(
@"delete from op_audit where bsno='" + BsNo + "' ");
db.ExecuteNonQuery(cmdUpdate2, tran);
tran.Commit();
result.Success = true;
result.Message = "保存成功" + result.Message;
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "撤销审核出现错误!" +e.Message;
}
}
return result;
}
static public int GetWorkDay(string startdate,string enddate)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [dbo].[CalculateWorkingDays]('"+ startdate + "','" + enddate + "') WORKDAY ");
var ct = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ct = Convert.ToInt16(reader["WORKDAY"]);
}
reader.Close();
}
return ct;
}
public static DBResult Modify(List<MsOpBill> bodyList, MsOpBill modifydata, string companyid, string userid,string username)
{
var result = new DBResult();
string errstr = "";
string tmperrstr = "";
int i = 0;
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var strSql = new StringBuilder();
strSql.Append("update "+ enumValue.OPLB + " set MASTERNO=MASTERNO ");
if (modifydata.OPFEECOUNT != "" && modifydata.OPFEECOUNT != null)
strSql.Append(",OPFEECOUNT=@OPFEECOUNT");
if (modifydata.OPCOUNT != "" && modifydata.OPCOUNT != null)
strSql.Append(",OPCOUNT=@OPCOUNT");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
cmdupdate.Parameters.Clear();
if (modifydata.OPFEECOUNT != "" && modifydata.OPFEECOUNT != null)
db.AddInParameter(cmdupdate, "@OPFEECOUNT", DbType.String, modifydata.OPFEECOUNT);
if (modifydata.OPCOUNT != "" && modifydata.OPCOUNT != null)
db.AddInParameter(cmdupdate, "@OPCOUNT", DbType.String, modifydata.OPCOUNT);
if (enumValue.OPTYPE=="更改单")
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.PARENTID);
else
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
db.ExecuteNonQuery(cmdupdate, tran);
i = i + 1;
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_audit_log (ADLGID,BSNO,SORT,ERRMSG,ERROP,AUDITREMARK,ISAMEND,AUDITUSER,AUDITTIME,AUDITTYPE)
values (@ADLGID,@BSNO,@SORT,@ERRMSG,@ERROP,@AUDITREMARK,@ISAMEND,@AUDITUSER,@AUDITTIME,@AUDITTYPE) ");
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@ADLGID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, 1);
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, "");
db.AddInParameter(cmdInsert, "@ERROP", DbType.String, "");
db.AddInParameter(cmdInsert, "@AUDITREMARK", DbType.String, "修改操作计算量["+enumValue.OPFEECOUNT+"-"+modifydata.OPFEECOUNT+ "]和考核票数[" + enumValue.OPCOUNT + "-" + modifydata.OPCOUNT + "]");
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, "修改考核");
if (enumValue.OPTYPE == "更改单")
db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, true);
else db.AddInParameter(cmdInsert, "@ISAMEND", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@AUDITUSER", DbType.String, username);
db.AddInParameter(cmdInsert, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.ExecuteNonQuery(cmdInsert, tran);
}
}
tran.Commit();
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "修改出现错误,请重试或联系系统管理员" + e.Message;
return result;
}
}
result.Success = true;
result.Message = "修改成功" + i.ToString() + "票";
if (errstr != "")
{
result.Message = result.Message + "(其中" + errstr + " 无法修改)";
}
return result;
}
}
}