|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Invoiceapplication;
|
|
|
|
|
using DSWeb.Areas.Account.Models.Chfee_do_detail;
|
|
|
|
|
using DSWeb.Areas.Account.Models.MsOpBill;
|
|
|
|
|
using DSWeb.Areas.Account.Models.BillChfeeDetail;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Exrate;
|
|
|
|
|
using DSWeb.Areas.Account.Models.Chfee_do_Sum;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.Areas.Account.Models.ChfeeDetail;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsCodeGoodInv;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.DAL;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.Account.DAL.Chfee_Invoiceapplication
|
|
|
|
|
{
|
|
|
|
|
public partial class ChinvoiceapplicationDAL
|
|
|
|
|
{
|
|
|
|
|
#region 发票申请列表
|
|
|
|
|
|
|
|
|
|
static public List<ChInvoiceapplication> GetDataList(string strCondition, string userid="", string usercode="", string orgcode="", string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAListStr("", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT GID,BILLNO,BILLSTATUS,CUSTOMERNAME,ACTUALCUSTOMERNAME,CURRENCY,INVOICECUSTNAME,INVOICECATEGORY ");
|
|
|
|
|
strSql.Append(" ,BSNO,MBLNO,VESSELVOYAGE,POL,POD,ETD,APPLYAMOUNT,INVAMOUNT,AMOUNTCAPITAL,OTCURRAMOUNT");
|
|
|
|
|
strSql.Append(" ,APPLICANT,APPLYTIME,ENTERTIME,OPERATOR,OPERATETIME,INVBILLNO ");
|
|
|
|
|
strSql.Append(" ,REMARK,COMPANYID,ISAPPLY,CUSTRATENO,CUSTADDRTEL,CUSTBANK,RATE,INVOICENO,RECVCURR,FEEAMOUNT ");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97010 and EnumValueID=cm.BILLSTATUS) as BILLSTATUSREF");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97008 and EnumValueID=cm.INVOICECATEGORY) as INVOICECATEGORYREF");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=cm.APPLICANT) as APPLICANTNAME");
|
|
|
|
|
strSql.Append(",(select top 1 INVOICENO from ch_fee_invoice where BILLNO=cm.INVBILLNO) as INVOICENOREF ");
|
|
|
|
|
strSql.Append(",PAYCOMPANYID,(select name from company where gid=cm.PAYCOMPANYID) PAYCOMPANYREF,0 IsAudit ");
|
|
|
|
|
strSql.Append(" FROM ch_fee_invoiceapplication cm where 1=1 ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by APPLYTIME DESC");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*可开发票列表 */
|
|
|
|
|
static public List<ChInvoiceapplication> GetDataInvList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAListStr("", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT GID,cm.BILLNO,BILLSTATUS,CUSTOMERNAME,ACTUALCUSTOMERNAME,CURRENCY,INVOICECUSTNAME,INVOICECATEGORY ");
|
|
|
|
|
strSql.Append(" ,BSNO,MBLNO,VESSELVOYAGE,POL,POD,ETD,APPLYAMOUNT,INVAMOUNT,AMOUNTCAPITAL,OTCURRAMOUNT");
|
|
|
|
|
strSql.Append(" ,APPLICANT,APPLYTIME,ENTERTIME,OPERATOR,OPERATETIME,INVBILLNO ");
|
|
|
|
|
strSql.Append(" ,REMARK,COMPANYID,ISAPPLY,CUSTRATENO,CUSTADDRTEL,CUSTBANK,RATE,INVOICENO,RECVCURR,FEEAMOUNT ");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97010 and EnumValueID=cm.BILLSTATUS) as BILLSTATUSREF");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97008 and EnumValueID=cm.INVOICECATEGORY) as INVOICECATEGORYREF");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=cm.APPLICANT) as APPLICANTNAME");
|
|
|
|
|
strSql.Append(",(select top 1 INVOICENO from ch_fee_invoice where BILLNO=cm.INVBILLNO) as INVOICENOREF ");
|
|
|
|
|
strSql.Append(",PAYCOMPANYID,(select name from company where gid=cm.PAYCOMPANYID) PAYCOMPANYREF,0 IsAudit ");
|
|
|
|
|
strSql.Append(" FROM ch_fee_invoiceapplication cm ");
|
|
|
|
|
strSql.Append(" left join v_fee_do_payinvoiceNoInv NV ON (NV.BILLNO=cm.BILLNO) where ISNULL(NV.BILLNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by APPLYTIME DESC");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public ChInvoiceapplication GetData(string condition, string userid = "", string usercode = "", string orgcode = "")
|
|
|
|
|
{
|
|
|
|
|
var list = GetDataList(condition,userid,usercode,orgcode);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
return list[0];
|
|
|
|
|
|
|
|
|
|
return new ChInvoiceapplication();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<ChInvoiceapplication> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<ChInvoiceapplication>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
ChInvoiceapplication data = new ChInvoiceapplication();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.BILLNO = Convert.ToString(reader["BILLNO"]);
|
|
|
|
|
if (reader["BILLSTATUS"] != DBNull.Value)
|
|
|
|
|
data.BILLSTATUS = Convert.ToInt32(reader["BILLSTATUS"]);
|
|
|
|
|
data.BILLSTATUSREF = Convert.ToString(reader["BILLSTATUSREF"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.ACTUALCUSTOMERNAME = Convert.ToString(reader["ACTUALCUSTOMERNAME"]);
|
|
|
|
|
if (reader["CURRENCY"] != DBNull.Value)
|
|
|
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
|
|
|
data.INVOICENO = Convert.ToString(reader["INVOICENO"]);
|
|
|
|
|
data.INVOICENOREF = Convert.ToString(reader["INVOICENOREF"]);
|
|
|
|
|
data.INVOICECUSTNAME = Convert.ToString(reader["INVOICECUSTNAME"]);
|
|
|
|
|
data.INVOICECATEGORY = Convert.ToString(reader["INVOICECATEGORY"]);
|
|
|
|
|
data.INVOICECATEGORYREF = Convert.ToString(reader["INVOICECATEGORYREF"]);
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.VESSELVOYAGE = Convert.ToString(reader["VESSELVOYAGE"]);
|
|
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
|
|
|
data.POL = Convert.ToString(reader["POL"]);
|
|
|
|
|
data.POD = Convert.ToString(reader["POD"]);
|
|
|
|
|
|
|
|
|
|
if (reader["APPLYAMOUNT"] != DBNull.Value)
|
|
|
|
|
data.APPLYAMOUNT = Convert.ToDecimal(reader["APPLYAMOUNT"]);
|
|
|
|
|
if (reader["INVAMOUNT"] != DBNull.Value)
|
|
|
|
|
data.INVAMOUNT = Convert.ToDecimal(reader["INVAMOUNT"]);
|
|
|
|
|
data.AMOUNTCAPITAL = Convert.ToString(reader["AMOUNTCAPITAL"]);
|
|
|
|
|
|
|
|
|
|
if (reader["OTCURRAMOUNT"] != DBNull.Value)
|
|
|
|
|
data.OTCURRAMOUNT = Convert.ToDecimal(reader["OTCURRAMOUNT"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (reader["RATE"] != DBNull.Value)
|
|
|
|
|
data.RATE = Convert.ToDecimal(reader["RATE"]);
|
|
|
|
|
else
|
|
|
|
|
data.RATE =0;
|
|
|
|
|
data.APPLICANT = Convert.ToString(reader["APPLICANT"]);
|
|
|
|
|
data.APPLICANTNAME = Convert.ToString(reader["APPLICANTNAME"]);
|
|
|
|
|
if (reader["APPLYTIME"] != DBNull.Value)
|
|
|
|
|
data.APPLYTIME = Convert.ToDateTime(reader["APPLYTIME"]).ToString("yyyy-MM-dd");
|
|
|
|
|
if (reader["ENTERTIME"] != DBNull.Value)
|
|
|
|
|
data.ENTERTIME = Convert.ToDateTime(reader["ENTERTIME"]);
|
|
|
|
|
data.OPERATOR = Convert.ToString(reader["OPERATOR"]);
|
|
|
|
|
if (reader["OPERATETIME"] != DBNull.Value)
|
|
|
|
|
data.OPERATETIME = Convert.ToDateTime(reader["OPERATETIME"]);
|
|
|
|
|
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
|
|
|
if (reader["ISAPPLY"] != DBNull.Value)
|
|
|
|
|
data.ISAPPLY = Convert.ToBoolean(reader["ISAPPLY"]);
|
|
|
|
|
data.CUSTRATENO = Convert.ToString(reader["CUSTRATENO"]);
|
|
|
|
|
data.CUSTADDRTEL = Convert.ToString(reader["CUSTADDRTEL"]);
|
|
|
|
|
data.CUSTBANK = Convert.ToString(reader["CUSTBANK"]);
|
|
|
|
|
|
|
|
|
|
data.PAYCOMPANYID = Convert.ToString(reader["PAYCOMPANYID"]);
|
|
|
|
|
data.PAYCOMPANYREF = Convert.ToString(reader["PAYCOMPANYREF"]);
|
|
|
|
|
data.RECVCURR = Convert.ToString(reader["RECVCURR"]);
|
|
|
|
|
data.FEEAMOUNT = Convert.ToString(reader["FEEAMOUNT"]);
|
|
|
|
|
data.IsAudit = Convert.ToString(reader["IsAudit"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 发票申请明细
|
|
|
|
|
|
|
|
|
|
static public List<ChInvoiceDetail> GetDetailList(string strCondition,string sort=null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT GID,PID,SerialNo,GOODSNAME,SPEC,UNIT ");
|
|
|
|
|
strSql.Append(",PKGS,TAXPRICE,PRICE,AMOUNT,TAXRATE,TAX,Remark,GOODCODE");
|
|
|
|
|
strSql.Append(",(Select GOODNAME from code_goods_inv where GID=ch_fee_invoicedetail.GOODSNAME) AS GOODSNAMEREF");
|
|
|
|
|
strSql.Append(" FROM ch_fee_invoicedetail ");
|
|
|
|
|
|
|
|
|
|
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 SerialNo");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return DetailSetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<ChInvoiceDetail> DetailSetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<ChInvoiceDetail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
ChInvoiceDetail data = new ChInvoiceDetail();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.PID = Convert.ToString(reader["PID"]);
|
|
|
|
|
data.SERIALNO = Convert.ToInt16(reader["SerialNo"]);
|
|
|
|
|
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
|
|
|
|
|
data.GOODSNAMEREF = Convert.ToString(reader["GOODSNAMEREF"]);
|
|
|
|
|
if (data.GOODSNAMEREF == "" || data.GOODSNAMEREF == null) data.GOODSNAMEREF = data.GOODSNAME;
|
|
|
|
|
data.SPEC = Convert.ToString(reader["SPEC"]);
|
|
|
|
|
data.UNIT = Convert.ToString(reader["UNIT"]);
|
|
|
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
|
|
|
data.TAXPRICE = Convert.ToDecimal(reader["TAXPRICE"]);
|
|
|
|
|
data.PRICE = Convert.ToDecimal(reader["PRICE"]);
|
|
|
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
|
|
|
data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]);
|
|
|
|
|
data.TAX = Convert.ToDecimal(reader["TAX"]);
|
|
|
|
|
data.REMARK= Convert.ToString(reader["Remark"]);
|
|
|
|
|
data.GOODCODE = Convert.ToString(reader["GOODCODE"]);
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发票申请费用明细
|
|
|
|
|
|
|
|
|
|
static public List<Chfee_do_detail> GetBodyList(string strCondition,string sort=null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,ISNULL(c.ORIGSTLAMOUNT,0) AS ORIGSTLAMOUNT,c.EXCHANGERATE ");
|
|
|
|
|
strSql.Append(",c.FEETYPE,c.CUSTOMERNAME as FEEOBJNAME,(CASE C.FEETYPE WHEN 1 THEN '收' ELSE '付' END) AS FEETYPEREF,(SELECT EXCHANGERATE from ch_fee where GID=c.FEEID) ORIGEXCHANGERATE");
|
|
|
|
|
strSql.Append(" ,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO");
|
|
|
|
|
strSql.Append(",b.CUSTOMERNAME");
|
|
|
|
|
strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD");
|
|
|
|
|
strSql.Append(",b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE");
|
|
|
|
|
strSql.Append(",b.DOC,b.SALE");
|
|
|
|
|
strSql.Append(",f.Remark Remark,f.INPUTMODE ");
|
|
|
|
|
strSql.Append(" FROM ch_fee_do c");
|
|
|
|
|
strSql.Append(" left join v_op_bill b on (b.bsno=c.bsno)");
|
|
|
|
|
strSql.Append(" left join ch_fee f on (f.gid=c.feeid) ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where (c.ISDELETED=0 or c.ISDELETED IS NULL) and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by b.MBLNO");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return BodySetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<Chfee_do_detail> BodySetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<Chfee_do_detail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
Chfee_do_detail data = new Chfee_do_detail();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.FEEDOID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.FEEID = Convert.ToString(reader["FEEID"]);
|
|
|
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
|
|
|
data.FEEOBJNAME = Convert.ToString(reader["FEEOBJNAME"]);
|
|
|
|
|
data.FEETYPE = Convert.ToInt16(reader["FEETYPE"]);
|
|
|
|
|
data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]);
|
|
|
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
|
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
|
|
|
data.DOAMOUNT = Convert.ToDecimal(reader["DOAMOUNT"]);
|
|
|
|
|
data.ORIGCURRENCY = Convert.ToString(reader["ORIGCURRENCY"]);
|
|
|
|
|
data.ORIGAMOUNT = Convert.ToDecimal(reader["ORIGAMOUNT"]);
|
|
|
|
|
data.ORIGSTLAMOUNT = Convert.ToDecimal(reader["ORIGSTLAMOUNT"]);
|
|
|
|
|
data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.HBLNO = Convert.ToString(reader["HBLNO"]);
|
|
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
|
|
if (reader["ORIGEXCHANGERATE"] != DBNull.Value)
|
|
|
|
|
data.ORIGEXCHANGERATE = Convert.ToDecimal(reader["ORIGEXCHANGERATE"]);
|
|
|
|
|
if (reader["BSSTATUS"] != DBNull.Value)
|
|
|
|
|
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
data.INPUTMODE = Convert.ToString(reader["INPUTMODE"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 明细金额币别合计
|
|
|
|
|
|
|
|
|
|
static public List<Chfee_do_Sum> GetBodySumList(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT c.FEETYPE,(CASE C.FEETYPE WHEN 1 THEN '收' ELSE '付' END) AS FEETYPEREF,c.ORIGCURRENCY CURRENCY,Sum(c.ORIGAMOUNT) AMOUNT ");
|
|
|
|
|
strSql.Append(" FROM ch_fee_do c");
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where (c.ISDELETED=0 or c.ISDELETED IS NULL) and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by c.FEETYPE,c.ORIGCURRENCY");
|
|
|
|
|
return BodySumSetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<Chfee_do_Sum> BodySumSetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<Chfee_do_Sum>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
Chfee_do_Sum data = new Chfee_do_Sum();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.FEETYPE = Convert.ToInt16(reader["FEETYPE"]);
|
|
|
|
|
data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]);
|
|
|
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
|
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Inquery FeeDataList
|
|
|
|
|
|
|
|
|
|
static public List<BillChfeeDetail> GetFeeDataList(string strCondition, string userid, string usercode, string orgcode, string sort)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("b.BSNO,b.OPLB,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO");
|
|
|
|
|
strSql.Append(",b.CUSTOMERNAME,b.CUSTOMNO");
|
|
|
|
|
strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD");
|
|
|
|
|
strSql.Append(",b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE");
|
|
|
|
|
strSql.Append(",b.DOC,b.SALE");
|
|
|
|
|
strSql.Append(",f.GID AS CH_ID,f.FeeType");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=f.FeeType) as FeeType_Ref");
|
|
|
|
|
strSql.Append(",f.feeName,f.customerName as FeeObjName,f.amount,f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) as balamount,f.currency,f.exChangerate,f.AccTaxRate");
|
|
|
|
|
strSql.Append(" from ch_fee f ");
|
|
|
|
|
strSql.Append(" left join v_op_bill b on (b.bsno=f.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 b.BsNo");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return SetFeeData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<BillChfeeDetail> SetFeeData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<BillChfeeDetail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
BillChfeeDetail data = new BillChfeeDetail();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
data.OPLB = Convert.ToString(reader["OPLB"]);
|
|
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.HBLNO = Convert.ToString(reader["HBLNO"]);
|
|
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
|
|
|
|
|
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
|
|
|
|
|
|
|
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
|
|
|
|
|
|
|
|
|
|
data.CH_ID = Convert.ToString(reader["CH_ID"]);
|
|
|
|
|
data.FeeType = Convert.ToInt16(reader["FeeType"]);
|
|
|
|
|
data.FeeType_Ref = Convert.ToString(reader["FeeType_Ref"]);
|
|
|
|
|
data.FeeName = Convert.ToString(reader["feeName"]);
|
|
|
|
|
data.FeeObjName = Convert.ToString(reader["FeeObjName"]);
|
|
|
|
|
data.Amount = Convert.ToDecimal(reader["Amount"]);
|
|
|
|
|
if (reader["BalAmount"] != DBNull.Value)
|
|
|
|
|
data.BalAmount = Convert.ToDecimal(reader["BalAmount"]);
|
|
|
|
|
if (reader["BalAmount"] != DBNull.Value)
|
|
|
|
|
data.StlAmount = Convert.ToDecimal(reader["BalAmount"]);
|
|
|
|
|
data.Currency = Convert.ToString(reader["Currency"]);
|
|
|
|
|
data.ExChangerate = Convert.ToDecimal(reader["exChangerate"]);
|
|
|
|
|
if (reader["AccTaxRate"]!=DBNull.Value)
|
|
|
|
|
data.AccTaxRate = Convert.ToDecimal(reader["AccTaxRate"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 添加列表
|
|
|
|
|
|
|
|
|
|
static public List<BillCustDetail> GetAddBillList(int start, int limit, string strCondition, string userid, string usercode, string orgcode, string sort)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append(@"SELECT * from (SELECT row_number() over (");
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
sortstring = sortstring.Replace("FEEOBJNAME", "F.CUSTOMERNAME").Replace("COMPANYID", "b.SALECORPID").Replace("COMPANYNAME", "b.SALECORPID");
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by b.BsNo");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(@") as num , ");
|
|
|
|
|
|
|
|
|
|
strSql.Append("b.BSNO,b.OPLB,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO");
|
|
|
|
|
strSql.Append(",b.CUSTOMERNAME");
|
|
|
|
|
strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD");
|
|
|
|
|
strSql.Append(",b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE");
|
|
|
|
|
strSql.Append(",b.DOC,b.SALE,b.ENTERP,b.CUSTOMNO,b.SALECORPID,(SELECT [NAME] from [COMPANY] WHERE GID=b.SALECORPID) SALECORP");
|
|
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALRMBCR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR");
|
|
|
|
|
strSql.Append(" FROM CH_FEE f ");
|
|
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" where f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
var INVISNOTSTL = MsSysParamSetDAL.GetData("PARAMNAME='INVISNOTSTL'");
|
|
|
|
|
if (INVISNOTSTL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.SETTLEMENT,0) ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSql.Append("GROUP BY b.BSNO,b.OPLB,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO");
|
|
|
|
|
strSql.Append(",b.CUSTOMERNAME");
|
|
|
|
|
strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD");
|
|
|
|
|
strSql.Append(",b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE");
|
|
|
|
|
strSql.Append(",b.DOC,b.SALE,b.ENTERP,b.CUSTOMNO,b.SALECORPID,f.CUSTOMERNAME");
|
|
|
|
|
strSql.Append( @")as t ");
|
|
|
|
|
strSql.Append(string.Format("where t.num>={0} and t.num<={1} ", start, start + limit)); //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return SetAddBillData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int getAddBillTotalCount(string strCondition, string userid, string usercode, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT COUNT(*) FROM (select b.BSNO,f.CUSTOMERNAME ");
|
|
|
|
|
strSql.Append(" FROM CH_FEE f ");
|
|
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" where f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append("GROUP BY b.BSNO,f.CUSTOMERNAME) AS T ");
|
|
|
|
|
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<BillCustDetail> SetAddBillData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<BillCustDetail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
BillCustDetail data = new BillCustDetail();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
data.OPLB = Convert.ToString(reader["OPLB"]);
|
|
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.HBLNO = Convert.ToString(reader["HBLNO"]);
|
|
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
|
|
|
|
|
|
|
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
|
|
|
|
|
data.FEEOBJNAME = Convert.ToString(reader["CUSTNAME"]);
|
|
|
|
|
data.COMPANYID = Convert.ToString(reader["SALECORPID"]);
|
|
|
|
|
data.COMPANYNAME = Convert.ToString(reader["SALECORP"]);
|
|
|
|
|
|
|
|
|
|
if (reader["RMBDR"] != DBNull.Value)
|
|
|
|
|
data.RMBDrAmount = Convert.ToDecimal(reader["RMBDR"]);
|
|
|
|
|
if (reader["BALRMBDR"] != DBNull.Value)
|
|
|
|
|
data.RMBDrBalAmount = Convert.ToDecimal(reader["BALRMBDR"]) - Convert.ToDecimal(reader["BALRMBCR"]);
|
|
|
|
|
if (reader["BALRMBDR"] != DBNull.Value)
|
|
|
|
|
data.RMBDrDoAmount = Convert.ToDecimal(reader["BALRMBDR"]) - Convert.ToDecimal(reader["BALRMBCR"]);
|
|
|
|
|
|
|
|
|
|
if (reader["RMBCR"] != DBNull.Value)
|
|
|
|
|
data.RMBCrAmount = Convert.ToDecimal(reader["RMBCR"]);
|
|
|
|
|
if (reader["BALRMBCR"] != DBNull.Value)
|
|
|
|
|
data.RMBCrBalAmount = Convert.ToDecimal(reader["BALRMBCR"]);
|
|
|
|
|
if (reader["BALRMBCR"] != DBNull.Value)
|
|
|
|
|
data.RMBCrDoAmount = Convert.ToDecimal(reader["BALRMBCR"]);
|
|
|
|
|
if (reader["USDDR"] != DBNull.Value)
|
|
|
|
|
data.USDDrAmount = Convert.ToDecimal(reader["USDDR"]);
|
|
|
|
|
if (reader["BALUSDDR"] != DBNull.Value)
|
|
|
|
|
data.USDDrBalAmount = Convert.ToDecimal(reader["BALUSDDR"]) - Convert.ToDecimal(reader["BALUSDCR"]);
|
|
|
|
|
if (reader["BALUSDDR"] != DBNull.Value)
|
|
|
|
|
data.USDDrDoAmount = Convert.ToDecimal(reader["BALUSDDR"]) - Convert.ToDecimal(reader["BALUSDCR"]);
|
|
|
|
|
if (reader["USDCR"] != DBNull.Value)
|
|
|
|
|
data.USDCrAmount = Convert.ToDecimal(reader["USDCR"]);
|
|
|
|
|
if (reader["BALUSDCR"] != DBNull.Value)
|
|
|
|
|
data.USDCrBalAmount = Convert.ToDecimal(reader["BALUSDCR"]);
|
|
|
|
|
if (reader["BALUSDCR"] != DBNull.Value)
|
|
|
|
|
data.USDCrDoAmount = Convert.ToDecimal(reader["BALUSDCR"]);
|
|
|
|
|
|
|
|
|
|
if (reader["OTDR"] != DBNull.Value)
|
|
|
|
|
data.OTDrAmount = Convert.ToDecimal(reader["OTDR"]);
|
|
|
|
|
if (reader["BALOTDR"] != DBNull.Value)
|
|
|
|
|
data.OTDrBalAmount = Convert.ToDecimal(reader["BALOTDR"]) - Convert.ToDecimal(reader["BALOTCR"]);
|
|
|
|
|
if (reader["BALOTDR"] != DBNull.Value)
|
|
|
|
|
data.OTDrDoAmount = Convert.ToDecimal(reader["BALOTDR"]) - Convert.ToDecimal(reader["BALOTCR"]);
|
|
|
|
|
if (reader["OTCR"] != DBNull.Value)
|
|
|
|
|
data.OTCrAmount = Convert.ToDecimal(reader["OTCR"]);
|
|
|
|
|
if (reader["BALOTCR"] != DBNull.Value)
|
|
|
|
|
data.OTCrBalAmount = Convert.ToDecimal(reader["BALOTCR"]);
|
|
|
|
|
if (reader["BALOTCR"] != DBNull.Value)
|
|
|
|
|
data.OTCrDoAmount = Convert.ToDecimal(reader["BALOTCR"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
static public List<Chfee_do_Sum> GetAddSum(string strCondition, string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append(" SELECT f.FEETYPE,(CASE f.FEETYPE WHEN 1 THEN '收' ELSE '付' END) AS FEETYPEREF,f.CURRENCY,Sum(f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0)) AMOUNT ");
|
|
|
|
|
strSql.Append(" from ch_fee f ");
|
|
|
|
|
strSql.Append(" left join v_op_bill b on (b.bsno=f.bsno)");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by f.FEETYPE,f.CURRENCY");
|
|
|
|
|
|
|
|
|
|
return BodySumSetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public List<ChFeeExrate> GetCurrExrateData(string billcust, string billcurr, string feesql,bool custgroup=false)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append(" SELECT DISTINCT CURRENCY,EXCHANGERATE ");
|
|
|
|
|
if (!custgroup)
|
|
|
|
|
strSql.Append(" FROM ch_fee f where CURRENCY<>'" + billcurr + "' AND CUSTOMERNAME='" + billcust + "'");
|
|
|
|
|
else
|
|
|
|
|
strSql.Append(" FROM ch_fee f where CURRENCY<>'" + billcurr + "'");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(feesql))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + feesql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetCurrExrateData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<ChFeeExrate> SetCurrExrateData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<ChFeeExrate>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
ChFeeExrate data = new ChFeeExrate();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.CURR = Convert.ToString(reader["CURRENCY"]);
|
|
|
|
|
data.EXRATE = 0;
|
|
|
|
|
if (reader["EXCHANGERATE"] != DBNull.Value)
|
|
|
|
|
data.DFEXRATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#region 费用列表明细
|
|
|
|
|
static public List<ChFeeDetail> GetFeeDetailList(string strCondition,string sort=null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT * from (SELECT ");
|
|
|
|
|
strSql.Append("f.BSNO,f.GID AS CH_ID,FeeType");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=f.FeeType) as FeeType_Ref");
|
|
|
|
|
strSql.Append(",f.feeName,f.customerName,f.amount,f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) as balamount,f.currency,f.exChangerate,f.AccTaxRate");
|
|
|
|
|
strSql.Append(",f.INPUTMODE,f.UNIT from ch_fee f ");
|
|
|
|
|
strSql.Append(" where f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" AND " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var INVISNOTSTL = MsSysParamSetDAL.GetData("PARAMNAME='INVISNOTSTL'");
|
|
|
|
|
if (INVISNOTSTL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.SETTLEMENT,0) ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(" ) AS VF ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by feeName");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetFeeDetailData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<ChFeeDetail> SetFeeDetailData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<ChFeeDetail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
ChFeeDetail data = new ChFeeDetail();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.CH_ID = Convert.ToString(reader["CH_ID"]);
|
|
|
|
|
data.FeeType = Convert.ToInt16(reader["FeeType"]);
|
|
|
|
|
data.FeeType_Ref = Convert.ToString(reader["FeeType_Ref"]);
|
|
|
|
|
data.FeeName = Convert.ToString(reader["feeName"]);
|
|
|
|
|
data.CustomerName = Convert.ToString(reader["customerName"]);
|
|
|
|
|
data.Amount = Convert.ToDecimal(reader["Amount"]);
|
|
|
|
|
if (reader["BalAmount"] != DBNull.Value)
|
|
|
|
|
data.BalAmount = Convert.ToDecimal(reader["BalAmount"]);
|
|
|
|
|
if (reader["BalAmount"] != DBNull.Value)
|
|
|
|
|
data.StlAmount = Convert.ToDecimal(reader["BalAmount"]);
|
|
|
|
|
data.Currency = Convert.ToString(reader["Currency"]);
|
|
|
|
|
data.ExChangerate = Convert.ToDecimal(reader["exChangerate"]);
|
|
|
|
|
if (reader["AccTaxRate"] != DBNull.Value)
|
|
|
|
|
data.AccTaxRate = Convert.ToDecimal(reader["AccTaxRate"]);
|
|
|
|
|
data.INPUTMODE = Convert.ToString(reader["INPUTMODE"]);
|
|
|
|
|
//data.UNIT = Convert.ToString(reader["UNIT"]);
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 发票明细保存,删除
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveInvDetail(string BsNo, List<ChInvoiceDetail> bodyList)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into ch_fee_invoicedetail (GID,PID,SerialNo,GOODSNAME,SPEC,UNIT,PKGS,TAXPRICE,PRICE,AMOUNT,TAXRATE,TAX,Remark,GOODCODE)
|
|
|
|
|
values (@GID,@PID,@SerialNo,@GOODSNAME,@SPEC,@UNIT,@PKGS,@TAXPRICE,@PRICE,@AMOUNT,@TAXRATE,@TAX,@Remark,@GOODCODE) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdate =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"update ch_fee_invoicedetail set SerialNo=@SerialNo,GOODSNAME=@GOODSNAME,SPEC=@SPEC,UNIT=@UNIT,PKGS=@PKGS,TAXPRICE=@TAXPRICE
|
|
|
|
|
,PRICE=@PRICE,AMOUNT=@AMOUNT,TAXRATE=@TAXRATE,Remark=@Remark,TAX=@TAX,GOODCODE=@GOODCODE where GID=@GID ");
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (enumValue.PID == "*" || enumValue.GID == "")
|
|
|
|
|
{
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsert, "@PID", DbType.String, BsNo);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@SerialNo", DbType.Int32, enumValue.SERIALNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GOODSNAME", DbType.String, enumValue.GOODSNAME);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@SPEC", DbType.String, enumValue.SPEC);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.UNIT);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@TAXPRICE", DbType.Decimal, enumValue.TAXPRICE);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@PRICE", DbType.Decimal, enumValue.PRICE);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, enumValue.TAXRATE);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@TAX", DbType.Decimal, enumValue.TAX);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@Remark", DbType.String, enumValue.REMARK);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GOODCODE", DbType.String, enumValue.GOODCODE);
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@SerialNo", DbType.Int32, enumValue.SERIALNO);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GOODSNAME", DbType.String, enumValue.GOODSNAME);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@SPEC", DbType.String, enumValue.SPEC);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@UNIT", DbType.String, enumValue.UNIT);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@TAXPRICE", DbType.Decimal, enumValue.TAXPRICE);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@PRICE", DbType.Decimal, enumValue.PRICE);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@AMOUNT", DbType.Decimal, enumValue.AMOUNT);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@TAXRATE", DbType.Decimal, enumValue.TAXRATE);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@TAX", DbType.Decimal, enumValue.TAX);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@Remark", DbType.String, enumValue.REMARK);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GOODCODE", DbType.String, enumValue.GOODCODE);
|
|
|
|
|
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 DelInvDetail(List<ChInvoiceDetail> bodyList)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"delete from ch_fee_invoicedetail where GID=@GID ");
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, enumValue.GID);
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "删除成功" + result.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult AddDetail(string billno, List<BillChfeeDetail> bodyList, string curr, string companyid,bool isList,string GID,ChInvoiceapplication headdata)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
var defGOOD = MsCodeGoodInvDAL.GetData(" ISDEF='1' and (DEFCURR='' or DEFCURR='"+headdata.RECVCURR+"')");
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into ch_fee_do (GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY
|
|
|
|
|
,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,ISDELETED,CREATETIME
|
|
|
|
|
,EXCHANGERATE,ORIGCURRENCY,ORIGAMOUNT,INVOICESETTLENO,COMPANYID)
|
|
|
|
|
values (@GID,@BILLNO,@BSNO,@MBLNO,@HBLNO,@CUSTOMERNAME,@BSTYPE,@FEEID,@FEENAME,@CURRENCY
|
|
|
|
|
,@AMOUNT,@DOAMOUNT,@FEETYPE,@CATEGORY,@BILLSTATUS,@ISDELETED,@CREATETIME
|
|
|
|
|
,@EXCHANGERATE,@ORIGCURRENCY,@ORIGAMOUNT,@INVOICESETTLENO,@COMPANYID) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdate =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"UPDATE CH_FEE SET ORDERINVOICE=ISNULL(ORDERINVOICE,0)+@ORDERINVOICE WHERE GID=@GID ");
|
|
|
|
|
|
|
|
|
|
var cmdInsertInv =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into ch_fee_invoicedetail (GID,PID,SerialNo,GOODSNAME,SPEC,UNIT,PKGS,TAXPRICE,PRICE,AMOUNT,TAXRATE,TAX,Remark,GOODCODE)
|
|
|
|
|
values (@GID,@PID,@SerialNo,@GOODSNAME,@SPEC,@UNIT,@PKGS,@TAXPRICE,@PRICE,@AMOUNT,@TAXRATE,@TAX,@Remark,@GOODCODE) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdateInv =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"update ch_fee_invoicedetail set TAXPRICE=@TAXPRICE
|
|
|
|
|
,PRICE=@PRICE,AMOUNT=@AMOUNT,TAX=@TAX where GID=@GID ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal amtttl = 0;
|
|
|
|
|
decimal acctaxrate =0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BILLNO", DbType.String, billno);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BSNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@MBLNO", DbType.String, enumValue.MBLNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@HBLNO", DbType.String, enumValue.HBLNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.FeeObjName);
|
|
|
|
|
var tops = enumValue.BSNO.Substring(0, 7);
|
|
|
|
|
if (tops == "topseae")
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, true);
|
|
|
|
|
else
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, false);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, enumValue.CH_ID);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FeeName);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, curr);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, Math.Round(enumValue.DoAmount,2));
|
|
|
|
|
db.AddInParameter(cmdInsert, "@DOAMOUNT", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEETYPE", DbType.Int16, enumValue.FeeType);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CATEGORY", DbType.Int16, 6);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BILLSTATUS", DbType.Int16, 1);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ISDELETED", DbType.Boolean, false);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.DateTime, DateTime.Now);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, enumValue.ExChangerate);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ORIGCURRENCY", DbType.String, enumValue.Currency);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ORIGAMOUNT", DbType.Decimal, enumValue.StlAmount);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@INVOICESETTLENO", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, companyid);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.CH_ID);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@ORDERINVOICE", DbType.Decimal, enumValue.StlAmount);
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
|
|
if (isList)
|
|
|
|
|
{
|
|
|
|
|
cmdInsertInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PID", DbType.String, GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SerialNo", DbType.Int32, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, enumValue.FeeName);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, "票");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, enumValue.DoAmount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal, headdata.RATE);
|
|
|
|
|
if (headdata.RATE == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, enumValue.DoAmount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, enumValue.DoAmount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(enumValue.DoAmount / (1 + headdata.RATE / 100) * (headdata.RATE / 100), 2);
|
|
|
|
|
var amount = amtttl - tax;
|
|
|
|
|
// var amount = Math.Round(enumValue.DoAmount / (1 + enumValue.AccTaxRate / 100),2);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal,tax);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String, "");
|
|
|
|
|
db.ExecuteNonQuery(cmdInsertInv, tran);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enumValue.FeeType==2)
|
|
|
|
|
amtttl = amtttl - enumValue.DoAmount;
|
|
|
|
|
else
|
|
|
|
|
amtttl = amtttl + enumValue.DoAmount;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
acctaxrate = headdata.RATE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isList) {
|
|
|
|
|
|
|
|
|
|
var dataList =GetDetailList(" PID='"+GID+"'");
|
|
|
|
|
if (dataList.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var invlist = dataList[0];
|
|
|
|
|
cmdUpdateInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@GID", DbType.String, invlist.GID);
|
|
|
|
|
if (acctaxrate == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT+amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal,Math.Round((invlist.AMOUNT + amtttl)/invlist.PKGS,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal,0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2);
|
|
|
|
|
var amount = amtttl - tax;
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT + amount,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round(((invlist.AMOUNT + amount) / invlist.PKGS) * (1 + acctaxrate / 100),2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amount) / invlist.PKGS,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal,invlist.TAX+tax);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateInv, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cmdInsertInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PID", DbType.String, GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SerialNo", DbType.Int32, 1);
|
|
|
|
|
if (defGOOD.GOODNAME == "")
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, "代理运杂费");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, "票");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, defGOOD.GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, defGOOD.UNIT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, defGOOD.SPEC);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal, acctaxrate);
|
|
|
|
|
if (acctaxrate == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2);
|
|
|
|
|
var amount = amtttl - tax;
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(amount,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(amount,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal,tax);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String,defGOOD.GOODCODE);
|
|
|
|
|
db.ExecuteNonQuery(cmdInsertInv, 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 AddBill(string billno, string billcust, string billcurr, string feesql, List<ChFeeExrate> exratelist, string companyid, bool isList, string GID,ChInvoiceapplication headdata,bool custgroup = false)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
decimal amtttl = 0;
|
|
|
|
|
decimal acctaxrate = 0;
|
|
|
|
|
bool adddo = true;
|
|
|
|
|
var FEENOAUDITCANTSHENINV = MsSysParamSetDAL.GetData("PARAMNAME='FEENOAUDITCANTSHENINV'");
|
|
|
|
|
List<DSWeb.MvcShipping.Models.MsOpBill.MsOpBill> billnoinvlist = null;
|
|
|
|
|
|
|
|
|
|
var defGOOD = MsCodeGoodInvDAL.GetData(" ISDEF='1' and (DEFCURR='' or DEFCURR='" + headdata.RECVCURR + "')");
|
|
|
|
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!custgroup)
|
|
|
|
|
feesql = feesql + " AND CUSTOMERNAME='" + billcust + "'";
|
|
|
|
|
var feelist = GetFeeDetailList(feesql);
|
|
|
|
|
if (FEENOAUDITCANTSHENINV.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
billnoinvlist = MsOpBillDAL.GetDataList(" BSNO IN (select DISTINCT BSNO from ch_fee (NOLOCK) where FEETYPE=1 and (FEESTATUS=1 OR FEESTATUS=2 ) AND BSNO IN (SELECT DISTINCT BSNO FROM CH_FEE f WHERE f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) AND " + feesql + " ))", "", "", "");
|
|
|
|
|
}
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into ch_fee_do (GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY
|
|
|
|
|
,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,ISDELETED,CREATETIME
|
|
|
|
|
,EXCHANGERATE,ORIGCURRENCY,ORIGAMOUNT,INVOICESETTLENO,COMPANYID)
|
|
|
|
|
values (@GID,@BILLNO,@BSNO,@MBLNO,@HBLNO,@CUSTOMERNAME,@BSTYPE,@FEEID,@FEENAME,@CURRENCY
|
|
|
|
|
,@AMOUNT,@DOAMOUNT,@FEETYPE,@CATEGORY,@BILLSTATUS,@ISDELETED,@CREATETIME
|
|
|
|
|
,@EXCHANGERATE,@ORIGCURRENCY,@ORIGAMOUNT,@INVOICESETTLENO,@COMPANYID) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdate =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"UPDATE CH_FEE SET ORDERINVOICE=ISNULL(ORDERINVOICE,0)+@ORDERINVOICE WHERE GID=@GID ");
|
|
|
|
|
|
|
|
|
|
var cmdInsertInv =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into ch_fee_invoicedetail (GID,PID,SerialNo,GOODSNAME,SPEC,UNIT,PKGS,TAXPRICE,PRICE,AMOUNT,TAXRATE,TAX,Remark,GOODCODE)
|
|
|
|
|
values (@GID,@PID,@SerialNo,@GOODSNAME,@SPEC,@UNIT,@PKGS,@TAXPRICE,@PRICE,@AMOUNT,@TAXRATE,@TAX,@Remark,@GOODCODE) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdateInv =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"update ch_fee_invoicedetail set TAXPRICE=@TAXPRICE
|
|
|
|
|
,PRICE=@PRICE,AMOUNT=@AMOUNT,TAX=@TAX where GID=@GID ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (feelist != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in feelist)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (FEENOAUDITCANTSHENINV.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (billnoinvlist != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var billnoinv in billnoinvlist)
|
|
|
|
|
{
|
|
|
|
|
if (enumValue.BSNO == billnoinv.BSNO) adddo = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adddo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
decimal feettl = 0;
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BILLNO", DbType.String, billno);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BSNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@MBLNO", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsert, "@HBLNO", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.CustomerName);
|
|
|
|
|
var tops = enumValue.BSNO.Substring(0, 7);
|
|
|
|
|
if (tops == "topseae")
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, true);
|
|
|
|
|
else
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, false);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, enumValue.CH_ID);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FeeName);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, billcurr);
|
|
|
|
|
|
|
|
|
|
if (billcurr == enumValue.Currency)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, Math.Round(enumValue.StlAmount, 2));
|
|
|
|
|
db.AddInParameter(cmdInsert, "@DOAMOUNT", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, 1);
|
|
|
|
|
|
|
|
|
|
if (enumValue.FeeType == 2)
|
|
|
|
|
amtttl = amtttl - enumValue.StlAmount;
|
|
|
|
|
else
|
|
|
|
|
amtttl = amtttl + enumValue.StlAmount;
|
|
|
|
|
feettl = enumValue.StlAmount;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var UExrate = GetExrate(enumValue.Currency, exratelist);
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMOUNT", DbType.Decimal, Math.Round(enumValue.StlAmount * UExrate, 2));
|
|
|
|
|
db.AddInParameter(cmdInsert, "@DOAMOUNT", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, UExrate);
|
|
|
|
|
|
|
|
|
|
if (enumValue.FeeType == 2)
|
|
|
|
|
amtttl = amtttl - enumValue.StlAmount * UExrate;
|
|
|
|
|
else
|
|
|
|
|
amtttl = amtttl + enumValue.StlAmount * UExrate;
|
|
|
|
|
feettl = enumValue.StlAmount * UExrate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@FEETYPE", DbType.Int16, enumValue.FeeType);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ORIGCURRENCY", DbType.String, enumValue.Currency);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ORIGAMOUNT", DbType.Decimal, enumValue.StlAmount);
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CATEGORY", DbType.Int16, 6);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BILLSTATUS", DbType.Int16, 1);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ISDELETED", DbType.Boolean, false);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.DateTime, DateTime.Now);
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@INVOICESETTLENO", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, companyid);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.CH_ID);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@ORDERINVOICE", DbType.Decimal, enumValue.StlAmount);
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
|
|
if (isList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var defGOODFEELIST = MsCodeGoodInvDAL.GetData(" GOODNAME='代理" + enumValue.FeeName + "'");
|
|
|
|
|
|
|
|
|
|
cmdInsertInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PID", DbType.String, GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SerialNo", DbType.Int32, 1);
|
|
|
|
|
if (defGOODFEELIST.GOODNAME == "")
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, "代理运杂费");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, "票");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, defGOODFEELIST.GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, defGOODFEELIST.UNIT);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, defGOODFEELIST.SPEC);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(feettl, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal,defGOODFEELIST.TAXRATE);
|
|
|
|
|
if (defGOODFEELIST.TAXRATE == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(feettl, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(feettl, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(feettl / (1 + defGOODFEELIST.TAXRATE / 100) * (defGOODFEELIST.TAXRATE / 100), 2);
|
|
|
|
|
var amount = feettl - tax;
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, tax);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String, defGOODFEELIST.GOODCODE);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsertInv, tran);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
acctaxrate = headdata.RATE;
|
|
|
|
|
|
|
|
|
|
if (!isList)
|
|
|
|
|
{
|
|
|
|
|
acctaxrate = defGOOD.TAXRATE;
|
|
|
|
|
var dataList = GetDetailList(" PID='" + GID + "'");
|
|
|
|
|
if (dataList.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var invlist = dataList[0];
|
|
|
|
|
cmdUpdateInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@GID", DbType.String, invlist.GID);
|
|
|
|
|
if (acctaxrate == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal,Math.Round(invlist.AMOUNT + amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2);
|
|
|
|
|
var amount = amtttl - tax;
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, invlist.AMOUNT + amount);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, ((invlist.AMOUNT + amount) / invlist.PKGS) * (1 + acctaxrate / 100));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, (invlist.AMOUNT + amount) / invlist.PKGS);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, invlist.TAX+tax);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateInv, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdInsertInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PID", DbType.String, GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SerialNo", DbType.Int32, 1);
|
|
|
|
|
if (defGOOD.GOODNAME == "")
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, "代理运杂费");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, "票");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, defGOOD.GID);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, defGOOD.UNIT);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, defGOOD.SPEC);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal, acctaxrate);
|
|
|
|
|
if (acctaxrate == 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(amtttl,2));
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2);
|
|
|
|
|
var amount = amtttl - tax;
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, amount);
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, tax);
|
|
|
|
|
}
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, "");
|
|
|
|
|
db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String, defGOOD.GOODCODE);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsertInv, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var MBLNOSTR = "";
|
|
|
|
|
if (FEENOAUDITCANTSHENINV.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (billnoinvlist != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var billnoinv in billnoinvlist)
|
|
|
|
|
{
|
|
|
|
|
MBLNOSTR = MBLNOSTR + billnoinv.MBLNO + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MBLNOSTR != "") MBLNOSTR = "主提单号:" + MBLNOSTR + " 业务应收费用中存在未审核的费用,不能添加发票申请!";
|
|
|
|
|
else MBLNOSTR = "添加成功";
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = MBLNOSTR;
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//result.Success = true;
|
|
|
|
|
//result.Message = "保存成功";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Decimal GetExrate(string curr, List<ChFeeExrate> exratelist)
|
|
|
|
|
{
|
|
|
|
|
decimal exrate = 0;
|
|
|
|
|
if (exratelist != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in exratelist)
|
|
|
|
|
{
|
|
|
|
|
if (enumValue.CURR == curr)
|
|
|
|
|
{
|
|
|
|
|
exrate = enumValue.EXRATE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return exrate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult DelFeeDo(List<Chfee_do_detail> boday,string GID)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
decimal AMOUNT = 0;
|
|
|
|
|
|
|
|
|
|
if (boday != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cmddelete = db.GetSqlStringCommand("delete from ch_fee_do where GID=@FEEDOID");
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee set ORDERINVOICE=ORDERINVOICE-@ORIGAMOUNT where GID=@GID");
|
|
|
|
|
|
|
|
|
|
foreach (var enumValue in boday)
|
|
|
|
|
{
|
|
|
|
|
cmddelete.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmddelete, "@FEEDOID", DbType.String, enumValue.FEEDOID);
|
|
|
|
|
db.ExecuteNonQuery(cmddelete, tran);
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@ORIGAMOUNT", DbType.Decimal, enumValue.ORIGAMOUNT);
|
|
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.FEEID);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
AMOUNT = AMOUNT + enumValue.AMOUNT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataList =GetDetailList(" PID='"+GID+"'");
|
|
|
|
|
if (dataList.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var cmdUpdateInv =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"update ch_fee_invoicedetail set TAXPRICE=@TAXPRICE
|
|
|
|
|
,PRICE=@PRICE,AMOUNT=@AMOUNT,TAX=@TAX where GID=@GID ");
|
|
|
|
|
var invlist = dataList[0];
|
|
|
|
|
cmdUpdateInv.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@GID", DbType.String, invlist.GID);
|
|
|
|
|
if (invlist.TAXRATE== 0)
|
|
|
|
|
{
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT-AMOUNT, 2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT - AMOUNT) / invlist.PKGS, 2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT - AMOUNT) / invlist.PKGS, 2));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tax = Math.Round(AMOUNT / (1 + invlist.TAXRATE / 100) * (invlist.TAXRATE / 100), 2);
|
|
|
|
|
var amount = AMOUNT - tax;
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, invlist.AMOUNT - amount);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, ((invlist.AMOUNT - amount) / invlist.PKGS) * (1 + invlist.TAXRATE / 100));
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, (invlist.AMOUNT - amount) / invlist.PKGS);
|
|
|
|
|
db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, invlist.TAX- tax);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdateInv, 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 int p_update_Amount(string billno,string GID)
|
|
|
|
|
{
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
var cmd = db.GetStoredProcCommand("p_update_invapplycation");
|
|
|
|
|
db.AddInParameter(cmd, "@con_no", DbType.String, billno);
|
|
|
|
|
db.AddInParameter(cmd, "@con_gid", DbType.String, GID);
|
|
|
|
|
db.ExecuteNonQuery(cmd);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 提交审核和撤销审核
|
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAudit(String WorkFlowName, String USERID, String bill)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName,bill, USERID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("BILLNO=@BILLNO");
|
|
|
|
|
if (WorkResult.islast == true)
|
|
|
|
|
{
|
|
|
|
|
cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=0 where BILLNO=@BILLNO");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=2 where BILLNO=@BILLNO");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "提交审核成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "提交审核错误!";
|
|
|
|
|
}
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAuditList(String WorkFlowName, String USERID, String bills)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
var billList = bills.Split(',');
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var bill in billList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, bill, USERID);
|
|
|
|
|
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("BILLNO=@BILLNO");
|
|
|
|
|
if (WorkResult.islast == true)
|
|
|
|
|
{
|
|
|
|
|
cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=0 where BILLNO=@BILLNO");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=2 where BILLNO=@BILLNO");
|
|
|
|
|
}
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "提交审核成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "提交审核错误!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAuditBack(String WorkFlowName, String USERID, String bill)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, bill, USERID);
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
|
|
{
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=1 where BILLNO=@BILLNO");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "撤销提交成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "已部分审核此业务,不允许撤回提交!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "撤销提交错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAuditBackList(String WorkFlowName, String USERID, String bills)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
var billList = bills.Split(',');
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
foreach (var bill in billList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, bill, USERID);
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
|
|
{
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=1 where BILLNO=@BILLNO");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "撤销提交成功";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "已部分审核此业务,不允许撤回提交!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "撤销提交错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 审核或驳回
|
|
|
|
|
|
|
|
|
|
public static DBResult AuditList(List<ChInvoiceapplication> boday,string PAYCOMPANYID, String USERID)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (boday != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=0 where BILLNO=@BILLNO");
|
|
|
|
|
var cmdupdate2 = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=0,PAYCOMPANYID=@PAYCOMPANYID where BILLNO=@BILLNO");
|
|
|
|
|
|
|
|
|
|
foreach (var enumValue in boday)
|
|
|
|
|
{
|
|
|
|
|
if (enumValue.BILLSTATUS == 2 || enumValue.BILLSTATUS ==4)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo("InvAudit", enumValue.BILLNO, USERID, tran);
|
|
|
|
|
if (WorkResult.Success == true&&WorkResult.islast==true)
|
|
|
|
|
{
|
|
|
|
|
if (boday.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
cmdupdate2.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate2, "@PAYCOMPANYID", DbType.String, PAYCOMPANYID);
|
|
|
|
|
db.AddInParameter(cmdupdate2, "@BILLNO", DbType.String, enumValue.BILLNO);
|
|
|
|
|
db.ExecuteNonQuery(cmdupdate2, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, enumValue.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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "审核通过";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult AuditBackList(List<ChInvoiceapplication> boday, String USERID)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (boday != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoiceapplication set BILLSTATUS=4 where BILLNO=@BILLNO");
|
|
|
|
|
|
|
|
|
|
foreach (var enumValue in boday)
|
|
|
|
|
{
|
|
|
|
|
if (enumValue.BILLSTATUS == 2 || enumValue.BILLSTATUS == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo("InvAudit", enumValue.BILLNO, USERID, "");
|
|
|
|
|
if (WorkResult.Success == true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, enumValue.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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "完成驳回";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发票审核列表
|
|
|
|
|
|
|
|
|
|
static public List<ChInvoiceapplication> GetAuditDataList(string strCondition, string userid, string isaudit,string companyid,string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append(" SELECT i.GID,i.BILLNO,i.BILLSTATUS,i.CUSTOMERNAME,i.ACTUALCUSTOMERNAME,i.CURRENCY,i.INVOICENO,i.INVOICECUSTNAME,i.INVOICECATEGORY ");
|
|
|
|
|
strSql.Append(" ,i.BSNO,i.MBLNO,i.VESSELVOYAGE,i.POL,i.POD,i.ETD,i.APPLYAMOUNT,i.INVAMOUNT,i.AMOUNTCAPITAL,i.OTCURRAMOUNT");
|
|
|
|
|
strSql.Append(" ,i.APPLICANT,i.APPLYTIME,i.ENTERTIME,i.OPERATOR,i.OPERATETIME,i.RECVCURR,i.FEEAMOUNT ");
|
|
|
|
|
strSql.Append(" ,i.REMARK,i.COMPANYID,i.ISAPPLY,i.CUSTRATENO,i.CUSTADDRTEL,i.CUSTBANK,i.RATE,'' INVOICENOREF ");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97010 and EnumValueID=i.BILLSTATUS) as BILLSTATUSREF");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97008 and EnumValueID=i.INVOICECATEGORY) as INVOICECATEGORYREF");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=i.APPLICANT) as APPLICANTNAME");
|
|
|
|
|
strSql.Append(",i.PAYCOMPANYID,(select name from company where gid=i.PAYCOMPANYID) PAYCOMPANYREF,dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit ");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM ch_fee_invoiceapplication i left join workflow_using wu on wu.bsno=i.billno where 1=1 ");
|
|
|
|
|
if (isaudit=="1")
|
|
|
|
|
strSql.Append(" and i.BILLSTATUS=2 and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 ");
|
|
|
|
|
else if (isaudit == "2")
|
|
|
|
|
// strSql.Append(" and i.BILLSTATUS=0 AND I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
|
|
|
strSql.Append(" and i.BILLSTATUS=0 ");
|
|
|
|
|
|
|
|
|
|
else if (isaudit == "")
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAListStr("", userid,"", companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + rangstr);
|
|
|
|
|
}
|
|
|
|
|
//strSql.Append(" and (dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 ");
|
|
|
|
|
//strSql.Append(" or (I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ))) ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by APPLYTIME desc ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发票申请列表权限范围
|
|
|
|
|
|
|
|
|
|
public static string GetRangDAListStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");
|
|
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
|
|
strSql.Append(" where [NAME]='modInvoiceAppList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = " (APPLICANT='" + userid + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
str = " (APPLICANT='" + userid + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")
|
|
|
|
|
{
|
|
|
|
|
var rangeDa = new RangeDA();
|
|
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
|
|
str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT 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 = " (APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
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 = " (APPLICANT='" + Convert.ToString(reader["OPID"]) + "' ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or APPLICANT='" + Convert.ToString(reader["OPID"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
str = str + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "0")
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发票申请费用查询范围
|
|
|
|
|
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
|
|
strSql.Append(" where [NAME]='modInvoiceAppSearch' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
|
|
|
|
|
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"]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR INPUTBY='" + username + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR INPUTBY='" + username + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")
|
|
|
|
|
{
|
|
|
|
|
var rangeDa = new RangeDA();
|
|
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
|
|
str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
|
|
|
|
|
+ " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
|
|
|
|
|
+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
|
|
|
|
|
+ " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
|
|
|
|
|
+ " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
|
|
|
|
|
+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
|
|
|
|
|
+ " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')))";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "0")
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|