You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/DAL/MsOp_BLISSUE/MsOp_BLISSUEDAL.cs

5058 lines
225 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 System.Web;
using System.Web.Mvc;
using System.IO;
using System.Data.SqlClient;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Comm;
using WebSqlHelper;
using DotNet4.Utilities;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using DSWeb.MvcShipping.Models.MsOp_BLISSUE;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.OA.Models.WorkFlow;
using DSWeb.Areas.OA.Controllers;
using DSWeb.MvcShipping.Helper;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.Areas.Account.Models.MsOpBill;
using DSWeb.Areas.TruckMng.Models; //附件类
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using static DSWeb.Areas.CommMng.DAL.BasicDataRefDAL;
using DSWeb.Common.DB;
using System.Linq;
using DSWeb.SoftMng.DAL;
using DSWeb.WorkFlow;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
using NPOI.SS.Formula.Functions;
namespace DSWeb.Areas.MvcShipping.DAL.MsOp_BLISSUE
{
public partial class MsOp_BLISSUEDAL:IGetTotalCount
{
#region 提单列表
public const string = "(SELECT TOP 1 case when STATUS='放单通知' then '可放单' else STATUS end FROM V_OP_STATUS WITH (NOLOCK) WHERE BSNO=B.BSNO and ISCOMP=1 and status not in('操作确认','待截VGM','已截VGM','未截VGM','紧急截VGM','待舱单','已舱单','未舱单','紧急舱单','待补料','已补料','未补料','紧急补料') ORDER BY COMPTIME DESC,INPUTTIME DESC)";
const string OPSEAE = "," + + " as OPSTATUS";
static public List<MsOp_BLISSUEmb> GetDataList ( string strCondition,int start,int limit,out int recordcount, string sort="" )
{ //合同信息/商品信息
var strSql = new StringBuilder();
strSql.Append(" select ob.GID,B.BSNO,B.mblno BLNO,B.HBLNO ");
strSql.Append(" ,B.OPTYPE ZDFD ");
strSql.Append(" ,ob.BLNAME,ob.BLSTATUS,ob.BLORDERNO ");
strSql.Append(" ,B.ISSUETYPE,B.ISSUEPLACE ");
strSql.Append(" ,ob.OPNAME,ob.OPTIME,ob.BSINKNO,ob.ISVESSELPROVE,ob.VESSELPROVETIME,ob.VESSELPROVEREMARK ");
strSql.Append(" ,ob.REMARK,ob.DELFLAG,ob.EXPRESSCORP,ob.EXPRESSNO,ob.ISADD,dbo.trimdate(ob.PUTSINGLETIME) PUTSINGLETIME ");
strSql.Append(" ,ob.PUTSINGLE,ob.PAYTIME,ob.PAYRMB,ob.PAYUSD,sp.SPREMARK SPREMARK,sp.REMARK SPSQREMARK,sp.ISCHAOQI,sp.MNGBLSTATUS ");
strSql.Append(" ,CASE WHEN exists(select 1 from v_op_seae_iscargo where CUSTOMERNAME=B.CUSTOMERNAME and BSNO<>B.BSNO) THEN '有' ELSE '无' END CUSTCARGOAFTER ");
// strSql.Append(" ,CASE WHEN isnull(bf.CUSTOMERNAME,'')='' THEN '无' ELSE '有' END CUSTCARGOAFTER ");
strSql.Append(" ,B.BLTYPE,B.CUSTNO,B.customername,B.sale ");
strSql.Append(" ,(select top 1 acctype from info_client_accdate where LINKGID=(select top 1 gid from info_client where SHORTNAME=B.customername) ");
strSql.Append(" and BGNDATE<=B.ETD and ENDDATE>B.ETD and (isnull(SALE,'')='' or SALE=B.SALE)) acctype ");
strSql.Append(" ,dbo.trimdate(B.ETD) ETD,dbo.trimdate(B.STLDATE) STLDATE,B.CARRIER,B.VESSEL,B.VOYNO,B.OP,B.CUSTSERVICE,B.PORTLOAD,B.PORTDISCHARGE,B.DOC ");
strSql.Append(" ,B.BLISSUESTATUS ");
strSql.Append(" ,sp.BLSTATUS TSFD ");
strSql.Append(" ,DATEDIFF(day,B.ETD,B.STLDATE) XYTS ");
strSql.Append(" ,datediff(day,B.STLDATE,getdate()) cqts ");
strSql.Append(" ,DATEDIFF(day,B.ETD,getdate()) SJTS ");
strSql.Append(" ,g.RMBDR-g.STLRMBDR RMBNODR ");
strSql.Append(" ,g.USDDR-g.STLUSDDR USDNODR ");
strSql.Append(" ,g.TTLDR-g.STLTTLDR TTLNODR ");
strSql.Append(" ,g.TTLDR TTLDR ");
strSql.Append(" ,B.OPLBNAME,B.STLNAME,B.ISGAIQIAN ");
strSql.Append(" ,(case when exists (select 1 from worklog where bsno=ob.GID and ACTNAME='提单签入') then 1 else 0 end) ISQR,ob.QRDATE,ob.QCDATE ");
strSql.Append(OPSEAE);
strSql.Append(" from v_op_blissue_bill B WITH (NOLOCK) ");
strSql.Append(" left join op_blissue ob on ob.BSNO=B.BSNO ");
strSql.Append(" left join v_op_gain_sum_ttl g on g.BSNO=B.BSNO ");
// strSql.Append(" left join v_op_seae_iscargo bf on (bf.CUSTOMERNAME=B.CUSTOMERNAME and bf.BSNO<>B.BSNO) ");
strSql.Append(" left join v_op_blissuelist_Detail sp on sp.BSNO=B.BSNO ");
//2018年2月8日15:57:08 鼎世 李进举 提单管理不显示iscancel=12的数据
//202211123 增加对【iscanel是否退舱】中状态3 退舱(仍计费用,但不放单)
strSql.Append(" where ((B.OPTYPE='主票' and isnull(B.iscancel,0)=0 and B.MBLNO<>'') or (B.OPTYPE='分票' and B.HBLNO<>'') ) and isnull(B.OPLBNAME,'') in('海运出口','海运进口')");
var sortstring = DatasetSort.Getsortstring(sort);
PagedQuaryParam pp = new PagedQuaryParam();
pp.strSql = strSql.ToString();
pp.start = start;
pp.limit = limit;
pp.strCondition = strCondition;
pp.defaultsortstr = "ETD desc";
pp.sortstring = sortstring;
//if (!string.IsNullOrEmpty(strCondition))
//{
// strSql.Append(" and " + strCondition.Replace("~",""));//str.Replace("b","**");
//}
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring);
//}
//else
//{
// // strSql.Append(" order by ob.OPTIME desc ");
// strSql.Append(" order by B.ETD desc ");
//}
var result = PagedQuaryStr(pp);
recordcount = PagedCount(pp);
return SetData(result);
}
static public DBResult GetDataListStr(string strCondition, string sort)
{
var result = new DBResult();
//合同信息/商品信息
var strSql = new StringBuilder();
strSql.Append(" select ob.GID,B.BSNO,B.mblno BLNO,B.HBLNO ");
strSql.Append(" ,B.OPTYPE ZDFD ");
strSql.Append(" ,ob.BLNAME,ob.BLSTATUS,ob.BLORDERNO ");
strSql.Append(" ,B.ISSUETYPE,B.ISSUEPLACE ");
strSql.Append(" ,ob.OPNAME,ob.OPTIME,ob.BSINKNO,ob.ISVESSELPROVE,ob.VESSELPROVETIME,ob.VESSELPROVEREMARK ");
strSql.Append(" ,ob.REMARK,ob.DELFLAG,ob.EXPRESSCORP,ob.EXPRESSNO,ob.ISADD,dbo.trimdate(ob.PUTSINGLETIME) PUTSINGLETIME ");
strSql.Append(" ,ob.PUTSINGLE,ob.PAYTIME,ob.PAYRMB,ob.PAYUSD,sp.SPREMARK SPREMARK,sp.REMARK SPSQREMARK,sp.ISCHAOQI,sp.MNGBLSTATUS ");
strSql.Append(" ,CASE WHEN(select COUNT(*) from v_op_seae_iscargo where CUSTOMERNAME=B.CUSTOMERNAME and BSNO<>B.BSNO)>0 THEN '有' ELSE '无' END CUSTCARGOAFTER ");
// strSql.Append(" ,CASE WHEN isnull(bf.CUSTOMERNAME,'')='' THEN '无' ELSE '有' END CUSTCARGOAFTER ");
strSql.Append(" ,B.BLTYPE,B.CUSTNO,B.customername,B.sale ");
strSql.Append(" ,(select top 1 acctype from info_client_accdate where LINKGID=(select top 1 gid from info_client where SHORTNAME=B.customername) ");
strSql.Append(" and BGNDATE<=B.ETD and ENDDATE>B.ETD and (isnull(SALE,'')='' or SALE=B.SALE)) acctype ");
strSql.Append(" ,dbo.trimdate(B.ETD) ETD,dbo.trimdate(B.STLDATE) STLDATE,B.CARRIER,B.VESSEL,B.VOYNO,B.OP,B.CUSTSERVICE,B.PORTLOAD,B.PORTDISCHARGE,B.DOC ");
strSql.Append(" ,B.BLISSUESTATUS ");
strSql.Append(" ,sp.BLSTATUS TSFD ");
strSql.Append(" ,DATEDIFF(day,B.ETD,B.STLDATE) XYTS ");
strSql.Append(" ,datediff(day,B.STLDATE,getdate()) cqts ");
strSql.Append(" ,DATEDIFF(day,B.ETD,getdate()) SJTS ");
strSql.Append(" ,g.RMBDR-g.STLRMBDR RMBNODR ");
strSql.Append(" ,g.USDDR-g.STLUSDDR USDNODR ");
strSql.Append(" ,g.TTLDR-g.STLTTLDR TTLNODR ");
strSql.Append(" ,g.TTLDR TTLDR ");
strSql.Append(" ,B.OPLBNAME,B.STLNAME,B.ISGAIQIAN ");
strSql.Append(" ,(case when (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='提单签入')>0 then 1 else 0 end) ISQR,ob.QRDATE,ob.QCDATE ");
strSql.Append(OPSEAE);
strSql.Append(" from v_op_blissue_bill B ");
strSql.Append(" left join op_blissue ob on ob.BSNO=B.BSNO ");
strSql.Append(" left join v_op_gain_sum_ttl g on g.BSNO=B.BSNO ");
// strSql.Append(" left join v_op_seae_iscargo bf on (bf.CUSTOMERNAME=B.CUSTOMERNAME and bf.BSNO<>B.BSNO) ");
strSql.Append(" left join v_op_blissuelist_Detail sp on sp.BSNO=B.BSNO ");
//2018年2月8日15:57:08 鼎世 李进举 提单管理不显示iscancel=12的数据
strSql.Append(" where ((B.OPTYPE='主票' and isnull(B.iscancel,0)=0 and B.MBLNO<>'') or (B.OPTYPE='分票' and B.HBLNO<>'') ) and isnull(B.OPLBNAME,'') in('海运出口','海运进口')");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition.Replace("~", ""));//str.Replace("b","**");
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by OPTIME desc ");
}
result.Success = true;
result.Data = strSql.ToString();
result.Message = strCondition;
return result;
}
static public MsOp_BLISSUEmb GetData ( string condition )
{
var recordcount = 0;
var list = GetDataList(condition,0,1,out recordcount);
if (list.Count > 0)
return list[0];
return new MsOp_BLISSUEmb();
}
private static List<MsOp_BLISSUEmb> SetData ( StringBuilder strSql )
{
var headList = new List<MsOp_BLISSUEmb>();
Database db = DatabaseFactory.CreateDatabase();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = strSql.ToString();
cmd.CommandTimeout = 120000; //要加这一句
using (IDataReader reader = db.ExecuteReader(cmd))
{
while (reader.Read())
{
MsOp_BLISSUEmb data = new MsOp_BLISSUEmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.BLNO = Convert.ToString(reader["BLNO"]);
data.HBLNO = Convert.ToString(reader["HBLNO"]);
data.ZDFD = Convert.ToString(reader["ZDFD"]);
data.BLNAME = Convert.ToString(reader["BLNAME"]);
data.BLSTATUS = Convert.ToString(reader["BLSTATUS"]);
data.BLORDERNO = Convert.ToString(reader["BLORDERNO"]);
data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);
data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);
data.OPNAME = Convert.ToString(reader["OPNAME"]);
data.OPTIME = Convert.ToString(reader["OPTIME"]);
data.BSINKNO = Convert.ToString(reader["BSINKNO"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.DELFLAG = Convert.ToString(reader["DELFLAG"]);
data.EXPRESSCORP = Convert.ToString(reader["EXPRESSCORP"]);
data.EXPRESSNO = Convert.ToString(reader["EXPRESSNO"]);
data.ISADD = Convert.ToString(reader["ISADD"]);
data.PUTSINGLETIME = Convert.ToString(reader["PUTSINGLETIME"]);
data.PUTSINGLE = Convert.ToString(reader["PUTSINGLE"]);
data.PAYTIME = Convert.ToString(reader["PAYTIME"]);
data.PAYRMB = Convert.ToString(reader["PAYRMB"]);
data.PAYUSD = Convert.ToString(reader["PAYUSD"]);
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.ACCTYPE = Convert.ToString(reader["ACCTYPE"]);
if (data.ACCTYPE == "") data.ACCTYPE = "现结买单";
data.ETD = Convert.ToString(reader["ETD"]);
data.STLDATE = Convert.ToString(reader["STLDATE"]);
data.STLNAME = Convert.ToString(reader["STLNAME"]);
if (data.STLNAME == "") data.STLNAME = "现结买单";
data.CARRIER = Convert.ToString(reader["CARRIER"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VOYNO = Convert.ToString(reader["VOYNO"]);
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
data.OP = Convert.ToString(reader["OP"]);
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);
data.TSFD = Convert.ToString(reader["TSFD"]);
data.XYTS = Convert.ToString(reader["XYTS"]);
data.CQTS = Convert.ToString(reader["CQTS"]);
data.SJTS = Convert.ToString(reader["SJTS"]);
data.RMBNODR = Convert.ToString(reader["RMBNODR"]);
data.USDNODR = Convert.ToString(reader["USDNODR"]);
data.TTLNODR = Convert.ToString(reader["TTLNODR"]);
data.TTLDR = Convert.ToString(reader["TTLDR"]);
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
data.SPREMARK = Convert.ToString(reader["SPREMARK"]);
data.SPSQREMARK = Convert.ToString(reader["SPSQREMARK"]);
data.ISVESSELPROVE = Convert.ToString(reader["ISVESSELPROVE"]);
data.VESSELPROVETIME = Convert.ToString(reader["VESSELPROVETIME"]);
data.VESSELPROVEREMARK = Convert.ToString(reader["VESSELPROVEREMARK"]);
data.ISQR = Convert.ToString(reader["ISQR"]);
data.ISCHAOQI = Convert.ToString(reader["ISCHAOQI"]);
data.MNGBLSTATUS = Convert.ToString(reader["MNGBLSTATUS"]);
data.CUSTCARGOAFTER = Convert.ToString(reader["CUSTCARGOAFTER"]);
data.QRDATE = Convert.ToString(reader["QRDATE"]);
data.QCDATE = Convert.ToString(reader["QCDATE"]);
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
data.ISGAIQIAN = Convert.ToString(reader["ISGAIQIAN"]);
data.DOC = Convert.ToString(reader["DOC"]);
data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 业务信息
static public List<MsOpBill> GetBillDataList(int start, int limit, string strCondition, string sort = null, bool all = false)
{
var strSql = new StringBuilder();
strSql.Append(@"SELECT * from (SELECT row_number() over (");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by ETD,MBLNO");
}
strSql.Append(@") as num , ");
strSql.Append(" BSNO,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO");
strSql.Append(",CUSTOMERNAME");
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD");
strSql.Append(",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE");
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,REMARK");
strSql.Append(",(CASE BSSTATUS WHEN 1 THEN '锁定' else '未锁定' end) as BSSTATUSREF");
strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF");
strSql.Append(",dbo.F_GetBillDrFeeStatus(op_seae.BSNO) DRFEESTATUS");
strSql.Append(",dbo.F_GetBillCrFeeStatus(op_seae.BSNO) CRFEESTATUS");
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=op_seae.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=OP_SEAE.BSNO) BLISSUESTATUS");
strSql.Append(",ISSUETYPE");
strSql.Append(" from op_seae where ISSUETYPE<>'SWB' ");//20230302 固化逻辑 不显示issuetype=SWB的业务 因为实际上扣不了
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(@")as t ");
strSql.Append(string.Format("where t.num>={0} and t.num<={1} order by t.num ", start, start + limit)); //
return SetBillData(strSql);
}
public static int getTotalCount(string strCondition)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(*) ");
strSql.Append(" from op_seae WITH (NOLOCK)");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
int cnt = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
cnt = Convert.ToInt32(reader[0]);
}
}
return cnt;
}
private static List<MsOpBill> SetBillData(StringBuilder strSql)
{
var headList = new List<MsOpBill>();
Database db = DatabaseFactory.CreateDatabase();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = strSql.ToString();
cmd.CommandTimeout = 120000; //要加这一句
using (IDataReader reader = db.ExecuteReader(cmd))
{
while (reader.Read())
{
MsOpBill data = new MsOpBill();
#region Set DB data to Object
data.BSNO = Convert.ToString(reader["BSNO"]);
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToString(reader["ETD"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
data.MBLNO = Convert.ToString(reader["MBLNO"]);
data.HBLNO = Convert.ToString(reader["HBLNO"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VOYNO = Convert.ToString(reader["VOYNO"]);
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
data.OP = Convert.ToString(reader["OP"]);
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
data.DOC = Convert.ToString(reader["DOC"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.ENTERP = Convert.ToString(reader["ENTERP"]);
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);
if (reader["CUSTOMSNUM"] != DBNull.Value)
data.CUSTOMSNUM = Convert.ToInt16(reader["CUSTOMSNUM"]);
data.PKGS = Convert.ToString(reader["PKGS"]);
data.CBM = Convert.ToString(reader["CBM"]);
data.KGS = Convert.ToString(reader["KGS"]);
if (reader["BSSTATUS"] != DBNull.Value)
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);
data.BSSTATUSREF = Convert.ToString(reader["BSSTATUSREF"]);// 业务状态
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);// 费用状态
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));
data.CNTRTOTAL = Convert.ToString(reader["CNTRTOTAL"]);//集装箱全部内容
data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);
data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static string getfeestatus(string feestatusint)
{
var result = "";
if (feestatusint == "0:")
{
return "审核通过";
}
else if (feestatusint == "1:")
{
return "录入状态";
}
else if (feestatusint == "2:")
{
return "提交审核";
}
else if (feestatusint == "8:")
{
return "部分结算";
}
else if (feestatusint == "9:")
{
return "结算完毕";
}
else if (feestatusint == "")
{
return "未录入";
}
else if (feestatusint == "3:")
{
return "申请修改";
}
else if (feestatusint == "4:")
{
return "申请删除";
}
else if (feestatusint == "6:")
{
return "驳回提交";
}
else if (feestatusint == "7:")
{
return "驳回申请";
}
else if (feestatusint.IndexOf("9:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("0:") > -1)
{
return "部分审核";
}
else if (feestatusint.IndexOf("2:") > -1)
{
return "部分提交";
}
return result;
}
#endregion
#region 特殊放单申请
static public List<MsOp_BLISSUEListmb> GetSPList(int start, int limit, string strCondition, string sort, string userid="", string usercode = "", string companyid = "")
{
if (!string.IsNullOrWhiteSpace(userid))
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
}
var strSql = new StringBuilder();
strSql.Append(@"SELECT * from (SELECT row_number() over (");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by OPTIME desc ");
}
strSql.Append(@") as num , ");
strSql.Append(" ob.GID,ob.BLSTATUS,(select top 1 BLSTATUS from op_blissue where bsno=ob.BSNO) BL_BLSTATUS");
strSql.Append(" ,ob.BSNO,ob.OPNAME,dbo.trimdate(ob.OPTIME) OPTIME,ob.REMARK,ob.SPREMARK,ob.ISCHAOQI,ob.COMMITREMARK,");
strSql.Append(" CASE WHEN exists(select 1 from v_op_seae_iscargo where CUSTOMERNAME=ob.CUSTOMERNAME) THEN '有' ELSE '无' END CUSTCARGOAFTER,ob.STLNAME,ob.SALEDEPT,ob.ISDEPTARREARS,ob.MNGBLSTATUS ");
strSql.Append(" ,ob.CUSTOMERNAME,ob.SALE ");//,g.MBLNO,g.HBLNO,g.ETD,g.VESSEL,g.VOYNO,g.OP
strSql.Append(" ,convert(bigint ,ob.TimeMark) as TimeMark,ob.RMBNODR,ob.USDNODR,ob.TTLNODR ");
strSql.Append(" ,isnull(dp.MAXARREARS,0) MAXARREARS,isnull((select sum(TTLDR-STLTTLDR) from v_op_gain_sum where EXISTS (select 1 from v_op_blissuelist_Detail bl");
strSql.Append(" where v_op_gain_sum.BSNO=bl.bsno and bl.BLSTATUS='审核通过' and bl.MNGBLSTATUS<>'审核通过' AND SALEDEPT=ob.SALEDEPT and ");
strSql.Append(" not exists (select 1 from v_op_seae_iscargo i where bl.customername=i.customername))),0) AS DEPTTTLNODR ");
strSql.Append(" ,ob.AUDITOR,ob.SALECORPID,ob.RMBNODR_ALL,ob.USDNODR_ALL,ob.TTLNODR_ALL ");
strSql.Append(" from op_blissuelist ob ");
//strSql.Append(" left join v_op_blissue_bill g on g.bsno=ob.bsno ");
strSql.Append(" left join workflow_using wu on wu.bsno=ob.GID ");
strSql.Append(" left join SYS_DEPT_ARREARS dp on dp.DEPT=ob.SALEDEPT ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition.Replace("~", ""));//str.Replace("b","**");
}
strSql.Append(@")as t ");
strSql.Append(string.Format("where t.num>={0} and t.num<={1} order by t.num", start, start + limit)); //
return SetSPData(strSql);
}
static public List<MsOp_BLISSUEListmb> GetSPCustList(int start, int limit, string strCondition, string sort,string userid,string usercode,string companyid)
{ //合同信息/商品信息
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append(@"SELECT * from (SELECT row_number() over (");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by OPTIME desc ");
}
strSql.Append(@") as num , ");
strSql.Append(" ob.GID,ob.BLSTATUS,(select top 1 BLSTATUS from op_blissue where bsno=ob.BSNO) BL_BLSTATUS");
strSql.Append(" ,ob.BSNO,ob.OPNAME,dbo.trimdate(ob.OPTIME) OPTIME,ob.REMARK,ob.SPREMARK,ob.ISCHAOQI,ob.COMMITREMARK,");
strSql.Append(" CASE WHEN exists(select 1 from v_op_seae_iscargo where CUSTOMERNAME=ob.CUSTOMERNAME) THEN '有' ELSE '无' END CUSTCARGOAFTER,ob.STLNAME,ob.SALEDEPT,ob.ISDEPTARREARS,ob.MNGBLSTATUS ");
strSql.Append(" ,ob.CUSTOMERNAME,ob.SALE ");//,g.MBLNO,g.HBLNO,g.ETD,g.VESSEL,g.VOYNO,g.OP
strSql.Append(" ,convert(bigint ,ob.TimeMark) as TimeMark,ob.RMBNODR,ob.USDNODR,ob.TTLNODR ");
strSql.Append(" ,isnull(dp.ALLOWAMOUNT,0) MAXARREARS,isnull((select sum(TTLDR-STLTTLDR) from v_op_gain_sum where EXISTS (select 1 from v_op_blissuelist_Detail bl");
strSql.Append(" where v_op_gain_sum.BSNO=bl.bsno and bl.BLSTATUS='审核通过' and bl.MNGBLSTATUS<>'审核通过' AND CUSTOMERNAME=ob.CUSTOMERNAME and ");
strSql.Append(" not exists (select 1 from v_op_seae_iscargo i where bl.customername=i.customername))),0) AS DEPTTTLNODR ");
strSql.Append(" ,ob.AUDITOR,ob.SALECORPID,ob.RMBNODR_ALL,ob.USDNODR_ALL,ob.TTLNODR_ALL ");
strSql.Append(" from op_blissuelist ob ");
//strSql.Append(" left join v_op_blissue_bill g on g.bsno=ob.bsno ");
strSql.Append(" left join workflow_using wu on wu.bsno=ob.GID ");
strSql.Append(" left join v_info_client_accdate dp on dp.CUSTOMERNAME=ob.CUSTOMERNAME AND dp.BGNDATE<=ob.OPTIME AND dp.ENDDATE>=ob.OPTIME ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition.Replace("~", ""));//str.Replace("b","**");
}
strSql.Append(@")as t ");
strSql.Append(string.Format("where t.num>={0} and t.num<={1} order by t.num", start, start + limit)); //
return SetSPData(strSql);
}
public static int getSpTotalCount(string strCondition, string userid, string usercode, string companyid)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr)) {
if (string.IsNullOrWhiteSpace(strCondition))
{
strCondition = rangstr;
}
else {
strCondition += " and " + rangstr;
}
}
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(*) ");
strSql.Append(" from op_blissuelist ob ");
//strSql.Append(" left join v_op_blissue_bill g on g.bsno=ob.bsno ");
strSql.Append(" left join workflow_using wu on wu.bsno=ob.GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition.Replace("~", ""));//str.Replace("b","**");
}
int cnt = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
cnt = Convert.ToInt32(reader[0]);
}
}
return cnt;
}
public int GetTotalCount(string strCondition, string userid, string usercode, string companyid) {
return getSpTotalCount( strCondition, userid, usercode, companyid);
}
static public MsOp_BLISSUEListmb GetSPData ( string condition )
{
var _t = "";
var list = GetSPList(0,1,condition, _t);
if (list.Count > 0)
return list[0];
return new MsOp_BLISSUEListmb();
}
private static List<MsOp_BLISSUEListmb> SetSPData ( StringBuilder strSql )
{
var headList = new List<MsOp_BLISSUEListmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOp_BLISSUEListmb data = new MsOp_BLISSUEListmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BLSTATUS = Convert.ToString(reader["BLSTATUS"]);
data.MNGBLSTATUS = Convert.ToString(reader["MNGBLSTATUS"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.OPNAME = Convert.ToString(reader["OPNAME"]);
data.OPTIME = Convert.ToString(reader["OPTIME"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
//,g.MBLNO,g.HBLNO,g.ETD,g.VESSEL,g.VOYNO,g.OP
//data.MBLNO = Convert.ToString(reader["MBLNO"]);
//data.HBLNO = Convert.ToString(reader["HBLNO"]);
//data.ETD = Convert.ToString(reader["ETD"]);
//data.VESSEL = Convert.ToString(reader["VESSEL"]);
//data.VOYNO = Convert.ToString(reader["VOYNO"]);
//data.OP = Convert.ToString(reader["OP"]);
data.RMBNODR = Convert.ToString(reader["RMBNODR"]);
data.USDNODR = Convert.ToString(reader["USDNODR"]);
data.TTLNODR = Convert.ToString(reader["TTLNODR"]);
data.RMBNODR_ALL = Convert.ToString(reader["RMBNODR_ALL"]);
data.USDNODR_ALL = Convert.ToString(reader["USDNODR_ALL"]);
data.TTLNODR_ALL = Convert.ToString(reader["TTLNODR_ALL"]);
data.BL_BLSTATUS = Convert.ToString(reader["BL_BLSTATUS"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.SPREMARK = Convert.ToString(reader["SPREMARK"]);
data.CUSTCARGOAFTER = Convert.ToString(reader["CUSTCARGOAFTER"]);
data.STLNAME = Convert.ToString(reader["STLNAME"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);
data.MAXARREARS = Convert.ToString(reader["MAXARREARS"]);
data.DEPTTTLNODR = Convert.ToString(reader["DEPTTTLNODR"]);
data.DEPTTTLDR =Convert.ToString(Convert.ToDecimal(data.MAXARREARS) - Convert.ToDecimal(data.DEPTTTLNODR));
data.ISDEPTARREARS = "否";
if (data.BLSTATUS == "审核通过" && data.MNGBLSTATUS != "审核通过"&&data.CUSTCARGOAFTER=="无") {
if (data.MAXARREARS != "0") data.ISDEPTARREARS = "是";
}
data.ISCHAOQI = Convert.ToString(reader["ISCHAOQI"]);
data.COMMITREMARK = Convert.ToString(reader["COMMITREMARK"]);
data.AUDITOR = Convert.ToString(reader["AUDITOR"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
//
/// <summary>
/// 特殊放单明细表
/// 特殊放单申请明细
/// </summary>
/// <param name="strCondition"></param>
/// <param name="start"></param>
/// <param name="limit"></param>
/// <param name="sort"></param>
/// <returns></returns>
static public List<MsOp_BLISSUEmb> GetSPDetail ( string strCondition,int start,int limit, string sort )
{ //合同信息/商品信息
var strSql = new StringBuilder();
/*
strSql.Append(" select obd.GID,op_seae.BSNO,op_seae.mblno BLNO,op_seae.HBLNO ");
strSql.Append(" ,(case when op_seae.bsno=op_seae.masterno then '主提单' else '分单' END) ZDFD ");
strSql.Append(" ,ob.BLNAME,ob.BLSTATUS,ob.BLORDERNO ");
strSql.Append(" ,(select top 1 ISSUETYPE from op_seae where bsno=op_seae.bsno) ISSUETYPE ");
strSql.Append(" ,ob.OPNAME,ob.OPTIME,ob.BSINKNO ");
strSql.Append(" ,ob.REMARK,ob.DELFLAG,ob.EXPRESSCORP,ob.EXPRESSNO,ob.ISADD,dbo.trimdate(ob.PUTSINGLETIME) PUTSINGLETIME ");
strSql.Append(" ,ob.PUTSINGLE,ob.PAYTIME,ob.PAYRMB,ob.PAYUSD ");
strSql.Append(" ,op_seae.BLTYPE,op_seae.CUSTNO,op_seae.customername,op_seae.sale ");
strSql.Append(" ,(select top 1 acctype from info_client_accdate where LINKGID=(select top 1 gid from info_client where SHORTNAME=op_seae.customername) ");
strSql.Append(" and BGNDATE<=op_seae.ETD and ENDDATE>op_seae.ETD and (isnull(SALE,'')='' or SALE=op_seae.SALE)) acctype ");
strSql.Append(" ,op_seae.ETD,op_seae.STLDATE,op_seae.CARRIER,op_seae.VESSEL,op_seae.VOYNO,op_seae.OP,op_seae.BLISSUESTATUS ");
strSql.Append(" ,(case when (select count(*) from op_blissuelist where bsno=op_seae.BSNO)>0 then '特殊放单' ELSE '' end) TSFD ");
strSql.Append(" ,DATEDIFF(day,op_seae.ETD,op_seae.STLDATE) XYTS ");
strSql.Append(" ,datediff(day,op_seae.STLDATE,getdate()) cqts ");
strSql.Append(" ,DATEDIFF(day,op_seae.ETD,getdate()) SJTS ");
strSql.Append(" ,(select RMBNODR from v_op_bill_gain where bsno=op_seae.bsno) RMBNODR ");
strSql.Append(" ,(select USDNODR from v_op_bill_gain where bsno=op_seae.bsno) USDNODR ");
strSql.Append(" ,(select TTLNODR from v_op_bill_gain where bsno=op_seae.bsno) TTLNODR ");
strSql.Append(" from op_seae ");
strSql.Append(" left join op_blissue ob on ob.BSNO=op_seae.BSNO ");
strSql.Append(" left join op_blissuelist_Detail obd on obd.BSNO=op_seae.BSNO ");
strSql.Append(" where isnull(op_seae.MBLNO,'')<>'' ");
strSql.Append(" ,ob.PUTSINGLE,ob.PAYTIME,ob.PAYRMB,ob.PAYUSD,sp.SPREMARK SPREMARK,sp.ISCHAOQI,sp.MNGBLSTATUS ");
strSql.Append(" ,CASE WHEN(select COUNT(*) from v_op_seae_iscargo where CUSTOMERNAME=ob.CUSTOMERNAME)>0 THEN '有' ELSE '无' END CUSTCARGOAFTER ");
*
*
*
*
*
*/
strSql.Append(" select obd.GID,B.BSNO,B.mblno BLNO,B.HBLNO ");
strSql.Append(" ,B.OPTYPE ZDFD ");
strSql.Append(" ,ob.BLNAME,ob.BLSTATUS,ob.BLORDERNO ");
strSql.Append(" ,B.ISSUETYPE,B.ISSUEPLACE ");
strSql.Append(" ,ob.OPNAME,ob.OPTIME,ob.BSINKNO,ob.ISVESSELPROVE,ob.VESSELPROVETIME,ob.VESSELPROVEREMARK ");
strSql.Append(" ,ob.REMARK,ob.DELFLAG,ob.EXPRESSCORP,ob.EXPRESSNO,ob.ISADD,dbo.trimdate(ob.PUTSINGLETIME) PUTSINGLETIME ");
strSql.Append(" ,ob.PUTSINGLE,ob.PAYTIME,ob.PAYRMB,ob.PAYUSD,obd.SPREMARK SPREMARK,obd.REMARK SPSQREMARK,'' ISCHAOQI,'' MNGBLSTATUS,'' CUSTCARGOAFTER ");
strSql.Append(" ,B.BLTYPE,B.CUSTNO,B.customername,B.sale ");
strSql.Append(" ,(select top 1 acctype from info_client_accdate where LINKGID=(select top 1 gid from info_client where SHORTNAME=B.customername) ");
strSql.Append(" and BGNDATE<=B.ETD and ENDDATE>B.ETD and (isnull(SALE,'')='' or SALE=B.SALE)) acctype ");
strSql.Append(" ,dbo.trimdate(B.ETD) ETD,dbo.trimdate(B.STLDATE) STLDATE,B.CARRIER,B.VESSEL,B.VOYNO,B.OP ,B.CUSTSERVICE,B.PORTLOAD,B.PORTDISCHARGE,B.DOC");
strSql.Append(" ,B.BLISSUESTATUS ");
strSql.Append(" ,obd.BLSTATUS TSFD ");
strSql.Append(" ,DATEDIFF(day,B.ETD,B.STLDATE) XYTS ");
strSql.Append(" ,datediff(day,B.STLDATE,getdate()) cqts ");
strSql.Append(" ,DATEDIFF(day,B.ETD,getdate()) SJTS ");
strSql.Append(" ,g.RMBDR-g.STLRMBDR RMBNODR ");
strSql.Append(" ,g.USDDR-g.STLUSDDR USDNODR ");
strSql.Append(" ,g.TTLDR-g.STLTTLDR TTLNODR ");
strSql.Append(" ,g.TTLDR TTLDR ");
strSql.Append(" ,B.OPLBNAME,B.STLNAME,0 ISQR,ob.QRDATE,ob.QCDATE,B.ISGAIQIAN ");
strSql.Append(OPSEAE);
strSql.Append(" from v_op_blissue_bill B ");
strSql.Append(" left join op_blissue ob on ob.BSNO=B.BSNO ");
strSql.Append(" left join v_op_blissuelist_Detail obd on obd.BSNO=B.BSNO ");//编辑页查询 obd.LINKGID=
strSql.Append(" left join v_op_gain_blissue_bill g on g.BSNO=B.PARENTID and b.MBLNO=g.MBLNO and b.HBLNO=g.HBLNO and g.CUSTOMERNAME=B.customername ");
strSql.Append(" where isnull(B.MBLNO,'')<>'' ");
//if (!string.IsNullOrEmpty(strCondition))
//{
// strSql.Append(" and " + strCondition.Replace("~", ""));//str.Replace("b","**");
//}
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring);
//}
//else
//{
// strSql.Append(" order by ob.OPTIME desc ");
//}
PagedQuaryParam pp = new PagedQuaryParam();
pp.strSql = strSql.ToString();
pp.start = start;
pp.limit = limit;
pp.strCondition = strCondition;
pp.defaultsortstr = "OPTIME desc";
pp.sortstring = sort;
var result = PagedQuaryStr(pp);
return SetData(result);
}
static public int DeleteDetail ( string LINKGID, string GIDList )
{
var strSql = new StringBuilder();
if (GIDList != "")
{
strSql.Append(" delete from op_blissuelist_detail where GID in(" + GIDList + ") ");
strSql.Append(" update op_blissuelist set CustomerName='',SALEDEPT='',STLNAME='' where (select count(*) from op_blissuelist_detail where linkgid=op_blissuelist.GID)=0 ");
}
var _count = 0;
Database db = DatabaseFactory.CreateDatabase();
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
return _count;
}
/// <summary>
/// 重新计算特殊放单涉及的欠费费用
/// </summary>
/// <param name="GID"></param>
/// <returns></returns>
static public int ResetSPAmount ( string GID , MsOp_BLISSUEListmb headdata)
{
var strSql = new StringBuilder();
strSql.Append(" update OP_BLISSUEList set RMBNODR= ");
strSql.Append(" (select sum(RMBDR-STLRMBDR) RMBNODR from v_op_gain_billcustomer ");
strSql.Append(" where BSNO in(select BSNO from OP_BLISSUEList_detail where linkgid='" + GID + "') and CUSTOMERNAME_DR='"+ headdata.CUSTOMERNAME + "' ), ");
strSql.Append(" USDNODR= ");
strSql.Append(" (select sum(USDDR-STLUSDDR) USDNODR from v_op_gain_billcustomer ");
strSql.Append(" where BSNO in(select BSNO from OP_BLISSUEList_detail where linkgid='" + GID + "') and CUSTOMERNAME_DR='"+ headdata.CUSTOMERNAME + "' ), ");
strSql.Append(" TTLNODR= ");
strSql.Append(" (select sum(TTLDR-STLTTLDR) TTLNODR from v_op_gain_billcustomer ");
strSql.Append(" where BSNO in(select BSNO from OP_BLISSUEList_detail where linkgid='" + GID + "') and CUSTOMERNAME_DR='"+ headdata.CUSTOMERNAME + "' ), ");
strSql.Append(" RMBNODR_ALL= ");
strSql.Append(" (select sum(RMBDR-STLRMBDR) RMBNODR_ALL from v_op_gain_billcustomer ");
strSql.Append(" where CUSTOMERNAME_DR='" + headdata.CUSTOMERNAME + "'), ");
strSql.Append(" USDNODR_ALL= ");
strSql.Append(" (select sum(USDDR-STLUSDDR) USDNODR_ALL from v_op_gain_billcustomer ");
strSql.Append(" where CUSTOMERNAME_DR='" + headdata.CUSTOMERNAME + "'), ");
strSql.Append(" TTLNODR_ALL= ");
strSql.Append(" (select sum(TTLDR-STLTTLDR) TTLNODR_ALL from v_op_gain_billcustomer ");
strSql.Append(" where CUSTOMERNAME_DR='" + headdata.CUSTOMERNAME + "') ");
strSql.Append(" where GID='"+GID+"' ");
var _count = 0;
Database db = DatabaseFactory.CreateDatabase();
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
return _count;
}
#endregion
#region 特殊放单权限
#region 权限范围
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOp_BLISSUESP' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
string AUTHORITYID = "";
string VSSQL = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
VSSQL = Convert.ToString(reader["VSSQL"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " ( ob.OPNAME='" + username + "' OR ob.SALE='" + username + "' OR ob.AUDITOR='" + username + "' )";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var deptid = rangeDa.GetDEPTGID(userid);
//str = " ( g.AUDITOR in (select showname from vw_user where deptgid='" + deptid + "')" +
// " OR ob.OPNAME in (select showname from vw_user where deptgid='" + deptid + "')" +
// " OR ob.SALE in (select showname from vw_user where deptgid='" + deptid + "')" +
//")";
str = " exists( select 1 from vw_user where deptgid='" + deptid + "' and(showname=g.AUDITOR OR showname=ob.OPNAME OR showname=ob.SALE )) ";
}
else
{
str = " (UPPER(g.Corpid)='" + companyid.ToUpper() + "') ";
}
}
else if (visiblerange == "5")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
}
else
{
str = str + " or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " ( UPPER(B.SALECORPID)='" + companyid + "' ) ";
}
}
else if (visiblerange == "6")
{
if (tb == "index")
{
//var opstr = "";
//var userstr = new StringBuilder();
//userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
//Database userdb = DatabaseFactory.CreateDatabase();
//using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
//{
// while (reader.Read())
// {
// if (opstr == "")
// {
// opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
// }
// else
// {
// opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
// };
// }
// if (opstr != "") opstr = opstr + ")";
// reader.Close();
//}
//if (opstr == "") opstr = "('" + username + "')";
//str = " (B.OP in " + opstr + " or B.SALE in " + opstr + " or B.CUSTSERVICE IN " + opstr + " or B.DOC IN " + opstr + " or B.FRCUSTSERVICE IN " + opstr + " or B.INPUTBY IN " + opstr + ")";
str = " EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (B.OPNAME=U.SHOWNAME OR B.SALE=U.SHOWNAME OR B.AUDITOR=U.SHOWNAME ) AND P.userid='" + userid + "' and P.AUTHORITYID='" + AUTHORITYID + "' and P.VISIBLERANGE=1) ";
}
else
{
str = " (ob.SALECORPID='" + companyid + "' or (select companyid from vw_user where showname=ob.OPNAME)='"+ companyid + "' or (select companyid from vw_user where showname=ob.AUDITOR)='"+ companyid + "' ) ";
}
}
else if (visiblerange == "1")
{
//str = " (ob.SALECORPID='" + companyid + "' or (select companyid from vw_user where showname=ob.OPNAME)='" + companyid + "' or (select companyid from vw_user where showname=ob.AUDITOR)='" + companyid + "' ) ";
str = " (ob.SALECORPID='" + companyid + "' or exists(select 1 from vw_user where companyid='" + companyid + "' and showname in(ob.OPNAME,ob.AUDITOR,ob.SALE))) ";
}
VSSQL = VSSQL.Trim();
if (!string.IsNullOrEmpty(VSSQL))
{
if (!string.IsNullOrEmpty(str))
{
str = str + " and (" + VSSQL + ") ";
}
else
{
str = " (" + VSSQL + ") ";
}
}
return str;
}
#endregion
#endregion
//判断特殊放单单号是否重复
static public int GetRdCount ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append("SELECT Count(GID) AS CT from Op_BLISSUEList (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;
}
#region 审核流程
#region 新_签入
public static DBResult QR ( List<MsOp_BLISSUEmb> _List, string USERID,string qrdate,string username,string reason ) //签入
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
//Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID);
/*
if (WorkResult.Success == true)
{*/
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='提单签入',QRDATE='" + qrdate + "' where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var CT = T_ALL_DA.GetStrSQL("CT", "SELECT ISNULL(SUM(CASE ACTNAME WHEN '提单签入' THEN 1 ELSE 0 END),0) CT FROM WorkLog WHERE (ACTNAME='提单签入' OR ACTNAME='取消签入') AND BSNO='" + _bill.GID + "'");
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "提单签入";
if (reason != "") reason = "_" + reason;
log.REMARK = (Convert.ToInt32(CT) + 1).ToString() + "次签入"+ reason;
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS='提单签入' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='提单签入' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='提单签入' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var blUpSQL = db.GetSqlStringCommand("insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','提单签入','提单签入','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')");
db.ExecuteNonQuery(blUpSQL, tran);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','提单签入',1,'" + qrdate + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','"+username+"')");
db.ExecuteNonQuery(blUpSQL2, tran);
//T_ALL_DA T_ALL_DA = new T_ALL_DA();
//DataSet dsHSCODE = T_ALL_DA.GetAllSQL("SELECT MBLNO,(SELECT TOP 1 GID FROM [user] where SHOWNAME=V_OP_BS.OP) OPID FROM V_OP_BS WHERE BSNO='" + _bill.BSNO + "'");
//if (dsHSCODE != null)
//{
// if (dsHSCODE.Tables[0].Rows.Count > 0)
// {
// var Msgdata = new SYSMessagemb();
// Msgdata.GID = Guid.NewGuid().ToString();
// Msgdata.NAME = "SALEORDER";
// Msgdata.DESCRIPTION = "提单签入";
// Msgdata.MESSAGECONTENT = "提单号:" + dsHSCODE.Tables[0].Rows[0]["MBLNO"].ToString() + "已签入";
// Msgdata.RECEIVER = dsHSCODE.Tables[0].Rows[0]["OPID"].ToString();
// Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// Msgdata.ISREAD = "0";
// Msgdata.READCOUNT = "0";
// Msgdata.TYPE = "0";
// Msgdata.TASKURL = "";
// Msgdata.TASKID = _bill.BSNO;
// Msgdata.NUMBER = "0";
// Msgdata.RECVTYPE = "2";
// Msgdata.DbOperationType = DbOperationType.DbotIns;
// Msgdata.ModelUIStatus = "I";
// var Msgmodb = new ModelObjectRepository();
// Msgmodb.Save(Msgdata);
// }
//}
/*}
else
{
result.Success = false;
result.Message = "提交错误!";
}*/
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
/// <summary>
/// 取消签入
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="username"></param>
/// <returns></returns>
public static DBResult UnQR ( List<MsOp_BLISSUEmb> _List, string USERID,string username) //签入_撤回
{
//20231121 增加判断 防止在未签入的情况下 执行 取消签出动作
//防止多余的 取消签入 影响提单签出状态的判断
//返回true即为可以取消签入
bool (MsOp_BLISSUEmb _p)
{
var condition = $" (BSNO='{_p.GID}' or BSNO in(select linkgid from op_blissuelist_detail where BSNO='{_p.BSNO}'))";
var loglist = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null);
var count = 0;
var count = 0;
foreach (var log in loglist)
{
if (log.ACTNAME == "提单签入") count++;
if (log.ACTNAME == "取消签入") count--;
if (log.ACTNAME == "提单签出") count++;
if (log.ACTNAME == "取消签出") count--;
}
if (count <= count)
{
return false;
}
else
{
return true;
}
}
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
if (!(_bill)) continue;
//Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
//if (WorkResult.Success == true)
//{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS=(case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '可放单' "
+ " else '' end),QRDATE='' where GID=@GID and BLSTATUS ='提单签入' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "取消签入";
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS='' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','取消提单签入','取消提单签入','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
//}
//else
//{
// result.Success = false;
// result.Message = "提交错误!";
//}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult CZQR(List<MsOp_BLISSUEmb> _List, string USERID, string CZQRDATE, string CZQRREMARK) //签入
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
//Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID);
/*
if (WorkResult.Success == true)
{*/
var cmdupdate = db.GetSqlStringCommand("update op_blissue set ISVESSELPROVE=1,VESSELPROVETIME='" + CZQRDATE + "',VESSELPROVEREMARK='" + CZQRREMARK + "' where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "船证签入";
SaveLog(log, USERID);
/*}
else
{
result.Success = false;
result.Message = "提交错误!";
}*/
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult UnCZQR(List<MsOp_BLISSUEmb> _List, string USERID) //签入_撤回
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
//Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
//if (WorkResult.Success == true)
//{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set ISVESSELPROVE='0',VESSELPROVETIME=null,VESSELPROVEREMARK='' where GID=@GID and ISVESSELPROVE='1' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "船证取消签入";
SaveLog(log, USERID);
//}
//else
//{
// result.Success = false;
// result.Message = "提交错误!";
//}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#region 状态更改
public static DBResult GGTD(List<MsOp_BLISSUEmb> _List,string status, string USERID, string username) //签入
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='"+ status + "' where GID=@GID ");
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "'"+status+"'";
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS='"+ status + "' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='"+ status + "' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='"+ status + "' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var blUpSQL = db.GetSqlStringCommand("insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','"+ status + "','"+ status + "','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')");
db.ExecuteNonQuery(blUpSQL, tran);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','"+ status + "',1,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + username + "')");
db.ExecuteNonQuery(blUpSQL2, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#region 换签背书
public static DBResult HQBS ( List<MsOp_BLISSUEmb> _List, string USERID,string username) //申请签入_驳回
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='换签(背书)' where GID=@GID and BLSTATUS not in ('扣单') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "换签(背书)";
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS='换签(背书)' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='换签(背书)' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='换签(背书)' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','换签背书','换签背书','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult UnHQBS(List<MsOp_BLISSUEmb> _List, string USERID,string username) //申请签入_驳回
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='提单签入' where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "取消换签(背书)";
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS='提单签入' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='提单签入' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='提单签入' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','取消换签背书','取消换签背书','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
/// <summary>
/// 签出
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="REASON"></param>
/// <param name="qcdate"></param>
/// <param name="username"></param>
/// <returns></returns>
public static DBResult QC ( List<MsOp_BLISSUEmb> _List, string USERID, string REASON,string qcdate,string username ) //申请签入_驳回
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='提单签出',QCDATE='" + qcdate + "' where GID=@GID and BLSTATUS not in ('扣单') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var CT = T_ALL_DA.GetStrSQL("CT", "SELECT ISNULL(SUM(CASE ACTNAME WHEN '提单签出' THEN 1 ELSE 0 END),0) CT FROM WorkLog WHERE (ACTNAME='提单签出' OR ACTNAME='取消签出') AND BSNO='" + _bill.GID + "'");
var log = new WorkLogmb();
log.BSNO = _bill.GID;
// log.REMARK = REASON;
log.ACTNAME = "提单签出";
if (REASON != "") REASON = "_" + REASON;
log.REMARK = (Convert.ToInt32(CT) + 1).ToString() + "次签出"+REASON;
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand( " update op_seae set BLISSUESTATUS='提单签出' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='提单签出' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='提单签出' where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var blUpSQL = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','提单签出',1,'" + qcdate + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','"+username+"')");
db.ExecuteNonQuery(blUpSQL, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','提单签出','提单签出','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
/// <summary>
/// 扣单
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="username"></param>
/// <param name="REMARK"></param>
/// <returns></returns>
public static DBResult KD(List<MsOp_BLISSUEmb> _List, string USERID, string username, string REMARK = "" ) //
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
//20230221 增加判断 如果ussuetype=swb的不进行扣单操作
foreach (var _bill in _List)
{
if (_bill.ISSUETYPE == "SWB" && _bill.BLISSUESTATUS!="扣单") {
result.Success = false;
result.Message = $"签单方式SWB的业务[{_bill.CUSTNO}]不能扣单";
}
if (string.IsNullOrWhiteSpace(_bill.ISSUETYPE))
{
result.Success = false;
result.Message = $"签单方式未指定的业务[{_bill.CUSTNO}]不能扣单";
}
//如果该业务被特殊放单审核通过了 则不允许
}
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='扣单' where GID=@GID and BLSTATUS ='签出' ");
if (_bill.BLSTATUS == "扣单")
{
cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS="
+ " (case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '可放单' "
+ " else case when (select count(1) from worklog where BSNO=@GID and actname='提单签入')>0 then '提单签入' "
+ " else '' end end) where GID=@GID ");
}
else {
cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='扣单' where GID=@GID ");
}
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
if (_bill.BLSTATUS == "扣单")
{
log.ACTNAME = "取消扣单";
}
else
{
log.ACTNAME = "扣单";
}
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where BSNO=@BSNO "
+ "update op_seae_billmanage set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','"+ log.ACTNAME + "',1,GETDATE(),'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + username + "')");
db.ExecuteNonQuery(blUpSQL2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','扣单','扣单','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
/// <summary>
/// 取消扣单 提单管理页面点击执行。
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="username"></param>
/// <param name="REMARK"></param>
/// <returns></returns>
public static DBResult UnKD(List<string> _BsnoList, string USERID, string username, string REMARK = "") //
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
var bsnosStr = "'"+ string.Join("','", _BsnoList) + "'";
var outcount = 0;
var _List = GetDataList($" B.BSNO in({bsnosStr})", 0, 999, out outcount, "");
result = UnKD_List(_List, USERID, username,true, REMARK);
return result;
}
/// <summary>
/// 取消扣单 用于特殊放单审过之后执行。
/// </summary>
/// <param name="_GidList"></param>
/// <param name="USERID"></param>
/// <param name="username"></param>
/// <param name="REMARK"></param>
/// <returns></returns>
public static DBResult UnKD_GID(List<string> _GidList, string USERID, string username, string REMARK = "") //
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
var outcount = 0;
var cdc = new CommonDataContext();
var List = cdc.op_blissuelist_Detail.Where(x => _GidList.Contains(x.LINKGID)).ToList();
if (List != null && List.Count > 0) {
var bsnoList = List.Select(s => s.BSNO).ToList();
var bsnoStr = "'" + string.Join("','", bsnoList) + "'";
var _List = GetDataList($" ob.BSNO in({bsnoStr})", 0, 999, out outcount, "");
result = UnKD_List(_List, USERID, username,false, REMARK);
}
return result;
}
/// <summary>
/// 如果是特放审批通过
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="username"></param>
/// <param name="是否判断财务扣单"></param>
/// <param name="REMARK"></param>
/// <returns></returns>
public static DBResult UnKD_List(List<MsOp_BLISSUEmb> _List, string USERID, string username,bool , string REMARK = "") //
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
var outcount = 0;
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var = (_bill, USERID, );
if (!.Success) continue;
var cmdupdate = db.GetSqlStringCommand(" ");
if (_bill.BLSTATUS == "扣单")
{
cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS="
+ " (case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '可放单' "
+ " else case when (select count(1) from worklog where BSNO=@GID and actname='已放货')>0 then '已放货' "
+ " else case when (select count(1) from worklog where BSNO=@GID and actname='提单签入')>0 then '提单签入' "
+ " else '' end end end) where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
}
var log = new WorkLogmb();
log.BSNO = _bill.GID;
//if (_bill.BLSTATUS == "扣单")
//{
log.ACTNAME = "取消扣单";
//}
//else
//{
// log.ACTNAME = "扣单";
//}
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where BSNO=@BSNO "
+ "update op_seae_billmanage set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS=(SELECT BLSTATUS FROM op_blissue WHERE BSNO=@BSNO) where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','" + log.ACTNAME + "',1,GETDATE(),'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + username + "')");
db.ExecuteNonQuery(blUpSQL2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','扣单','扣单','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
/// <summary>
/// 放单通知
/// </summary>
/// <param name="_List"></param>
/// <param name="USERID"></param>
/// <param name="REASON"></param>
/// <param name="username"></param>
/// <returns></returns>
public static DBResult FDTZ ( List<MsOp_BLISSUEmb> _List, string USERID,string REASON,string username ) //申请签入_驳回
{
//20230302 对于这些业务来说
//电放 、目放、SWB状态改为已放货
//
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var ACTNAME = "";
var BLSTATUSNAME = "";
//if (_bill.能直接签出())
//{
// ACTNAME = "已放货";
// BLSTATUSNAME = "已放货";
//}
//else
//{
ACTNAME = "放单通知";
BLSTATUSNAME = "可放单";
//}
var cmdupdate = db.GetSqlStringCommand($"update op_blissue set BLSTATUS='{BLSTATUSNAME}' where GID=@GID "
+ $" update op_seae set BLISSUESTATUS='{BLSTATUSNAME}' where BSNO=@BSNO "
+ $" update op_aire set BLISSUESTATUS='{BLSTATUSNAME}' where BSNO=@BSNO "
+ $" update op_airi set BLISSUESTATUS='{BLSTATUSNAME}' where BSNO=@BSNO "
+ $" update op_seae_billmanage set BLISSUESTATUS='{BLSTATUSNAME}' where AS_ID=@BSNO3 "
+ $" update op_seai set BLISSUESTATUS='{BLSTATUSNAME}' where BSNO=@BSNO2 ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.REMARK = REASON;
log.ACTNAME = ACTNAME;
SaveLog(log, USERID);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','"+ ACTNAME + "',1,GETDATE(),'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + username + "')");
db.ExecuteNonQuery(blUpSQL2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','放单通知','放单通知','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult UNFDTZ(List<MsOp_BLISSUEmb> _List, string USERID,string username) //申请签入_驳回
{
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS="
+ " (case when (select count(1) from worklog where BSNO=@GID and actname='提单签入')>0 then '提单签入' "
+ " else '' end) where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "取消放单通知";
SaveLog(log, USERID);
var blUpSQL2 = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP) values(NEWID(),'" + _bill.BSNO + "','取消放单通知',1,GETDATE(),'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + username + "')");
db.ExecuteNonQuery(blUpSQL2, tran);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','取消提单签出','取消提单签出','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员"+e.Message;
//return result;
}
}
return result;
}
public static DBResult FDTZBACK(List<MsOp_BLISSUEmb> _List, string USERID) //申请签入_驳回
{
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='驳回放单通知' where GID=@GID "
+ " update op_seae set BLISSUESTATUS='驳回放单通知' where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS='驳回放单通知' where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS='驳回放单通知' where BSNO=@BSNO2 ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "驳回放单通知";
SaveLog(log, USERID);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult QXQC ( List<MsOp_BLISSUEmb> _List, string USERID,string username ) //取消签出
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
//Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
//if (WorkResult.Success == true)
//{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS="
+ " (case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '可放单' "
+ " else case when (select count(1) from worklog where BSNO=@GID and actname='提单签入')>0 then '提单签入' "
+ " else '' end end),QCDATE='' where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "取消签出";
SaveLog(log, USERID);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','取消提单签出','取消提单签出','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
//}
//else
//{
// result.Success = false;
// result.Message = "提交错误!";
//}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult REQR ( List<MsOp_BLISSUEmb> _List, string USERID ) //重新签入
{
//var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
//Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
//if (WorkResult.Success == true)
//{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='提单签入' where GID=@GID and BLSTATUS ='提单签出' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "重新签入";
SaveLog(log, USERID);
var cmdupdate2 = db.GetSqlStringCommand(" update op_seae set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO "
+ " update op_seae_billmanage set BLISSUESTATUS=(select blstatus from op_blissue where bsno=@BSNO) where AS_ID=@BSNO3 "
+ " update op_seai set BLISSUESTATUS==(select blstatus from op_blissue where bsno=@BSNO) where BSNO=@BSNO2 ");
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO2", DbType.String, _bill.BSNO);
db.AddInParameter(cmdupdate2, "@BSNO3", DbType.String, _bill.BSNO);
db.ExecuteNonQuery(cmdupdate2, tran);
//}
//else
//{
// result.Success = false;
// result.Message = "提交错误!";
//}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#region 签入
public static DBResult SQQR ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签入
{
var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID,_bill.MBLNO,_bill.GID,"");
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='待签入' where GID=@GID and BLSTATUS ='录入状态' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "申请签入";
SaveLog(log,USERID);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQQR_back ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签入_撤回
{
var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='录入状态' where GID=@GID and BLSTATUS ='待签入' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQQR_Auditback ( List<MsOp_BLISSUEmb> _List, string USERID, string REASON ) //申请签入_驳回
{
var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, _bill.GID, USERID,REASON);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='录入状态' where GID=@GID and BLSTATUS in ('待签入','已签入') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQQR_Audit ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签入_驳回
{
var WorkFlowName = "MsOp_BLISSUE_IN";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, _bill.GID, USERID,_bill.MBLNO);
if (WorkResult.Success == true)
{
if (WorkResult.islast == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='已签入' where GID=@GID and BLSTATUS ='待签入' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else {
}
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#region 特殊放单 审核流程
public static DBResult SP_Start ( List<MsOp_BLISSUEListmb> _List, string USERID ) //签入
{
var WorkFlowName = "MsOp_BLISSUE_SP";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID,_bill.MBLNO,_bill.GID,"");
if (WorkResult.Success == true)
{
if (WorkResult.islast != true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='提交审核',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='"+USERID+"') where GID=@GID and BLSTATUS in('录入状态','驳回提交') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单申请提交";
SaveLog(log, USERID);
}
else
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='审核通过' where GID=@GID and BLSTATUS in('录入状态','驳回提交') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单申请自动通过";
SaveLog(log, USERID);
//var blUpSQL = "insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + _bill.BSNO + "','提单签出','提单签出','" + username + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
//db.ExecuteNonQuery(blUpSQL, tran);
}
}
else
{
result.Success = false;
result.Message = WorkResult.Message;
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SP_Back ( List<MsOp_BLISSUEListmb> _List, string USERID ) //签入_撤回
{
var WorkFlowName = "MsOp_BLISSUE_SP";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='录入状态',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS ='提交审核' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单申请 撤回";
SaveLog(log, USERID);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SP_Audit ( List<MsOp_BLISSUEListmb> _List, string USERID, string REASON ) //申请签入_驳回
{
var WorkFlowName = "MsOp_BLISSUE_SP";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var UnKDGIDList = new List<string>();
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, _bill.GID, USERID,_bill.MBLNO);
if (WorkResult.Success == true)
{
if (WorkResult.islast != true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='提交审核',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS in('提交审核') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单审核";
log.REMARK = REASON;
SaveLog(log, USERID);
}
else
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='审核通过',SPREMARK='"+REASON+"' where GID=@GID and BLSTATUS in('提交审核') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
//var cmdUpdate = db.GetSqlStringCommand(
// @"if (select bsno from op_blissue where bsno='" + _bill.BSNO + "') is null insert into op_close values(newid(),'" + bsno + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
// + "','" + Convert.ToString(Session["SHOWNAME"]) + "',null,'') else update op_close set BSCLOSETIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
// + "',BSCLOSEOP='" + Convert.ToString(Session["SHOWNAME"]) + "' where BSNO='" + bsno + "' ");
//db.ExecuteNonQuery(cmdUpdate, tran);
//放单通知
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.REMARK = REASON;
log.ACTNAME = "特殊放单审核完成";
SaveLog(log, USERID);
//
UnKDGIDList.Add(_bill.GID);//此处为特放申请单头表的GID
}
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
if (UnKDGIDList != null && UnKDGIDList.Count > 0) {
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sshowname = T_ALL_DA.GetSHOWNAME(USERID);
UnKD_GID(UnKDGIDList, USERID, sshowname);
}
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SP_AuditBack ( List<MsOp_BLISSUEListmb> _List, string USERID, string REASON ) //
{
var WorkFlowName = "MsOp_BLISSUE_SP";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, _bill.GID, USERID,REASON);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set BLSTATUS='驳回提交',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单申请 驳回";
log.REMARK = REASON;
SaveLog(log, USERID);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#region 特放复核
public static DBResult MNGSP_Audit(List<MsOp_BLISSUEListmb> _List, string USERID) //申请签入_驳回
{
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set MNGBLSTATUS='审核通过' where GID=@GID ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
//var cmdUpdate = db.GetSqlStringCommand(
// @"if (select bsno from op_blissue where bsno='" + _bill.BSNO + "') is null insert into op_close values(newid(),'" + bsno + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
// + "','" + Convert.ToString(Session["SHOWNAME"]) + "',null,'') else update op_close set BSCLOSETIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
// + "',BSCLOSEOP='" + Convert.ToString(Session["SHOWNAME"]) + "' where BSNO='" + bsno + "' ");
//db.ExecuteNonQuery(cmdUpdate, tran);
//放单通知
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单复核完成";
SaveLog(log, USERID);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult MNGSP_AuditBack(List<MsOp_BLISSUEListmb> _List, string USERID) //
{
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissuelist set MNGBLSTATUS='驳回提交' where GID=@GID ");
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
var log = new WorkLogmb();
log.BSNO = _bill.GID;
log.ACTNAME = "特殊放单复核驳回";
SaveLog(log, USERID);
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#region 申请正常放单
public static DBResult SQFD ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签出
{
var WorkFlowName = "MsOp_BLISSUE_FD";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID,_bill.MBLNO,_bill.GID,"");
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='申请放单',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS ='已签入' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQFD_back ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签出_撤回
{
var WorkFlowName = "MsOp_BLISSUE_FD";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='已签入',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS ='申请放单' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQFD_Auditback ( List<MsOp_BLISSUEmb> _List, string USERID, string REASON ) //申请签出_驳回
{
var WorkFlowName = "MsOp_BLISSUE_FD";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, _bill.GID, USERID, REASON);
if (WorkResult.Success == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='已签入',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS in ('申请放单','准许放单') ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
public static DBResult SQFD_Audit ( List<MsOp_BLISSUEmb> _List, string USERID ) //申请签出_通过
{
var WorkFlowName = "MsOp_BLISSUE_FD";
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var _bill in _List)
{
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, _bill.GID, USERID,_bill.MBLNO);
if (WorkResult.Success == true)
{
if (WorkResult.islast == true)
{
var cmdupdate = db.GetSqlStringCommand("update op_blissue set BLSTATUS='准许放单',OPTIME=getdate(),OPNAME=(select showname from [USER] where gid='" + USERID + "') where GID=@GID and BLSTATUS ='申请放单' ");
cmdupdate.Parameters.Clear();
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
}
}
else
{
result.Success = false;
result.Message = "提交错误!";
}
}
result = new DBResult();
result.Success = true;
result.Message = "提交成功";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "提交错误,请重试或联系系统管理员";
//return result;
}
}
return result;
}
#endregion
#endregion
public static ContentResult SaveLog ( WorkLogmb data,string USERID )
{
var headData = data;//JsonConvert.Deserialize<WorkLogmb>(data);
headData.GID = System.Guid.NewGuid().ToString();
headData.OP = USERID ;
headData.OPDATE = System.DateTime.Now.ToString();
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
var result = new DBResult();
var modb = new ModelObjectRepository();
result = modb.Save(headData);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message//,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 获取提单的放单相关信息
static public List<BLINFOmb> GetBLINFO(string BSNO)
{ //合同信息/商品信息
var strSql = GetBLINFOStr(BSNO);
return SetBLINFO(strSql);
}
static public StringBuilder GetBLINFOStr(string BSNO)
{ //合同信息/商品信息
var BLISSUENOSHEN = MsSysParamSetDAL.GetData("PARAMNAME='BLISSUENOSHEN'");
BSNO = BSNO.Replace("''", "'");
var strSql = new StringBuilder();
strSql.Append(" select vb.CUSTOMERNAME,(select ISSP from info_client where shortname=vb.CUSTOMERNAME) ISSP ");
strSql.Append(" ,C.ACCTYPE ,(g.RMBDR-g.STLRMBDR) RMBNODR,(g.USDDR-g.STLUSDDR) USDNODR,(g.TTLDR-g.STLTTLDR)TTLNODR , ");
strSql.Append(" isnull(dbo.trimdate(vb.stldate),'') stldate , CN.RMBNODR RMBNODR_All,CN.USDNODR USDNODR_All,CN.TTLNODR TTLNODR_All ");
strSql.Append(" , CN.ZLRMBNODR ZLRMBNODR_All,CN.ZLUSDNODR ZLUSDNODR_All,CN.ZLTTLNODR ZLTTLNODR_All ");
strSql.Append(" ,ISNULL(C.ALLOWAMOUNT,0) ALLOWAMOUNT,'' WFDHT,vb.SALE,vb.OPLBNAME,vb.ETD ");
strSql.Append(" from v_OP_bs VB ");
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" left join v_op_gain_sum_shen g on g.BSNO=vb.bsno left join V_Client_ACCDATE C ON (C.SHORTNAME=VB.CUSTOMERNAME and vb.ETD between c.BGNDATE and c.ENDDATE) ");
strSql.Append(" left join V_CUSTOMER_NODR_shen CN ON (CN.CUSTOMERNAME=VB.CUSTOMERNAME)");
}
else
{
strSql.Append(" left join v_op_gain_sum g on g.BSNO=vb.bsno left join V_Client_ACCDATE C ON (C.SHORTNAME=VB.CUSTOMERNAME and vb.ETD between c.BGNDATE and c.ENDDATE) ");
strSql.Append(" left join V_CUSTOMER_NODR CN ON (CN.CUSTOMERNAME=VB.CUSTOMERNAME)");
}
if (!string.IsNullOrEmpty(BSNO))
{
// strSql.Append(" where vb.MBLNO='" + MBLNO +"'");//str.Replace("b","**");
if (!string.IsNullOrEmpty(BSNO))
{
strSql.Append(" where vb.BSNO in( " + BSNO + " )");//str.Replace("b","**");
}
}
return strSql;
}
private static List<BLINFOmb> SetBLINFO(StringBuilder strSql)
{
var headList = new List<BLINFOmb>();
//var _nomsg = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
BLINFOmb data = new BLINFOmb();
while (reader.Read())
{
#region Set DB data to Object
#region 结费类型
data. = "";
if (reader["ISSP"] != DBNull.Value)
{
if (Convert.ToBoolean(reader["ISSP"]))
{
data. = "注意:该客户是特批放单客户!" + "\n";
}
}
if (Convert.ToString(reader["ACCTYPE"]).Trim() == "")
{
data. = data. + "客户结费类型为:现结买单";
}
else
{
data. = data. + "客户结费类型为:" + Convert.ToString(reader["ACCTYPE"]);
}
if (Convert.ToString(reader["ACCTYPE"]) == "约定天数")
{
//data.结费类型 = data.结费类型 + Convert.ToString(reader["stldays"]) + "天 ";
//string CUSTOMERNAME, string OPLBNAME, string BUSDATE, string SALE
var CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
var OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
var BUSDATE = Convert.ToString(reader["ETD"]);
var SALE = Convert.ToString(reader["SALE"]);
data. = data. + MsInfoClientDAL.GetSTLDAYS(CUSTOMERNAME, OPLBNAME, BUSDATE, SALE).STLDAYS + "天 ";
}
data. = data. + ",结算日期为 " + Convert.ToString(reader["stldate"]) + "";
data.STLDATE = Convert.ToString(reader["stldate"]);
#endregion
#region 该业务是否 欠费超期
//var TTLNODR=0M;
if (reader["TTLNODR"] != DBNull.Value)
data.TTLNODR = data.TTLNODR + Convert.ToDecimal(reader["TTLNODR"]);
//var RMBNODR=0M;
if (reader["RMBNODR"] != DBNull.Value)
data.RMBNODR = data.RMBNODR + Convert.ToDecimal(reader["RMBNODR"]);
//var USDNODR=0M;
if (reader["USDNODR"] != DBNull.Value)
data.USDNODR = data.USDNODR + Convert.ToDecimal(reader["USDNODR"]);
#endregion
#region 累计欠费
data.TTLNODR_All = 0M;
if (reader["TTLNODR_All"] != DBNull.Value)
data.TTLNODR_All = Convert.ToDecimal(reader["TTLNODR_All"]);
data.RMBNODR_All = 0M;
if (reader["RMBNODR_All"] != DBNull.Value)
data.RMBNODR_All = Convert.ToDecimal(reader["RMBNODR_All"]);
data.USDNODR_All = 0M;
if (reader["USDNODR_All"] != DBNull.Value)
data.USDNODR_All = Convert.ToDecimal(reader["USDNODR_All"]);
data.ZLTTLNODR_All = 0M;
if (reader["ZLTTLNODR_All"] != DBNull.Value)
data.ZLTTLNODR_All = Convert.ToDecimal(reader["ZLTTLNODR_All"]);
data.ZLRMBNODR_All = 0M;
if (reader["ZLRMBNODR_All"] != DBNull.Value)
data.ZLRMBNODR_All = Convert.ToDecimal(reader["ZLRMBNODR_All"]);
data.ZLUSDNODR_All = 0M;
if (reader["ZLUSDNODR_All"] != DBNull.Value)
data.ZLUSDNODR_All = Convert.ToDecimal(reader["ZLUSDNODR_All"]);
var Rate_All = 0M;
if (data.TTLNODR_All > 0 && data.USDNODR_All > 0)
{
Rate_All = (data.TTLNODR_All - data.RMBNODR_All) / data.USDNODR_All;
}
var _Rate_All = Rate_All.ToString("#0.0000");
data. = data.InfoText + "累计未结算费用:"
+ "USD" + Convert.ToString(data.USDNODR_All)
+ " RMB" + Convert.ToString(data.RMBNODR_All)
+ ",合计" + Convert.ToString(data.TTLNODR_All);
var ALLOWAMOUNT = 0M;
if (reader["ALLOWAMOUNT"] != DBNull.Value)
ALLOWAMOUNT = Convert.ToDecimal(reader["ALLOWAMOUNT"]);
data. = "信用额度:" + ALLOWAMOUNT;
if (ALLOWAMOUNT > data.TTLNODR_All)
{
data.IS = "no";
data. = data. + " 额度范围内";
}
else
{
if (data.TTLNODR_All != 0)
{
data.IS = "yes";
data. = data. + " <已超额>";
}
}
#endregion
#endregion
//headList.Add(data);
}
reader.Close();
#region Set DB data to Object
#region 该业务欠费是否超期
var Rate = 0M;
if (data.TTLNODR > 0 && data.USDNODR > 0)
{
Rate = (data.TTLNODR - data.RMBNODR) / data.USDNODR;
}
var _Rate = Rate.ToString("#0.0000");
data. = "未结算费用:"
+ "USD" + Convert.ToString(data.USDNODR)
+ " RMB" + Convert.ToString(data.RMBNODR)
+ ",合计" + Convert.ToString(data.TTLNODR);
if (Rate != 0M)
{
data. = data. + "(" + _Rate + ")";
}
data. = "";
if (data.ZLTTLNODR_All != 0)
{
data. = "超期欠费:"
+ "USD" + Convert.ToString(data.ZLUSDNODR_All)
+ " RMB" + Convert.ToString(data.ZLRMBNODR_All)
+ ",合计" + Convert.ToString(data.ZLTTLNODR_All);
}
//data.欠费超期 = data.欠费超期 + "\n";
//data.欠费超期 = data.欠费超期 + "付款日期:" + data.STLDATE;
if (data.STLDATE != "")
{
if (System.DateTime.Now >= Convert.ToDateTime(data.STLDATE) && data.TTLNODR > 0)
{
data.IS = "yes";
data. = data. + " <span style=\"colorred\">已欠费超期</span>";
}
else
{
data.IS = "no";
}
}
else
{
if (data.TTLNODR != 0)
data.IS = "yes";
data. = data. + " 结算时间未知 ";
}
#endregion
data.InfoText = data. + "\n";
data.InfoText = data.InfoText + data. + "\n";
data.InfoText = data.InfoText + data. + "\n";
data.InfoText = data.InfoText + data. + "\n";
#endregion
headList.Add(data);
}
return headList;
}
static public List<BLINFOmb> GetBLINFO2 ( string BSNO )
{ //合同信息/商品信息
var BLISSUENOSHEN = MsSysParamSetDAL.GetData("PARAMNAME='BLISSUENOSHEN'");
var strSql = new StringBuilder();
strSql.Append(" select vb.CUSTOMERNAME,(select ISSP from info_client where shortname=vb.CUSTOMERNAME) ISSP ");
strSql.Append(" ,C.ACCTYPE ,(g.RMBDR-g.STLRMBDR) RMBNODR,(g.USDDR-g.STLUSDDR) USDNODR,(g.TTLDR-g.STLTTLDR)TTLNODR , ");
strSql.Append(" isnull(dbo.trimdate(vb.stldate),'') stldate ");
strSql.Append(" ,ISNULL(C.ALLOWAMOUNT,0) ALLOWAMOUNT,'' WFDHT,vb.SALE,vb.OPLBNAME,vb.ETD ");
strSql.Append(" from v_OP_bs VB ");
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" left join v_op_gain_sum_shen g on g.BSNO=vb.bsno left join V_Client_ACCDATE C ON (C.SHORTNAME=VB.CUSTOMERNAME and vb.ETD between c.BGNDATE and c.ENDDATE) ");
}
else strSql.Append(" left join v_op_gain_sum_ttl g on g.BSNO=vb.bsno left join V_Client_ACCDATE C ON (C.SHORTNAME=VB.CUSTOMERNAME and vb.ETD between c.BGNDATE and c.ENDDATE) ");
// strSql.Append(" left join V_CUSTOMER_NODR CN ON (CN.CUSTOMERNAME=VB.CUSTOMERNAME)");
if (!string.IsNullOrEmpty(BSNO))
{
strSql.Append(" where vb.BSNO in( " + BSNO + " )");//str.Replace("b","**");
}
return SetBLINFO2(strSql);
}
private static List<BLINFOmb> SetBLINFO2 ( StringBuilder strSql )
{
var headList = new List<BLINFOmb>();
//var _nomsg = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
BLINFOmb data = new BLINFOmb();
while (reader.Read())
{
#region Set DB data to Object
#region 结费类型
data. = "";
if (reader["ISSP"] != DBNull.Value)
{
if (Convert.ToBoolean(reader["ISSP"]))
{
data. = "注意:该客户是特批放单客户!" + "\n";
}
}
if (Convert.ToString(reader["ACCTYPE"]).Trim() == "")
{
data. = data. + "客户结费类型为:现结买单";
}
else
{
data. = data. + "客户结费类型为:" + Convert.ToString(reader["ACCTYPE"]);
}
if (Convert.ToString(reader["ACCTYPE"]) == "约定天数")
{
//data.结费类型 = data.结费类型 + Convert.ToString(reader["stldays"]) + "天 ";
//string CUSTOMERNAME, string OPLBNAME, string BUSDATE, string SALE
var CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
var OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
var BUSDATE = Convert.ToString(reader["ETD"]);
var SALE = Convert.ToString(reader["SALE"]);
data. = data. + MsInfoClientDAL.GetSTLDAYS(CUSTOMERNAME, OPLBNAME, BUSDATE, SALE).STLDAYS + "天 ";
}
data. = data. + ",结算日期为 " + Convert.ToString(reader["stldate"]) + "";
data.STLDATE = Convert.ToString(reader["stldate"]);
#endregion
#region 该业务是否 欠费超期
//var TTLNODR=0M;
if (reader["TTLNODR"] != DBNull.Value)
data.TTLNODR = data.TTLNODR + Convert.ToDecimal(reader["TTLNODR"]);
//var RMBNODR=0M;
if (reader["RMBNODR"] != DBNull.Value)
data.RMBNODR = data.RMBNODR + Convert.ToDecimal(reader["RMBNODR"]);
//var USDNODR=0M;
if (reader["USDNODR"] != DBNull.Value)
data.USDNODR = data.USDNODR + Convert.ToDecimal(reader["USDNODR"]);
#endregion
#region 累计欠费
//data.TTLNODR_All = 0M;
//if (reader["TTLNODR_All"] != DBNull.Value)
// data.TTLNODR_All = Convert.ToDecimal(reader["TTLNODR_All"]);
//data.RMBNODR_All = 0M;
//if (reader["RMBNODR_All"] != DBNull.Value)
// data.RMBNODR_All = Convert.ToDecimal(reader["RMBNODR_All"]);
//data.USDNODR_All = 0M;
//if (reader["USDNODR_All"] != DBNull.Value)
// data.USDNODR_All = Convert.ToDecimal(reader["USDNODR_All"]);
//data.ZLTTLNODR_All = 0M;
//if (reader["ZLTTLNODR_All"] != DBNull.Value)
// data.ZLTTLNODR_All = Convert.ToDecimal(reader["ZLTTLNODR_All"]);
//data.ZLRMBNODR_All = 0M;
//if (reader["ZLRMBNODR_All"] != DBNull.Value)
// data.ZLRMBNODR_All = Convert.ToDecimal(reader["ZLRMBNODR_All"]);
//data.ZLUSDNODR_All = 0M;
//if (reader["ZLUSDNODR_All"] != DBNull.Value)
// data.ZLUSDNODR_All = Convert.ToDecimal(reader["ZLUSDNODR_All"]);
//var Rate_All = 0M;
//if (data.TTLNODR_All > 0 && data.USDNODR_All > 0)
//{
// Rate_All = (data.TTLNODR_All - data.RMBNODR_All) / data.USDNODR_All;
//}
//var _Rate_All = Rate_All.ToString("#0.0000");
//data.累计欠费 = data.InfoText + "累计未结算费用:"
// + "USD" + Convert.ToString(data.USDNODR_All)
// + " RMB" + Convert.ToString(data.RMBNODR_All)
// + ",合计" + Convert.ToString(data.TTLNODR_All) ;
var ALLOWAMOUNT = 0M;
if (reader["ALLOWAMOUNT"] != DBNull.Value)
ALLOWAMOUNT = Convert.ToDecimal(reader["ALLOWAMOUNT"]);
data. = "信用额度:" + ALLOWAMOUNT;
if (ALLOWAMOUNT > data.TTLNODR_All)
{
data.IS = "no";
data. = data. + " 额度范围内";
}
else
{
if (data.TTLNODR_All != 0)
{
data.IS = "yes";
data. = data. + " <已超额>";
}
}
#endregion
#region 显示目前已有明细箱号且未提单签出的业务的箱数
var _CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
var = (_CUSTOMERNAME);
data. = "未放单业务数:" + .ToString();
//if (reader["NUMTYPPE"].ToString() == "提单签出")
//{
//}
//if (reader["NUMTYPPE"].ToString() == "未签出")
//{
//}
#endregion
#endregion
//headList.Add(data);
}
reader.Close();
#region Set DB data to Object
#region 该业务欠费是否超期
var Rate = 0M;
if (data.TTLNODR > 0 && data.USDNODR > 0)
{
Rate = (data.TTLNODR - data.RMBNODR) / data.USDNODR;
}
var _Rate = Rate.ToString("#0.0000");
data. = "未结算费用:"
+ "USD" + Convert.ToString(data.USDNODR)
+ " RMB" + Convert.ToString(data.RMBNODR)
+ ",合计" + Convert.ToString(data.TTLNODR);
if (Rate != 0M)
{
data. = data. + "(" + _Rate + ")";
}
data. = "";
if (data.ZLTTLNODR_All != 0) {
data. = "超期欠费:"
+ "USD" + Convert.ToString(data.ZLUSDNODR_All)
+ " RMB" + Convert.ToString(data.ZLRMBNODR_All)
+ ",合计" + Convert.ToString(data.ZLTTLNODR_All);
}
//data.欠费超期 = data.欠费超期 + "\n";
//data.欠费超期 = data.欠费超期 + "付款日期:" + data.STLDATE;
if (data.STLDATE != "")
{
if (System.DateTime.Now >= Convert.ToDateTime(data.STLDATE) && data.TTLNODR > 0)
{
data.IS = "yes";
data. = data. + " <span style=\"colorred\">已欠费超期</span>";
}
else {
data.IS = "no";
}
}
else
{
if (data.TTLNODR!=0)
data.IS = "yes";
data. = data. + " 结算时间未知 ";
}
#endregion
data.InfoText = data. + "\r\n";
data.InfoText = data.InfoText + data. + "\r\n";
data.InfoText = data.InfoText + data. + "\r\n";
data.InfoText = data.InfoText + data. + "\r\n";
data.InfoText = data.InfoText + data. + "\r\n";
#endregion
headList.Add(data);
}
return headList;
}
static public List<BLINFOLIST> GetBLINFOLIST(string CUSTNAME, string SALE)
{ //合同信息/商品信息
var BLISSUENOSHEN = MsSysParamSetDAL.GetData("PARAMNAME='BLISSUENOSHEN'");
var searchStr = new StringBuilder();
searchStr.Append(" ,SUM(RMBNODR) RMBNODR,SUM(USDNODR) USDNODR,SUM(TTLNODR) TTLNODR");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN RMBNODR ELSE 0 END) CRMBNODR");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN USDNODR ELSE 0 END) CUSDNODR");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN TTLNODR ELSE 0 END) CTTLNODR ");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS='提单签出' then RMBNODR else 0 END) RMBNODR_YQC");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS='提单签出' then USDNODR else 0 END) USDNODR_YQC");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS='提单签出' then TTLNODR else 0 END) TTLNODR_YQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS='提单签出' then RMBNODR else 0 END ELSE 0 END) CRMBNODR_YQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS='提单签出' then USDNODR else 0 END ELSE 0 END) CUSDNODR_YQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS='提单签出' then TTLNODR else 0 END ELSE 0 END) CTTLNODR_YQC");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS<>'提单签出' then RMBNODR else 0 END) RMBNODR_WQC");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS<>'提单签出' then USDNODR else 0 END) USDNODR_WQC");
searchStr.Append(" ,sum(CASE WHEN BLISSUESTATUS<>'提单签出' then TTLNODR else 0 END) TTLNODR_WQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS<>'提单签出' then RMBNODR else 0 END ELSE 0 END) CRMBNODR_WQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS<>'提单签出' then USDNODR else 0 END ELSE 0 END) CUSDNODR_WQC");
searchStr.Append(" ,SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN CASE WHEN BLISSUESTATUS<>'提单签出' then TTLNODR else 0 END ELSE 0 END) CTTLNODR_WQC");
var strSql = new StringBuilder();
strSql.Append(" SELECT '委托单位:'+CUSTOMERNAME+'('+SALE+')' INFOTEXT ");
strSql.Append(searchStr);
//strSql.Append(",SUM(RMBNODR) RMBNODR,SUM(USDNODR) USDNODR,SUM(TTLNODR) TTLNODR ");
//strSql.Append(",SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN RMBNODR ELSE 0 END) CRMBNODR,");
//strSql.Append("SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN USDNODR ELSE 0 END) CUSDNODR,");
//strSql.Append("SUM(CASE WHEN (DATEDIFF([day],ISNULL(STLDATE,ETD),GETDATE())>0) THEN TTLNODR ELSE 0 END) CTTLNODR");
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" from v_op_bill_gain_shen WHERE CUSTOMERNAME='" + CUSTNAME + "' and SALE='" + SALE + "'");
}
else strSql.Append(" from v_op_bill_gain WHERE CUSTOMERNAME='" + CUSTNAME + "' and SALE='" + SALE + "'");
strSql.Append(" GROUP BY CUSTOMERNAME,SALE ");
strSql.Append(" UNION");
strSql.Append(" SELECT '委托单位:'+CUSTOMERNAME INFOTEXT");
strSql.Append(searchStr);
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" from v_op_bill_gain_shen WHERE CUSTOMERNAME='" + CUSTNAME + "' ");
} else
strSql.Append(" from v_op_bill_gain WHERE CUSTOMERNAME='" +CUSTNAME+ "' ");
strSql.Append(" GROUP BY CUSTOMERNAME ");
strSql.Append(" UNION");
strSql.Append(" SELECT '结算单位:'+CUSTNAME+'('+SALE+')' INFOTEXT ");
strSql.Append(searchStr);
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" from v_op_bill_cust_gain_shen WHERE CUSTNAME='" + CUSTNAME + "' and SALE='" + SALE + "'");
} else
strSql.Append(" from v_op_bill_cust_gain WHERE CUSTNAME='"+CUSTNAME+"' and SALE='"+SALE+"'");
strSql.Append(" GROUP BY CUSTNAME,SALE ");
strSql.Append(" UNION");
strSql.Append(" SELECT '结算单位:'+CUSTNAME INFOTEXT");
strSql.Append(searchStr);
if (BLISSUENOSHEN.PARAMVALUE == "1")
{
strSql.Append(" from v_op_bill_cust_gain_shen WHERE CUSTNAME='" + CUSTNAME + "'");
} else
strSql.Append(" from v_op_bill_cust_gain WHERE CUSTNAME='"+CUSTNAME+"'");
strSql.Append(" GROUP BY CUSTNAME ");
return SetBLINFOLIST(strSql);
}
private static List<BLINFOLIST> SetBLINFOLIST(StringBuilder strSql)
{
var headList = new List<BLINFOLIST>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
BLINFOLIST data = new BLINFOLIST();
#region Set DB data to Object
data.INFOTEXT = Convert.ToString(reader["INFOTEXT"]);
data.RMBNODR = Convert.ToString(reader["RMBNODR"]) + "(" + Convert.ToString(reader["CRMBNODR"]) + ")";
data.USDNODR = Convert.ToString(reader["USDNODR"]) + "(" + Convert.ToString(reader["CUSDNODR"]) + ")";
data.TTLNODR = Convert.ToString(reader["TTLNODR"]) + "(" + Convert.ToString(reader["CTTLNODR"]) + ")";
data.RMBNODR_YQC = Convert.ToString(reader["RMBNODR_YQC"]) + "(" + Convert.ToString(reader["CRMBNODR_YQC"]) + ")";
data.USDNODR_YQC = Convert.ToString(reader["USDNODR_YQC"]) + "(" + Convert.ToString(reader["CUSDNODR_YQC"]) + ")";
data.TTLNODR_YQC = Convert.ToString(reader["TTLNODR_YQC"]) + "(" + Convert.ToString(reader["CTTLNODR_YQC"]) + ")";
data.RMBNODR_WQC = Convert.ToString(reader["RMBNODR_WQC"]) + "(" + Convert.ToString(reader["CRMBNODR_WQC"]) + ")";
data.USDNODR_WQC = Convert.ToString(reader["USDNODR_WQC"]) + "(" + Convert.ToString(reader["CUSDNODR_WQC"]) + ")";
data.TTLNODR_WQC = Convert.ToString(reader["TTLNODR_WQC"]) + "(" + Convert.ToString(reader["CTTLNODR_WQC"]) + ")";
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 判断该业务能否执行提单签出 如果是 则修改状态至 放单通知/已放货
/// <summary>
/// 判断该业务能否执行提单签出 如果是 则修改状态至 放单通知/已放货
/// 不包括特放审批中的部分
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public static DBResult CanCheckOut(string BSNO,string USERNAME) {
//20230207 增加判断 该单是否能够签出
var result = new DBResult();
result.OK();
try
{
//在海运出口列表的其他操作下的放单通知中参数为一个单独的bsno前后加单引号
//在财务管理的特殊放单列表的添加明细时,参数为 'bsno1','bsno2'
var _recount = 0;
var headList = GetDataList(" B.BSNO in (" + BSNO + ") ", 0, 999, out _recount);
if (headList.Count == 0)
{
result.SetErrorInfo("没有可以放单或放货的业务");
return result;
}
//0 如果所有BSNO对应的特殊放单申请都已被审核通过 则直接返回true
result = (BSNO);
if (result.Success) return result;
//20230525 增加判断是否有箱号
var cdc = new CommonDataContext();
var bsnoList = BSNO.Replace("'", "").Split(',').ToList();
var bodylist = cdc.OP_CTN.Where(x => bsnoList.Contains(x.BSNO)).ToList();
if (bodylist.Exists(x => x.CNTRNO == null || x.CNTRNO.Trim() == ""))
{
result.SetErrorInfo("存在无箱号的业务,不允许执行放单操作");
return result;
}
//如果有财务扣单的 直接报错返回
result = ISKDWithCW(BSNO);
if (result.Success)
{
result.Success = false;
return result;
}
//20230407 使用新的分月结票结判断流程
//var bsnoList = BSNO.Replace("'", "").Split(',').ToList();
foreach (var head in headList)
{
var = false;
//1 判断该业务中该客户属于何种账期类型
var ACCTYPE = MsInfoClientDAL.GetCustAcctype(head.BSNO);
if (ACCTYPE == "票结")
{
//走票结流程
//1 看是否扣单
result = (head);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
var = ISKDWithCW("'" + head.BSNO + "'");
if (.Success)
{
result.SetErrorInfo($"已扣货,该客户无欠费,需联系财务解除扣单。请点否然后联系财务。");
return result;
}
}
//20230601 改为先看本票是否欠费
//3 本票业务是否欠费
result = (head);
if (!result.Success) return result;//出错返回报错
if ((bool)result.Data == true)
{
//本票有欠费 返回错误 走保函
result.SetErrorInfo(result.Message);
//result.Success = false;
return result;
}
//2 看该客户目前是否欠费 如无直接可放
result = _(head);
if (result.Success == false)
{
result.OK();
return result;
}
//本票无欠费 继续走逻辑
//如果是“最后一单” 即:这票业务是 未签出的业务当中ATD(ETD)最晚的
//则 只要客户有欠费 即不允许提单签出
result = (headList);
if (!result.Success) return result;
//如果是最后一票
if ((bool)result.Data == true)
{ //看是否存在欠费:
var msg = result.Message;
result = (head);
if (result.Success == true)
{
result.SetErrorInfo($"{msg},且存在欠费[{result.Message}],是否确认保函放货?");
return result;
}
}
result.OK();
return result;
}
else
{
//月结流程
//1客户是否欠费
result = (head);
if (result.Success == false)
{//无欠费 直接可出
//0 看该业务是否扣单 如果处于扣单状态 将其解除
result = (head);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
var kdlist = new List<MsOp_BLISSUEmb>{
head
};
MsOp_BLISSUEDAL.KD(kdlist, USERNAME, USERNAME);
}
result.OK();
return result;
}
//2 如果存在超期的欠费 则不允许提单签出
result = (head, BSNO);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
//result.SetErrorInfo(result.Message);
result.Success = false;
return result;
}
//无超期欠费 看是否最后一票
result = (headList);
if (!result.Success) return result;
//如果是最后一票
if ((bool)result.Data == true)
{
//result.SetErrorInfo("");
result.Success = false;
return result;
}
else
{
//0 看该业务是否扣单 如果处于扣单状态 将其解除
result = (head);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
var kdlist = new List<MsOp_BLISSUEmb>{
head
};
MsOp_BLISSUEDAL.KD(kdlist, USERNAME, USERNAME);
}
}
result = (head);
if (!result.Success) return result;//出错返回报错
if ((bool)result.Data == true)
{
//本票有欠费 看欠费是否超限
var helper = new InfoClientLimitHelper(head.BSNO, USERNAME);
result = helper.CanCheckOut();
if (!result.Success)
{
return result;
}
else
{
}
}
result.OK();
return result;
}
//20231226 增加 判断该委托单位,是否【本票业务欠费】+【当前已放单欠费】>欠费放单总额度
//以下为原第二版流程
/*
//1 如果是“最后一单” 即:除了这票业务之外,其他业务都已“提单签出”
//则 只要客户有欠费 即不允许提单签出
result = 是否最后一票业务(headList);
if (!result.Success) return result;
//如果是最后一票
if ((bool)result.Data == true)
{ //看是否存在欠费:
var msg = result.Message;
result = 是否存在欠费(headList);
if (result.Success == true)
{
result.SetErrorInfo($"{msg},且存在欠费[{result.Message}],是否确认保函放货?");
return result;
}
}
//2 如果存在超期的欠费 则不允许提单签出
result = 是否存在超期的欠费(headList, BSNO);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
result.SetErrorInfo(result.Message);
//result.Success = false;
return result;
}
//3 本票业务是否欠费
result = 本票是否欠费(headList);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
result.SetErrorInfo(result.Message);
//result.Success = false;
return result;
}
//4 本票是否被扣货
result = 本票是否被扣货(headList);
if (!result.Success) return result;
if ((bool)result.Data == true)
{
//20230320 如果客户不欠费 用另一个提示
var 欠费result = 是否存在欠费(headList);
if (result.Success != true)
{
result.SetErrorInfo($"已扣货,该客户无欠费,需联系财务解除扣单。请点否然后联系财务。");
return result;
}
result.SetErrorInfo(result.Message);
//result.Success = false;
return result;
}*/
}
}catch(Exception e) {
result.SetErrorInfo(e.Message);
}
return result;
}
/// <summary>
/// 判断该业务能否执行提单签出 用于对操作给出提示
/// 包括特放审批中的部分
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public static DBResult CanCheckOut_Start(string BSNO,string USERNAME)
{
//20230207 增加判断 该单是否能够签出
var result = CanCheckOut(BSNO, USERNAME);
if (!result.Success)
{
return result;
}
var _result = (BSNO);
if (_result.Success)
{
result.SetErrorInfo(_result.Message);
return result;
}
else {
}
return result;
}
/// <summary>
/// 判断该业务能否执行[取消提单签出]
/// </summary>
/// <param name="BSNO"></param>
/// <param name="USERNAME"></param>
/// <returns></returns>
public static DBResult CanUNFDTZ(string BSNO, string USERNAME)
{
//20230207 增加判断 该单是否能够签出
var result = new DBResult();
result.OK();
var _recount = 0;
var headList = GetDataList(" B.BSNO in (" + BSNO + ") ", 0, 999, out _recount);
if (headList != null && headList.Count > 0) {
foreach (var item in headList) {
if (!BLSTATUSTYPE.CanUNFDTZ(item.BLSTATUS)) {
result.SetErrorInfo($"{item.MBLNO}业务状态【{item.BLSTATUS}】,不能取消放单通知");
return result;
}
}
}
return result;
}
/// <summary>
/// GID是特殊放单申请op_blissueList的GID形如R2300727
/// 来自
/// </summary>
/// <param name="GID"></param>
/// <returns></returns>CanCheckOut_SP
public static DBResult CanCheckOut_SP(string GID,string USERNAME)
{
var result = new DBResult();
var cdc = new CommonDataContext();
var BSNOList = cdc.op_blissuelist_Detail.Where(x => x.LINKGID == GID).Select(s => s.BSNO).ToList();
if (BSNOList.Count > 0) {
var BSNOStr = "'" + String.Join("','", BSNOList)+"'";
result = CanCheckOut(BSNOStr, USERNAME);
}
if (!result.Success)
{
return result;
}
else {
}
return result;
}
/// <summary>
/// 判断指定的提单信息
/// 不管此次传入的是几条业务,如果他们看作一票业务的话,是否除此之外均已提单签出。
/// 实质是:如果【这些业务审核通过之后,就没有其他未提单签出的业务了】
/// 20230227增加 如果有还要判断headList这些业务是否为ATD最晚
/// 如果是 返回 success=truedata=true
/// 如果否 返回 success=truedata=false
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
private static DBResult (List<MsOp_BLISSUEmb> headList)
{
var result = new DBResult();
result.OK();
try
{
//判断标准 该客户的全部其他业务 是否存在 BLISSUESTATUS<>'提单签出'且<>'已放货' 且其下属明细中有箱号长度11位的箱号 的
var recordcount = 0;
var bsnostr = "'" + string.Join("','", headList.Select(s => s.BSNO)) + "'";
var List = GetDataList($" b.CUSTOMERNAME='{headList[0].CUSTOMERNAME}' and b.BLISSUESTATUS<>'提单签出' and b.BLISSUESTATUS<>'已放货' and exists(select 1 from op_ctn where BSNO=b.BSNO and len(CNTRNO)=11) and b.BSNO not in({bsnostr})", 0, 9, out recordcount);
if (recordcount > 0)
{
//result.OK("", false);
//判断这个或者这些业务当中 是否有其下属明细中有箱号长度11位的箱号 的 且 ETD=【该客户所有业务中其下属明细中有箱号长度11位的箱号的ETD最晚的】
//如果有 也认为符合该条件的业务为【最后一票业务】
var 11ETD = GetDataList($" b.CUSTOMERNAME='{headList[0].CUSTOMERNAME}' and b.BLISSUESTATUS<>'提单签出' and b.BLISSUESTATUS<>'已放货' and exists(select 1 from op_ctn where BSNO=b.BSNO and len(CNTRNO)=11) ", 0, 9, out recordcount);
11ETD = 11ETD.OrderByDescending(o => o.ETD).ToList();
//var LastEtd = 该客户所有业务中未放货未提单签出且具备箱号长度11位的箱号当中ETD最大的业务.Max(s=> Convert.ToDateTime(s.ETD));
var LastEtd = 11ETD[0].ETD;
if (headList.Exists(e => e.ETD == LastEtd))
{
var = headList.Where(x => x.ETD == LastEtd).ToList();
//有其他未签出的 且用于判断的这些业务是ETD最晚的 是最后一票
var custnoStr = "单号[" + string.Join(",", .Select(s => s.CUSTNO).Distinct().ToArray()) + "]ATD:" + LastEtd + ",此后无单";
result.OK($"最后开船的{headList.Count}票," + custnoStr + "", true);
}
else
{
//有其他未签出的 但用于判断的这些业务不是ETD最晚的 不是最后一票
result.OK("", false);
}
}
else
{
//没有其他未签出的业务了 是最后一票
result.OK($"警示!!!该客户仅剩此{headList.Count}票", true);
}
}
catch (Exception e) {
result.SetErrorInfo(e.Message);
}
return result;
}
/// <summary>
/// 判断是否欠费,如是 返回success=true data=欠款金额usd;
/// 如否 返回success=false data=null;
/// </summary>
/// <param name="headList"></param>
/// <returns></returns>
private static DBResult (MsOp_BLISSUEmb head)
{
var result = new DBResult();
result.OK();
try
{
var cdc = new CommonDataContext();
var _customername = head.CUSTOMERNAME;
var FeeList = cdc.ch_fee.Where(x => x.CUSTOMERNAME == _customername && x.SETTLEMENT < x.AMOUNT && x.FEETYPE==1 ).ToList();
if (FeeList != null && FeeList.Count > 0)
{
//存在欠费 则success=truedata返回true
//result.SetErrorInfo(欠费文字(欠费FeeList));
result.OK((FeeList), true);
}
else
{
//不存在欠费 则success=truedata返回false
result.SetErrorInfo("");
}
}
catch (Exception e) {
result.SetErrorInfo(e.Message);
return result;
}
return result;
}
private static DBResult _(MsOp_BLISSUEmb head)
{
var result = new DBResult();
result.OK();
try
{
var cdc = new CommonDataContext();
var _customername = head.CUSTOMERNAME;
var =DateTime.Now;
var = cdc.v_op_bs.Where(x => x.CUSTOMERNAME == _customername && x.ETD <= ).ToList();
var BSNO = .Select(s => s.BSNO).ToList();
var FeeList = cdc.ch_fee.Where(x => x.CUSTOMERNAME == _customername && BSNO.Contains(x.BSNO) && x.SETTLEMENT < x.AMOUNT && x.FEETYPE == 1).ToList();
if (FeeList != null && FeeList.Count > 0)
{
//存在欠费 则success=truedata返回true
//result.SetErrorInfo(欠费文字(欠费FeeList));
result.OK((FeeList), true);
}
else
{
//不存在欠费 则success=truedata返回false
result.SetErrorInfo("");
}
}
catch (Exception e)
{
result.SetErrorInfo(e.Message);
return result;
}
return result;
}
/// <summary>
/// 目前仅由月结账期调用
/// 存在超期欠费 则success=truedata返回true
/// 不存在超期欠费 则success=truedata返回false
/// </summary>
/// <param name="head"></param>
/// <param name="BSNO"></param>
/// <returns></returns>
private static DBResult (MsOp_BLISSUEmb head,string BSNO)
{
var result = new DBResult();
result.OK();
try
{
var cdc = new CommonDataContext();
var customername = head.CUSTOMERNAME;
var FeeList = cdc.ch_fee.Where(x => x.CUSTOMERNAME == customername && x.SETTLEMENT != x.AMOUNT && x.FEETYPE==1).ToList();
var bsnolist = FeeList.Select(s => s.BSNO).Distinct().ToList();
var List = cdc.v_op_bill.Where(x => bsnolist.Contains(x.BSNO) ).ToList();
if (List.Exists(x => x.STLDATE == null)) {
var errorrec = List.FirstOrDefault(x => x.STLDATE == null);
result.SetErrorInfo($"存在至少一票没有结算日期的业务[{errorrec.OPLBNAME + ":" + errorrec.CUSTNO}],无法判断欠费超期");
return result;
}
if (FeeList != null && FeeList.Count > 0)
{
if (List.Exists(x => x.STLDATE == null && x.BSNO == BSNO))
{
//存在超期欠费 则success=truedata返回true
var _bill = List.FirstOrDefault(x => x.STLDATE == null);
result.OK($"该业务还未取得费用应结日期【{_bill}】请尝试重新编辑开船日期ATD并保存。", true);
}
else
{
//超期的判断 月结 STLDATE + sys_para_set.paramname= BILLOVERTIME_MONTH
//票结 STLDATE + sys_para_set.paramname= BILLOVERTIME_BILL
//var 月结延迟天数 = Convert.ToInt32( MsSysParamSetDAL.GetSysParamValue("BILLOVERTIME_MONTH"));
//var 票结延迟日期 = Convert.ToInt32( MsSysParamSetDAL.GetSysParamValue("BILLOVERTIME_BILL"));
var = new List<v_op_bill_mb>();
var delaydays = 0;
foreach (var item in List){
//if (item.STLNAME == "现结买单")
//{
// delaydays = 票结延迟日期;
//}
//if (item.STLNAME == "月结")
//{
// delaydays = 月结延迟天数;
//}
if (DateTime.Now > (DateTime)item.STLDATE) //.AddDays(delaydays)
{
.Add(item);
}
}
if (.Count>0)
{
//存在超期欠费 则success=truedata返回true
var str = "[";
foreach (var item in ) {
if (str != "[") str += " <br/> ";
var list = FeeList.Where(x => x.BSNO == item.BSNO).ToList();
var Str = (list);
str += "单号 "+ item.CUSTNO.ToString()+",ATD "+ item.ETD + $" ,欠费[{该单欠款Str}]" ;
}
str += "] <br/> ,是否确认保函放货?";
result.OK($"警示!!!{单号str}", true);
}
else
{
//不存在超期欠费 则success=truedata返回false
result.OK("", false);
}
}
}
else
{
//不存在超期欠费 则success=truedata返回false
result.OK("", false);
}
}
catch (Exception e) {
result.SetErrorInfo(e.Message);
}
return result;
}
public static List<ch_fee_md> (string BSNO) {
var cdc = new CommonDataContext();
//var bsnoList = headList.Select(s => s.BSNO).ToList();
var FeeList = new List<ch_fee_md>();
FeeList = cdc.ch_fee.Where(x => BSNO == x.BSNO && x.SETTLEMENT != null && x.SETTLEMENT < x.AMOUNT && x.FEETYPE == 1).ToList();
var List = cdc.op_amend.Where(x => x.PARENTID == BSNO).ToList();
if (List != null && List.Count > 0)
{
var BSNO = List.Select(s => s.BSNO).ToList();
var List = cdc.ch_fee.Where(x => BSNO == x.BSNO && x.SETTLEMENT != null && x.SETTLEMENT < x.AMOUNT && x.FEETYPE == 1).ToList();
if (List != null && List.Count > 0)
{
FeeList.AddRange(List);
}
}
return FeeList;
}
public static List<ch_fee_md> (List<string> BSNOList)
{
var result = new List<ch_fee_md>();
if (BSNOList != null && BSNOList.Count > 0) {
foreach (var bsno in BSNOList) {
var _r = (bsno);
if (_r != null && _r.Count > 0) {
result.AddRange(_r);
}
}
}
return result;
}
/// <summary>
/// 存在欠费 则success=truedata返回true
/// 不存在欠费 则success=truedata返回false
/// </summary>
/// <param name="headList"></param>
/// <returns></returns>
private static DBResult (MsOp_BLISSUEmb head)
{
var result = new DBResult();
result.OK();
try
{
var cdc = new CommonDataContext();
//var bsnoList = headList.Select(s => s.BSNO).ToList();
var FeeList = (head.BSNO);
if (FeeList != null && FeeList.Count > 0)
{
//存在欠费 则success=truedata返回true
var Str = (FeeList);
result.OK("业务欠费,"+Str+",是否确认保函放货?", true);
}
else
{
//不存在欠费 则success=truedata返回false
result.OK("", false);
}
}
catch (Exception e)
{
result.SetErrorInfo(e.Message);
return result;
}
return result;
}
/// <summary>
/// 目前扣单 则success=truedata返回true
/// 目前未扣单 则success=truedata返回false
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
private static DBResult (MsOp_BLISSUEmb head)
{
var result = new DBResult();
result.OK();
try
{
var cdc = new CommonDataContext();
//var 欠费FeeList = cdc.ch_fee.Where(x => x.CUSTOMERNAME == _customername && x.SETTLEMENT < x.AMOUNT && x.FEETYPE == 1).ToList();
if ( head.BLSTATUS== BLSTATUSTYPE. )
{
//目前扣单 则success=truedata返回true
result.OK("此票被扣货,是否确认保函放货?", true);
}
else
{
//如果日志中扣单的条数多于解除扣单的条数 也认为属于扣单状态
//var condition = $" (BSNO='{head.GID}' or BSNO in(select linkgid from op_blissuelist_detail where BSNO='{head.BSNO}'))";
//var loglist = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null);
var loglist = (head);
var = loglist.Where(x=>x.ACTNAME==BLSTATUSTYPE.).ToList();
var = loglist.Where(x => x.ACTNAME == BLSTATUSTYPE.).ToList();
if (.Count > .Count) {
if ( == null || .Count == 0)
{
result.OK("此票被扣货,是否确认保函放货?", true);
return result;
}
else {
//20231019 看最晚的扣单 和最晚的解除 哪条最晚
var = Convert.ToDateTime(.Max(s => s.OPDATE));
var = Convert.ToDateTime(.Max(s => s.OPDATE));
if ( > )
{
//result.OK("", false);
}
else
{
result.OK("此票被扣货,是否确认保函放货?", true);
return result;
}
}
}
//目前未扣单 则success=truedata返回false
result.OK("", false);
}
}
catch (Exception e)
{
result.SetErrorInfo(e.Message);
return result;
}
return result;
}
private static List<WorkLogmb> (MsOp_BLISSUEmb head)
{
var condition = $" (BSNO='{head.GID}' or BSNO in(select linkgid from op_blissuelist_detail where BSNO='{head.BSNO}'))";
var loglist = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null);
return loglist;
}
public static string (List<ch_fee_md> feelist) {
var result = "";
var resultdic=new Dictionary<string, decimal>();
foreach (var fee in feelist.Where(x=>x.SETTLEMENT!=x.AMOUNT))
{
if (!resultdic.ContainsKey(fee.CURRENCY))
{
resultdic.Add(fee.CURRENCY, (decimal)fee.AMOUNT - (fee.SETTLEMENT == null ? 0 : (decimal)fee.SETTLEMENT));
}
else {
resultdic[fee.CURRENCY] += (decimal)fee.AMOUNT - (fee.SETTLEMENT == null ? 0 : (decimal)fee.SETTLEMENT);
}
}
if (resultdic.Count > 0) {
foreach (var item in resultdic) {
if (result != "") result += ";";
result += item.Key + ":" + item.Value.ToString();
}
}
return result;
}
/// <summary>
///
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public static DBResult (string BSNO)
{
var result = new DBResult();
var cdc = new CommonDataContext();
var bsnoList = BSNO.Replace("'", "").Split(',').ToList();
try
{
var List = cdc.v_op_blissuelist_Detail.Where(x => bsnoList.Contains(x.bsno));
var = true;
foreach (var bsno in bsnoList)
{
var = List.Where(x => x.bsno == bsno && x.BLSTATUS == "审核通过").ToList();
var = List.Where(x => x.bsno == bsno && x.BLSTATUS != "审核通过").ToList();
if ( != null && .Count > 0 && ( == null || .Count == 0))
{
}
//else
//if (未审批通过的特放明细 != null && 未审批通过的特放明细.Count > 0) {
// result.SetErrorInfo("已在特殊放单流程中,但未通过");
//}
else
{
= false;
break;
}
}
if ()
{
result.OK();
}
else
{
result.SetErrorInfo("");
}
}
catch (Exception e) {
result.SetErrorInfo(e.Message);
}
return result;
}
public static DBResult (string BSNO)
{
var result = new DBResult();
var cdc = new CommonDataContext();
var bsnoList = BSNO.Replace("'", "").Split(',').ToList();
try
{
var List = cdc.v_op_blissuelist_Detail.Where(x => bsnoList.Contains(x.bsno));
foreach (var bsno in bsnoList)
{
//var 审批通过的特放明细 = 特放明细List.Where(x => x.bsno == bsno && x.BLSTATUS == "审核通过").ToList();
var = List.Where(x => x.bsno == bsno && x.BLSTATUS != "审核通过").ToList();
if ( != null && .Count > 0)
{
result.OK($"已在特殊放单流程中[{未审批通过的特放明细[0].GID}],但未通过,是否还要进行特殊放单申请?(可能无法进行申请)");
return result;
}
else
{
result.SetErrorInfo("");
break;
}
}
}
catch (Exception e)
{
result.SetErrorInfo(e.Message);
}
return result;
}
/// <summary>
/// 是否财务扣单
/// 由财务扣单的业务 不可以申请特放;
/// 如有财务扣单 返回true,如无返回false
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public static DBResult ISKDWithCW(string BSNO)
{
var _recount = 0;
var headList = GetDataList(" B.BSNO in (" + BSNO + ") ", 0, 999, out _recount);
return ISKDWithCW(headList);
}
/// <summary>
/// 是否财务扣单
/// 由财务扣单的业务 不可以申请特放;
/// 如有财务扣单 返回true,如无返回false
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public static DBResult ISKDWithCW(List<MsOp_BLISSUEmb> headList)
{
var result = new DBResult();
result.SetErrorInfo("");
//var _recount = 0;
//var headList = GetDataList(" B.BSNO in (" + BSNO + ") and oB.blstatus='扣单' ", 0, 999, out _recount);
//headList = headList.Where(x => x.BLSTATUS == BLSTATUSTYPE.扣单).ToList();
if (headList != null && headList.Count > 0)
{
var cdc = new CommonDataContext();
foreach (var head in headList) {
var = (head);
if (.Success && (bool).Data==true)
{
var loglist = (head);
//var 扣单动作日志 = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null);
//var 扣单动作日志 = cdc.WorkLog.Where(x => 特放GIDList.Contains(x.BSNO) && x.ACTNAME == BLSTATUSTYPE.扣单).ToList();
var = loglist.Where(x => x.ACTNAME == BLSTATUSTYPE.).ToList();
var List = .Select(s => s.OP).Distinct().ToList();
var UserList = cdc.VW_user.Where(x => List.Contains(x.USERID) || List.Contains(x.SHOWNAME)).ToList();
var UseridList = UserList.Select(s => s.USERID).ToList();
var List = ();
var IDList = List.Where(x => x.GVALUE.Contains("财务")).Select(s => s.GID).ToList();
var IDList = cdc.user_role.Where(x => UseridList.Contains(x.USERID) && IDList.Contains(x.ROLEID)).ToList();
if (IDList.Count > 0)
{
var USER = UserList[0];
var = .First(x => x.OP == USER.USERID || x.OP == USER.SHOWNAME);
//var head = headList.First(x => x.GID == 扣单动作.BSNO);
//var msg = $"存在一个由财务扣单的业务,不能执行放货或特殊放单申请【{head.CUSTNO}】";
var msg = $"【{head.CUSTNO}】此票被财务扣单,如要放货,请联系财务解除扣单";
result.OK(msg);
return result;
}
else
{
result.SetErrorInfo("没有财务角色扣单");
}
}
}
}
return result;
}
/// <summary>
/// result.success=true 可以解除
/// false不能解除
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
public static DBResult (MsOp_BLISSUEmb head,string Userid,bool )
{
var result = new DBResult();
result.SetErrorInfo("");
var = (head);
if (.Success && (bool).Data == true )
{
if ( == false) {
result.OK("不需要判断是否财务扣单,可以解除");
return result;
}
var cdc = new CommonDataContext();
var loglist = (head);
//var 扣单动作日志 = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null);
//var 扣单动作日志 = cdc.WorkLog.Where(x => 特放GIDList.Contains(x.BSNO) && x.ACTNAME == BLSTATUSTYPE.扣单).ToList();
var = loglist.Where(x => x.ACTNAME == BLSTATUSTYPE.).ToList();
var List = .Select(s => s.OP).Distinct().ToList();
var UserList = cdc.VW_user.Where(x => List.Contains(x.USERID) || List.Contains(x.SHOWNAME)).ToList();
var UseridList = UserList.Select(s => s.USERID).ToList();
var List = ();
var IDList = List.Where(x => x.GVALUE.Contains("财务")).Select(s => s.GID).ToList();
var IDList = cdc.user_role.Where(x => UseridList.Contains(x.USERID) && IDList.Contains(x.ROLEID)).ToList();
if (IDList.Count > 0)
{
//看 解除扣单人Userid 是否是财务
var = cdc.user_role.Where(x => x.USERID == Userid).ToList();
if (.Exists(x => IDList.Contains(x.ROLEID)))
{
result.OK("财务扣单,解除扣单人也是财务,可以解除扣单");
}
else {
result.SetErrorInfo("财务扣单,解除扣单人非财务,不能解除扣单");
}
}
else
{
result.OK("非财务扣单,可以解除扣单");
}
//
}
else {
result.SetErrorInfo("本票未扣单");
}
return result;
}
#endregion
#region 判断能否在提单管理界面做提单签出
/// <summary>
///
/// </summary>
/// <param name="BSNO"></param>
/// <param name="USERNAME"></param>
/// <returns></returns>
public static DBResult CanDoCheckOut(string BSNO, string USERNAME)
{
var result = new DBResult();
result.OK();
result = (BSNO);
if (result.Success) return result;
var _recount = 0;
var headList = GetDataList(" B.BSNO in (" + BSNO + ") ", 0, 999, out _recount);
var cdc = new CommonDataContext();
if (headList != null && headList.Count > 0)
{
var blissueGIDList = headList.Select(s => s.GID).ToList();
var worklogList = cdc.WorkLog.Where(x => blissueGIDList.Contains(x.BSNO)).ToList();
foreach (var item in headList)
{
if (item.BLSTATUS==BLSTATUSTYPE.)
{
result.SetErrorInfo($"{item.MBLNO}业务状态【{item.BLSTATUS}】,不能做提单签出");
return result;
}
var _worklog = worklogList.Where(x => x.BSNO == item.GID).ToList();
//如果
result = (_worklog);
if (!result.Success) {
return result;
}
}
}
return result;
}
public static DBResult (List<WorkLog_md> worklogList)
{
var result = new DBResult();
result.OK();
if (worklogList == null || worklogList.Count == 0)
{
result.SetErrorInfo("无提单签入数据,无法签出");
return result;
}
else {
var count = worklogList.Where(x => x.ACTNAME == "提单签入").Count();
var count = worklogList.Where(x => x.ACTNAME == "提单签出").Count();
var count = worklogList.Where(x => x.ACTNAME == "取消签入").Count();
var count = worklogList.Where(x => x.ACTNAME == "取消签出").Count();
if (count == 0)
{
result.SetErrorInfo("无提单签入数据,无法签出");
return result;
}
if (count- count == count- count)
{
result.SetErrorInfo("签入与签出次数一致,无法进行一次提单签出");
return result;
}
}
return result;
}
#endregion
#region 附件处理
#region FileList
static public List<DSWeb.Areas.TruckMng.Models.MsUpLoadFile> GetUpLoadFileList ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,PID,FILENAME,FILETYPE,IMGFILE,UPLOADEMPLY,UPLOADDATE,FILEPATH");
strSql.Append(" from info_files ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetUpLoadFileData(strSql);
}
private static List<DSWeb.Areas.TruckMng.Models.MsUpLoadFile> SetUpLoadFileData ( StringBuilder strSql )
{
var headList = new List<DSWeb.Areas.TruckMng.Models.MsUpLoadFile>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
DSWeb.Areas.TruckMng.Models.MsUpLoadFile data = new DSWeb.Areas.TruckMng.Models.MsUpLoadFile();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.PID = Convert.ToString(reader["PID"]);
data.UPLOADEMPLY = Convert.ToString(reader["UPLOADEMPLY"]);
data.UPLOADDATE = Convert.ToString(reader["UPLOADDATE"]);
data.FILETYPE = Convert.ToString(reader["FILETYPE"]);
data.FILENAME = Convert.ToString(reader["FILENAME"]);
data.FILEPATH = Convert.ToString(reader["FILEPATH"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
public static bool UpdateFileData ( HttpRequestBase request, string filename, string fileurl, string GID, out string msg )
{
var isSucess = false;
msg = "";
Stream stream = new FileStream(filename, FileMode.Open);
byte[] data = new byte[stream.Length];
stream.Read(data, 0, data.Length);
stream.Close();
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
const string insertSql = @"update info_files set IMGFILE=@Image,FILEPATH=@FILEPATH where GID=@GID";
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter("@GID",SqlDbType.VarChar),
new SqlParameter("@Image",SqlDbType.Image),
new SqlParameter("@FILEPATH",SqlDbType.VarChar)
};
updateParms[0].Value = GID;
updateParms[1].Value = data;
updateParms[2].Value = fileurl;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, insertSql, updateParms);
sqlTran.Commit();
isSucess = true;//状态为1表示插入成功
}
catch (Exception execError)
{
isSucess = false;//有异常,插入失败
sqlTran.Rollback();
msg = execError.Message;
}
finally
{
SqlHelper.CloseConnection();
}
}
return isSucess;
}
static public int SaveFileList ( IList<DSWeb.Areas.TruckMng.Models.MsUpLoadFile> tempFileEntities, string tempBSNO )
{
int iResult = 0;
const string SQL_INSERT = @"insert info_files (GID,PID,UPLOADEMPLY,UPLOADDATE,FILENAME,FILETYPE) VALUES(@GID,@PID,@UPLOADEMPLY,@UPLOADDATE,@FILENAME,@FILETYPE) ";
const string SQL_UPDATE = @"update info_files SET FILENAME=@FILENAME where GID=@GID";
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (DSWeb.Areas.TruckMng.Models.MsUpLoadFile fileEntity in tempFileEntities)
{
if (fileEntity.PID == "*" || fileEntity.PID == "")
{
SqlParameter[] insertParms = new SqlParameter[] {
new SqlParameter("@GID",SqlDbType.VarChar),
new SqlParameter("@PID",SqlDbType.VarChar),
new SqlParameter("@UPLOADEMPLY",SqlDbType.VarChar),
new SqlParameter("@UPLOADDATE",SqlDbType.VarChar),
new SqlParameter("@FILENAME",SqlDbType.VarChar),
new SqlParameter("@FILETYPE",SqlDbType.VarChar)
};
insertParms[0].Value = fileEntity.GID;
insertParms[1].Value = tempBSNO;
insertParms[2].Value = fileEntity.UPLOADEMPLY;
insertParms[3].Value = fileEntity.UPLOADDATE;
insertParms[4].Value = fileEntity.FILENAME;
insertParms[5].Value = fileEntity.FILETYPE;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT, insertParms);
}
else
{
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter("@FILENAME",SqlDbType.VarChar),
new SqlParameter("@GID",SqlDbType.VarChar)
};
updateParms[1].Value = fileEntity.GID;
//updateParms[1].Value = tempBSNO;
//updateParms[2].Value = fileEntity.UPLOADEMPLY;
//updateParms[3].Value = fileEntity.UPLOADDATE;
updateParms[0].Value = fileEntity.FILENAME;
//updateParms[5].Value = fileEntity.FILETYPE;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE, updateParms);
}
}
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
static public int DeleteUploadFile ( string tempGId )
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
var strSql = new StringBuilder();
strSql.Append("Delete from info_files where ");
strSql.Append(" GId in (" + tempGId + ")");
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString());
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 未放单量查询
public static int (string CUSTOMERNAME) {
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(1) BLCOUNT from v_op_bs WHERE BLISSUESTATUS<>'提单签出' AND CUSTOMERNAME='" + CUSTOMERNAME + "'");
return Convert.ToInt32( BLCOUNT);
}
#endregion
}
}