|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Data.Common;
|
|
|
using System.Text;
|
|
|
using DSWeb.MvcShipping.Models.MsChFee;
|
|
|
using HcUtility.Comm;
|
|
|
using System.Data.SqlClient;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.Account.Models.MsOpBill;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using DSWeb.MvcShipping.DAL.MsInfoClient;
|
|
|
using DSWeb.MvcShipping.DAL.DsSendmail;
|
|
|
using DSWeb.Areas.SysMng.DAL.SysUser;
|
|
|
using DSWeb.Account.Models.MsOpAuditDetail;
|
|
|
using System.Web;
|
|
|
using HtmlAgilityPack;
|
|
|
using System.IO;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.Chfee_AuditDAL
|
|
|
{
|
|
|
public class Chfee_AuditDAL
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询费用数据
|
|
|
|
|
|
static public List<MsChFee> GetDataList(string bsno, int type, string optype, string isAll, string condition, string userid, string username, string companyid, string worktype = "")
|
|
|
{
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAStr(type, optype, userid, username, companyid);
|
|
|
|
|
|
#region 无机密费用权限的用户不让看到相关费用
|
|
|
//2018年2月6日14:53:53 李进举 鼎世
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int power = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, @"select count(*) from user_action
|
|
|
where ACTIONID = (SELECT GID FROM action where DESCRIPTION = '机密费用')
|
|
|
and USERID = '" + userid + "'"));
|
|
|
if (power > 0)
|
|
|
{
|
|
|
rangstr += " ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rangstr += " and IsOpen = 0";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//var WorkFlowNameM = "FeeOpOtherModifyAudit";
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowNameM = "FeeModifyAudit";
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowNameM = "FeeSeaiModifyAudit";
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowNameM = "AireFeeModify";
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowNameM = "AiriFeeModify";
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowNameM = "ApplyFeeModify";
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowNameM = "BulkFeeModify";
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowNameM = "FeeOpOtherModifyAudit";
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowNameM = "RailwayFeeModify";
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
|
|
|
//if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowNameM = "RailwayFeeModify";
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GId,ch_fee.BsNo,FeeStatus,");
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=ch_fee.FeeStatus) as FeeStatus_Ref");
|
|
|
strSql.Append(",FeeType,");
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=ch_fee.FeeType) as FeeType_Ref");
|
|
|
strSql.Append(",FeeName,");
|
|
|
strSql.Append("FeeDescription,CustomerType,CustomerName,");
|
|
|
strSql.Append("Unit,UnitPrice,Quantity,TaxRate,TaxUnitPrice,NoTaxAmount,Amount,AccTaxRate,TAX,Currency,ExChangerate,ch_fee.Reason");
|
|
|
strSql.Append(",Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice,SubmitDate,SUBMITOP");
|
|
|
strSql.Append(",Auditoperator,AuditDate,EnteroPerator,EnterDate,DebitNo,IsDebit,IsOpen");
|
|
|
strSql.Append(",(select ShowName from [user] where GID=ch_fee.EnteroPerator) as OpName");
|
|
|
strSql.Append(",IsAdvancedpay,Sort,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus,InvoiceNum");
|
|
|
strSql.Append(",ChequeNum,WmsOutBsNo,LineNum,INPUTMODE,PreAmount,SALECORP,(select top 1 DESCRIPTION from info_client where SHORTNAME=ch_fee.CustomerName) CustomerFullName");
|
|
|
strSql.Append(",(select showname from [user] where gid=ch_fee.Auditoperator) Auditoperatorref ");
|
|
|
strSql.Append(",(select showname from [user] where gid=ch_fee.SUBMITOP) SUBMITOPREF ");
|
|
|
if (optype == "罐箱业务卡")
|
|
|
{
|
|
|
if (isAll == "1")
|
|
|
{
|
|
|
strSql.Append(",1 as IsAudit ");
|
|
|
strSql.Append(" from ch_fee ");
|
|
|
strSql.Append(" where ch_fee.bsno='" + bsno + "' ");
|
|
|
if (type != 0)
|
|
|
strSql.Append(" and ch_fee.FeeType=" + type);
|
|
|
strSql.Append(" and ch_fee.FeeStatus!=1 ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",1 as IsAudit ");
|
|
|
strSql.Append(" from ch_fee ");
|
|
|
strSql.Append(" where ch_fee.bsno='" + bsno + "' ");
|
|
|
if (type != 0)
|
|
|
strSql.Append(" and ch_fee.FeeType=" + type);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (isAll == "1")
|
|
|
{
|
|
|
strSql.Append(",dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit ");
|
|
|
strSql.Append(" from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID ");
|
|
|
strSql.Append(" where ch_fee.bsno='" + bsno + "' ");
|
|
|
if (type != 0)
|
|
|
strSql.Append(" and ch_fee.FeeType=" + type);
|
|
|
strSql.Append(" and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 ");
|
|
|
// strSql.Append(" and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 and (wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('" + WorkFlowName + "',ch_fee.GID) or wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('" + WorkFlowNameM + "',ch_fee.GID) or wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('OpFeeAudit',ch_fee.GID) ");
|
|
|
// strSql.Append(" or wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('AmendFeefyAudit',ch_fee.GID) or wu.WORKFLOWID=dbo.[GetBSNOWorkFlowID]('YjFeefyAudit',ch_fee.GID) ) ");
|
|
|
|
|
|
}
|
|
|
else if (isAll == "2")
|
|
|
{
|
|
|
strSql.Append(",0 as IsAudit ");
|
|
|
strSql.Append(" from ch_fee ");
|
|
|
strSql.Append(" where ch_fee.bsno='" + bsno + "' ");
|
|
|
if (type != 0)
|
|
|
strSql.Append(" and ch_fee.FeeType=" + type);
|
|
|
strSql.Append(" and ch_fee.FeeStatus=0 AND ch_fee.GID IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit ");
|
|
|
strSql.Append(" from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID and wu.FINISHED=0 ");
|
|
|
strSql.Append(" where ch_fee.bsno='" + bsno + "' ");
|
|
|
if (type != 0)
|
|
|
strSql.Append(" and ch_fee.FeeType=" + type);
|
|
|
if (worktype== "SALEORDER") strSql.Append(" and ch_fee.IsCrmOrderFee=1 ");
|
|
|
else if (worktype != "") strSql.Append(" and isnull(ch_fee.IsCrmOrderFee,0)=0 ");
|
|
|
if (worktype == "BLAUDIT") strSql.Append(" and wu.TYPENO=602 ");
|
|
|
else if (worktype == "FEEAUDIT") strSql.Append(" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) ");
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
|
}
|
|
|
if ((optype != "罐箱业务卡") && (!string.IsNullOrEmpty(rangstr)))
|
|
|
{
|
|
|
strSql.Append(" and " + rangstr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
strSql.Append(" order by sort,LineNum ");
|
|
|
return SetData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsChFee> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<MsChFee>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsChFee data = new MsChFee();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.BsNo = Convert.ToString(reader["BsNo"]);
|
|
|
data.FeeStatus = Convert.ToInt16(reader["FeeStatus"]);
|
|
|
data.FeeStatus_Ref = Convert.ToString(reader["FeeStatus_Ref"]);
|
|
|
data.FeeType = Convert.ToDecimal(reader["FeeType"]);
|
|
|
data.FeeName = Convert.ToString(reader["FeeName"]);
|
|
|
data.FeeDescription = Convert.ToString(reader["FeeDescription"]);
|
|
|
data.CustomerType = Convert.ToString(reader["CustomerType"]);
|
|
|
data.CustomerName = Convert.ToString(reader["CustomerName"]);
|
|
|
data.CustomerFullName = Convert.ToString(reader["CustomerFullName"]);
|
|
|
data.Unit = Convert.ToString(reader["Unit"]);
|
|
|
if (reader["UnitPrice"] != DBNull.Value)
|
|
|
data.UnitPrice = Convert.ToDecimal(reader["UnitPrice"]);
|
|
|
if (reader["Quantity"] != DBNull.Value)
|
|
|
data.Quantity = Convert.ToDecimal(reader["Quantity"]);
|
|
|
if (reader["TaxRate"] != DBNull.Value)
|
|
|
data.TaxRate = Convert.ToDecimal(reader["TaxRate"]);
|
|
|
if (reader["TaxUnitPrice"] != DBNull.Value)
|
|
|
data.TaxUnitPrice = Convert.ToDecimal(reader["TaxUnitPrice"]);
|
|
|
if (reader["NoTaxAmount"] != DBNull.Value)
|
|
|
data.NoTaxAmount = Convert.ToDecimal(reader["NoTaxAmount"]);
|
|
|
if (reader["Amount"] != DBNull.Value)
|
|
|
data.Amount = Convert.ToDecimal(reader["Amount"]);
|
|
|
if (reader["AccTaxRate"] != DBNull.Value)
|
|
|
data.AccTaxRate = Convert.ToDecimal(reader["AccTaxRate"]);
|
|
|
data.Currency = Convert.ToString(reader["Currency"]);
|
|
|
if (reader["ExChangerate"] != DBNull.Value)
|
|
|
data.ExChangerate = Convert.ToDecimal(reader["ExChangerate"]);
|
|
|
data.Reason = Convert.ToString(reader["Reason"]);
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
data.Commissionrate = Convert.ToDecimal(reader["Commissionrate"]);
|
|
|
data.Settlement = Convert.ToDecimal(reader["Settlement"]);
|
|
|
if (reader["Invoice"] != DBNull.Value)
|
|
|
data.Invoice = Convert.ToDecimal(reader["Invoice"]);
|
|
|
if (reader["OrderAmount"] != DBNull.Value)
|
|
|
data.OrderAmount = Convert.ToDecimal(reader["OrderAmount"]);
|
|
|
data.OrderInvoice = Convert.ToDecimal(reader["OrderInvoice"]);
|
|
|
if (reader["SubmitDate"] != DBNull.Value)
|
|
|
data.SubmitDate = Convert.ToDateTime(reader["SubmitDate"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
data.SUBMITOPREF = Convert.ToString(reader["SUBMITOPREF"]);
|
|
|
data.Auditoperator = Convert.ToString(reader["Auditoperatorref"]);
|
|
|
|
|
|
if (reader["AuditDate"] != DBNull.Value)
|
|
|
data.AuditDate = Convert.ToDateTime(reader["AuditDate"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
data.EnteroPerator = Convert.ToString(reader["EnteroPerator"]);
|
|
|
data.OpName = Convert.ToString(reader["OpName"]);
|
|
|
if (reader["EnterDate"] != DBNull.Value)
|
|
|
data.EnterDate = Convert.ToDateTime(reader["EnterDate"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
data.DebitNo = Convert.ToString(reader["DebitNo"]);
|
|
|
if (reader["IsDebit"] != DBNull.Value)
|
|
|
data.IsDebit = Convert.ToString(reader["IsDebit"]);
|
|
|
if (reader["IsOpen"] != DBNull.Value)
|
|
|
data.IsOpen = Convert.ToString(reader["IsOpen"]);
|
|
|
if (reader["IsAdvancedpay"] != DBNull.Value)
|
|
|
data.IsAdvancedpay = Convert.ToString(reader["IsAdvancedpay"]);
|
|
|
data.Sort = Convert.ToString(reader["Sort"]);
|
|
|
if (reader["IsInvoice"] != DBNull.Value)
|
|
|
data.IsInvoice = Convert.ToString(reader["IsInvoice"]);
|
|
|
data.FeeFrt = Convert.ToString(reader["FeeFrt"]);
|
|
|
data.IsCrmOrderFee = Convert.ToString(reader["IsCrmOrderFee"]);
|
|
|
data.AuditStatus = Convert.ToDecimal(reader["AuditStatus"]);
|
|
|
data.InvoiceNum = Convert.ToString(reader["InvoiceNum"]);
|
|
|
data.ChequeNum = Convert.ToString(reader["ChequeNum"]);
|
|
|
data.WmsOutBsNo = Convert.ToString(reader["WmsOutBsNo"]);
|
|
|
data.LineNum = Convert.ToDecimal(reader["LineNum"]);
|
|
|
if (reader["IsAudit"] != DBNull.Value)
|
|
|
data.IsAudit = Convert.ToString(reader["IsAudit"]);
|
|
|
data.INPUTMODE = Convert.ToString(reader["INPUTMODE"]);
|
|
|
data.SALECORP= Convert.ToString(reader["SALECORP"]);
|
|
|
if (reader["PREAMOUNT"] != DBNull.Value)
|
|
|
data.PreAmount = Convert.ToDecimal(reader["PREAMOUNT"]);
|
|
|
|
|
|
if (data.AccTaxRate != 0)
|
|
|
{
|
|
|
data.AccTax = Math.Round(data.Amount / (1 + data.AccTaxRate / 100) * data.AccTaxRate / 100, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
if (reader["TAX"] != DBNull.Value)
|
|
|
data.Tax = Convert.ToDecimal(reader["TAX"]);
|
|
|
if (data.Tax == 0 && data.TaxRate != 0 && data.NoTaxAmount != 0)
|
|
|
{
|
|
|
data.Tax = Math.Round(data.Amount - data.NoTaxAmount, 2);
|
|
|
}
|
|
|
data.AccAmount = data.Amount - data.AccTax;
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Inquery BillDataList
|
|
|
|
|
|
static public List<MsOpBill> GetBillDataList(string strCondition, string userid, string username, string companyid,string sort = null,bool all=false)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
var rangstr = GetListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//if (all == true)
|
|
|
strSql.Append("SELECT ");
|
|
|
//else
|
|
|
// strSql.Append("SELECT TOP 100 ");
|
|
|
strSql.Append(" v_op_bill.BSNO,v_op_bill.SLNO,PARENTID,OPLB,OPLBNAME,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO,BSTYPE,OPTYPE,ORDERNO,v_op_bill.CREATETIME,BLTYPE ");
|
|
|
strSql.Append(",CUSTOMERNAME,INVNO,BillFeeStatus,BILLFEESTATUSTIME");
|
|
|
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD,PLACERECEIPT,DESTINATION ");
|
|
|
strSql.Append(",PORTDISCHARGE,INPUTBY,v_op_bill.OP,CUSTSERVICE,GOODSNAME");
|
|
|
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,BSCUSTOMNO,REMARK,TRADETERM,v_op_bill.REASON,BLFRT");
|
|
|
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(v_op_bill.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_bill.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
|
|
|
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
|
|
|
strSql.Append(",CARRIER,YARD,FORWARDER,CONTRACTNO,ISSUETYPE,SERVICE,REMARK2,CARGOID,DCLASS,op_audit.PROFITSTATUS ");
|
|
|
strSql.Append(",SALEDEPT,(select [NAME] from [company] where GID=v_op_bill.SALECORPID) as SALECORP,op_audit.SUBMITUSER BILLFEEOP ");//
|
|
|
strSql.Append(",op_audit.SHENREMARK,(SELECT TOP 1 [NAME] FROM workflow_step WHERE workflowid=wu.WORKFLOWID and groupid =wu.currentid) AUDITPATH,op_audit.SORT ");
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
strSql.Append(" left join op_audit on (op_audit.BSNO=v_op_bill.BSNO) ");
|
|
|
strSql.Append(" left join workflow_using wu on (wu.bsno =v_op_bill.BSNO) ");
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" order by ETD,MBLNO");
|
|
|
}
|
|
|
return SetBillData(strSql);
|
|
|
}
|
|
|
static public string GetBillDataListStr(string strCondition, string userid, string username, string companyid, string sort = null, bool all = false)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
var rangstr = GetListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//if (all == true)
|
|
|
strSql.Append("SELECT ");
|
|
|
//else
|
|
|
// strSql.Append("SELECT TOP 100 ");
|
|
|
strSql.Append(" BSNO,PARENTID,OPLB,OPLBNAME,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO,BSTYPE,OPTYPE,ORDERNO,CREATETIME,BLTYPE ");
|
|
|
strSql.Append(",CUSTOMERNAME,INVNO,BillFeeStatus,BILLFEESTATUSTIME");
|
|
|
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD,PLACERECEIPT,DESTINATION ");
|
|
|
strSql.Append(",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE,GOODSNAME");
|
|
|
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,BSCUSTOMNO,REMARK,TRADETERM,REASON,BLFRT");
|
|
|
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(v_op_bill.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_bill.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
|
|
|
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
|
|
|
strSql.Append(",CARRIER,YARD,FORWARDER,CONTRACTNO,ISSUETYPE,SERVICE,REMARK2,CARGOID,DCLASS,(select top 1 PROFITSTATUS from op_audit where bsno=v_op_bill.bsno) PROFITSTATUS ");
|
|
|
strSql.Append(",SALEDEPT,(select [NAME] from [company] where GID=v_op_bill.SALECORPID) as SALECORP,'' BILLFEEOP,'' SHENREMARK ,'' AUDITPATH ");//
|
|
|
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" order by ETD,MBLNO");
|
|
|
}
|
|
|
return strSql.ToString();
|
|
|
}
|
|
|
static public List<MsOpBill> GetBillDataList(int start, int limit, string strCondition, string userid, string username, string companyid, string sort = null, bool all = false)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
var rangstr = GetListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
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 , * from (");
|
|
|
|
|
|
strSql.Append(" SELECT BSNO,v_op_bill.SLNO,PARENTID,OPLB,OPLBNAME,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO,BSTYPE,OPTYPE,ORDERNO,CREATETIME,BLTYPE ");
|
|
|
strSql.Append(",CUSTOMERNAME,INVNO,BillFeeStatus,BILLFEESTATUSTIME");
|
|
|
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD,PLACERECEIPT,DESTINATION ");
|
|
|
strSql.Append(",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE,GOODSNAME");
|
|
|
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,BSCUSTOMNO,REMARK,TRADETERM,REASON,BLFRT");
|
|
|
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(v_op_bill.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_bill.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
|
|
|
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
|
|
|
strSql.Append(",CARRIER,YARD,FORWARDER,CONTRACTNO,ISSUETYPE,SERVICE,REMARK2,CARGOID,DCLASS,(select top 1 PROFITSTATUS from op_audit where bsno=v_op_bill.bsno) PROFITSTATUS ");//
|
|
|
strSql.Append(",SALEDEPT,(select [NAME] from [company] where GID=v_op_bill.SALECORPID) as SALECORP,'' BILLFEEOP,'' SHENREMARK,'' AUDITPATH,0 SORT ");//
|
|
|
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" ) as v ");
|
|
|
strSql.Append(@")as t ");
|
|
|
strSql.Append(string.Format("where t.num>{0} and t.num<={1} ", start, start + limit)); //
|
|
|
|
|
|
return SetBillData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
static public List<MsOpBill> GetBillDataList3(int start, int limit, string strCondition, string userid, string username, string companyid, string sort = null, bool all = false)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
var rangstr = GetListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//strSql.Append(@"SELECT * from (SELECT row_number() over (");
|
|
|
|
|
|
|
|
|
|
|
|
//strSql.Append(@") as num , * from (");
|
|
|
|
|
|
strSql.Append(" SELECT BSNO,v_op_bill.SLNO,PARENTID,OPLB,OPLBNAME,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO,BSTYPE,OPTYPE,ORDERNO,CREATETIME,BLTYPE ");
|
|
|
strSql.Append(",CUSTOMERNAME,INVNO,BillFeeStatus,BILLFEESTATUSTIME");
|
|
|
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD,PLACERECEIPT,DESTINATION ");
|
|
|
strSql.Append(",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE,GOODSNAME");
|
|
|
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,BSCUSTOMNO,REMARK,TRADETERM,REASON,BLFRT");
|
|
|
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(v_op_bill.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_bill.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
|
|
|
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
|
|
|
strSql.Append(",CARRIER,YARD,FORWARDER,CONTRACTNO,ISSUETYPE,SERVICE,REMARK2,CARGOID,DCLASS,(select top 1 PROFITSTATUS from op_audit where bsno=v_op_bill.bsno) PROFITSTATUS,'' SHENREMARK ");//
|
|
|
strSql.Append(",SALEDEPT,(select [NAME] from [company] where GID=v_op_bill.SALECORPID) as SALECORP,(select top 1 SHOWNAME from VW_user where userid in (select top 1 op from workflow_using where TYPENO='602' and bsno=v_op_bill.bsno)) BILLFEEOP,'' AUDITPATH,0 SORT ");//
|
|
|
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by ETD,MBLNO");
|
|
|
}
|
|
|
//strSql.Append(" ) as v ");
|
|
|
//strSql.Append(@")as t ");
|
|
|
//strSql.Append(string.Format("where t.num>{0} and t.num<={1} ", start, start + limit)); //
|
|
|
|
|
|
return SetBillData(strSql);
|
|
|
}
|
|
|
|
|
|
public static int getTotalCount(string strCondition, string userid, string username, string companyid)
|
|
|
{
|
|
|
var rangstr = GetListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select count(*) ");
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
static public MsOpBill GetBillData(string condition, string userid = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" V_OP_BILL.BSNO,v_op_bill.SLNO,PARENTID,OPLB,OPLBNAME,BSSTATUS,FEESTATUS,ACCDATE,MBLNO,HBLNO,CUSTNO,CUSTOMNO,BSTYPE,OPTYPE,ORDERNO,CREATETIME,BLTYPE ");
|
|
|
strSql.Append(",CUSTOMERNAME,INVNO,BillFeeStatus,BILLFEESTATUSTIME");
|
|
|
strSql.Append(",VESSEL,VOYNO,ETD,PORTLOAD,PLACERECEIPT,DESTINATION ");
|
|
|
strSql.Append(",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE,GOODSNAME");
|
|
|
strSql.Append(",DOC,SALE,ENTERP,BSSOURCE,BSSOURCEDETAIL,CUSTOMSNUM,CNTRTOTAL,PKGS,CBM,KGS,BSCUSTOMNO,REMARK,TRADETERM,REASON,BLFRT");
|
|
|
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(v_op_bill.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_bill.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
|
|
|
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
|
|
|
strSql.Append(",CARRIER,YARD,FORWARDER,CONTRACTNO,ISSUETYPE,SERVICE,REMARK2,CARGOID,DCLASS,(select top 1 PROFITSTATUS from op_audit where bsno=v_op_bill.bsno) PROFITSTATUS ");
|
|
|
strSql.Append(",SALEDEPT,(select [NAME] from [company] where GID=v_op_bill.SALECORPID) as SALECORP,'' BILLFEEOP ");//
|
|
|
strSql.Append(",(select top 1 SHENREMARK from op_audit where bsno=v_op_bill.bsno) SHENREMARK,'' AUDITPATH,0 SORT ");
|
|
|
|
|
|
strSql.Append(" from v_op_bill ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
var list = SetBillData(strSql);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
return new MsOpBill();
|
|
|
}
|
|
|
|
|
|
|
|
|
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"]);
|
|
|
data.PARENTID = Convert.ToString(reader["PARENTID"]);
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
data.OPLB = Convert.ToString(reader["OPLB"]);
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
|
data.BSTYPE = Convert.ToString(reader["BSTYPE"]);
|
|
|
data.OPTYPE = Convert.ToString(reader["OPTYPE"]);
|
|
|
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.ORDERNO = Convert.ToString(reader["ORDERNO"]);
|
|
|
data.INVNO = Convert.ToString(reader["INVNO"]);
|
|
|
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.PLACERECEIPT = Convert.ToString(reader["PLACERECEIPT"]);
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
data.DESTINATION = Convert.ToString(reader["DESTINATION"]);
|
|
|
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.ToInt32(reader["CUSTOMSNUM"]);
|
|
|
data.PKGS = Convert.ToString(reader["PKGS"]);
|
|
|
data.CBM = Convert.ToString(reader["CBM"]);
|
|
|
data.KGS = Convert.ToString(reader["KGS"]);
|
|
|
data.BSCUSTOMNO = Convert.ToString(reader["BSCUSTOMNO"]);
|
|
|
if (reader["BSSTATUS"] != DBNull.Value)
|
|
|
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
|
|
|
if (reader["FEESTATUS"] != DBNull.Value)
|
|
|
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.REASON = Convert.ToString(reader["REASON"]);
|
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
|
data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]);
|
|
|
data.COMMISSIONRATE = Convert.ToString(reader["COMMISSIONRATE"]);
|
|
|
data.GOODSNAME= Convert.ToString(reader["GOODSNAME"]);
|
|
|
data.BLFRT = Convert.ToString(reader["BLFRT"]);
|
|
|
data.CARRIER = Convert.ToString(reader["CARRIER"]);
|
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
|
data.FORWARDER = Convert.ToString(reader["FORWARDER"]);
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
|
data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);
|
|
|
data.SERVICE = Convert.ToString(reader["SERVICE"]);
|
|
|
data.REMARK2 = Convert.ToString(reader["REMARK2"]);
|
|
|
if (reader["BILLFEESTATUSTIME"] != DBNull.Value)
|
|
|
data.BILLFEESTATUSTIME = Convert.ToString(reader["BILLFEESTATUSTIME"]);
|
|
|
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);
|
|
|
data.SALECORP = Convert.ToString(reader["SALECORP"]);
|
|
|
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
|
|
|
data.BILLFEEOP = Convert.ToString(reader["BILLFEEOP"]);
|
|
|
data.CARGOID = Convert.ToString(reader["CARGOID"]);
|
|
|
data.DCLASS = Convert.ToString(reader["DCLASS"]);
|
|
|
data.PROFITSTATUS = Convert.ToString(reader["PROFITSTATUS"]);
|
|
|
data.SHENREMARK = Convert.ToString(reader["SHENREMARK"]);
|
|
|
data.AUDITPATH = Convert.ToString(reader["AUDITPATH"]);
|
|
|
if (reader["SORT"] != DBNull.Value)
|
|
|
data.SORT = Convert.ToInt16(reader["SORT"]);
|
|
|
if (reader["SLNO"] != DBNull.Value)
|
|
|
data.SLNO = Convert.ToInt16(reader["SLNO"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 陆运
|
|
|
|
|
|
static public List<BillTruck> GetTruckBillDataList(int start, int limit, string strCondition, string userid, string username, string companyid, string sort = null, bool all = false)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
var rangstr = GetTruckListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
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,OPTYPE,TRANSTYPE,TRANSSTATUS,CUSTOMERNAME,CUSTNO,CONTRACTNO,ORDERNO,BSDATE,");
|
|
|
strSql.Append("ETD,ETA,OP,SALE,CUSTSERVICE,CUSTATTN,CUSTTEL,CONSIGNEENAME,CONSIGNEEATTN,CONSIGNEETEL,CONSIGNEEADDR,");
|
|
|
strSql.Append("PORTLOAD,PORTDISCHARGE,GOODSNAME,KGS,NETWEIGHT,CBM,PKGS,KINDPKGS,TRUCKER,TRUCKNO,MBLNO");
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(v_op_truck_bulk.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(v_op_truck_bulk.BSNO) CRFEESTATUS");
|
|
|
|
|
|
|
|
|
strSql.Append(" from v_op_truck_bulk ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
strSql.Append(@")as t ");
|
|
|
strSql.Append(string.Format("where t.num>{0} and t.num<={1} ", start, start + limit)); //
|
|
|
|
|
|
return SetTruckBillData(strSql);
|
|
|
}
|
|
|
|
|
|
public static int getTruckTotalCount(string strCondition, string userid, string username, string companyid)
|
|
|
{
|
|
|
var rangstr = GetTruckListRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select count(*) ");
|
|
|
strSql.Append(" from v_op_truck_bulk ");
|
|
|
|
|
|
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<BillTruck> SetTruckBillData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<BillTruck>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
cmd.CommandText = strSql.ToString();
|
|
|
cmd.CommandTimeout = 120000; //要加这一句
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(cmd))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
BillTruck data = new BillTruck();
|
|
|
#region Set DB data to Object
|
|
|
data.TRANSTYPE = Convert.ToString(reader["TRANSTYPE"]);
|
|
|
data.OPTYPE = Convert.ToString(reader["OPTYPE"]);
|
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");
|
|
|
if (reader["ETA"] != DBNull.Value)
|
|
|
data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");
|
|
|
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
|
data.CUSTATTN = Convert.ToString(reader["CUSTATTN"]);
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
data.CUSTTEL = Convert.ToString(reader["CUSTTEL"]);
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
|
|
|
data.CONSIGNEENAME = Convert.ToString(reader["CONSIGNEENAME"]);
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
data.CONSIGNEEATTN = Convert.ToString(reader["CONSIGNEEATTN"]);
|
|
|
data.CONSIGNEETEL = Convert.ToString(reader["CONSIGNEETEL"]);
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
data.CONSIGNEEADDR = Convert.ToString(reader["CONSIGNEEADDR"]);
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
|
|
|
data.TRUCKER = Convert.ToString(reader["TRUCKER"]);
|
|
|
data.TRUCKNO = Convert.ToString(reader["TRUCKNO"]);
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);
|
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
|
data.PKGS = Convert.ToInt32(reader["PKGS"]);
|
|
|
if (reader["KGS"] != DBNull.Value)
|
|
|
data.KGS = Convert.ToDecimal(reader["KGS"]);
|
|
|
if (reader["NETWEIGHT"] != DBNull.Value)
|
|
|
data.NETWEIGHT = Convert.ToDecimal(reader["NETWEIGHT"]);
|
|
|
if (reader["CBM"] != DBNull.Value)
|
|
|
data.CBM = Convert.ToDecimal(reader["CBM"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
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.IndexOf("9:") > -1)
|
|
|
{
|
|
|
return "部分结算";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("0:") > -1)
|
|
|
{
|
|
|
return "部分审核";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("2:") > -1)
|
|
|
{
|
|
|
return "部分提交";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("6:")>-1)
|
|
|
{
|
|
|
return "驳回提交";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("7:") > -1)
|
|
|
{
|
|
|
return "驳回申请";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region fee_gain
|
|
|
|
|
|
static public List<MsChFeeGain> GetDataGainList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GId,BsNo,RMBDR,");
|
|
|
strSql.Append("RMBCR,USDDR,USDCR,");
|
|
|
strSql.Append("OTDR,OTCR,DRTTL,CRTTL,RMBPROFIT,USDPROFIT,OTPROFIT,TTLPROFIT");
|
|
|
strSql.Append(",CREATETIME,CREATEUSER");
|
|
|
strSql.Append(" from fee_gain ");
|
|
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
|
|
|
return SetGainData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsChFeeGain> SetGainData(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<MsChFeeGain>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsChFeeGain data = new MsChFeeGain();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.BsNo = Convert.ToString(reader["BsNo"]);
|
|
|
data.RMBDR = Convert.ToDecimal(reader["RMBDR"]);
|
|
|
data.RMBCR = Convert.ToDecimal(reader["RMBCR"]);
|
|
|
data.USDDR = Convert.ToDecimal(reader["USDDR"]);
|
|
|
data.USDCR = Convert.ToDecimal(reader["USDCR"]);
|
|
|
data.OTDR = Convert.ToDecimal(reader["OTDR"]);
|
|
|
data.OTCR = Convert.ToDecimal(reader["OTCR"]);
|
|
|
data.TTLDR = Convert.ToDecimal(reader["DRTTL"]);
|
|
|
data.TTLCR = Convert.ToDecimal(reader["CRTTL"]);
|
|
|
data.RMBPROFIT = Convert.ToString(reader["RMBPROFIT"]);
|
|
|
data.USDPROFIT = Convert.ToString(reader["USDPROFIT"]);
|
|
|
data.OTPROFIT = Convert.ToString(reader["OTPROFIT"]);
|
|
|
data.TTLPROFIT = Convert.ToString(reader["TTLPROFIT"]);
|
|
|
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public static string GetWorkFlowNameByOptype(string optype) {
|
|
|
optype = optype.ToLower();
|
|
|
var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
{
|
|
|
WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_seai")
|
|
|
{
|
|
|
WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_aire")
|
|
|
{
|
|
|
WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_airi")
|
|
|
{
|
|
|
WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_apply")
|
|
|
{
|
|
|
WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_bulk")
|
|
|
{
|
|
|
WorkFlowName = "BulkFeeAudit";
|
|
|
}
|
|
|
if (optype == "op_other" || optype == "tmswlpchead" || optype == "opctnbscard" || optype == "import_main" || optype == "op_supervision_truck")
|
|
|
{
|
|
|
WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
}
|
|
|
if (optype == "op_railway")
|
|
|
{
|
|
|
WorkFlowName = "RailwayFeeAudit";
|
|
|
}
|
|
|
if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
{
|
|
|
var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
}
|
|
|
return WorkFlowName;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetWorkFlowNameByOptype_Modify(string optype)
|
|
|
{
|
|
|
optype = optype.ToLower();
|
|
|
var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
{
|
|
|
WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_seai")
|
|
|
{
|
|
|
WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_aire")
|
|
|
{
|
|
|
WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_airi")
|
|
|
{
|
|
|
WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_apply")
|
|
|
{
|
|
|
WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
}
|
|
|
if (optype == "op_bulk")
|
|
|
{
|
|
|
WorkFlowName = "BulkFeeModify";
|
|
|
}
|
|
|
if (optype == "op_other" || optype == "tmswlpchead" || optype == "opctnbscard" || optype == "import_main" || optype == "op_supervision_truck")
|
|
|
{
|
|
|
WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
}
|
|
|
if (optype == "op_railway")
|
|
|
{
|
|
|
WorkFlowName = "RailwayFeeModify";
|
|
|
}
|
|
|
if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
{
|
|
|
var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
}
|
|
|
return WorkFlowName;
|
|
|
}
|
|
|
|
|
|
public static DBResult SubmitAudit(String optype, String USERID, String bill, string bsno, string WorkFlowstr,string companyid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
var mblno = "";
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
var WorkFlowid = "";
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// var _Comm = "update ch_fee set FEESTATUS=2 where GID=@GID";
|
|
|
// var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
// cmdupdate.Parameters.Clear();
|
|
|
// db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
// db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
if ((mblno == "")&&(bsno != ""))
|
|
|
mblno = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO+' 客户名称:'+CUSTOMERNAME+' 业务来源:'+BSSOURCE from v_op_bs where BSNO='" + bsno + "'");
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
var tmpWorkFlowName=WorkFlowName;
|
|
|
if (WorkFlowid == "")
|
|
|
{
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + tmpWorkFlowName + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + USERID + "') order by SORTNO ";
|
|
|
DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + bsno + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, billno, USERID, mblno, bsno, "Account/Chfee_Audit", WorkFlowid);
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=0 where GID=@GID";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=2 where GID=@GID";
|
|
|
}
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
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 SubmitAuditAmend(string GidStr, string optype, string userid, string companyid, string bsno = "")
|
|
|
{
|
|
|
var workflowstr = "";
|
|
|
var AMENDSELFWORK = MsSysParamSetDAL.GetData("PARAMNAME='AMENDSELFWORKFLOW'");
|
|
|
if (AMENDSELFWORK.PARAMVALUE == "1") workflowstr = "AmendFeefyAudit";
|
|
|
|
|
|
|
|
|
DBResult result = Chfee_AuditDAL.SubmitAudit(optype, userid, GidStr, bsno, workflowstr, companyid);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static string GetServiceFeeMsg(string optype, string bsno, Database db, DbTransaction tran)
|
|
|
{
|
|
|
var result = "";
|
|
|
var servicesql = "";
|
|
|
|
|
|
if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
{
|
|
|
var head = MsOpSeaeDAL.MsOpSeaeDAL.GetData("BSNO='"+bsno+"'");
|
|
|
if (head.ISAGENT == true)
|
|
|
if (servicesql=="")
|
|
|
servicesql = " OPField='ISAGENT' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISAGENT' ";
|
|
|
if (head.ISBOOKING == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISBOOKING' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISBOOKING' ";
|
|
|
if (head.ISFUMIGATION == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISFUMIGATION' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISFUMIGATION' ";
|
|
|
if (head.ISSTORAGE == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISSTORAGE' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISSTORAGE' ";
|
|
|
if (head.ISLAND == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISLAND' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISLAND' ";
|
|
|
if (head.ISCUSTOMS == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISCUSTOMS' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISCUSTOMS' ";
|
|
|
if (head.ISINSPECTION == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISINSPECTION' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISINSPECTION' ";
|
|
|
if (head.ISHBLNO == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISHBLNO' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISHBLNO' ";
|
|
|
if (head.SERVICE9 == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.SERVICE10 == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
if (servicesql == "") result = "";
|
|
|
else {
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')",db,tran);
|
|
|
}
|
|
|
|
|
|
} if (optype == "op_Seai")
|
|
|
{
|
|
|
var head = MsOpSeaiDAL.MsOpSeaiDAL.GetData("BSNO='" + bsno + "'");
|
|
|
if (head.ISAGENT == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISAGENT' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISAGENT' ";
|
|
|
if (head.ISBOOKING == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISBOOKING' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISBOOKING' ";
|
|
|
if (head.ISFUMIGATION == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISFUMIGATION' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISFUMIGATION' ";
|
|
|
if (head.ISSTORAGE == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISSTORAGE' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISSTORAGE' ";
|
|
|
if (head.ISLAND == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISLAND' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISLAND' ";
|
|
|
if (head.ISCUSTOMS == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISCUSTOMS' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISCUSTOMS' ";
|
|
|
if (head.ISINSPECTION == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISINSPECTION' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISINSPECTION' ";
|
|
|
if (head.ISHBLNO == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='ISHBLNO' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='ISHBLNO' ";
|
|
|
if (head.SERVICE9 == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.SERVICE10 == true)
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
if (servicesql == "") result = "";
|
|
|
else
|
|
|
{
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')", db, tran);
|
|
|
}
|
|
|
|
|
|
} if (optype == "op_Aire")
|
|
|
{
|
|
|
var head = MsOpAireDAL.MsOpAireDAL.GetData("BSNO='" + bsno + "'");
|
|
|
if (head.IsSERVICE1 =="1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE1' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE1' ";
|
|
|
if (head.IsSERVICE2 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE2' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE2' ";
|
|
|
if (head.IsSERVICE3 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE3' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE3' ";
|
|
|
if (head.IsSERVICE4 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE4' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE4' ";
|
|
|
if (head.IsSERVICE5 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE5' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE5' ";
|
|
|
if (head.IsSERVICE6 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE6' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE6' ";
|
|
|
if (head.IsSERVICE7 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE7' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE7' ";
|
|
|
if (head.IsSERVICE8 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE8' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE8' ";
|
|
|
if (head.IsSERVICE9 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.IsSERVICE10 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
|
|
|
if (servicesql == "") result = "";
|
|
|
else
|
|
|
{
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')", db, tran);
|
|
|
}
|
|
|
|
|
|
} if (optype == "op_Airi")
|
|
|
{
|
|
|
var head = MsOpAiriDAL.MsOpAiriDAL.GetData("BSNO='" + bsno + "'");
|
|
|
if (head.IsSERVICE1 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE1' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE1' ";
|
|
|
if (head.IsSERVICE2 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE2' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE2' ";
|
|
|
if (head.IsSERVICE3 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE3' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE3' ";
|
|
|
if (head.IsSERVICE4 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE4' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE4' ";
|
|
|
if (head.IsSERVICE5 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE5' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE5' ";
|
|
|
if (head.IsSERVICE6 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE6' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE6' ";
|
|
|
if (head.IsSERVICE7 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE7' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE7' ";
|
|
|
if (head.IsSERVICE8 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE8' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE8' ";
|
|
|
if (head.IsSERVICE9 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.IsSERVICE10 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
|
|
|
if (servicesql == "") result = "";
|
|
|
else
|
|
|
{
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')", db, tran);
|
|
|
}
|
|
|
|
|
|
} if (optype == "op_Apply")
|
|
|
{
|
|
|
var head = MsOpApplyDAL.MsOpApplyDAL.GetData("BSNO='" + bsno + "'");
|
|
|
if (head.IsSERVICE1 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE1' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE1' ";
|
|
|
if (head.IsSERVICE2 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE2' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE2' ";
|
|
|
if (head.IsSERVICE3 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE3' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE3' ";
|
|
|
if (head.IsSERVICE4 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE4' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE4' ";
|
|
|
if (head.IsSERVICE5 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE5' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE5' ";
|
|
|
if (head.IsSERVICE6 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE6' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE6' ";
|
|
|
if (head.IsSERVICE7 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE7' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE7' ";
|
|
|
if (head.IsSERVICE8 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE8' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE8' ";
|
|
|
if (head.IsSERVICE9 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.IsSERVICE10 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
|
|
|
if (servicesql == "") result = "";
|
|
|
else
|
|
|
{
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')", db, tran);
|
|
|
}
|
|
|
|
|
|
} if (optype == "op_other")
|
|
|
{
|
|
|
var head = MsOpOtherDAL.MsOpOtherDAL.GetData("BSNO='" + bsno + "'");
|
|
|
if (head.IsSERVICE1 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE1' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE1' ";
|
|
|
if (head.IsSERVICE2 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE2' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE2' ";
|
|
|
if (head.IsSERVICE3 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE3' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE3' ";
|
|
|
if (head.IsSERVICE4 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE4' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE4' ";
|
|
|
if (head.IsSERVICE5 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE5' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE5' ";
|
|
|
if (head.IsSERVICE6 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE6' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE6' ";
|
|
|
if (head.IsSERVICE7 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE7' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE7' ";
|
|
|
if (head.IsSERVICE8 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE8' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE8' ";
|
|
|
if (head.IsSERVICE9 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE9' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE9' ";
|
|
|
if (head.IsSERVICE10 == "1")
|
|
|
if (servicesql == "")
|
|
|
servicesql = " OPField='SERVICE10' ";
|
|
|
else
|
|
|
servicesql = servicesql + " or OPField='SERVICE10' ";
|
|
|
|
|
|
if (servicesql == "") result = "";
|
|
|
else
|
|
|
{
|
|
|
result = GetServiceFeesqlMsg("(" + servicesql + ") and FEENAME NOT IN (SELECT FEENAME FROM ch_fee where feetype=1 and bsno='" + bsno + "')", db, tran);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
static public string GetServiceFeesqlMsg(string consql, Database db, DbTransaction tran)
|
|
|
{
|
|
|
string result = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select * from v_code_service_fee where " + consql);
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(tran, CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
result =result+"服务项目:"+Convert.ToString(reader["SERVICENAME"])+"(费用名称:"+ Convert.ToString(reader["FEENAME"])+")";
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
if (result != "") result = "注意:以下费用未录入 " + result;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAuditNew(String optype, String USERID, List<MsChFee> billList, bool isbl = false, string WorkFlowstr="",string issalework="",string companyid="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
var bsno = "1";
|
|
|
var mblno = "";
|
|
|
var saleid = "";
|
|
|
var WorkFlowid = "";
|
|
|
result.Success = true;
|
|
|
var msg = "";
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//optype = optype.ToLower();
|
|
|
//if (optype == "op_seae"|| optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tmswlpchead" || optype == "opctnbscard" || optype == "import_main" || optype == "OP_SuperVision_Truck")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
var BLSTLAUTOAUDIT = MsSysParamSetDAL.GetData("PARAMNAME='BLSTLAUTOAUDIT'");
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
var autoAudit=false;
|
|
|
|
|
|
bsno = billno.BsNo;
|
|
|
if (BLSTLAUTOAUDIT.PARAMVALUE == "1")
|
|
|
{
|
|
|
var client = MsInfoClientDAL.GetData("SHORTNAME='"+billno.CustomerName+"'");
|
|
|
if (client.STLNAME == "票结") autoAudit = true;
|
|
|
}
|
|
|
|
|
|
if (autoAudit)
|
|
|
{
|
|
|
|
|
|
var _Comm = "update ch_fee set FEESTATUS=0 where GID=@GID";
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (mblno == "" || (issalework=="1"&&saleid=="")) {
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT TOP 1 GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID,SALE,BSSOURCE,CUSTOMERNAME from v_op_bs where BSNO='" + bsno + "'";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
mblno = dsUser.Tables[0].Rows[0]["MBLNO"].ToString()+" 客户名称:"+ dsUser.Tables[0].Rows[0]["CUSTOMERNAME"].ToString()+" 业务来源:"+ dsUser.Tables[0].Rows[0]["BSSOURCE"].ToString();
|
|
|
if (issalework=="1")
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
if (saleid == "") saleid = USERID;
|
|
|
|
|
|
|
|
|
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// var _Comm = "update ch_fee set FEESTATUS=2 where GID=@GID";
|
|
|
// var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
// cmdupdate.Parameters.Clear();
|
|
|
// db.AddInParameter(cmdupdate, "@GID", DbType.String, billno.GId);
|
|
|
// db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
var tmpWorkFlowName=WorkFlowName;
|
|
|
if (billno.IsOpen != null)
|
|
|
{
|
|
|
if (billno.IsOpen == "1" || billno.IsOpen == "true" || billno.IsOpen == "True") tmpWorkFlowName = "YjFeefyAudit";
|
|
|
}
|
|
|
|
|
|
if (WorkFlowid == "") {
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='"+companyid+"' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + tmpWorkFlowName + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + USERID+"') order by SORTNO ";
|
|
|
DataSet dsworkflow= T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL= Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'"+billno.BsNo+"'").Replace("[费用对象]", "'" + billno.CustomerName+ "'").Replace("[FEEID]", "'" + billno.GId + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(tmpWorkFlowName, billno.GId, saleid, mblno, bsno, "Account/Chfee_Audit", WorkFlowid);
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=0,SUBMITDATE=GETDATE(),SUBMITOP='"+USERID+"' where GID=@GID";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=2,SUBMITDATE=GETDATE(),SUBMITOP='" + USERID + "' where GID=@GID";
|
|
|
}
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "提交审核错误!";
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
if (billno.Currency != "RMB" && (billno.FeeName == "预付款" || billno.FeeName == "尾款" || billno.FeeName == "购货款"))
|
|
|
{
|
|
|
InsertImportPayRecord(billno, USERID, db,tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isbl&&result.Success != false) {
|
|
|
//var cmdDelete = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE) values(NEWID(),'" + bsno + "','费用提交',1,'" + DateTime.Now.ToString() + "','" + DateTime.Now.ToString() + "','2')");
|
|
|
//db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
}
|
|
|
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
// msg = GetServiceFeeMsg(optype, bsno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "提交审核成功";
|
|
|
result.Data = msg;
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult piliangSubmitAudit(string optype, string bsnos, int feetype, string userid, string username, string companyid, string issalework="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var BLSTLAUTOAUDIT = MsSysParamSetDAL.GetData("PARAMNAME='BLSTLAUTOAUDIT'");
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT GId,BsNo,CustomerName,FeeName,Currency,ExChangerate,IsOpen from ch_fee where FEESTATUS=1 and " + bsnos);
|
|
|
if (feetype==1){
|
|
|
strSql.Append(" and FEETYPE=1 ");
|
|
|
var drrangstr = GetRangDAStr(feetype, optype,userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else if (feetype == 2){
|
|
|
strSql.Append(" and FEETYPE=2 ");
|
|
|
var drrangstr = GetRangDAStr(feetype, optype, userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
var drrangstr = GetRangDAStr(1, optype, userid, username, companyid);
|
|
|
var crrangstr = GetRangDAStr(2, optype, userid, username, companyid);
|
|
|
strSql.Append(" and ((FEETYPE=1 ");
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
strSql.Append(" ) or (FEETYPE=2 ");
|
|
|
if (!string.IsNullOrEmpty(crrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + crrangstr);
|
|
|
|
|
|
}
|
|
|
|
|
|
strSql.Append(" )) ");
|
|
|
|
|
|
}
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var billno = Convert.ToString(reader["GId"]);
|
|
|
var bsno = Convert.ToString(reader["BsNo"]);
|
|
|
var CustomerName = Convert.ToString(reader["CustomerName"]);
|
|
|
var FeeName = Convert.ToString(reader["FeeName"]);
|
|
|
var Currency = Convert.ToString(reader["Currency"]);
|
|
|
decimal ExChangerate=0;
|
|
|
if (reader["ExChangerate"] != DBNull.Value)
|
|
|
ExChangerate = Convert.ToDecimal(reader["ExChangerate"]);
|
|
|
else
|
|
|
ExChangerate =0;
|
|
|
var tmpWorkFlowName = WorkFlowName;
|
|
|
if (reader["IsOpen"] != DBNull.Value && Convert.ToBoolean(reader["IsOpen"]) == true)
|
|
|
tmpWorkFlowName = "YjFeefyAudit";
|
|
|
|
|
|
if (CustomerName == "" || FeeName == "" || Currency == "" || ExChangerate == 0)
|
|
|
{
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var autoAudit=false;
|
|
|
|
|
|
if (BLSTLAUTOAUDIT.PARAMVALUE == "1")
|
|
|
{
|
|
|
var client = MsInfoClientDAL.GetData("SHORTNAME='" + CustomerName + "'");
|
|
|
if (client.STLNAME == "票结") autoAudit = true;
|
|
|
}
|
|
|
|
|
|
if (autoAudit)
|
|
|
{
|
|
|
|
|
|
var _Comm = "update ch_fee set FEESTATUS=0,SUBMITDATE=GETDATE(),SUBMITOP='" + userid + "' where GID=@GID";
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var mblno = "";
|
|
|
var saleid = "";
|
|
|
if (mblno == "" || (issalework == "1" && saleid == ""))
|
|
|
{
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID,SALE,BSSOURCE,CUSTOMERNAME from v_op_bs where BSNO='" + bsno + "'";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
mblno = dsUser.Tables[0].Rows[0]["MBLNO"].ToString() + " 客户名称:" + dsUser.Tables[0].Rows[0]["CUSTOMERNAME"].ToString() + " 业务来源:" + dsUser.Tables[0].Rows[0]["BSSOURCE"].ToString();
|
|
|
if (issalework == "1")
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
if (saleid == "") saleid = userid;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(tmpWorkFlowName, billno, saleid, mblno, bsno, "Account/Chfee_Audit");
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=0,SUBMITDATE=GETDATE(),SUBMITOP='" + userid + "',AUDITOPERATOR='" + userid + "',AUDITDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID=@GID";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "update ch_fee set FEESTATUS=2,SUBMITDATE=GETDATE(),SUBMITOP='" + userid + "' where GID=@GID";
|
|
|
}
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "提交审核错误!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (feetype == 0) {
|
|
|
|
|
|
//var cmdDelete = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE) select NEWID(),bsno,'费用提交',1,getdate(),getdate(),'2' from v_op_bill where "+bsnos);
|
|
|
//db.ExecuteNonQuery(cmdDelete, 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 GetErrorFeeMbl(string optype, string bsnos, int feetype, string userid, string username, string companyid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var mblnos = "";
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT MBLNO FROM V_OP_BILL WHERE BSNO IN (SELECT distinct BSNO from ch_fee where FEESTATUS=1 and (CustomerName='' or FeeName='' or ExChangerate=0 or Currency='')" + bsnos);
|
|
|
if (feetype == 1)
|
|
|
{
|
|
|
strSql.Append(" and FEETYPE=1 ");
|
|
|
var drrangstr = GetRangDAStr(feetype, optype, userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else if (feetype == 2)
|
|
|
{
|
|
|
strSql.Append(" and FEETYPE=2 ");
|
|
|
var drrangstr = GetRangDAStr(feetype, optype, userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var drrangstr = GetRangDAStr(1, optype, userid, username, companyid);
|
|
|
var crrangstr = GetRangDAStr(2, optype, userid, username, companyid);
|
|
|
strSql.Append(" and ((FEETYPE=1 ");
|
|
|
if (!string.IsNullOrEmpty(drrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + drrangstr);
|
|
|
|
|
|
}
|
|
|
strSql.Append(" ) or (FEETYPE=2 ");
|
|
|
if (!string.IsNullOrEmpty(crrangstr))
|
|
|
{
|
|
|
strSql.Append(" and " + crrangstr);
|
|
|
|
|
|
}
|
|
|
|
|
|
strSql.Append(" ))) ");
|
|
|
|
|
|
}
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var billno = Convert.ToString(reader["MBLNO"]);
|
|
|
mblnos = mblnos + billno + ",";
|
|
|
}
|
|
|
}
|
|
|
if (mblnos != "")
|
|
|
{
|
|
|
result = new DBResult();
|
|
|
result.Success = false;
|
|
|
result.Message = "提单号:"+mblnos+" 费用录入不完整,请先检查费用录入情况,在批量提交!";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
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 CancelAudit(String optype, String USERID, String bill, string WorkFlowstr, string issalework="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out") {
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value=="1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var saleid = "";
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
var FEESTATUS = T_ALL_DA.GetStrSQL("FEESTATUS", "select FEESTATUS from ch_fee WHERE GID='" + billno + "'");
|
|
|
if (FEESTATUS == "2"|| FEESTATUS == "0")
|
|
|
{
|
|
|
|
|
|
if (optype == "OpCtnBsCard")
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (saleid == "" && issalework == "1")
|
|
|
{
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID from v_op_bs where BSNO in (select bsno from ch_fee where GID='" + billno + "')";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (saleid == "") saleid = USERID;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, billno, saleid);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(billno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
WorkResult = WorkFlowDAL.WorkFlowReset("BLFeeAudit", billno, USERID);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(billno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
WorkResult = WorkFlowDAL.WorkFlowReset("BLFeeAudit", billno, USERID);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
|
|
|
WorkResult = WorkFlowDAL.WorkFlowReset("OpFeeAudit", billno, USERID);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(billno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WorkResult = WorkFlowDAL.WorkFlowReset("YjFeefyAudit", billno, USERID);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(billno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "撤销提交错误!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
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 Audit(String optype, String USERID, String bill, string mblno, string bsno, string WorkFlowstr,string worktype="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (worktype == "BLAUDIT") WorkFlowstr = "BLFeeAudit";
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
|
|
|
var defcustname = "";
|
|
|
var ORDERCREATEOPFEE = MsSysParamSetDAL.GetData("PARAMNAME='ORDERCREATEOPFEE'");
|
|
|
if (ORDERCREATEOPFEE.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
var CREATEOPFEECUST = MsSysParamSetDAL.GetData("PARAMNAME='CREATEOPFEECUST'");
|
|
|
defcustname = CREATEOPFEECUST.PARAMVALUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
//if (optype == "OpCtnBsCard" || optype == "罐箱业务卡")
|
|
|
//{
|
|
|
// var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0,AUDITOPERATOR='" + USERID + "',AUDITDATE=@AUDITDATE 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, billno);
|
|
|
// db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
// Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, billno, USERID, mblno, bsno, "../MvcShipping/MsOpSeae/PiLiangFeeEdit");
|
|
|
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, billno, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true) WorkResult = WorkFlowDAL.InsertWorkFlowDo("OpFeeAudit", billno, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true) WorkResult = WorkFlowDAL.InsertWorkFlowDo("BLFeeAudit", billno, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//出库业务产生的费用还可能是海运进口业务的
|
|
|
if (optype == "wms_out")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeSeaiRecvPayAudit", billno, USERID, tran, mblno, bsno, "");
|
|
|
}
|
|
|
|
|
|
if (WorkResult.Success == true )
|
|
|
{
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0,AUDITOPERATOR='" + USERID + "',AUDITDATE=@AUDITDATE 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, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (ORDERCREATEOPFEE.PARAMVALUE == "1")
|
|
|
{
|
|
|
var cmdinsert = db.GetSqlStringCommand("INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
+ " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,JKGID) "
|
|
|
+ " SELECT NEWID(), BSNO, 2, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE,'"+defcustname+"' CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,(SELECT TOP 1 GID FROM [user] WHERE SHOWNAME=(SELECT OP FROM V_OP_BS WHERE BSNO=CH_FEE.BSNO)) ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
+ " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,GID FROM CH_FEE WHERE GID='" + billno+ "' AND FEETYPE=1 AND ISCRMORDERFEE=1 and ISNULL(ISOPEN,0)<>1");
|
|
|
db.ExecuteNonQuery(cmdinsert, tran);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set AUDITOPERATOR='" + USERID + "',AUDITDATE=@AUDITDATE 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, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误!";
|
|
|
//tran.Rollback();
|
|
|
//return result;
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "审核成功";
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
var AuditAutoLock = MsSysParamSetDAL.GetData("PARAMNAME='AuditAutoLock'");
|
|
|
if (AuditAutoLock.PARAMVALUE == "1"&& bsno!="")
|
|
|
{
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
Chfee_AuditDAL.UpLock(bsno, optype);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
public static DBResult AuditList(String optype, String USERID, List<MsChFee> billList, string mblno, string bsno, string WorkFlowstr, string worktype = "")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (worktype == "BLAUDIT") WorkFlowstr = "BLFeeAudit";
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
|
|
|
var defcustname = "";
|
|
|
var ORDERCREATEOPFEE = MsSysParamSetDAL.GetData("PARAMNAME='ORDERCREATEOPFEE'");
|
|
|
if (ORDERCREATEOPFEE.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
var CREATEOPFEECUST = MsSysParamSetDAL.GetData("PARAMNAME='CREATEOPFEECUST'");
|
|
|
defcustname = CREATEOPFEECUST.PARAMVALUE;
|
|
|
}
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
|
|
|
var WorkFlow = "";
|
|
|
if (bill.IsOpen == "True" || bill.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlow, bill.GId, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true) WorkResult = WorkFlowDAL.InsertWorkFlowDo("OpFeeAudit", bill.GId, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true) WorkResult = WorkFlowDAL.InsertWorkFlowDo("BLFeeAudit", bill.GId, USERID, tran, mblno, bsno, "");
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//入库或出库业务产生的费用还可能是海运进口业务的
|
|
|
if(optype=="wms_out"|| optype == "wms")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeSeaiRecvPayAudit", bill.GId, USERID, tran, mblno, bsno, "");
|
|
|
}
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//出入库内的费用 进了 综合应收应付费用工作流 但是存在这样的可能:这个费用的父节点是海运进口,从海运进口业务下提交费用导致optype=opseai
|
|
|
if (optype == "op_seai")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeOpOpOtherRecvPayAudit", bill.GId, USERID, tran, mblno, bsno, "");
|
|
|
}
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0,AUDITOPERATOR='" + USERID + "',AUDITDATE=@AUDITDATE 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);
|
|
|
|
|
|
if (ORDERCREATEOPFEE.PARAMVALUE == "1")
|
|
|
{
|
|
|
var cmdinsert = db.GetSqlStringCommand("INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
+ " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,JKGID) "
|
|
|
+ " SELECT NEWID(), BSNO, 2, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE,'" + defcustname + "', UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,(SELECT TOP 1 GID FROM [user] WHERE SHOWNAME=(SELECT OP FROM V_OP_BS WHERE BSNO=CH_FEE.BSNO)) ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
+ " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,GID FROM CH_FEE WHERE GID='" + bill.GId + "' AND FEETYPE=1 AND ISCRMORDERFEE=1 and ISNULL(ISOPEN,0)<>1 ");
|
|
|
db.ExecuteNonQuery(cmdinsert, tran);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set AUDITOPERATOR='" + USERID + "',AUDITDATE=@AUDITDATE 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);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误!<" + WorkResult.Message + ">";
|
|
|
tran.Rollback();
|
|
|
}
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "审核成功";
|
|
|
tran.Commit();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误!<"+WorkResult.Message+">";
|
|
|
tran.Rollback();
|
|
|
//return result;
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
//tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误<"+e.Message+">,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
var AuditAutoLock = MsSysParamSetDAL.GetData("PARAMNAME='AuditAutoLock'");
|
|
|
if (AuditAutoLock.PARAMVALUE == "1" && bsno != "")
|
|
|
{
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
Chfee_AuditDAL.UpLock(bsno, optype);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult AuditBack(String optype, String USERID, List<MsChFee> billList, string reasean, string WorkFlowstr,string companyid,string worktype="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (worktype == "BLAUDIT") WorkFlowstr = "BLFeeAudit";
|
|
|
var WorkFlowid = "";
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeAudit";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeAudit";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard" || optype == "import_main")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOpOtherRecvPayAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeAudit";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiRecvPayAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
var i = 0;
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
result.Success = true;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE) ");
|
|
|
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
if (mblno == "")
|
|
|
mblno = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from v_op_bs where BSNO='" +bill.BsNo+ "'");
|
|
|
if (mblno == "") mblno = bill.BsNo;
|
|
|
|
|
|
var WorkFlow="";
|
|
|
if (bill.IsOpen == "True" || bill.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
|
|
|
//if (WorkFlowid == "")
|
|
|
//{
|
|
|
// string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + WorkFlow + "') "
|
|
|
// + " and GID in (select workflowID from workflow_Userpath where userid ='" + USERID + "') order by SORTNO ";
|
|
|
|
|
|
|
|
|
// DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
// if (dsworkflow != null)
|
|
|
// {
|
|
|
// if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
// {
|
|
|
// foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
// {
|
|
|
// var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
// CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + bill.BsNo + "'").Replace("[费用对象]", "'" + bill.CustomerName + "'");
|
|
|
// var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
// if (strCOUNT != "0")
|
|
|
// {
|
|
|
// WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
// continue;
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
//}
|
|
|
|
|
|
Resultmb WorkResult = null;
|
|
|
|
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from workflow_using WHERE BSNO='" + bill.GId + "'");
|
|
|
|
|
|
if (BLCOUNT != "0")
|
|
|
{
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlow, bill.GId, USERID, reasean, mblno, bill.BsNo, "", WorkFlowid);
|
|
|
if (WorkResult.Success != true)
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("BLFeeAudit", bill.GId, USERID, reasean, mblno, bill.BsNo, "", WorkFlowid);
|
|
|
if (WorkResult.Success != true)
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("OpFeeAudit", bill.GId, USERID, reasean, mblno, bill.BsNo, "", WorkFlowid);
|
|
|
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//出入库业务产生的费用还可能是海运进口业务的
|
|
|
if (optype == "wms_out"|| optype == "wms")
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("FeeSeaiRecvPayAudit", bill.GId, USERID, reasean, mblno, bill.BsNo, "");
|
|
|
}
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//出入库内的费用 进了 综合应收应付费用工作流 但是存在这样的可能:这个费用的父节点是海运进口,从海运进口业务下提交费用导致optype=opseai
|
|
|
if (optype == "op_seai")
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("FeeOpOpOtherRecvPayAudit", bill.GId, USERID, reasean, mblno, bill.BsNo, "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (BLCOUNT == "0"||WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=1,REASON='" + reasean + "' where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, bill.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 6);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, "");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, bill.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, bill.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, bill.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, bill.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, bill.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, bill.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, bill.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, bill.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, bill.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, bill.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, bill.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, bill.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, bill.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, USERID);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, "");
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, bill.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, bill.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, bill.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, bill.TaxUnitPrice);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
i = i + 1;
|
|
|
result.Success = WorkResult.Success;
|
|
|
result.Message = WorkResult.Message;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "驳回提交成功";
|
|
|
tran.Commit();
|
|
|
}
|
|
|
else {
|
|
|
result.Success =true;
|
|
|
result.Message ="驳回完成,其中"+i.ToString()+"票驳回错误,错误信息"+ result.Message;
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "驳回提交错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static DBResult ShenModify(MsChFee NewFee, MsChFee OldFee, string userid, string optype, string companyid, string WorkFlowstr="",string issalework="",string WorkFlowid="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
var tmpWorkFlowName = WorkFlowName;
|
|
|
if (OldFee.IsOpen == "True" || OldFee.IsOpen == "1") WorkFlowName = "YjFeefyAudit";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var cmdUpdateOld =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"update ch_fee_modify set APPLYSTATUS=0 WHERE FEEID=@FEEID ");
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,ISINVOICE,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE,MANAGER,SALECORP,CUSTOMERTYPE)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@ISINVOICE,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE,@MANAGER,@SALECORP,@CUSTOMERTYPE) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET FEESTATUS=3,REASON=@REASON WHERE GID=@GID ");
|
|
|
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
|
|
|
|
|
|
|
|
|
cmdUpdateOld.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdateOld, "@FEEID", DbType.String, OldFee.GId);
|
|
|
db.ExecuteNonQuery(cmdUpdateOld, tran);
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, OldFee.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, "");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, OldFee.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, OldFee.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, OldFee.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, OldFee.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, OldFee.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, OldFee.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, OldFee.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, OldFee.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, OldFee.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, OldFee.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, OldFee.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, OldFee.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, OldFee.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@ISINVOICE", DbType.String, OldFee.IsInvoice);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, OldFee.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, OldFee.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, OldFee.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, OldFee.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, OldFee.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, OldFee.MANAGER);
|
|
|
db.AddInParameter(cmdInsert, "@SALECORP", DbType.String, OldFee.SALECORP);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERTYPE", DbType.String, OldFee.CustomerType);
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, NewFee.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 2);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, NewFee.Reason);
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, NewFee.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, NewFee.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, NewFee.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, NewFee.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, NewFee.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, NewFee.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, NewFee.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, NewFee.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, NewFee.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, NewFee.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, NewFee.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, NewFee.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, NewFee.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@ISINVOICE", DbType.String, NewFee.IsInvoice);
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, NewFee.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, NewFee.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, NewFee.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, NewFee.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, NewFee.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, NewFee.MANAGER);
|
|
|
db.AddInParameter(cmdInsert, "@SALECORP", DbType.String, NewFee.SALECORP);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERTYPE", DbType.String, NewFee.CustomerType);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
var saleid="";
|
|
|
if (mblno == "" || (issalework == "1" && saleid == ""))
|
|
|
{
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID,CUSTOMERNAME,BSSOURCE from v_op_bs where BSNO='" + OldFee.BsNo+ "'";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
mblno = dsUser.Tables[0].Rows[0]["MBLNO"].ToString();
|
|
|
if (issalework == "1")
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (mblno == "") mblno =OldFee.BsNo;
|
|
|
if (saleid == "") saleid = userid;
|
|
|
|
|
|
if (WorkFlowid == "")
|
|
|
{
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + tmpWorkFlowName + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + userid + "') order by SORTNO ";
|
|
|
DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + OldFee.BsNo + "'").Replace("[费用对象]", "'" + OldFee.CustomerName + "'").Replace("[FEEID]", "'" + OldFee.GId + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, NewFee.GId, saleid, mblno, OldFee.BsNo, "Account/Chfee_AuditBL", WorkFlowid);
|
|
|
if (WorkResult.Success != true) {
|
|
|
if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
{
|
|
|
WorkResult = WorkFlowDAL.WorkFlowStart("FeeSeaiModifyAudit", NewFee.GId, saleid, mblno, OldFee.BsNo, "Account/Chfee_AuditBL", WorkFlowid);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, bill.BSNO, USERID, bill.MBLNO, bill.BSNO, "Account/Chfee_AuditBL", WorkFlowid);
|
|
|
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, NewFee.GId);
|
|
|
db.AddInParameter(cmdUpdate, "@REASON", DbType.String, NewFee.Reason);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
if (WorkResult.islast == true) {
|
|
|
var cmdupdate = db.GetSqlStringCommand(@"update ch_fee set FEENAME=a.FEENAME,CUSTOMERNAME=a.CUSTOMERNAME,UNIT=a.UNIT,UNITPRICE=a.UNITPRICE,
|
|
|
QUANTITY=a.QUANTITY,AMOUNT=a.AMOUNT,CURRENCY=a.CURRENCY,EXCHANGERATE=a.EXCHANGERATE,REASON=a.REASON,REMARK=a.REMARK,ISINVOICE=a.ISINVOICE,ISADVANCEDPAY=a.ISADVANCEDPAY,
|
|
|
TAXRATE=a.TAXRATE,NOTAXAMOUNT=a.NOTAXAMOUNT,ACCTAXRATE=a.ACCTAXRATE,TAXUNITPRICE=a.TAXUNITPRICE,MANAGER=a.MANAGER,CUSTOMERTYPE=a.CUSTOMERTYPE,FEESTATUS=0
|
|
|
from ch_fee left join ch_fee_modify a on (a.FEEID=ch_fee.GID and a.APPLYSTATUS=1 AND a.APPLYTYPE=2 ) where ch_fee.GID=@GID");
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, NewFee.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
if (NewFee.Currency != "RMB" && (NewFee.FeeName == "预付款" || NewFee.FeeName == "尾款" || NewFee.FeeName == "购货款"))
|
|
|
{
|
|
|
InsertImportPayRecord(NewFee, userid, db, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String, NewFee.GId);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, userid);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "申请修改出现错误,请重试或联系系统管理员";
|
|
|
return result;
|
|
|
}
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请修改出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
internal static DBResult ShenDelete(MsChFee OldFee, string userid, string optype, string companyid, string WorkFlowstr = "", string issalework="",string WorkFlowid="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
if (OldFee.IsOpen == "True" || OldFee.IsOpen == "1") WorkFlowName = "YjFeefyAudit";
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE,MANAGER)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE,@MANAGER) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET FEESTATUS=4,REASON=@REASON WHERE GID=@GID ");
|
|
|
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, OldFee.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 3);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, OldFee.Reason);
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, OldFee.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, OldFee.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, OldFee.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, OldFee.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, OldFee.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, OldFee.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, OldFee.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, OldFee.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, OldFee.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, OldFee.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, OldFee.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, OldFee.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, OldFee.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, OldFee.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, OldFee.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, OldFee.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, OldFee.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, OldFee.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, OldFee.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
//{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
var saleid = "";
|
|
|
if (mblno == "" || (issalework == "1" && saleid == ""))
|
|
|
{
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID from v_op_bs where BSNO='" + OldFee.BsNo + "'";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
mblno = dsUser.Tables[0].Rows[0]["MBLNO"].ToString();
|
|
|
if (issalework == "1")
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (mblno == "") mblno = OldFee.BsNo;
|
|
|
if (saleid == "") saleid = userid;
|
|
|
|
|
|
var WorkFlow = "";
|
|
|
if (OldFee.IsOpen == "True" || OldFee.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
|
|
|
|
|
|
if (WorkFlowid == "")
|
|
|
{
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + WorkFlow + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + userid + "') order by SORTNO ";
|
|
|
DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + OldFee.BsNo + "'").Replace("[费用对象]", "'" + OldFee.CustomerName + "'").Replace("[FEEID]", "'" + OldFee.GId + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, OldFee.GId, saleid, mblno, OldFee.BsNo, "", WorkFlowid);
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
{
|
|
|
WorkResult = WorkFlowDAL.WorkFlowStart("FeeSeaiModifyAudit", OldFee.GId, saleid, mblno, OldFee.BsNo, "", WorkFlowid);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, OldFee.GId);
|
|
|
db.AddInParameter(cmdUpdate, "@REASON", DbType.String, OldFee.Reason);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
if (WorkResult.islast==true){
|
|
|
var cmdupdate = db.GetSqlStringCommand("delete from ch_fee where GID=@GID");
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, OldFee.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(OldFee.GId, db, tran);
|
|
|
}
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String, OldFee.GId);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, userid);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请删除出现错误," + WorkResult.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请删除成功";
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请删除出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请删除成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
internal static DBResult ShenDeleteList(MsChFee OldFee,List<MsChFee> FeeList, string userid, string optype, string companyid, string WorkFlowstr = "", string issalework = "", string WorkFlowid = "")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//}
|
|
|
//if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//}
|
|
|
//if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//}
|
|
|
//if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//}
|
|
|
//if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//}
|
|
|
//if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//}
|
|
|
//if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//}
|
|
|
//if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
if (OldFee.IsOpen == "True" || OldFee.IsOpen == "1") WorkFlowName = "YjFeefyAudit";
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE,MANAGER)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE,@MANAGER) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET FEESTATUS=4,REASON=@REASON WHERE GID=@GID ");
|
|
|
|
|
|
foreach (var FeeItem in FeeList)
|
|
|
{
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, FeeItem.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 3);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, OldFee.Reason);
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, FeeItem.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, FeeItem.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, FeeItem.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, FeeItem.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, FeeItem.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, FeeItem.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, FeeItem.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, FeeItem.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, FeeItem.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, FeeItem.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, FeeItem.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, FeeItem.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, FeeItem.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, FeeItem.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, FeeItem.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, FeeItem.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, FeeItem.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, FeeItem.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, FeeItem.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
//{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
var saleid = "";
|
|
|
if (mblno == "" || (issalework == "1" && saleid == ""))
|
|
|
{
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID from v_op_bs where BSNO='" + OldFee.BsNo + "'";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
mblno = dsUser.Tables[0].Rows[0]["MBLNO"].ToString();
|
|
|
if (issalework == "1")
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (mblno == "") mblno = FeeItem.BsNo;
|
|
|
if (saleid == "") saleid = userid;
|
|
|
|
|
|
var WorkFlow = "";
|
|
|
if (FeeItem.IsOpen == "True" || FeeItem.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
|
|
|
|
|
|
if (WorkFlowid == "")
|
|
|
{
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + WorkFlow + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + userid + "') order by SORTNO ";
|
|
|
DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + FeeItem.BsNo + "'").Replace("[费用对象]", "'" + FeeItem.CustomerName + "'").Replace("[FEEID]", "'" + FeeItem.GId + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, FeeItem.GId, saleid, mblno, FeeItem.BsNo, "", WorkFlowid);
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
{
|
|
|
WorkResult = WorkFlowDAL.WorkFlowStart("FeeSeaiModifyAudit", FeeItem.GId, saleid, mblno, FeeItem.BsNo, "", WorkFlowid);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, FeeItem.GId);
|
|
|
db.AddInParameter(cmdUpdate, "@REASON", DbType.String, OldFee.Reason);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("delete from ch_fee where GID=@GID");
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, FeeItem.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(FeeItem.GId, db, tran);
|
|
|
}
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String, FeeItem.GId);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, userid);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请删除出现错误," + WorkResult.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请删除成功";
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请删除出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请删除成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
internal static DBResult CancelShen(string Feeid, string optype, string userid, string WorkFlowstr = "", string issalework="", string isopen = "")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_Seae" || optype == "op_SeaeOrder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_Aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_Bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
if (isopen == "True" || isopen == "1") WorkFlowName = "YjFeefyAudit";
|
|
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var cmddelete =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"update ch_fee_modify set applystatus=7 WHERE FeeID=@Feeid and applystatus=1 ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET FEESTATUS=0 WHERE GID=@GID ");
|
|
|
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// cmddelete.Parameters.Clear();
|
|
|
// db.AddInParameter(cmddelete, "@Feeid", DbType.String, Feeid);
|
|
|
// db.ExecuteNonQuery(cmddelete, tran);
|
|
|
|
|
|
// cmdUpdate.Parameters.Clear();
|
|
|
// db.AddInParameter(cmdUpdate, "@GID", DbType.String, Feeid);
|
|
|
// db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
|
|
|
var saleid = "";
|
|
|
if (saleid == "" && issalework == "1")
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string lsSQLuser = "select top 1 MBLNO,(SELECT GID from [user] where SHOWNAME=v_op_bs.SALE) SALEID from v_op_bs where BSNO in (select bsno from ch_fee where GID='" + Feeid + "')";
|
|
|
DataSet dsUser = T_ALL_DA.GetAllSQL(lsSQLuser);
|
|
|
if (dsUser != null)
|
|
|
{
|
|
|
if (dsUser.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
saleid = dsUser.Tables[0].Rows[0]["SALEID"].ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (saleid == "") saleid = userid;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, Feeid, saleid);
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
cmddelete.Parameters.Clear();
|
|
|
db.AddInParameter(cmddelete, "@Feeid", DbType.String, Feeid);
|
|
|
db.ExecuteNonQuery(cmddelete, tran);
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, Feeid);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请取消出现错误," + WorkResult.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请取消成功";
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请取消出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请取消成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult AuditShen(string optype, string USERID, string bill, int Feestatus, string bsno, string WorkFlowstr)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
//var dataList = GetModifyData(billno);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
if (mblno == "")
|
|
|
mblno = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from v_op_bs where BSNO='" + bsno + "'");
|
|
|
if (mblno == "") mblno = bsno;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, billno, USERID, mblno,bsno, "");
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//入库或出库业务产生的费用还可能是海运进口业务的
|
|
|
if (optype == "wms_out" || optype == "wms")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeSeaiRecvPayAudit", billno, USERID,mblno, bsno, "");
|
|
|
}
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//出入库内的费用 进了 综合应收应付费用工作流 但是存在这样的可能:这个费用的父节点是海运进口,从海运进口业务下提交费用导致optype=opseai
|
|
|
if (optype == "op_seai")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeOpOpOtherRecvPayAudit", billno, USERID, mblno, bsno, "");
|
|
|
}
|
|
|
|
|
|
if (WorkResult.Success == true && WorkResult.islast == true)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (Feestatus == 3)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(@"update ch_fee set FEENAME=a.FEENAME,CUSTOMERNAME=a.CUSTOMERNAME,UNIT=a.UNIT,UNITPRICE=a.UNITPRICE,
|
|
|
QUANTITY=a.QUANTITY,AMOUNT=a.AMOUNT,CURRENCY=a.CURRENCY,EXCHANGERATE=a.EXCHANGERATE,REASON=a.REASON,REMARK=a.REMARK,ISINVOICE=a.ISINVOICE,ISADVANCEDPAY=a.ISADVANCEDPAY,
|
|
|
TAXRATE=a.TAXRATE,NOTAXAMOUNT=a.NOTAXAMOUNT,ACCTAXRATE=a.ACCTAXRATE,TAXUNITPRICE=a.TAXUNITPRICE,MANAGER=a.MANAGER,SALECORP=a.SALECORP,CUSTOMERTYPE=a.CUSTOMERTYPE,FEESTATUS=0,MODIFIEDUSER=a.AUDITUSER,MODIFIEDTIME=GETDATE()
|
|
|
from ch_fee left join ch_fee_modify a on (a.FEEID=ch_fee.GID and a.APPLYSTATUS=1 AND a.APPLYTYPE=2 ) where ch_fee.FeeStatus=3 and ch_fee.GID=@GID");
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (Feestatus == 4)
|
|
|
{
|
|
|
|
|
|
var cmdupdate2 = db.GetSqlStringCommand("update ch_fee set WmsOutBsNo='' where GID IN (SELECT WmsOutBsNo FROM CH_FEE WHERE GID=@GID)");
|
|
|
|
|
|
|
|
|
cmdupdate2.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate2, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate2, tran);
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("delete from ch_fee where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(billno, db, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String, billno);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, USERID);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "批准申请错误!";
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "批准申请成功";
|
|
|
tran.Commit();
|
|
|
p_op_gain(bsno, USERID);
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "批准申请错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult AuditShenNew(string optype, string USERID, List<MsChFee> billList, string WorkFlowstr)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
//var dataList = GetModifyData(billno);
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
if (mblno == "")
|
|
|
mblno = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from v_op_bs where BSNO='" + bill.BsNo+ "'");
|
|
|
if (mblno == "") mblno = bill.BsNo;
|
|
|
var WorkFlow = "";
|
|
|
if (bill.IsOpen == "True" || bill.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlow, bill.GId, USERID, mblno, bill.BsNo, "");
|
|
|
if (WorkResult.Success == false) {
|
|
|
if (WorkFlowName == "FeeSeaiModifyAudit")
|
|
|
{//可能是从仓储模块生成到海运出口下面的费用 在仓储模块下提交修改 则工作流应为/109 FeeOpOtherModifyAudit 综合业务信息费用修改审核/
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeOpOtherModifyAudit", bill.GId, USERID, mblno, bill.BsNo, "");
|
|
|
}
|
|
|
}
|
|
|
if (WorkResult.Success != true)
|
|
|
{
|
|
|
//入库或出库业务产生的费用还可能是海运进口业务的
|
|
|
if (optype == "wms_out" || optype == "wms")
|
|
|
WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeSeaiRecvPayAudit", bill.GId, USERID, mblno, bill.BsNo, "");
|
|
|
}
|
|
|
|
|
|
if (WorkResult.Success == true && WorkResult.islast == true)
|
|
|
{
|
|
|
|
|
|
if (bill.FeeStatus == 3)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(@"update ch_fee set FEENAME=a.FEENAME,CUSTOMERNAME=a.CUSTOMERNAME,UNIT=a.UNIT,UNITPRICE=a.UNITPRICE,
|
|
|
QUANTITY=a.QUANTITY,AMOUNT=a.AMOUNT,CURRENCY=a.CURRENCY,EXCHANGERATE=a.EXCHANGERATE,REASON=a.REASON,REMARK=a.REMARK,ISINVOICE=a.ISINVOICE,ISADVANCEDPAY=a.ISADVANCEDPAY,
|
|
|
TAXRATE=a.TAXRATE,NOTAXAMOUNT=a.NOTAXAMOUNT,ACCTAXRATE=a.ACCTAXRATE,TAXUNITPRICE=a.TAXUNITPRICE,MANAGER=a.MANAGER,SALECORP=a.SALECORP,CUSTOMERTYPE=a.CUSTOMERTYPE,FEESTATUS=0,MODIFIEDUSER=a.AUDITUSER,MODIFIEDTIME=GETDATE()
|
|
|
from ch_fee left join ch_fee_modify a on (a.FEEID=ch_fee.GID and a.APPLYSTATUS=1 AND a.APPLYTYPE=2 ) where ch_fee.FeeStatus=3 and ch_fee.GID=@GID");
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
if (bill.Currency != "RMB" && (bill.FeeName == "预付款" || bill.FeeName == "尾款" || bill.FeeName == "购货款"))
|
|
|
{
|
|
|
InsertImportPayRecord(bill, USERID, db, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (bill.FeeStatus == 4)
|
|
|
{
|
|
|
|
|
|
var cmdupdate2 = db.GetSqlStringCommand("update ch_fee set WmsOutBsNo='' where GID IN (SELECT WmsOutBsNo FROM CH_FEE WHERE GID=@GID)");
|
|
|
|
|
|
|
|
|
cmdupdate2.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate2, "@GID", DbType.String, bill.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate2, tran);
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("delete from ch_fee where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
if (optype == "import_main")
|
|
|
{
|
|
|
DeleteImportPayRecord(bill.GId, db, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=2,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String, bill.GId);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, USERID);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
{
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "批准申请错误!";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "批准申请成功";
|
|
|
tran.Commit();
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "批准申请错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult AuditBackShen(String optype, String USERID, List<MsChFee> billList, string reasean, string WorkFlowstr)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//var WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
|
|
|
//if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_seai")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
|
|
|
//} if (optype == "op_aire")
|
|
|
//{
|
|
|
// WorkFlowName = "AireFeeModify";
|
|
|
|
|
|
//} if (optype == "op_airi")
|
|
|
//{
|
|
|
// WorkFlowName = "AiriFeeModify";
|
|
|
|
|
|
//} if (optype == "op_apply")
|
|
|
//{
|
|
|
// WorkFlowName = "ApplyFeeModify";
|
|
|
|
|
|
//} if (optype == "op_bulk")
|
|
|
//{
|
|
|
// WorkFlowName = "BulkFeeModify";
|
|
|
//} if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// WorkFlowName = "FeeOpOtherModifyAudit";
|
|
|
//} if (optype == "op_railway")
|
|
|
//{
|
|
|
// WorkFlowName = "RailwayFeeModify";
|
|
|
//}
|
|
|
//if (optype.ToLower() == "wms" || optype.ToLower() == "wms_in" || optype.ToLower() == "wms_out")
|
|
|
//{
|
|
|
// var value = WMSNewDAL.WMSNewDAL.GetSysFeeConfig("");
|
|
|
// if (value == "1") WorkFlowName = "FeeSeaiModifyAudit";
|
|
|
//}
|
|
|
var WorkFlowName = GetWorkFlowNameByOptype_Modify(optype);
|
|
|
|
|
|
if (WorkFlowstr != "") WorkFlowName = WorkFlowstr;
|
|
|
|
|
|
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var mblno = "";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
//if (optype == "OpCtnBsCard")
|
|
|
//{
|
|
|
// var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=3,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
// cmdupdateModify.Parameters.Clear();
|
|
|
// db.AddInParameter(cmdupdateModify, "@GID", DbType.String, billno);
|
|
|
// db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, USERID);
|
|
|
// db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
// db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
|
|
|
// var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0,REASON='" + reasean + "' where GID=@GID");
|
|
|
|
|
|
|
|
|
// cmdupdate.Parameters.Clear();
|
|
|
// db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
// db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
if (mblno == "")
|
|
|
mblno = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from v_op_bs where BSNO in (select bsno from ch_fee where gid='" +bill.BsNo+ "')");
|
|
|
|
|
|
if (mblno == "") mblno = bill.BsNo;
|
|
|
var WorkFlow = "";
|
|
|
if (bill.IsOpen == "True" || bill.IsOpen == "1") WorkFlow = "YjFeefyAudit"; else WorkFlow = WorkFlowName;
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlow, bill.GId, USERID, reasean, mblno, mblno, "");
|
|
|
|
|
|
if (WorkResult.Success == false)
|
|
|
{
|
|
|
if (WorkFlowName == "FeeSeaiModifyAudit")
|
|
|
{//可能是从仓储模块生成到海运出口下面的费用 在仓储模块下提交修改 则工作流应为/109 FeeOpOtherModifyAudit 综合业务信息费用修改审核/
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("FeeOpOtherModifyAudit", bill.GId, USERID, reasean, mblno, mblno, "");
|
|
|
}
|
|
|
}
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
|
|
|
var cmdupdateModify = db.GetSqlStringCommand("update ch_fee_modify set applystatus=3,audituser=@audituser,audittime=@audittime where FEEID=@GID and applystatus=1");
|
|
|
|
|
|
|
|
|
cmdupdateModify.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdateModify, "@GID", DbType.String,bill.GId);
|
|
|
db.AddInParameter(cmdupdateModify, "@audituser", DbType.String, USERID);
|
|
|
db.AddInParameter(cmdupdateModify, "@audittime", DbType.Date, DateTime.Now);
|
|
|
db.ExecuteNonQuery(cmdupdateModify, tran);
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0,REASON='" + reasean + "' where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String,bill.GId);
|
|
|
db.ExecuteNonQuery(cmdupdate, 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 NoIvoice(String bill)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set ISINVOICE=1 where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, 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 SetIsOpen(string bill,bool isopen)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
if (isopen)
|
|
|
{
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set ISOPEN=1 where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
}
|
|
|
else {
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set ISOPEN=o where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, 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 CancelNoIvoice(String bill)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
var billList = bill.Split(',');
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var billno in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set ISINVOICE=0 where GID=@GID");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, billno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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 SubmitAuditBL(String USERID,string username, List<MsOpBill> billList, bool isbl = false, string WorkFlowstr = "", string issalework = "", string companyid = "",string SUBMITFEEBLFEELOCK="0")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
var bsno = "1";
|
|
|
var mblno = "";
|
|
|
var saleid = "";
|
|
|
var WorkFlowid = "";
|
|
|
result.Success = true;
|
|
|
var msg = "";
|
|
|
|
|
|
var WorkFlowName = "BLFeeAudit";
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
if (bill.BillFeeStatus == "2" || bill.BillFeeStatus == "1")
|
|
|
{
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "当前整票状态(已提交或审核通过)无法提交整票审核!";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (WorkFlowid == "")
|
|
|
{
|
|
|
string lsSQL = "select * FROM workflow WHERE COMPANYID='" + companyid + "' AND ISCONDITION=1 and [TYPE]=(SELECT TYPENO FROM workflow_type WHERE [NAME]='" + WorkFlowName + "') "
|
|
|
+ " and GID in (select workflowID from workflow_Userpath where userid ='" + USERID + "') order by SORTNO ";
|
|
|
DataSet dsworkflow = T_ALL_DA.GetAllSQL(lsSQL);
|
|
|
if (dsworkflow != null)
|
|
|
{
|
|
|
if (dsworkflow.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
foreach (DataRow row in dsworkflow.Tables[0].Rows)
|
|
|
{
|
|
|
var CONDITIONSQL = Convert.ToString(row["CONDITIONSQL"]);
|
|
|
CONDITIONSQL = CONDITIONSQL.Replace("[业务编号]", "'" + bill.BSNO + "'");
|
|
|
var strCOUNT = T_ALL_DA.GetStrSQL("BLCT", CONDITIONSQL);
|
|
|
if (strCOUNT != "0")
|
|
|
{
|
|
|
WorkFlowid = Convert.ToString(row["GID"]);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (WorkFlowid == "") WorkFlowid = "no";
|
|
|
|
|
|
}
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, bill.BSNO, USERID, bill.MBLNO, bill.BSNO, "Account/Chfee_AuditBL", WorkFlowid);
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
var _feeComm = "";
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
if (bill.OPTYPE == "更改单")
|
|
|
{
|
|
|
_Comm = "UPDATE OP_AMEND SET BillFeeStatus=2 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPLB == "WMS")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2 WHERE ASSOCIATEDNO=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "WMS_IN" || bill.OPLB == "WMS_OUT")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2 WHERE GID=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "crm_seaeorder")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2,BSSTATUS=1 WHERE ORDNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2,BSSTATUS=1 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
}
|
|
|
_feeComm = "update ch_fee set FEESTATUS=0 where FEESTATUS=2 AND BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPTYPE == "更改单")
|
|
|
{
|
|
|
if (SUBMITFEEBLFEELOCK == "1")
|
|
|
_Comm = "UPDATE OP_AMEND SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO";
|
|
|
else _Comm = "UPDATE OP_AMEND SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPLB == "WMS")
|
|
|
{
|
|
|
if (SUBMITFEEBLFEELOCK == "1")
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE(),FEESTATUS=1 WHERE ASSOCIATEDNO=@BSNO";
|
|
|
else _Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE ASSOCIATEDNO=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "WMS_IN" || bill.OPLB == "WMS_OUT")
|
|
|
{
|
|
|
if (SUBMITFEEBLFEELOCK == "1")
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE(),FEESTATUS=1 WHERE GID=@BSNO";
|
|
|
else _Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE GID=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "crm_seaeorder")
|
|
|
{
|
|
|
if (SUBMITFEEBLFEELOCK == "1")
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE(),FEESTATUS=1 WHERE ORDNO=@BSNO";
|
|
|
else _Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE ORDNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (SUBMITFEEBLFEELOCK == "1")
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO";
|
|
|
else _Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=1,BILLFEESTATUSTIME=GETDATE() WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
}
|
|
|
_feeComm = "update ch_fee set FEESTATUS=2 where (FEESTATUS=1 or FEESTATUS=6 or FEESTATUS=7) AND BSNO=@BSNO";
|
|
|
|
|
|
}
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmdupdatefee = db.GetSqlStringCommand(_feeComm);
|
|
|
cmdupdatefee.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdatefee, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdatefee, tran);
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "提交审核成功";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
//tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "提交审核错误<" + WorkResult.Message + ">.";
|
|
|
|
|
|
//return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isbl && result.Success != false)
|
|
|
{
|
|
|
var cmdDelete = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,COMPOP,INPUTTIME,STTYPE) values(NEWID(),'" + bsno + "','整票提交',1,'" + DateTime.Now.ToString() + "','"+username+"','" + DateTime.Now.ToString() + "','2')");
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
}
|
|
|
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
// msg = GetServiceFeeMsg(optype, bsno, db, tran);
|
|
|
}
|
|
|
|
|
|
|
|
|
//result = new DBResult();
|
|
|
//result.Success = true;
|
|
|
//result.Message = "提交审核成功";
|
|
|
//result.Data = msg;
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult CancelAuditBL(String USERID, List<MsOpBill> billList)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var WorkFlowName = "BLFeeAudit";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var saleid = "";
|
|
|
int audittotal = 0;
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
if (bill.BillFeeStatus == "2")
|
|
|
{
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "已整票审核,不允许撤销整票提交!";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
|
|
|
var WorkResult = WorkFlowDAL.WorkFlowReset("BLFeeAudit", bill.BSNO, USERID);
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
var _feeComm = "";
|
|
|
if (bill.OPTYPE == "更改单")
|
|
|
{
|
|
|
_Comm = "UPDATE OP_AMEND SET BillFeeStatus=0,BILLFEESTATUSTIME=null WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPLB == "WMS")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=0,BILLFEESTATUSTIME=null WHERE ASSOCIATEDNO=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "WMS_IN" || bill.OPLB == "WMS_OUT")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=0,BILLFEESTATUSTIME=null WHERE GID=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "crm_seaeorder")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=0,BILLFEESTATUSTIME=null WHERE ORDNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=0,BILLFEESTATUSTIME=null,FEESTATUS=0 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
}
|
|
|
_feeComm = "update ch_fee set FEESTATUS=1 where FEESTATUS=2 AND BSNO=@BSNO";
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmdupdatefee = db.GetSqlStringCommand(_feeComm);
|
|
|
cmdupdatefee.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdatefee, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdatefee, tran);
|
|
|
|
|
|
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"update op_audit set SORT=0 where bsno='" + bill.BSNO + "'");
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (WorkResult.totalCount == 1)
|
|
|
{
|
|
|
audittotal++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "撤销提交成功";
|
|
|
if (audittotal != 0)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "在审核流程中部分审核的业务,不允许撤销提交";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception E)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "撤销提交错误,请重试或联系系统管理员"+E.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult AuditListBL(String USERID, List<MsOpBill> billList, string companyid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var WorkFlowName = "BLFeeAudit";
|
|
|
|
|
|
var defcustname = "";
|
|
|
var ORDERCREATEOPFEE = MsSysParamSetDAL.GetData("PARAMNAME='ORDERCREATEOPFEE'");
|
|
|
if (ORDERCREATEOPFEE.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
var CREATEOPFEECUST = MsSysParamSetDAL.GetData("PARAMNAME='CREATEOPFEECUST'");
|
|
|
defcustname = CREATEOPFEECUST.PARAMVALUE;
|
|
|
}
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo("BLFeeAudit", bill.BSNO, USERID, tran, bill.MBLNO, bill.BSNO, "");
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
var _feeComm = "";
|
|
|
if (WorkResult.islast == true)
|
|
|
{
|
|
|
//var period = ChMonthCloseDAL.ChMonthCloseDAL.GetData("", companyid);
|
|
|
|
|
|
//string strCwACCDATE = period.PERIOD;
|
|
|
if (bill.OPTYPE == "更改单")
|
|
|
{
|
|
|
_Comm = "UPDATE OP_AMEND SET BillFeeStatus=2,FEESTATUS=1 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPLB == "WMS")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2 WHERE ASSOCIATEDNO=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "WMS_IN" || bill.OPLB == "WMS_OUT")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2 WHERE GID=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "crm_seaeorder")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2 WHERE ORDNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=2,FEESTATUS=1 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
}
|
|
|
_feeComm = "update ch_fee set FEESTATUS=0 where FEESTATUS=2 AND BSNO=@BSNO";
|
|
|
var _feeComm2 = "update ch_fee set AUDITOPERATOR='" + USERID + "',AUDITDATE=GETDATE() where BSNO=@BSNO";
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmdupdatefee = db.GetSqlStringCommand(_feeComm);
|
|
|
cmdupdatefee.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdatefee, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdatefee, tran);
|
|
|
var cmdupdatefee2 = db.GetSqlStringCommand(_feeComm2);
|
|
|
cmdupdatefee2.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdatefee2, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdatefee2, tran);
|
|
|
|
|
|
var cmdUpdate = db.GetSqlStringCommand(
|
|
|
@"if (select bsno from op_close where bsno='" + bill.BSNO + "') is null insert into op_close values(newid(),'" + bill.BSNO + "',null,null,null,null,null"
|
|
|
+ ",1,1) else update op_close set DRCLOSE=1,CRCLOSE=1"
|
|
|
+ " where BSNO='" + bill.BSNO + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
//if ((bill.OPLB == "crm_seaeorder") && (ORDERCREATEOPFEE.PARAMVALUE == "1"))
|
|
|
//{
|
|
|
// var cmdinsert = db.GetSqlStringCommand("INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
// + " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
// + " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,JKGID) "
|
|
|
// + " SELECT NEWID(), BSNO=(SELECT TOP 1 BSNO FROM crm_seaeorder WHERE ORDNO='" + bill.BSNO + "'), 2, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE,'" + defcustname + "', UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
|
|
|
// + " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,(SELECT TOP 1 GID FROM [user] WHERE SHOWNAME=(SELECT OP FROM V_OP_BS WHERE BSNO=CH_FEE.BSNO)) ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
|
|
|
// + " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,AUDITOPERATOR,AUDITDATE,SALECORP,GID FROM CH_FEE WHERE BSNO='" + bill.BSNO + "' "
|
|
|
// + " AND FEETYPE=1 AND ISCRMORDERFEE=1 and ISNULL(ISOPEN,0)<>1 AND GID NOT IN (SELECT JKGID FROM ch_fee WHERE BSNO=(SELECT TOP 1 BSNO FROM crm_seaeorder WHERE ORDNO='" + bill.BSNO + "') ) ");
|
|
|
|
|
|
// db.ExecuteNonQuery(cmdinsert, tran);
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "审核错误!";
|
|
|
//tran.Rollback();
|
|
|
//return result;
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
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 AuditBackBL(String USERID, List<MsOpBill> billList, string reason,string username,string tz="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var WorkFlowName = "BLFeeAudit";
|
|
|
|
|
|
var i = 0;
|
|
|
var mblno = "";
|
|
|
result.Success = true;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
{
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = null;
|
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo("BLFeeAudit", bill.BSNO, USERID, reason, bill.MBLNO, bill.BSNO, "", "");
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
{
|
|
|
var _Comm = "";
|
|
|
var _feeComm = "";
|
|
|
if (bill.OPTYPE == "更改单")
|
|
|
{
|
|
|
_Comm = "UPDATE OP_AMEND SET BillFeeStatus=4,BILLFEESTATUSTIME=null WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (bill.OPLB == "WMS")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=4,BILLFEESTATUSTIME=null WHERE ASSOCIATEDNO=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "WMS_IN" || bill.OPLB == "WMS_OUT")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=4,BILLFEESTATUSTIME=null WHERE GID=@BSNO";
|
|
|
}
|
|
|
else if (bill.OPLB == "crm_seaeorder")
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=4,BILLFEESTATUSTIME=null,BSSTATUS=0 WHERE ORDNO=@BSNO";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Comm = "UPDATE " + bill.OPLB + " SET BillFeeStatus=4,BILLFEESTATUSTIME=null,BSSTATUS=0,FEESTATUS=0 WHERE BSNO=@BSNO";
|
|
|
}
|
|
|
}
|
|
|
_feeComm = "update ch_fee set FEESTATUS=6,REASON=@REASON where FEESTATUS=2 AND BSNO=@BSNO";
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmdupdatefee = db.GetSqlStringCommand(_feeComm);
|
|
|
cmdupdatefee.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdatefee, "@REASON", DbType.String, "整票驳回原因:" + reason);
|
|
|
db.AddInParameter(cmdupdatefee, "@BSNO", DbType.String, bill.BSNO);
|
|
|
db.ExecuteNonQuery(cmdupdatefee, tran);
|
|
|
|
|
|
var cmdUpdate = db.GetSqlStringCommand(
|
|
|
@" update op_close set CRCLOSE=0,DRCLOSE=0"
|
|
|
+ " where BSNO='" + bill.BSNO + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"update op_audit set SORT=0 where bsno='" + bill.BSNO + "'");
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
i = i + 1;
|
|
|
result.Success = WorkResult.Success;
|
|
|
result.Message = WorkResult.Message;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "驳回提交成功";
|
|
|
tran.Commit();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = true;
|
|
|
result.Message = "驳回完成,其中" + i.ToString() + "票驳回错误,错误信息" + result.Message;
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "驳回提交错误,请重试或联系系统管理员" + e.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult PiliangAudit(string optype, string bsno, string USERID, string USERNAME, string COMPANYID, string workflowstr, string worktype = "",string MBLNO="",string feesql="")
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var modAuditOnlyFeeDr=MsBaseInfoDAL.MsBaseInfoDAL.GetUserModuleEnable("modAuditOnlyFeeDr",USERID);
|
|
|
var modAuditOnlyFeeCr = MsBaseInfoDAL.MsBaseInfoDAL.GetUserModuleEnable("modAuditOnlyFeeCr", USERID);
|
|
|
|
|
|
var feeListdr = new List<MsChFee>();
|
|
|
var feeListcr = new List<MsChFee>();
|
|
|
if (!modAuditOnlyFeeCr)
|
|
|
feeListdr = GetDataList(bsno, 1, optype, "1", feesql, USERID, USERNAME, COMPANYID, worktype);
|
|
|
if (!modAuditOnlyFeeDr)
|
|
|
feeListcr = GetDataList(bsno, 2, optype, "1", feesql, USERID, USERNAME, COMPANYID, worktype);
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var fee in feeListdr)
|
|
|
{
|
|
|
|
|
|
if (fee.IsAudit != "0") {
|
|
|
if (fee.IsOpen == "1" || fee.IsOpen == "True")
|
|
|
{
|
|
|
Audit(optype, USERID, fee.GId, MBLNO, fee.BsNo, "YjFeefyAudit");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (fee.FeeStatus == 2)
|
|
|
{
|
|
|
Audit(optype, USERID, fee.GId, MBLNO, fee.BsNo, workflowstr, worktype);
|
|
|
}
|
|
|
else if (fee.FeeStatus == 3 || fee.FeeStatus == 4)
|
|
|
{
|
|
|
AuditShen(optype, USERID, fee.GId, fee.FeeStatus, fee.BsNo, workflowstr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
foreach (var fee in feeListcr)
|
|
|
{
|
|
|
|
|
|
if (fee.IsAudit != "0")
|
|
|
{
|
|
|
if (fee.IsOpen == "1" || fee.IsOpen == "True")
|
|
|
{
|
|
|
Audit(optype, USERID, fee.GId, MBLNO, fee.BsNo, "YjFeefyAudit");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (fee.FeeStatus == 2)
|
|
|
{
|
|
|
Audit(optype, USERID, fee.GId, MBLNO, fee.BsNo, workflowstr, worktype);
|
|
|
}
|
|
|
else if (fee.FeeStatus == 3 || fee.FeeStatus == 4)
|
|
|
{
|
|
|
AuditShen(optype, USERID, fee.GId, fee.FeeStatus, fee.BsNo, workflowstr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ShenNewCustName(List<MsChFee> FeeList,string NewCustName,string userid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE,MANAGER)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE,@MANAGER) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET CUSTOMERNAME=@CUSTOMERNAME WHERE GID=@GID ");
|
|
|
|
|
|
|
|
|
if (FeeList != null)
|
|
|
{
|
|
|
foreach (var enumValue in FeeList)
|
|
|
{
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, enumValue.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, "");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, enumValue.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, enumValue.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, enumValue.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, enumValue.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, enumValue.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, enumValue.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, enumValue.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, enumValue.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, enumValue.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, enumValue.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, enumValue.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, enumValue.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, enumValue.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, enumValue.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 2);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String,"修改费用对象");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, enumValue.GId);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String,NewCustName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, enumValue.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, enumValue.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, enumValue.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, enumValue.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, enumValue.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, enumValue.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, enumValue.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 2);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, enumValue.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, enumValue.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, enumValue.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, enumValue.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, enumValue.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GId);
|
|
|
db.AddInParameter(cmdUpdate, "@CUSTOMERNAME", DbType.String,NewCustName);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请修改出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult ShenCF(MsChFee Fee, List<FeeCF> FeeCfList, string userid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var FeeList = new List<MsChFee>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into ch_fee_modify (GID,TYPE,APPLYTYPE,REASON,FEEID,BSNO,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,
|
|
|
AMOUNT,CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,APPLYUSER,APPLYTIME,
|
|
|
APPLYSTATUS,REMARK,GROUPID,TAXRATE,NOTAXAMOUNT,ACCTAXRATE,TAXUNITPRICE,MANAGER)
|
|
|
values (@GID,@TYPE,@APPLYTYPE,@REASON,@FEEID,@BSNO,@FEENAME,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,
|
|
|
@AMOUNT,@CURRENCY,@FRT,@COMMISSIONRATE,@EXCHANGERATE,@ISADVANCEDPAY,@APPLYUSER,@APPLYTIME,
|
|
|
@APPLYSTATUS,@REMARK,@GROUPID,@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@TAXUNITPRICE,@MANAGER) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"UPDATE CH_FEE SET CUSTOMERNAME=@CUSTOMERNAME,QUANTITY=@QUANTITY,AMOUNT=@AMOUNT,NOTAXAMOUNT=@NOTAXAMOUNT,UNITPRICE=@UNITPRICE,TAXUNITPRICE=@TAXUNITPRICE WHERE GID=@GID ");
|
|
|
|
|
|
int feecount = 0;
|
|
|
|
|
|
if (FeeCfList != null)
|
|
|
{
|
|
|
foreach (var enumValue in FeeCfList)
|
|
|
{
|
|
|
|
|
|
var GROUPID = Guid.NewGuid().ToString();
|
|
|
var FEEID = Fee.GId;
|
|
|
if (feecount != 0)
|
|
|
{
|
|
|
FEEID = Guid.NewGuid().ToString();
|
|
|
}
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, Fee.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, "");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, FEEID);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, Fee.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, Fee.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, Fee.CustomerName);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, Fee.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, Fee.UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, Fee.Quantity);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, Fee.Amount);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, Fee.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, Fee.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, Fee.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, Fee.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, Fee.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 1);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, Fee.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, Fee.TaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, Fee.NoTaxAmount);
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, Fee.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, Fee.TaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, Fee.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
var notaxamount= Math.Round(enumValue.AMOUNT*(1+Fee.TaxRate/100), 2, MidpointRounding.AwayFromZero);
|
|
|
var UnitPrice = Math.Round(enumValue.AMOUNT /enumValue.QUANTITY, 2, MidpointRounding.AwayFromZero);
|
|
|
var notaxUnitPrice = Math.Round(notaxamount /enumValue.QUANTITY, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
db.AddInParameter(cmdInsert, "@TYPE", DbType.Int16, Fee.FeeType);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTYPE", DbType.Int16, 2);
|
|
|
db.AddInParameter(cmdInsert, "@REASON", DbType.String, "费用拆分");
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, FEEID);
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, Fee.BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, Fee.FeeName);
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.CUST);
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, Fee.Unit);
|
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, notaxUnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, enumValue.QUANTITY);
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, Fee.Currency);
|
|
|
db.AddInParameter(cmdInsert, "@FRT", DbType.String, Fee.FeeFrt);
|
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal, Fee.Commissionrate);
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, Fee.ExChangerate);
|
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.String, Fee.IsAdvancedpay);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYUSER", DbType.String, userid);
|
|
|
db.AddInParameter(cmdInsert, "@APPLYTIME", DbType.String, DateTime.Now.ToString());
|
|
|
db.AddInParameter(cmdInsert, "@APPLYSTATUS", DbType.Int16, 2);
|
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, Fee.Remark);
|
|
|
db.AddInParameter(cmdInsert, "@GROUPID", DbType.String, GROUPID);
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, Fee.TaxRate);
|
|
|
if (Fee.TaxRate == 0)
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
else {
|
|
|
db.AddInParameter(cmdInsert, "@NOTAXAMOUNT", DbType.Decimal, notaxamount);
|
|
|
|
|
|
|
|
|
}
|
|
|
db.AddInParameter(cmdInsert, "@ACCTAXRATE", DbType.Decimal, Fee.AccTaxRate);
|
|
|
db.AddInParameter(cmdInsert, "@TAXUNITPRICE", DbType.Decimal, UnitPrice);
|
|
|
db.AddInParameter(cmdInsert, "@MANAGER", DbType.String, Fee.MANAGER);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
if (feecount == 0)
|
|
|
{
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, Fee.GId);
|
|
|
db.AddInParameter(cmdUpdate, "@CUSTOMERNAME", DbType.String, enumValue.CUST);
|
|
|
db.AddInParameter(cmdUpdate, "@QUANTITY", DbType.Decimal, enumValue.QUANTITY);
|
|
|
db.AddInParameter(cmdUpdate, "@AMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
if (Fee.TaxRate == 0)
|
|
|
db.AddInParameter(cmdUpdate, "@NOTAXAMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
else
|
|
|
{
|
|
|
db.AddInParameter(cmdUpdate, "@NOTAXAMOUNT", DbType.Decimal, notaxamount);
|
|
|
|
|
|
|
|
|
}
|
|
|
db.AddInParameter(cmdUpdate, "@UNITPRICE", DbType.Decimal, notaxUnitPrice);
|
|
|
db.AddInParameter(cmdUpdate, "@TAXUNITPRICE", DbType.Decimal, UnitPrice);
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
}else
|
|
|
{
|
|
|
var NewFee = new MsChFee();
|
|
|
NewFee.FeeType = Fee.FeeType;
|
|
|
NewFee.FeeName = Fee.FeeName;
|
|
|
NewFee.CustomerType = Fee.CustomerType;
|
|
|
NewFee.Unit = Fee.Unit;
|
|
|
NewFee.FeeDescription = Fee.FeeDescription;
|
|
|
NewFee.Currency = Fee.Currency;
|
|
|
NewFee.ExChangerate = Fee.ExChangerate;
|
|
|
NewFee.Reason = Fee.Reason;
|
|
|
NewFee.Remark = Fee.Remark;
|
|
|
NewFee.Commissionrate = Fee.Commissionrate;
|
|
|
NewFee.IsOpen = Fee.IsOpen;
|
|
|
NewFee.IsAdvancedpay = Fee.IsAdvancedpay;
|
|
|
NewFee.Sort = Fee.Sort;
|
|
|
NewFee.FeeFrt = Fee.FeeFrt;
|
|
|
NewFee.TaxRate = Fee.TaxRate;
|
|
|
NewFee.AccTaxRate = Fee.AccTaxRate;
|
|
|
NewFee.WmsOutBsNo = Fee.WmsOutBsNo;
|
|
|
NewFee.PreAmount = Fee.PreAmount;
|
|
|
NewFee.INPUTMODE = Fee.INPUTMODE;
|
|
|
NewFee.IsInvoice = Fee.IsInvoice;
|
|
|
NewFee.LOCALCURR = Fee.LOCALCURR;
|
|
|
NewFee.MANAGER = Fee.MANAGER;
|
|
|
NewFee.ISACC = Fee.ISACC;
|
|
|
NewFee.GId = FEEID;
|
|
|
NewFee.BsNo = "*";
|
|
|
NewFee.CustomerName = enumValue.CUST;
|
|
|
NewFee.Amount = enumValue.AMOUNT;
|
|
|
NewFee.Quantity = enumValue.QUANTITY;
|
|
|
if (Fee.TaxRate == 0) NewFee.NoTaxAmount = enumValue.AMOUNT;
|
|
|
else NewFee.NoTaxAmount = notaxamount;
|
|
|
NewFee.TaxUnitPrice = UnitPrice;
|
|
|
NewFee.UnitPrice = notaxUnitPrice;
|
|
|
NewFee.FeeStatus = Fee.FeeStatus;
|
|
|
FeeList.Add(NewFee);
|
|
|
}
|
|
|
|
|
|
feecount = feecount + 1;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
|
if (FeeList != null && FeeList.Count != 0)
|
|
|
{
|
|
|
result = MsChFeeDAL.MsChFeeDAL.SaveFee(FeeList, Fee.BsNo, userid,"",true);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result = new DBResult();
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "申请修改出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "申请修改成功";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
public static int p_op_gain(string bsno, string userId)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
var cmd = db.GetStoredProcCommand("p_op_gain");
|
|
|
db.AddInParameter(cmd, "@con_no", DbType.String, bsno);
|
|
|
db.AddInParameter(cmd, "@userid", DbType.String, userId);
|
|
|
db.ExecuteNonQuery(cmd);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
#region 审核明细
|
|
|
|
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
|
static public List<MsOpAuditDetail> GetAuditDetailDataList(string strCondition, string sort = null)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("ADID,BSNO,SORT,ERRDATA,OPREMARK,ERRMSG,CREATEUSER,CREATETIME,AUDITTYPE,AUDITDETAILID");
|
|
|
strSql.Append(" from op_audit_detail ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by SORT ");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SetAuditDetailData(strSql);
|
|
|
}
|
|
|
|
|
|
static public MsOpAuditDetail GetAuditDetailData(string condition)
|
|
|
{
|
|
|
var list = GetAuditDetailDataList(condition);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
|
|
|
return new MsOpAuditDetail();
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<MsOpAuditDetail> SetAuditDetailData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpAuditDetail>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpAuditDetail data = new MsOpAuditDetail();
|
|
|
#region Set DB data to Object
|
|
|
data.ADID = Convert.ToString(reader["ADID"]);
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
if (reader["SORT"] != DBNull.Value)
|
|
|
data.SORT = Convert.ToInt32(reader["SORT"]);
|
|
|
data.ERRDATA = Convert.ToString(reader["ERRDATA"]);
|
|
|
data.OPREMARK = Convert.ToString(reader["OPREMARK"]);
|
|
|
data.ERRMSG = Convert.ToString(reader["ERRMSG"]);
|
|
|
data.AUDITTYPE = Convert.ToString(reader["AUDITTYPE"]);
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
data.AUDITDETAILID = Convert.ToString(reader["AUDITDETAILID"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
public static DBResult SaveUpdateAuditDetail(List<MsOpAuditDetail> bodyList, string BsNo, string username)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from op_audit_detail where BSNO='" + BsNo + "'");
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
var cmdInsert =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"insert into op_audit_detail (ADID,BSNO,SORT,ERRDATA,OPREMARK,ERRMSG,AUDITTYPE,CREATEUSER,CREATETIME,AUDITDETAILID)
|
|
|
values (@ADID,@BSNO,@SORT,@ERRDATA,@OPREMARK,@ERRMSG,@AUDITTYPE,@CREATEUSER,@CREATETIME,@AUDITDETAILID) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
|
db.GetSqlStringCommand(
|
|
|
@"update op_audit_detail set ERRDATA=@ERRDATA,OPREMARK=@OPREMARK,ERRMSG=@ERRMSG where ADID=@ADID ");
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
foreach (var enumValue in bodyList)
|
|
|
{
|
|
|
|
|
|
if (enumValue.BSNO == "*")
|
|
|
{
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
db.AddInParameter(cmdInsert, "@ADID", DbType.String, Guid.NewGuid().ToString());
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, BsNo);
|
|
|
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, enumValue.SORT);
|
|
|
db.AddInParameter(cmdInsert, "@ERRDATA", DbType.String, enumValue.ERRDATA);
|
|
|
db.AddInParameter(cmdInsert, "@OPREMARK", DbType.String, enumValue.OPREMARK);
|
|
|
db.AddInParameter(cmdInsert, "@ERRMSG", DbType.String, enumValue.ERRMSG);
|
|
|
db.AddInParameter(cmdInsert, "@AUDITTYPE", DbType.String, enumValue.AUDITTYPE);
|
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, username);
|
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
db.AddInParameter(cmdInsert, "@AUDITDETAILID", DbType.String, enumValue.AUDITDETAILID);
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
//db.AddInParameter(cmdUpdate, "@ST_ID", DbType.String, enumValue.ST_ID);
|
|
|
db.AddInParameter(cmdUpdate, "@ADID", DbType.String, enumValue.ADID);
|
|
|
db.AddInParameter(cmdUpdate, "@ERRDATA", DbType.String, enumValue.ERRDATA);
|
|
|
db.AddInParameter(cmdUpdate, "@OPREMARK", DbType.String, enumValue.OPREMARK);
|
|
|
db.AddInParameter(cmdUpdate, "@ERRMSG", DbType.String, enumValue.ERRMSG);
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DBResult SaveUpdateAudit(string shenremark, string BsNo, string username,string profitstatus="",string uptype="",int sort=0)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
if (uptype=="update")
|
|
|
{
|
|
|
if (sort == 1)
|
|
|
{
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@" update op_audit set SORT=SORT+1,AUDITUSER='" + username + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
}else if (sort == 2)
|
|
|
{
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@" update op_audit set SORT=SORT+1,AUDITUSER2='" + username + "',AUDITTIME2='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (uptype == "insert")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(profitstatus))
|
|
|
{
|
|
|
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,null,null,'"
|
|
|
+ shenremark + "','" + username + "',GETDATE(),'',null,null) else update op_audit set SUBMITUSER='" + username + "',SORT=1,SUBMITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',SHENREMARK='" + shenremark + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,null,null,'"
|
|
|
+ shenremark + "','" + username + "',GETDATE(),'" + profitstatus + "',null,null) else update op_audit set SUBMITUSER='" + username + "',SORT=1,SUBMITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',SHENREMARK='" + shenremark + "',PROFITSTATUS='" + profitstatus + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(profitstatus))
|
|
|
{
|
|
|
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,null,null,'"
|
|
|
+ shenremark + "','" + username + "',GETDATE(),'',null,null) else update op_audit set SUBMITUSER='" + username + "',SORT=SORT+1,SUBMITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',SHENREMARK='" + shenremark + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var cmdUpdateAudit = db.GetSqlStringCommand(
|
|
|
@"if (select bsno from op_audit where bsno='" + BsNo + "') is null insert into op_audit values(newid(),'" + BsNo + "',1,null,null,'"
|
|
|
+ shenremark + "','" + username + "',GETDATE(),'" + profitstatus + "',null,null) else update op_audit set SUBMITUSER='" + username + "',SORT=SORT+1,SUBMITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',SHENREMARK='" + shenremark + "',PROFITSTATUS='" + profitstatus + "' where BSNO='" + BsNo + "' ");
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateAudit, tran);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 自动费用锁定
|
|
|
|
|
|
public static DBResult UpLock(string bsno, string optype)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var ct =GetRdCount("BSNO='"+bsno+"' AND FEESTATUS NOT IN (0,8,9)");
|
|
|
if (ct != 0)
|
|
|
{
|
|
|
result.Success = true;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update " + optype + " SET FEESTATUS=1 where BSNO=@BSNO");
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bsno);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmdupdate2 = db.GetSqlStringCommand("update op_amend SET FEESTATUS=1 where BSNO=@BSNO");
|
|
|
|
|
|
|
|
|
cmdupdate2.Parameters.Clear();
|
|
|
db.AddInParameter(cmdupdate2, "@BSNO", DbType.String, bsno);
|
|
|
db.ExecuteNonQuery(cmdupdate2, 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
|
|
|
|
|
|
public static decimal GetUsdExrate(string currdate, string curr)
|
|
|
{
|
|
|
decimal result = -1;
|
|
|
|
|
|
if (currdate == "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select CODENAME,DEFAULTRATE ");
|
|
|
strSql.Append(" from code_currency where CODENAME='" + curr + "'");
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
result = Convert.ToDecimal(reader["DEFAULTRATE"]);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select CURRENCYID,VALUE ");
|
|
|
strSql.Append(" from currency_exchange ");
|
|
|
strSql.Append(" left join code_currency c on (c.GID=currency_exchange.CURRENCYID) ");
|
|
|
strSql.Append(" where c.CODENAME='" + curr + "' and STARTTIME<='" + currdate + "' and ENDTIME>='" + currdate + "'");
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
result = Convert.ToDecimal(reader["VALUE"]);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
if (result == -1)
|
|
|
{
|
|
|
|
|
|
var strSql2 = new StringBuilder();
|
|
|
strSql2.Append("Select CODENAME,DEFAULTRATE ");
|
|
|
strSql2.Append(" from code_currency where CODENAME='USD'");
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql2.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
result = Convert.ToDecimal(reader["DEFAULTRATE"]);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static DBResult GetEmailHtml(string billno, string userid, string username, string companyid,string deptname,List<MsOpAuditDetail> MsOpAuditDetail)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
var head = GetBillData("v_op_bill.BSNO='" + billno + "'");
|
|
|
if (string.IsNullOrEmpty(head.PROFITSTATUS)) {
|
|
|
result.Success = false;
|
|
|
result.Message = "无需发送邮件!";
|
|
|
return result;
|
|
|
}
|
|
|
if (head.PROFITSTATUS.IndexOf("利润过低") >= 0 || head.PROFITSTATUS.IndexOf("利润为零") >= 0
|
|
|
|| head.PROFITSTATUS.IndexOf("利润为负") >= 0 || head.PROFITSTATUS.IndexOf("不成比例") >= 0)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "无需发送邮件!";
|
|
|
return result;
|
|
|
}
|
|
|
var mailaddr = MsSysParamSetDAL.GetData("PARAMNAME='RptLrMail'").PARAMVALUE;
|
|
|
if (string.IsNullOrEmpty(mailaddr))
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "无需发送邮件!";
|
|
|
return result;
|
|
|
}
|
|
|
var profitstr = "";
|
|
|
var feettlsum = MsChFeeDAL.MsChFeeDAL.GetttlGainList("BSNO='" + head.PARENTID + "'");
|
|
|
|
|
|
|
|
|
|
|
|
var htmlfile = HttpContext.Current.Server.MapPath("../../EDIFiles/报表利润情况说明.html");
|
|
|
result.Success = true;
|
|
|
result.Message = "已发送邮件!";
|
|
|
|
|
|
if (File.Exists(htmlfile))
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var PSCUSTOMERNAME = "";
|
|
|
decimal USDHYFDR = 0;
|
|
|
decimal USDHYFCR = 0;
|
|
|
var PSTTLSTR = "";
|
|
|
int pscount = 0;
|
|
|
decimal psperttl = 0;
|
|
|
decimal psamountttl = 0;
|
|
|
var usdexrate = GetUsdExrate(DateTime.Now.ToString("yyyy-MM-dd"), "USD");
|
|
|
var DrChfeeList = MsChFeeDAL.MsChFeeDAL.GetAllDataList("BSNO in (select BSNO FROM V_OP_BILL WHERE PARENTID='" + head.BSNO + "')");
|
|
|
if (DrChfeeList != null && DrChfeeList.Count != 0)
|
|
|
{
|
|
|
foreach (var fee in DrChfeeList)
|
|
|
{
|
|
|
if (fee.FeeName == "海运费" || fee.FeeName == "HP/S") {
|
|
|
if (fee.FeeType == 1)
|
|
|
{
|
|
|
if (fee.Currency == "USD") USDHYFDR = USDHYFDR + fee.Amount;
|
|
|
else if (fee.Currency == "RMB")
|
|
|
{
|
|
|
USDHYFDR = USDHYFDR + Math.Round(fee.Amount / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
USDHYFDR = USDHYFDR + Math.Round(fee.Amount* GetUsdExrate(DateTime.Now.ToString("yyyy-MM-dd"), fee.Currency) / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (fee.Currency == "USD") USDHYFCR = USDHYFCR + fee.Amount;
|
|
|
else if (fee.Currency == "RMB")
|
|
|
{
|
|
|
USDHYFCR = USDHYFCR + Math.Round(fee.Amount / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
USDHYFCR = USDHYFCR + Math.Round(fee.Amount * GetUsdExrate(DateTime.Now.ToString("yyyy-MM-dd"), fee.Currency) / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
foreach (var fee in DrChfeeList)
|
|
|
{
|
|
|
if (fee.FeeName == "P/S")
|
|
|
{
|
|
|
pscount = pscount + 1;
|
|
|
if (string.IsNullOrEmpty(PSCUSTOMERNAME)) PSCUSTOMERNAME = fee.CustomerName;
|
|
|
else PSCUSTOMERNAME = PSCUSTOMERNAME + "," + fee.CustomerName;
|
|
|
decimal psamount = 0;
|
|
|
if (fee.Currency == "USD") {
|
|
|
if (fee.FeeType==2)
|
|
|
psamount = fee.Amount;
|
|
|
else psamount = -fee.Amount;
|
|
|
}
|
|
|
else if (fee.Currency == "RMB")
|
|
|
{
|
|
|
if (fee.FeeType == 2)
|
|
|
psamount = Math.Round(fee.Amount / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
else psamount = Math.Round(-fee.Amount / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (fee.FeeType == 2)
|
|
|
psamount = Math.Round(fee.Amount * GetUsdExrate(DateTime.Now.ToString("yyyy-MM-dd"), fee.Currency) / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
else psamount = Math.Round(-fee.Amount * GetUsdExrate(DateTime.Now.ToString("yyyy-MM-dd"), fee.Currency) / usdexrate, 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
|
}
|
|
|
psamountttl = psamountttl + psamount;
|
|
|
var psper = Math.Round(psamount / (USDHYFDR - USDHYFCR), 2, MidpointRounding.AwayFromZero);
|
|
|
psperttl = psperttl + psper;
|
|
|
PSTTLSTR = PSTTLSTR + " " + fee.CustomerName+ ":$" + psamount.ToString()+"("+ psper.ToString() + ")";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (feettlsum.TTLCR == feettlsum.NOPSTTLCR)
|
|
|
{
|
|
|
profitstr = "RMB:" + feettlsum.RMBPROFIT + " USD:" + feettlsum.USDPROFIT + " TOTAL RMB:" + feettlsum.TTLPROFIT;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
profitstr = "海运费利润:$" + (USDHYFDR - USDHYFCR) + ", 公司:$"
|
|
|
+ ((USDHYFDR - USDHYFCR) - psamountttl) + "("+ Math.Round(1 - psperttl, 2, MidpointRounding.AwayFromZero) + "),"+ PSTTLSTR + ", 整票业务利润:¥" + feettlsum.TTLPROFIT;
|
|
|
|
|
|
}
|
|
|
var profitstatus = "";
|
|
|
foreach (var detial in MsOpAuditDetail) {
|
|
|
if (detial.AUDITDETAILID== "SEA006")
|
|
|
profitstatus = profitstatus + detial.ERRMSG;
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(profitstatus)) profitstatus = head.PROFITSTATUS;
|
|
|
|
|
|
var CUSTTYPE = T_ALL_DA.GetStrSQL("CUSTTYPE", "SELECT CUSTTYPE from info_client WHERE SHORTNAME='" + head.CUSTOMERNAME+ "'");
|
|
|
|
|
|
var content = File.ReadAllText(htmlfile);
|
|
|
content = content.Replace("$OP$",deptname+"_"+ head.OP.Replace("\r\n", "<br />"));
|
|
|
content = content.Replace("$ETD$", head.ETD.Replace("\r\n", "<br />"));
|
|
|
content = content.Replace("$CUSTNO$", head.CUSTNO.Replace("\r\n", "<br />"));
|
|
|
content = content.Replace("$MBLNO$", head.MBLNO.Replace("\r\n", "<br />"));
|
|
|
content = content.Replace("$CNTRTOTAL$", head.CNTRTOTAL.Replace("\r\n", "<br />"));
|
|
|
content = content.Replace("$CUSTOMERNAME$", head.CUSTOMERNAME.Replace("\r\n", "<br />"));
|
|
|
//content = content.Replace("$ISNOFEE$", head.MBLNO);
|
|
|
//content = content.Replace("$ISCONTRACT$", head.MBLNO);
|
|
|
content = content.Replace("$CUSTTYPE$", CUSTTYPE);
|
|
|
content = content.Replace("$CARRIER$", head.CARRIER);
|
|
|
content = content.Replace("$PROFITSTATUS$", profitstatus);
|
|
|
content = content.Replace("$PROFITSTR$", profitstr);
|
|
|
content = content.Replace("$SHENREMARK$", head.SHENREMARK);
|
|
|
content = content.Replace("$PSCUSTNAME$", PSCUSTOMERNAME);
|
|
|
|
|
|
HtmlDocument htmlDoc = new HtmlDocument();
|
|
|
htmlDoc.LoadHtml(content);
|
|
|
StringWriter writer = new StringWriter();
|
|
|
htmlDoc.Save(writer);
|
|
|
string mailbody = writer.ToString();
|
|
|
var mailtopic = head.MBLNO+"_利润情况说明";
|
|
|
|
|
|
var MAILTONAME = "admin@dongshengsoft.com";
|
|
|
var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOPASSWORD = "ds!@#)(*";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOSERVER = "smtpcom.263xmail.com";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILTOPORT = "465";
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'");
|
|
|
if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE;
|
|
|
var MAILISSSL = false;
|
|
|
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILISSSL'");
|
|
|
if (PARAMVALUE.PARAMVALUE == "1") MAILISSSL = true;
|
|
|
|
|
|
|
|
|
|
|
|
var OPUSER = BasicDataRefDAL.GetUserLinkRef("u.GID='" + userid + "'", companyid);
|
|
|
if (!string.IsNullOrEmpty(OPUSER.Email)) mailaddr = mailaddr + "," + OPUSER.Email;
|
|
|
|
|
|
SendEmail se = new SendEmail(mailaddr, MAILTONAME, "", "", mailtopic, mailbody, true);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
se.SetSmtp(MAILTONAME, MAILTOPASSWORD, MAILTOSERVER, Convert.ToInt32(MAILTOPORT), MAILISSSL, System.Net.Mail.MailPriority.Normal); //必须在所有参数设置完后调用此方法
|
|
|
}
|
|
|
catch (Exception E) {
|
|
|
result.Success = false;
|
|
|
result.Message = "发送邮件发生错误!"+E.Message;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "没找到相应的邮件html模板!";
|
|
|
|
|
|
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT Count(BSNO) AS CT from ch_fee (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;
|
|
|
}
|
|
|
|
|
|
|
|
|
static private int InsertImportPayRecord(MsChFee msChFee, string USERID, Database db, DbTransaction transaction)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" delete from Import_Payment where gid='" + msChFee.GId + "' ");
|
|
|
strSql.Append(" Insert into Import_Payment (gid,amount,CURRENCY,op,buyer,seller,remark,CREATETIME,PAYTIME,FEENAME) ");
|
|
|
strSql.Append(" (select cf.gid ,cf.AMOUNT,cf.currency,'" + USERID + "',M.buyer,cf.CUSTOMERNAME,'',getdate() createtime,null,cf.FEENAME ");
|
|
|
strSql.Append(" from ch_fee cf left join import_main m on m.contractno=cf.BSNO where cf.gid='" + msChFee.GId + "') ");
|
|
|
var _count = 0;
|
|
|
// Database db = DatabaseFactory.CreateDatabase();
|
|
|
_count = db.ExecuteNonQuery(transaction,CommandType.Text, strSql.ToString());
|
|
|
return _count;
|
|
|
}
|
|
|
static private int DeleteImportPayRecord(string Feeid, Database db, DbTransaction transaction)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" delete from import_payment where gid in (select gid from ch_fee where (feename='预付款' or feename='尾款' or feename='购货款') and Currency<>'RMB' and gid= '" + Feeid + "') ");
|
|
|
|
|
|
var _count = db.ExecuteNonQuery(transaction,CommandType.Text, strSql.ToString());
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
|
|
|
private static int GetFeeStatusRecordCount(Database db, string bsNo, int feeStatus, DbTransaction transaction)
|
|
|
{
|
|
|
var cmdRejectCount = db.GetSqlStringCommand("select count(*) from ch_fee where BsNo=@BsNo and FeeStatus=@FeeStatus");
|
|
|
db.AddInParameter(cmdRejectCount, "@BsNo", DbType.String, bsNo);
|
|
|
db.AddInParameter(cmdRejectCount, "@FeeStatus", DbType.Int32, feeStatus);
|
|
|
var rejectCount = Convert.ToInt32(db.ExecuteScalar(cmdRejectCount, transaction));
|
|
|
return rejectCount;
|
|
|
}
|
|
|
|
|
|
public static string GetListRangDAStr(string tb, string userid, string usercode, 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]='modFeeAudit' 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 = " (v_op_bill.OP='" + usercode + "' OR v_op_bill.SALE='" + usercode + "' OR v_op_bill.CUSTSERVICE='" + usercode + "' OR v_op_bill.DOC='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptid = rangeDa.GetDEPTGID(userid);
|
|
|
str = " (v_op_bill.OP in (select showname from vw_user where deptgid='" + deptid + "') OR v_op_bill.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR v_op_bill.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') "
|
|
|
+ " OR v_op_bill.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR v_op_bill.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR v_op_bill.INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " (v_op_bill.OP in (select showname from vw_user where COMPANYID='" + companyid + "') OR v_op_bill.SALE in (select showname from vw_user where COMPANYID='" + companyid + "') OR v_op_bill.CUSTSERVICE in (select showname from vw_user where COMPANYID='" + companyid + "') "
|
|
|
+ " OR v_op_bill.DOC in (select showname from vw_user where COMPANYID='" + companyid + "') OR v_op_bill.FRCUSTSERVICE in (select showname from vw_user where COMPANYID='" + companyid + "') OR v_op_bill.INPUTBY in (select showname from vw_user where COMPANYID='" + companyid + "'))";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
|
|
|
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 = " (v_op_bill.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or v_op_bill.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
str = " EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (v_op_bill.OP=U.SHOWNAME OR v_op_bill.SALE=U.SHOWNAME OR v_op_bill.CUSTSERVICE=U.SHOWNAME) AND P.userid='" + userid + "' and P.AUTHORITYID='" + AUTHORITYID + "' and P.VISIBLERANGE=1) ";
|
|
|
}
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
public static string GetTruckListRangDAStr(string tb, string userid, string usercode, 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]='modFeeAudit' 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 = " (v_op_truck_bulk.OP='" + usercode + "' OR v_op_truck_bulk.SALE='" + usercode + "' OR v_op_truck_bulk.CUSTSERVICE='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (v_op_truck_bulk.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'" + " OR v_op_truck_bulk.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or v_op_truck_bulk.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'" + " OR v_op_truck_bulk.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " 1=1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
str = " 1=1 ";
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
|
|
|
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()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (v_op_truck_bulk.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or v_op_truck_bulk.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR v_op_truck_bulk.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " 1=1 ";
|
|
|
}
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static string GetRangDAStr(int type, string optype, string userid, string username, string companyid)
|
|
|
{
|
|
|
|
|
|
string str = "";
|
|
|
string modustr = "";
|
|
|
if (type == 1)
|
|
|
{
|
|
|
modustr = "modOtherRecvFeeManagement";
|
|
|
if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
{
|
|
|
modustr = "modRecvFeeManagement";
|
|
|
}
|
|
|
else if (optype == "op_apply")
|
|
|
{
|
|
|
modustr = "modApplyRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_seai")
|
|
|
{
|
|
|
modustr = "modSeaiRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_aire")
|
|
|
{
|
|
|
modustr = "modAireRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_airi")
|
|
|
{
|
|
|
modustr = "modAiriRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
{
|
|
|
modustr = "modOtherRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_bulk")
|
|
|
{
|
|
|
modustr = "modBulkRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_railway")
|
|
|
{
|
|
|
modustr = "modRailwayRecvFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "import_main")
|
|
|
{
|
|
|
modustr = "modImportTrade";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (type == 2)
|
|
|
{
|
|
|
modustr = "modOtherPayFeeManagement";
|
|
|
if (optype == "op_seae" || optype == "op_seaeorder")
|
|
|
{
|
|
|
modustr = "modPayFeeManagement";
|
|
|
}
|
|
|
else if (optype == "op_apply")
|
|
|
{
|
|
|
|
|
|
modustr = "modApplyPayFeeManagement";
|
|
|
}
|
|
|
else if (optype == "op_seai")
|
|
|
{
|
|
|
|
|
|
modustr = "modSeaiPayFeeManagement";
|
|
|
}
|
|
|
else if (optype == "op_aire")
|
|
|
{
|
|
|
|
|
|
modustr = "modAirePayFeeManagement";
|
|
|
}
|
|
|
|
|
|
else if (optype == "op_airi")
|
|
|
{
|
|
|
|
|
|
modustr = "modAiriPayFeeManagement";
|
|
|
}
|
|
|
|
|
|
else if (optype == "op_other" || optype == "tMsWlPcHead" || optype == "OpCtnBsCard")
|
|
|
{
|
|
|
modustr = "modOtherPayFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_bulk")
|
|
|
{
|
|
|
modustr = "modBulkPayFeeManagement";
|
|
|
|
|
|
}
|
|
|
else if (optype == "op_railway")
|
|
|
{
|
|
|
modustr = "modRailwayPayFeeManagement";
|
|
|
|
|
|
}else if (optype == "import_main")
|
|
|
{
|
|
|
modustr = "modImportTrade";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='" + modustr+ "' 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 = " ENTEROPERATOR='" + userid + "'";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
str = " ENTEROPERATOR='" + userid + "'";
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
str = " ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') and ENTEROPERATOR in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')";
|
|
|
}
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
|
|
|
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 = " (ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "')";
|
|
|
};
|
|
|
}
|
|
|
if (str!="")
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
|
|
|
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()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (ENTEROPERATOR='" + Convert.ToString(reader["OPID"]) + "' ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or ENTEROPERATOR='" + Convert.ToString(reader["OPID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
if (str != "")
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " ENTEROPERATOR in (select USERID from user_company where COMPANYID='" + companyid + "') ";
|
|
|
}
|
|
|
else if (visiblerange == "0")
|
|
|
{
|
|
|
str = " 1=1 ";
|
|
|
}
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
internal class MsChFeeDealException : Exception
|
|
|
{
|
|
|
internal MsChFeeDealException(string message)
|
|
|
: base(message)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
} |