|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using HcUtility.Comm;
|
|
|
using DSWeb.MvcShipping.Models.WMSNew;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Models.MsStevedores;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using System.Data.SqlClient;
|
|
|
using DSWeb.DataAccess;
|
|
|
using DSWeb.Areas.MvcShipping.Models.WMSFeeModel;
|
|
|
using DSWeb.Areas.MvcShipping.DAL.WMSFeeModel;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.MvcShipping.DAL.WMSDeliver;
|
|
|
using System.Linq;
|
|
|
using System.Data.Common;
|
|
|
using System.Configuration;
|
|
|
using DSWeb.MvcShipping.Models.MsChFee;
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
|
using DSWeb.Areas.MvcShipping.Helper;
|
|
|
using DSWeb.Common.DB;
|
|
|
using System.Data.Entity.Migrations;
|
|
|
//using DSWeb.MvcShipping.Models.WMS;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.WMSNewDAL
|
|
|
{
|
|
|
public class WMSNewDAL
|
|
|
{
|
|
|
static public List<WMSNewList> GetDataList(string strCondition, int start, int limit, string userid, string username, string companyid, out int total, string sort = null)
|
|
|
{
|
|
|
var rangstr = GetRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(@"SELECT GID,
|
|
|
isnull(EIP,0) EIP,
|
|
|
ISLOCK=(CASE ISLOCK WHEN 'True' THEN '1' WHEN 'False' THEN '0' END),
|
|
|
(case ISCHANGE when 1 then '货权转移' else '' end) as ISCHANGE,
|
|
|
blno,
|
|
|
CUSTOMNO,
|
|
|
WMSNO,
|
|
|
CUSTOMERNAME,
|
|
|
COMPANY,
|
|
|
STORAGENAME,
|
|
|
ARCLIENT,
|
|
|
TRUCKNAME,
|
|
|
isnull(GOODSNAME,(select GOODNAME from code_goods where GID = GOODSNAMEID)) GOODSNAME,
|
|
|
dbo.F_WMSINCOUNTRY_CN(GID) COUNTRYOFORIGIN,
|
|
|
GOODSMODEL,
|
|
|
isnull(GOODSPACK,0) GOODSPACK,
|
|
|
isnull(GOODSPACKSTOCK,0) GOODSPACKSTOCK,
|
|
|
isnull(GOODSRKSL,0) GOODSRKSL,
|
|
|
isnull(GOODSSTOCK,0) GOODSSTOCK,
|
|
|
CHARGEUNIT,
|
|
|
isnull(ARFEE,0) ARFEE,
|
|
|
isnull(APFEE,0) APFEE,
|
|
|
WMSOP,
|
|
|
convert(char(10),WMSDATE,20) AS WMSDATE,
|
|
|
convert(char(10),STARTBILLINGDATE,20) AS STARTBILLINGDATE,
|
|
|
MARKETVALUE,
|
|
|
BANKVALUE,
|
|
|
BZTCHNO,
|
|
|
FREESTORAGEPERIOD,
|
|
|
FREESTORAGEPERIODAP,
|
|
|
CONTRACTNO,
|
|
|
CUSTNO,
|
|
|
AREANAME,
|
|
|
GOODSSTANDARD,
|
|
|
ASSOCIATEDNO,
|
|
|
WHS_CODE,
|
|
|
convert(char(10),STARTBILLINGDATEAP,20) AS STARTBILLINGDATEAP,
|
|
|
ACCDATE,
|
|
|
FEESTATUS,(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,
|
|
|
REMARKS,
|
|
|
WET,
|
|
|
CASE FEESTATUS WHEN 0 THEN '未锁定' ELSE '已锁定' END AS FEESTATUSDISC ,
|
|
|
(select top 1 CNTRNO from op_ctn where BSNO=wms.ASSOCIATEDNO) CNTRNO,
|
|
|
(select top 1 CTNALL from op_ctn where BSNO=wms.ASSOCIATEDNO) CTNALL,
|
|
|
(select top 1 SEALNO from op_ctn where BSNO=wms.ASSOCIATEDNO) SEALNO,
|
|
|
ISNULL((select sum(pkgs) from op_apply where mblno = (SELECT mblno from op_seai where bsno=wms.ASSOCIATEDNO )),0) BAOGUANJIANSHU ,ISLOCK2=(CASE ISLOCK2 WHEN 'True' THEN '1' WHEN 'False' THEN '0' END),
|
|
|
GOODSPACK AS PKGS,
|
|
|
ISNULL((select ISBONDED from op_seai where BSNO= wms.ASSOCIATEDNO),0) ISBONDED,
|
|
|
dbo.F_GetBillDrFeeStatus_WMS(GID) DRFEESTATUS,
|
|
|
dbo.F_GetBillCrFeeStatus_WMS(GID) CRFEESTATUS,
|
|
|
GOODSNAMEID ,
|
|
|
(SELECT wi.PICIHAO+'/'FROM wms_in wi where wi.ASSOCIATEDNO=wms.GID FOR XML PATH(''))as PICIHAO
|
|
|
,isnull(TiDanJianShu,'0') TiDanJianShu
|
|
|
,isnull(TiDanZhongLiang,'0') TiDanZhongLiang,GOODSKGS,''AREACODE,''FilePath,isnull(RENTAREA,'0') RENTAREA,SALE
|
|
|
|
|
|
FROM wms where 1=1");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(sort))
|
|
|
{
|
|
|
var so = JsonConvert.Deserialize<List<SortObject>>(sort);
|
|
|
string orderbyStr = " order by ";
|
|
|
foreach (var s in so)
|
|
|
{
|
|
|
orderbyStr += s.property + " " + s.direction + ",";
|
|
|
}
|
|
|
orderbyStr = orderbyStr.Substring(0, orderbyStr.Length - 1);
|
|
|
strSql.Append(orderbyStr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by WMSDATE DESC ");
|
|
|
}
|
|
|
int totalCount = 0;
|
|
|
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out totalCount);
|
|
|
total = totalCount;
|
|
|
return SetData(sb);
|
|
|
}
|
|
|
|
|
|
static public List<WMSNewList> GetDataList_LTJY(string strCondition, int start, int limit, string userid, string username, string companyid, out int total, string sort = null)
|
|
|
{
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, username, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(@"SELECT GID,
|
|
|
0 EIP,
|
|
|
ISLOCK=(CASE ISLOCK WHEN 'True' THEN '1' WHEN 'False' THEN '0' END),
|
|
|
(case ISCHANGE when 1 then '货权转移' else '' end) as ISCHANGE,
|
|
|
blno,
|
|
|
CUSTOMNO,
|
|
|
WMSNO,
|
|
|
CUSTOMERNAME,
|
|
|
STORAGENAME,
|
|
|
ARCLIENT,
|
|
|
TRUCKNAME,
|
|
|
COMPANY,
|
|
|
dbo.F_Str_wmsgoodsname(GID) GOODSNAME,
|
|
|
GOODSMODEL,
|
|
|
isnull(GOODSPACK,0) GOODSPACK,
|
|
|
isnull(GOODSPACKSTOCK,0) GOODSPACKSTOCK,
|
|
|
isnull(GOODSRKSL,0) GOODSRKSL,
|
|
|
isnull(GOODSSTOCK,0) GOODSSTOCK,
|
|
|
CHARGEUNIT,
|
|
|
isnull(ARFEE,0) ARFEE,
|
|
|
isnull(APFEE,0) APFEE,
|
|
|
WMSOP,
|
|
|
convert(char(10),WMSDATE,20) AS WMSDATE,
|
|
|
convert(char(10),STARTBILLINGDATE,20) AS STARTBILLINGDATE,
|
|
|
MARKETVALUE,
|
|
|
BANKVALUE,
|
|
|
BZTCHNO,
|
|
|
FREESTORAGEPERIOD,
|
|
|
FREESTORAGEPERIODAP,
|
|
|
CONTRACTNO,
|
|
|
CUSTNO,
|
|
|
AREANAME,
|
|
|
GOODSSTANDARD,
|
|
|
ASSOCIATEDNO,
|
|
|
WHS_CODE,
|
|
|
convert(char(10),STARTBILLINGDATEAP,20) AS STARTBILLINGDATEAP,
|
|
|
ACCDATE,
|
|
|
FEESTATUS,(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,
|
|
|
REMARKS,
|
|
|
'' WET,
|
|
|
CASE FEESTATUS WHEN 0 THEN '未锁定' ELSE '已锁定' END AS FEESTATUSDISC ,
|
|
|
(select top 1 CNTRNO from op_ctn where BSNO=wms.ASSOCIATEDNO) CNTRNO,
|
|
|
(select top 1 CTNALL from op_ctn where BSNO=wms.ASSOCIATEDNO) CTNALL,
|
|
|
(select top 1 SEALNO from op_ctn where BSNO=wms.ASSOCIATEDNO) SEALNO,
|
|
|
ISNULL((select sum(pkgs) from op_apply where mblno = (SELECT mblno from op_seai where bsno=wms.ASSOCIATEDNO )),0) BAOGUANJIANSHU ,ISLOCK2 ,
|
|
|
ISNULL((select count(*) from wms_in where ASSOCIATEDNO= wms.GID),0) PKGS,
|
|
|
ISNULL((select ISBONDED from op_seai where BSNO= wms.ASSOCIATEDNO),0) ISBONDED,
|
|
|
dbo.F_GetBillDrFeeStatus(GID) DRFEESTATUS,
|
|
|
dbo.F_GetBillCrFeeStatus(GID) CRFEESTATUS,
|
|
|
GOODSNAMEID ,
|
|
|
(SELECT distinct wi.PICIHAO+'/' FROM wms_in wi where wi.ASSOCIATEDNO=wms.GID and ISNULL(wi.PICIHAO,'')<>'' FOR XML PATH(''))as PICIHAO
|
|
|
,(SELECT distinct wi.AREACODE+'/' FROM wms_in wi where wi.ASSOCIATEDNO=wms.GID and ISNULL(wi.AREACODE,'')<>'' FOR XML PATH(''))as AREACODE
|
|
|
,isnull(TiDanJianShu,'0') TiDanJianShu
|
|
|
,isnull(TiDanZhongLiang,'0') TiDanZhongLiang,GOODSKGS,'0' RENTAREA,SALE
|
|
|
,FilePath
|
|
|
FROM wms where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(sort))
|
|
|
{
|
|
|
var so = JsonConvert.Deserialize<List<SortObject>>(sort);
|
|
|
string orderbyStr = " order by ";
|
|
|
foreach (var s in so)
|
|
|
{
|
|
|
orderbyStr += s.property + " " + s.direction + ",";
|
|
|
}
|
|
|
orderbyStr = orderbyStr.Substring(0, orderbyStr.Length - 1);
|
|
|
strSql.Append(orderbyStr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by WMSDATE ");
|
|
|
}
|
|
|
int totalCount = 0;
|
|
|
StringBuilder sb = PagerHelper.PageSQL(strSql.ToString(), start, limit, out totalCount);
|
|
|
total = totalCount;
|
|
|
return SetData(sb);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<WMSNewList> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<WMSNewList>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WMSNewList data = new WMSNewList();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = reader["GID"].ToString();
|
|
|
data.EIP = Convert.ToBoolean((reader["EIP"]));
|
|
|
data.ISLOCK = reader["ISLOCK"].ToString();
|
|
|
data.ISCHANGE = reader["ISCHANGE"].ToString();
|
|
|
data.BLNO = reader["BLNO"].ToString();
|
|
|
data.WMSNO = reader["WMSNO"].ToString();
|
|
|
data.CUSTOMERNAME = reader["CUSTOMERNAME"].ToString();
|
|
|
data.STORAGENAME = reader["STORAGENAME"].ToString();
|
|
|
data.ARCLIENT = reader["ARCLIENT"].ToString();
|
|
|
data.TRUCKNAME = reader["TRUCKNAME"].ToString();
|
|
|
data.GOODSNAME = reader["GOODSNAME"].ToString();
|
|
|
data.GOODSMODEL = reader["GOODSMODEL"].ToString();
|
|
|
data.GOODSPACK = reader["GOODSPACK"].ToString();
|
|
|
data.GOODSPACKSTOCK = reader["GOODSPACKSTOCK"].ToString();
|
|
|
data.GOODSRKSL = reader["GOODSRKSL"].ToString();
|
|
|
data.GOODSSTOCK = reader["GOODSSTOCK"].ToString();
|
|
|
data.CHARGEUNIT = reader["CHARGEUNIT"].ToString();
|
|
|
data.ARFEE = reader["ARFEE"].ToString();
|
|
|
data.APFEE = reader["APFEE"].ToString();
|
|
|
data.WMSOP = reader["WMSOP"].ToString();
|
|
|
data.WMSDATE = reader["WMSDATE"].ToString();
|
|
|
data.STARTBILLINGDATE = reader["STARTBILLINGDATE"].ToString();
|
|
|
data.MARKETVALUE = reader["MARKETVALUE"].ToString();
|
|
|
data.BANKVALUE = reader["BANKVALUE"].ToString();
|
|
|
data.BZTCHNO = reader["BZTCHNO"].ToString();
|
|
|
data.FREESTORAGEPERIOD = reader["FREESTORAGEPERIOD"].ToString();
|
|
|
data.FREESTORAGEPERIODAP = reader["FREESTORAGEPERIODAP"].ToString();
|
|
|
data.CONTRACTNO = reader["CONTRACTNO"].ToString();
|
|
|
data.STARTBILLINGDATEAP = reader["STARTBILLINGDATEAP"].ToString();
|
|
|
data.CUSTOMNO = reader["CUSTOMNO"].ToString();
|
|
|
data.GOODSSTANDARD = reader["GOODSSTANDARD"].ToString();
|
|
|
data.AREANAME = reader["AREANAME"].ToString();
|
|
|
data.CUSTNO = reader["CUSTNO"].ToString();
|
|
|
data.ASSOCIATEDNO = reader["ASSOCIATEDNO"].ToString();
|
|
|
data.WHS_CODE = reader["WHS_CODE"].ToString();
|
|
|
data.FEESTATUSDISC = reader["FEESTATUSDISC"].ToString();
|
|
|
data.CNTRNO = reader["CNTRNO"].ToString();
|
|
|
data.CTNALL = reader["CTNALL"].ToString();
|
|
|
data.BAOGUANJIANSHU = Convert.ToInt32(reader["BAOGUANJIANSHU"]);
|
|
|
data.ISLOCK2 = reader["ISLOCK2"].ToString();
|
|
|
data.PKGS = reader["PKGS"].ToString();
|
|
|
data.SEALNO = reader["SEALNO"].ToString();
|
|
|
data.GOODSKGS = reader["GOODSKGS"].ToString();
|
|
|
data.REMARKS = reader["REMARKS"].ToString();
|
|
|
data.COMPANY = reader["COMPANY"].ToString();
|
|
|
data.ACCDATE = reader["ACCDATE"].ToString();
|
|
|
if (reader["FEESTATUS"] != DBNull.Value)
|
|
|
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);//费用状态
|
|
|
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);// 费用状态
|
|
|
|
|
|
data.ISBONDED = reader["ISBONDED"].ToString() == "0" ? "否" : "是";
|
|
|
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));
|
|
|
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));
|
|
|
data.GOODSNAMEID = getfeestatus(Convert.ToString(reader["GOODSNAMEID"]));
|
|
|
|
|
|
|
|
|
if(BasicDataRefDAL.ReadFieldExist(reader,"COUNTRYOFORIGIN"))
|
|
|
data.COUNTRYOFORIGIN = reader["COUNTRYOFORIGIN"].ToString();
|
|
|
|
|
|
string picihao = "";
|
|
|
if (reader["PICIHAO"] != DBNull.Value)
|
|
|
{
|
|
|
string[] picihaoarr = reader["PICIHAO"].ToString().Split('/');
|
|
|
|
|
|
foreach (var item in picihaoarr)
|
|
|
{
|
|
|
if (item == "")
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
picihao += (item + "/");
|
|
|
}
|
|
|
}
|
|
|
if (picihao.Contains("/"))
|
|
|
{
|
|
|
picihao = picihao.Substring(0, picihao.Length - 1);
|
|
|
}
|
|
|
}
|
|
|
data.PICIHAO = picihao;
|
|
|
|
|
|
string AREACODE = "";
|
|
|
if (reader["AREACODE"] != DBNull.Value)
|
|
|
{
|
|
|
string[] AREACODEarr = reader["AREACODE"].ToString().Split('/');
|
|
|
|
|
|
foreach (var item in AREACODEarr)
|
|
|
{
|
|
|
if (item == "")
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AREACODE += (item + "/");
|
|
|
}
|
|
|
}
|
|
|
if (AREACODE.Contains("/"))
|
|
|
{
|
|
|
AREACODE = AREACODE.Substring(0, AREACODE.Length - 1);
|
|
|
}
|
|
|
}
|
|
|
data.AREACODE = AREACODE;
|
|
|
data.TiDanJianShu = reader["TiDanJianShu"].ToString();
|
|
|
data.TiDanZhongLiang = reader["TiDanZhongLiang"].ToString();
|
|
|
data.FilePath = reader["FilePath"].ToString();
|
|
|
data.WET = reader["WET"].ToString();
|
|
|
data.RENTAREA = reader["RENTAREA"].ToString();
|
|
|
|
|
|
if (BasicDataRefDAL.ReadFieldExist(reader, "ACCDATE")) {
|
|
|
data.ACCDATE = reader["ACCDATE"].ToString();
|
|
|
}
|
|
|
data.SALE= reader["SALE"].ToString();
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool Delete(List<WMSNewList> list, out string msg)
|
|
|
{
|
|
|
string message;
|
|
|
string ids = "";
|
|
|
bool bEIP = false;
|
|
|
foreach (var m in list)
|
|
|
{
|
|
|
ids += "'" + m.GID + "',";
|
|
|
bEIP = m.EIP;
|
|
|
}
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
//检测是否有费用,有的话不允许删除
|
|
|
string SelSql = @"SELECT count(*) FROM wms w
|
|
|
INNER join ch_fee c on w.GID = c.BSNO
|
|
|
WHERE w.GID in (" + ids + ")";
|
|
|
|
|
|
int feeRst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, SelSql));
|
|
|
if (feeRst > 0)
|
|
|
{
|
|
|
msg = "该入库单存在费用,无法删除!";
|
|
|
return false;
|
|
|
}
|
|
|
string DelSql = "DELETE FROM WMS WHERE GID IN (" + ids + ")";
|
|
|
bool result = false;
|
|
|
try
|
|
|
{
|
|
|
result = db.ExecuteNonQuery(CommandType.Text, DelSql) > 0;
|
|
|
if (result)
|
|
|
{
|
|
|
message = "删除成功!";
|
|
|
string UpdateCtrnSql = "UPDATE op_ctn SET ISWMS='0',WMSDATE=NULL,AREANAME=NULL FROM op_ctn INNER JOIN WMS_IN ON op_ctn.CTN_ID=WMS_IN.GID WHERE WMS_IN.ASSOCIATEDNO IN (" + ids + ")";
|
|
|
db.ExecuteNonQuery(CommandType.Text, UpdateCtrnSql);
|
|
|
string DelDetSql = "DELETE FROM WMS_IN WHERE ASSOCIATEDNO IN (" + ids + ")";
|
|
|
db.ExecuteNonQuery(CommandType.Text, DelDetSql);
|
|
|
if (bEIP)
|
|
|
{
|
|
|
string DelGoodsSql = "DELETE FROM WMS_EIPGOODS WHERE BSNO IN (" + ids + ")";
|
|
|
db.ExecuteNonQuery(CommandType.Text, DelGoodsSql);
|
|
|
WMSEIPSDeliverDAL.UpdateByDeliverNo(ids, "1", true);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "删除失败!";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result = false;
|
|
|
message = ex.Message;
|
|
|
}
|
|
|
msg = message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static WMSNewList GetData(string conditions, string userid, string username, string companyid)
|
|
|
{
|
|
|
int total = 0;
|
|
|
var TList = GetDataList(conditions, 0, 1, userid, username, companyid, out total);
|
|
|
WMSNewList wms = new WMSNewList();
|
|
|
if (TList.Count > 0)
|
|
|
{
|
|
|
wms = GetDataList(conditions, 0, 1, userid, username, companyid, out total)[0];
|
|
|
}
|
|
|
return wms;
|
|
|
}
|
|
|
|
|
|
public static WMSNewList GetData_LTJY(string conditions, string userid, string username, string companyid)
|
|
|
{
|
|
|
int total = 0;
|
|
|
var TList = GetDataList_LTJY(conditions, 0, 1, userid, username, companyid, out total);
|
|
|
WMSNewList wms = new WMSNewList();
|
|
|
if (TList.Count > 0)
|
|
|
{
|
|
|
wms = GetDataList_LTJY(conditions, 0, 1, userid, username, companyid, out total)[0];
|
|
|
}
|
|
|
return wms;
|
|
|
}
|
|
|
|
|
|
#region 入库信息列表
|
|
|
|
|
|
static public List<WMSNewIN> GetWMSINList(string strCondition, string sort)
|
|
|
{
|
|
|
//库存信息
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" SELECT wi.GID,wi.ASSOCIATEDNO,wi.TRAYNO,wi.BLNO,wi.CONTRACTNO,wi.CNTRNO,wi.SEALNO,wi.BSNO,wi.CLIENTCODE,wi.CLIENTNAME, ");
|
|
|
strSql.Append(" wi.DODATE,wi.STORAGECODE,wi.STORAGENAME,wi.AREACODE,wi.AREANAME,wi.GOODSCODE,wi.GOODSTYPE,wi.GOODSNAME,wi.GOODSMODEL, ");
|
|
|
strSql.Append(" ISNULL(wi.GOODSNAMEID,wi.GOODSNAME) AS GOODSNAMEID,wi.GOODSSTANDARD,wi.GOODSPACK,wi.CHARGEUNIT,wi.GOODSRKSL,wi.GOODSSTOCK,");
|
|
|
strSql.Append(" wi.FREESTORAGEPERIOD,wi.ISLOCK,wi.LOCKTIME,wi.LOCKUSER,wi.ISDELETE,wi.DELETETIME,wi.DELETEUSER,wi.CREATEUSER,wi.TrayNo,");
|
|
|
strSql.Append(" wi.MODIFIEDTIME,wi.REMARK,wi.GOODSPACKSTOCK,wi.KINDPKGS,wi.GOODSKGS,wi.CLIENTCODEOLD,wi.CLIENTNAMEOLD,wi.ARFEE,wi.APFEE,");
|
|
|
strSql.Append(" wi.CORPID,wi.CTNALL,wi.CREATETIME,wi.MODIFIEDUSER,wi.GOODSTHICKNESS,wi.GOODSWIDTH,wi.GOODSLENGTH,wi.GOODSSLICE,wi.GOODSGRADE,wi.STACKLOCATION,wi.GOODSPACKACTUAL,wi.GOODSRKSLACTUAL,");
|
|
|
strSql.Append(" wi.ISCHANGE,wi.MARKETVALUE,wi.BANKVALUE,wi.LINENUM,wi.JIANSHU1,wi.JIANSHU2,wi.XIANGHAO2,wi.TRUCKNO,wi.ZHUANGXIEGONGID,");
|
|
|
strSql.Append(" wi.LUYUNFEI,wi.DIAOTOUFEI,wi.XIUXIXIANGFEI,wi.DIAOZHUANGFEI,wi.CHEDUIID,wi.ZHONGLIANG2,wi.CHIMA1,wi.CHIMA2,");
|
|
|
strSql.Append(" wi.SHIJIZHONGLIANG,wi.SHIJICHIMA,wi.PICIHAO,wi.ZHUANGXIEFEI,wi.ZhuangXieFeeType,wi.LOADERFEE,");
|
|
|
//strSql.Append(" wi.COUNTRYID,dbo.trimdate(wi.Productiondate) Productiondate,wi.FactoryNo,wi.DOCK,wi.LinShiZhuangXieFeiDanJiaDun,wi.LinShiZhuangXieFeiDanJiaJian,");
|
|
|
strSql.Append(" wi.COUNTRYID,isnull(wi.Productiondate,'') Productiondate,wi.FactoryNo,wi.DOCK,wi.LinShiZhuangXieFeiDanJiaDun,wi.LinShiZhuangXieFeiDanJiaJian,");
|
|
|
|
|
|
var WMSGOODNAMEIMPORTTRADE = MsSysParamSetDAL.GetData("PARAMNAME='WMSGOODNAMEIMPORTTRADE'");
|
|
|
if (WMSGOODNAMEIMPORTTRADE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" goodsname as GOODSNAMEDISPLAY ,");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" IsNull((SELECT TOP 1 (GOODNAME) as CodeAndName from code_goods where GID = wi.goodsnameid),(SELECT TOP 1 (GOODNAME) as CodeAndName from code_goods where GOODNAME = wi.goodsname)) as GOODSNAMEDISPLAY ,");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(" IsNull((SELECT CODE+'-'+NAME as CODENAME from wms_stevedores where GID = wi.ZHUANGXIEGONGID),'') as ZHUANGXIEGONG , ");
|
|
|
strSql.Append(" IsNull((SELECT PriceJian from wms_stevedores where GID = wi.ZHUANGXIEGONGID),'0') as ZhuangXieFeiDanJiaJian , ");
|
|
|
strSql.Append(" IsNull((SELECT PriceLiangTon from wms_stevedores where GID = wi.ZHUANGXIEGONGID),'0') as ZhuangXieFeiDanJiaTon , ");
|
|
|
strSql.Append(" IsNull((SELECT CODENAME+'-'+SHORTNAME as CODENAME from info_client where GID = wi.CHEDUIID),'') as CHEDUI, ");
|
|
|
strSql.Append(" IsNull((select substring(country,0,(charindex('(',country)) ) as country from code_country where COUNTRYID=wi.countryid),'') as COUNTRY ");
|
|
|
|
|
|
strSql.Append(" ,wi.INVOICENO,wi.BZTCHNO ");
|
|
|
|
|
|
strSql.Append(" FROM [wms_in] wi ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition.Replace("~", ""));
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by wi.LINENUM ");
|
|
|
}
|
|
|
return SetWMSINData(strSql);
|
|
|
}
|
|
|
#endregion
|
|
|
static public WMSNewIN GetWMSINData(string condition)
|
|
|
{
|
|
|
var _t = "";
|
|
|
var list = GetWMSINList(condition, _t);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
|
|
|
return new WMSNewIN();
|
|
|
}
|
|
|
|
|
|
private static List<WMSNewIN> SetWMSINData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<WMSNewIN>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WMSNewIN data = new WMSNewIN();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.ASSOCIATEDNO = Convert.ToString(reader["ASSOCIATEDNO"]);
|
|
|
data.BLNO = Convert.ToString(reader["BLNO"]);
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
|
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);
|
|
|
data.SEALNO = Convert.ToString(reader["SEALNO"]);
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
data.CLIENTCODE = Convert.ToString(reader["CLIENTCODE"]);
|
|
|
data.CLIENTNAME = Convert.ToString(reader["CLIENTNAME"]);
|
|
|
data.DODATE = Convert.ToString(reader["DODATE"]);
|
|
|
data.STORAGECODE = Convert.ToString(reader["STORAGECODE"]);
|
|
|
data.STORAGENAME = Convert.ToString(reader["STORAGENAME"]);
|
|
|
data.AREACODE = Convert.ToString(reader["AREACODE"]);
|
|
|
data.AREANAME = Convert.ToString(reader["AREANAME"]);
|
|
|
data.GOODSCODE = Convert.ToString(reader["GOODSCODE"]);
|
|
|
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
|
|
|
data.GOODSTYPE = Convert.ToString(reader["GOODSTYPE"]);
|
|
|
data.GOODSMODEL = Convert.ToString(reader["GOODSMODEL"]);
|
|
|
data.GOODSSTANDARD = Convert.ToString(reader["GOODSSTANDARD"]);
|
|
|
data.GOODSPACK = Convert.ToString(reader["GOODSPACK"]);
|
|
|
data.CHARGEUNIT = Convert.ToString(reader["CHARGEUNIT"]);
|
|
|
data.GOODSRKSL = Convert.ToString(reader["GOODSRKSL"]);
|
|
|
data.GOODSSTOCK = Convert.ToString(reader["GOODSSTOCK"]);
|
|
|
data.FREESTORAGEPERIOD = Convert.ToString(reader["FREESTORAGEPERIOD"]);
|
|
|
data.ISLOCK = Convert.ToString(reader["ISLOCK"]);
|
|
|
data.LOCKTIME = Convert.ToString(reader["LOCKTIME"]);
|
|
|
data.LOCKUSER = Convert.ToString(reader["LOCKUSER"]);
|
|
|
data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
|
|
|
data.DELETETIME = Convert.ToString(reader["DELETETIME"]);
|
|
|
data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]);
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
|
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
data.GOODSPACKSTOCK = Convert.ToString(reader["GOODSPACKSTOCK"]);
|
|
|
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);
|
|
|
data.GOODSKGS = Convert.ToString(reader["GOODSKGS"]);
|
|
|
data.CLIENTCODEOLD = Convert.ToString(reader["CLIENTCODEOLD"]);
|
|
|
data.CLIENTNAMEOLD = Convert.ToString(reader["CLIENTNAMEOLD"]);
|
|
|
data.ARFEE = Convert.ToString(reader["ARFEE"]);
|
|
|
data.APFEE = Convert.ToString(reader["APFEE"]);
|
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
|
data.CTNALL = Convert.ToString(reader["CTNALL"]);
|
|
|
data.GOODSTHICKNESS = Convert.ToString(reader["GOODSTHICKNESS"]);
|
|
|
data.GOODSWIDTH = Convert.ToString(reader["GOODSWIDTH"]);
|
|
|
data.GOODSLENGTH = Convert.ToString(reader["GOODSLENGTH"]);
|
|
|
data.GOODSSLICE = Convert.ToString(reader["GOODSSLICE"]);
|
|
|
data.GOODSGRADE = Convert.ToString(reader["GOODSGRADE"]);
|
|
|
data.STACKLOCATION = Convert.ToString(reader["STACKLOCATION"]);
|
|
|
data.GOODSPACKACTUAL = Convert.ToString(reader["GOODSPACKACTUAL"]);
|
|
|
data.GOODSRKSLACTUAL = Convert.ToString(reader["GOODSRKSLACTUAL"]);
|
|
|
data.ISCHANGE = Convert.ToString(reader["ISCHANGE"]);
|
|
|
data.MARKETVALUE = Convert.ToString(reader["MARKETVALUE"]);
|
|
|
data.BANKVALUE = Convert.ToString(reader["BANKVALUE"]);
|
|
|
data.LINENUM = Convert.ToString(reader["LINENUM"]);
|
|
|
data.GOODSNAMEID = Convert.ToString(reader["GOODSNAMEID"]);
|
|
|
data.GOODSNAMEDISPLAY = Convert.ToString(reader["GOODSNAMEDISPLAY"]);
|
|
|
if (String.IsNullOrEmpty(data.GOODSNAMEDISPLAY))
|
|
|
data.GOODSNAMEDISPLAY = data.GOODSNAME;
|
|
|
data.JIANSHU1 = Convert.ToString(reader["JIANSHU1"]);
|
|
|
data.JIANSHU2 = Convert.ToString(reader["JIANSHU2"]);
|
|
|
data.XIANGHAO2 = Convert.ToString(reader["XIANGHAO2"]);
|
|
|
data.TRUCKNO = Convert.ToString(reader["TRUCKNO"]);
|
|
|
data.ZHUANGXIEGONGID = Convert.ToString(reader["ZHUANGXIEGONGID"]);
|
|
|
data.ZHUANGXIEGONG = Convert.ToString(reader["ZHUANGXIEGONG"]);
|
|
|
|
|
|
data.LUYUNFEI = Convert.ToString(reader["LUYUNFEI"]);
|
|
|
data.DIAOTOUFEI = Convert.ToString(reader["DIAOTOUFEI"]);
|
|
|
data.XIUXIXIANGFEI = Convert.ToString(reader["XIUXIXIANGFEI"]);
|
|
|
data.DIAOZHUANGFEI = Convert.ToString(reader["DIAOZHUANGFEI"]);
|
|
|
|
|
|
data.CHEDUIID = Convert.ToString(reader["CHEDUIID"]);
|
|
|
data.CHEDUI = Convert.ToString(reader["CHEDUI"]);
|
|
|
|
|
|
data.ZHONGLIANG2 = Convert.ToString(reader["ZHONGLIANG2"]);
|
|
|
data.CHIMA1 = Convert.ToString(reader["CHIMA1"]);
|
|
|
data.CHIMA2 = Convert.ToString(reader["CHIMA2"]);
|
|
|
data.SHIJIZHONGLIANG = Convert.ToString(reader["SHIJIZHONGLIANG"]);
|
|
|
data.SHIJICHIMA = Convert.ToString(reader["SHIJICHIMA"]);
|
|
|
data.PICIHAO = Convert.ToString(reader["PICIHAO"]);
|
|
|
|
|
|
data.ZhuangXieFei = Convert.ToString(reader["ZHUANGXIEFEI"]);
|
|
|
data.ZhuangXieFeeType = Convert.ToString(reader["ZhuangXieFeeType"]);
|
|
|
data.ZhuangXieFeiDanJiaJian = Convert.ToString(reader["ZhuangXieFeiDanJiaJian"]);
|
|
|
data.ZhuangXieFeiDanJiaTon = Convert.ToString(reader["ZhuangXieFeiDanJiaTon"]);
|
|
|
|
|
|
data.COUNTRY = Convert.ToString(reader["COUNTRY"]);
|
|
|
data.COUNTRYID = Convert.ToString(reader["COUNTRYID"]);
|
|
|
|
|
|
data.PRODUCTIONDATE = Convert.ToString(reader["Productiondate"]);
|
|
|
data.FACTORYNO = Convert.ToString(reader["FactoryNo"]);
|
|
|
data.TRAYNO = Convert.ToString(reader["TrayNo"]);
|
|
|
|
|
|
data.DOCK = Convert.ToString(reader["DOCK"]);
|
|
|
data.LinShiZhuangXieFeiDanJiaDun = Convert.ToString(reader["LinShiZhuangXieFeiDanJiaDun"]);
|
|
|
data.LinShiZhuangXieFeiDanJiaJian = Convert.ToString(reader["LinShiZhuangXieFeiDanJiaJian"]);
|
|
|
|
|
|
data.LOADERFEE = Convert.ToString(reader["LOADERFEE"]);
|
|
|
|
|
|
data.INVOICENO = Convert.ToString(reader["INVOICENO"]);
|
|
|
data.BZTCHNO = Convert.ToString(reader["BZTCHNO"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
public static WMSNewIN GetDataWithBLNOAndWMSNO(string BLNO, string WMSNO)
|
|
|
{
|
|
|
|
|
|
WMSNewIN wms = new WMSNewIN();
|
|
|
string sql = @"";
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public static List<WMSNewGoodsDetails> GetGoodsDetailsWithGid(string codegoodsid)
|
|
|
{
|
|
|
//string sql = @"SELECT * FROM code_goods_detail WHERE LINKGID = '" + codegoodsid + "'";
|
|
|
string sql = @"SELECT code_goods_detail.* from code_goods_detail inner join code_goods on code_goods_detail.LINKGID=code_goods.GID where code_goods.GID = '" + codegoodsid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var list = new List<WMSNewGoodsDetails>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WMSNewGoodsDetails gd = new WMSNewGoodsDetails();
|
|
|
gd.GID = reader["GID"].ToString();
|
|
|
gd.NAME = reader["GOODSDETAILNAME"].ToString();
|
|
|
list.Add(gd);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public static string GetPKGWithGoodsDetailsNameAndCodeGoodsId(string goodsDetailsName, string codeGoodsId)
|
|
|
{
|
|
|
//string sql = @"select GOODSDETAILPKGS FROM code_goods_detail WHERE GOODSDETAILNAME = '" + goodsDetailsName + "' AND LINKGID = '" + codeGoodsId + "'";
|
|
|
string sql = @"SELECT code_goods_detail.GOODSDETAILPKGS from code_goods_detail inner join code_goods on code_goods_detail.LINKGID=code_goods.GID where GOODSDETAILNAME = '" + goodsDetailsName + "' AND code_goods.GID = '" + codeGoodsId + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string pkg = "";
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
pkg = reader["GOODSDETAILPKGS"].ToString();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return pkg;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="BLNO">提单号</param>
|
|
|
/// <param name="CUSTOMNO">报关单号</param>
|
|
|
/// <param name="CONTRACTNO">合同号</param>
|
|
|
/// <param name="CUSTNO">委托编号</param>
|
|
|
/// <param name="CUSTOMERNAME">客户名称</param>
|
|
|
/// <param name="BSNO">海运进口业务gid</param>
|
|
|
/// <param name="CTNALL">箱型</param>
|
|
|
/// <param name="CNTRNO">箱号</param>
|
|
|
/// <param name="BAOGUANJIANSHU">报关件数</param>
|
|
|
/// <param name="PKGS">件数</param>
|
|
|
/// <param name="SEALNO">封号</param>
|
|
|
public static void GetDataWithBLNOAndWMSNO(string BLNO, string CUSTOMNO, string _OPLBNAME, out string MBLNO, out string MCUSTOMNO, out string CONTRACTNO, out string CUSTNO, out string CUSTOMERNAME, out string BSNO, out string CTNALL, out string CNTRNO, out int BAOGUANJIANSHU, out int PKGS, out decimal KGS, out string SEALNO, out string ISBONDED, out string OPLBNAME, out string COMPANYID, out string STORAGENAME)
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.Append(@"select CUSTOMERNAME,CONTRACTNO,CUSTOMNO,CUSTNO,MBLNO,BSNO,ISBONDED,CTNALL,CNTRNO ,BAOGUANJIANSHU ,SEALNO ,PKGS,OPLBNAME,COMPANYID,");
|
|
|
sb.Append("KGS,STORAGENAME from v_op_wmsbs where 1=1");
|
|
|
if (BLNO != null && BLNO != "")
|
|
|
{
|
|
|
sb.Append(" and (MBLNO = '" + BLNO + "' or CUSTNO = '" + BLNO + "' or CONTRACTNO = '" + BLNO + "' or CNTRNO = '" + BLNO + "' )");
|
|
|
}
|
|
|
if (CUSTOMNO != null && CUSTOMNO != "")
|
|
|
{
|
|
|
sb.Append(" and CUSTOMNO = '" + CUSTOMNO + "'");
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(_OPLBNAME))
|
|
|
{
|
|
|
sb.Append(" and OPLBNAME = '" + _OPLBNAME + "'");
|
|
|
}
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string sMBLNO = "";//提单号
|
|
|
string sCUSTOMNO = "";//报关单号
|
|
|
string sCONTRACTNO = "";//合同号
|
|
|
string sCUSTNO = "";//委托编号
|
|
|
string sCUSTOMERNAME = "";//客户名称
|
|
|
string sBSNO = "";//海运进口业务gid
|
|
|
string sCTNALL = "";//箱型
|
|
|
string sCNTRNO = "";//箱号
|
|
|
string sSEALNO = "";//封号
|
|
|
string sISBONDED = "";//是否报关业务
|
|
|
string sOPLBNAME = "";//业务类型
|
|
|
string sCompanyID = "";//货属分部
|
|
|
string sStorageName = "";//仓库
|
|
|
int sBAOGUANJIANSHU = 0;
|
|
|
int sPKGS = 0;
|
|
|
decimal sKGS = 0;
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sb.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
sMBLNO = reader["MBLNO"].ToString();
|
|
|
sCUSTOMNO = reader["CUSTOMNO"].ToString();
|
|
|
sCONTRACTNO = reader["CONTRACTNO"].ToString();
|
|
|
sCUSTNO = reader["CUSTNO"].ToString();
|
|
|
sCUSTOMERNAME = reader["CUSTOMERNAME"].ToString();
|
|
|
sBSNO = reader["BSNO"].ToString();
|
|
|
sCTNALL = reader["CTNALL"].ToString();
|
|
|
sCNTRNO = reader["CNTRNO"].ToString();
|
|
|
sBAOGUANJIANSHU = Convert.ToInt32(reader["BAOGUANJIANSHU"]);
|
|
|
sPKGS = Convert.ToInt32(reader["PKGS"]);
|
|
|
sKGS = Convert.ToDecimal(reader["KGS"]);
|
|
|
sSEALNO = reader["SEALNO"].ToString();
|
|
|
sISBONDED = reader["ISBONDED"].ToString() == "0" ? "否" : "是";
|
|
|
sOPLBNAME = reader["OPLBNAME"].ToString();
|
|
|
sCompanyID = reader["CompanyID"].ToString();
|
|
|
sStorageName = reader["STORAGENAME"].ToString();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
MBLNO = sMBLNO;
|
|
|
MCUSTOMNO = sCUSTOMNO;
|
|
|
CONTRACTNO = sCONTRACTNO;
|
|
|
CUSTNO = sCUSTNO;
|
|
|
CUSTOMERNAME = sCUSTOMERNAME;
|
|
|
BSNO = sBSNO;
|
|
|
CTNALL = sCTNALL;
|
|
|
CNTRNO = sCNTRNO;
|
|
|
BAOGUANJIANSHU = sBAOGUANJIANSHU;
|
|
|
PKGS = sPKGS;
|
|
|
KGS = sKGS;
|
|
|
SEALNO = sSEALNO;
|
|
|
ISBONDED = sISBONDED;
|
|
|
OPLBNAME = sOPLBNAME;
|
|
|
COMPANYID = sCompanyID;
|
|
|
STORAGENAME = sStorageName;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断报关单号是否报关
|
|
|
/// </summary>
|
|
|
/// <param name="customsno">报关单号</param>
|
|
|
/// <param name="customsno">提单号</param>
|
|
|
/// <returns></returns>
|
|
|
public static bool CheckISCustomsClearance(string customsno, string blno)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
//判断是否是需要关联报关
|
|
|
string sqlcheck = @"SELECT [PARAMVALUE] FROM [sys_param_set] WHERE GID = '517FA648-45D9-489D-ADE9-D1E96D10D111'";
|
|
|
int flag = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlcheck));
|
|
|
if (flag == 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
//判断是否需要报关
|
|
|
string bsql = @"select ISBONDED from op_seai WHERE MBLNO = '" + blno + "'";
|
|
|
bool needBaoGuan = Convert.ToString(db.ExecuteScalar(CommandType.Text, bsql)) == "1";
|
|
|
if (needBaoGuan)
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
if (customsno == string.Empty)
|
|
|
{
|
|
|
cnt = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
string sql = @"select count(*) from op_apply
|
|
|
where ISCLEAR='1'
|
|
|
and CUSTOMTYPE='入区报关'
|
|
|
and CUSTOMNO = '" + customsno + "'";
|
|
|
cnt = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
|
|
|
}
|
|
|
|
|
|
return cnt > 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据提单号和报关单号,获取报关单号列表
|
|
|
/// </summary>
|
|
|
/// <param name="BLNO"></param>
|
|
|
/// <param name="CUSTOMNO"></param>
|
|
|
/// <returns></returns>
|
|
|
public static List<CustomNo> GetCustomsNoListWithBLNOAndCustomNo(string BLNO, string CUSTOMNO)
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.Append(@"select CUSTOMNO from op_apply where ISCLEAR='1' and CUSTOMTYPE='入区报关' ");
|
|
|
if (BLNO != null && BLNO != "")
|
|
|
{
|
|
|
sb.Append("and MBLNO ='" + BLNO + "' ");
|
|
|
}
|
|
|
if (CUSTOMNO != null && CUSTOMNO != "")
|
|
|
{
|
|
|
sb.Append("and CUSTOMNO = '" + CUSTOMNO + "'");
|
|
|
}
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
List<CustomNo> list = new List<CustomNo>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sb.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
string customno = reader["CUSTOMNO"].ToString();
|
|
|
if (customno == string.Empty)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
CustomNo cn = new CustomNo();
|
|
|
cn.CUSTOMNO = customno;
|
|
|
list.Add(cn);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public static bool LockWMS(string wmsno, bool eip, int type, out string msg,string userid)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
//判断是否是需要关联报关,不需要关联报关的话取消入账时判断该票货是否已经出库,如果出库不允许取消入账
|
|
|
if (type == 0)
|
|
|
{
|
|
|
string sqlcheck = @"SELECT [PARAMVALUE] FROM [sys_param_set] WHERE GID = '517FA648-45D9-489D-ADE9-D1E96D10D111'";
|
|
|
int flag = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlcheck));
|
|
|
if (flag == 0)
|
|
|
{
|
|
|
//判断该票货是否已经出库
|
|
|
string sqlCheckOut = "select count(*) from wms_out_detail where INBSNO in ((select GID from wms_in where ASSOCIATEDNO = (SELECT gid FROM wms where WMSNO in (" + wmsno + "))) union (SELECT gid FROM wms where WMSNO in (" + wmsno + ")))";
|
|
|
int checkOutResult = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlCheckOut));
|
|
|
if (checkOutResult > 0)
|
|
|
{
|
|
|
//该票已经做过出库
|
|
|
msg = "已经做过出库,无法取消入账!";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 送货单状态,更新储位
|
|
|
|
|
|
if (eip)
|
|
|
{
|
|
|
|
|
|
Database dbEIP = DatabaseFactory.CreateDatabase("EIP");
|
|
|
using (var connEIP = dbEIP.CreateConnection())
|
|
|
{
|
|
|
connEIP.Open();
|
|
|
string ConnectionStringLocalTransactionEIP = ConfigurationManager.ConnectionStrings["EIP"].ConnectionString;
|
|
|
SqlTransaction sqlTran = SqlHelper.BeginTransaction(ConnectionStringLocalTransactionEIP);
|
|
|
try
|
|
|
{
|
|
|
//状态更新
|
|
|
var strEIPType = "2";
|
|
|
if (type == 1)
|
|
|
strEIPType = "3";
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("update EIP_Deliver set BSSTATUS='" + strEIPType + "' where DeliverNO=" + wmsno + "");
|
|
|
dbEIP.ExecuteNonQuery(CommandType.Text, strSql.ToString());
|
|
|
//储位逐个更新
|
|
|
if (type == 1)
|
|
|
{
|
|
|
StringBuilder strSqlWMS = new StringBuilder();
|
|
|
strSqlWMS.Append(
|
|
|
"select wms_in.gid,wms_in.areaname from wms_in inner join wms on wms_in.ASSOCIATEDNO = wms.GID where wmsno= " +
|
|
|
wmsno + " ");
|
|
|
string tmpGID = "";
|
|
|
string tmpAreaName = "";
|
|
|
StringBuilder strSqlAN = new StringBuilder();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSqlWMS.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
tmpGID = reader["GID"].ToString();
|
|
|
tmpAreaName = reader["AreaName"].ToString();
|
|
|
strSqlAN.Append("update EIP_Tray set AreaName ='" + tmpAreaName + "' where gid = '" +
|
|
|
tmpGID + "' ");
|
|
|
dbEIP.ExecuteNonQuery(CommandType.Text, strSqlAN.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ee)
|
|
|
{
|
|
|
|
|
|
sqlTran.Rollback();
|
|
|
}
|
|
|
|
|
|
connEIP.Close();
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否已经出区报关
|
|
|
string sqlc = @"select count(*) from op_apply where customtype = '出区报关' and masterno in(
|
|
|
select ASSOCIATEDNO from wms WHERE WMSNO in (" + wmsno + "))";
|
|
|
int check = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlc));
|
|
|
if (check > 0)
|
|
|
{
|
|
|
msg = "已有出区报关,无法取消入账,请先删除出区数据后再执行取消入账操作!";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//2023-1-9 如果
|
|
|
if (ConfigurationManager.AppSettings["DingTalkAuditWMSIN"] == "true" && type == 1)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//如果是费用入账动作 且配置了钉钉审批入库 则调用向钉钉发送新建审批实例方法
|
|
|
result = DingTalkHelper.Send_WMSIN(userid, wmsno);
|
|
|
|
|
|
//仅用于测试解析读取钉钉审批实例内容
|
|
|
//result = TestReadDingtalkInstanceinfo();
|
|
|
|
|
|
msg = result.Message;
|
|
|
return result.Success;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (type == 1) {
|
|
|
var _r = DoWMSLOCK(wmsno);
|
|
|
|
|
|
msg= _r.Message;
|
|
|
return _r.Success;
|
|
|
}
|
|
|
|
|
|
else
|
|
|
{
|
|
|
var _r = DoWMSUNLOCK(wmsno);
|
|
|
|
|
|
msg = _r.Message;
|
|
|
return _r.Success;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public static DBResult DoWMSLOCK(string wmsnoListStr) {
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
string sql = @" update wms set ISLOCK = 'true' WHERE WMSNO in (" + wmsnoListStr + ")";
|
|
|
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
result.OK ( "操作成功!");
|
|
|
string sql2 = @"update wms_in set ISLOCK = 'true' WHERE ASSOCIATEDNO in (SELECT GID FROM WMS WHERE WMSNO in (" + wmsnoListStr + ")) ";
|
|
|
rst += db.ExecuteNonQuery(CommandType.Text, sql2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//msg = "操作失败!";
|
|
|
result.SetErrorInfo("操作失败!");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
private static DBResult DoWMSUNLOCK(string wmsnoListStr)
|
|
|
{
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
string sql = @" update wms set ISLOCK = 'false' WHERE WMSNO in (" + wmsnoListStr + ")";
|
|
|
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
result.OK("操作成功!");
|
|
|
string sql2 = @"update wms_in set ISLOCK = 'false' WHERE ASSOCIATEDNO in (SELECT GID FROM WMS WHERE WMSNO in (" + wmsnoListStr + ")) ";
|
|
|
rst += db.ExecuteNonQuery(CommandType.Text, sql2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//msg = "操作失败!";
|
|
|
result.SetErrorInfo("操作失败!");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 用于测试读取钉钉审批实例内容
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult TestReadDingtalkInstanceinfo()
|
|
|
{
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
//var userid=
|
|
|
try
|
|
|
{
|
|
|
//如果是费用入账动作 且配置了钉钉审批入库 则调用
|
|
|
result = DingTalkHelper.DingTalk_Instanceinfo("Wnr2YHcmSD-PjBWkTDkqIg05361673511300");
|
|
|
|
|
|
DingTalkInstanceinfo di = JsonConvert.Deserialize<DingTalkInstanceinfo>(result.Data.ToString());
|
|
|
|
|
|
//根据内容修改wms和wmsin值
|
|
|
var cdc = new CommonDataContext();
|
|
|
var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", "Wnr2YHcmSD-PjBWkTDkqIg05361673511300");
|
|
|
if (lv != null && lv.ContainsKey("instanceId"))
|
|
|
{
|
|
|
var wmsno = lv["BSNO"];
|
|
|
|
|
|
var wmsold = new Models.WMS.WMS_IN_OLD(wmsno);
|
|
|
var wms = wmsold.wms;
|
|
|
var wmslist = wmsold.wms_in;
|
|
|
//var wms = cdc.wms.FirstOrDefault(x => x.WMSNO == wmsno);
|
|
|
//var wmslist = new List<wms_in_md>();
|
|
|
//if (wms != null) {
|
|
|
// wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList();
|
|
|
//}
|
|
|
var updwmsinlist = new List<wms_in_md>();
|
|
|
var newwmsinlist = new List<wms_in_md>();
|
|
|
var 车辆信息 = new wms_in_md();
|
|
|
foreach (var item in di.result.formComponentValues)
|
|
|
{
|
|
|
//从其中查找货物信息 并更新至当前
|
|
|
if (item.name == "客户名称")
|
|
|
{
|
|
|
|
|
|
//var cust=cdc.info_client.Where(x=>x.SHORTNAME==item.value || x.DESCRIPTION==item.value)
|
|
|
}
|
|
|
if (item.name == "入库日期")
|
|
|
{
|
|
|
wms.WMSDATE = Convert.ToDateTime(item.value);
|
|
|
}
|
|
|
if (item.name == "入库信息")
|
|
|
{
|
|
|
var 入库信息list = FormComponentValues.GetRowValues(item.value);
|
|
|
if (入库信息list != null) {
|
|
|
foreach (var DingWmsin in 入库信息list)
|
|
|
{
|
|
|
var 提单号 = DingWmsin.getValue("提单号");
|
|
|
var 箱号 = DingWmsin.getValue("箱号");
|
|
|
if (wmslist.Exists(x => x.BLNO == 提单号 && x.CNTRNO == 箱号))
|
|
|
{
|
|
|
|
|
|
var updrec = wmslist.First(x => x.BLNO == 提单号 && x.CNTRNO == 箱号);
|
|
|
|
|
|
//new DingTalkFormField("提单号", item.BLNO),
|
|
|
//new DingTalkFormField("箱号", item.CNTRNO),
|
|
|
//new DingTalkFormField("品名", item.GOODSNAME),
|
|
|
//new DingTalkFormField("重量", item.GOODSRKSL.ToString()),
|
|
|
//new DingTalkFormField("件数", item.GOODSPACK.ToString()),
|
|
|
//new DingTalkFormField("尺码", item.CHIMA1.ToString()),
|
|
|
//new DingTalkFormField("库位", item.CHIMA1.ToString())
|
|
|
updrec.GOODSNAME = DingWmsin.getValue("品名");
|
|
|
|
|
|
if (wms.CHARGEUNIT == "吨"|| wms.CHARGEUNIT == "千克")
|
|
|
{
|
|
|
updrec.GOODSRKSL = DingWmsin.getValue_decimal("重量");
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
//updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
}
|
|
|
|
|
|
if (wms.CHARGEUNIT == "CBM")
|
|
|
{
|
|
|
updrec.GOODSRKSL = DingWmsin.getValue_decimal("尺码");
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
//updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
}
|
|
|
updrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
|
|
|
updrec.AREANAME = DingWmsin.getValue("库位");
|
|
|
updrec.DODATE = wms.WMSDATE;
|
|
|
updwmsinlist.Add(updrec);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var newrec = new wms_in_md();
|
|
|
newrec.ASSOCIATEDNO = wms.GID;
|
|
|
newrec.GID = Guid.NewGuid().ToString();
|
|
|
newrec.BLNO = DingWmsin.getValue("提单号");
|
|
|
newrec.CNTRNO = DingWmsin.getValue("箱号");
|
|
|
newrec.CLIENTNAME = wms.CUSTOMERNAME;
|
|
|
newrec.DODATE = wms.WMSDATE;
|
|
|
newrec.GOODSNAME = DingWmsin.getValue("品名");
|
|
|
newrec.GOODSRKSL = DingWmsin.getValue_decimal("重量");
|
|
|
newrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
newrec.AREANAME = DingWmsin.getValue("库位");
|
|
|
newrec.CREATETIME = DateTime.Now;
|
|
|
newrec.CHARGEUNIT = wms.CHARGEUNIT;
|
|
|
newrec.CORPID = wms.CORPID;
|
|
|
newwmsinlist.Add(newrec);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (item.name == "车队信息")
|
|
|
{
|
|
|
var 车队信息list = FormComponentValues.GetRowValues(item.value);
|
|
|
if (车队信息list != null && 车队信息list.Count > 0)
|
|
|
{
|
|
|
var 车队name = 车队信息list[0].getValue("车队");
|
|
|
var 车队 = cdc.info_client.FirstOrDefault(x => x.SHORTNAME == 车队name);
|
|
|
if (车队 != null && 车队.SHORTNAME != null && 车队.SHORTNAME != "")
|
|
|
{
|
|
|
车辆信息.CHEDUIID = 车队.GID;
|
|
|
车辆信息.TRUCKNO = 车队信息list[0].getValue("车牌号");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
cdc.wms.AddOrUpdate(wms);
|
|
|
if (updwmsinlist != null && updwmsinlist.Count > 0)
|
|
|
{
|
|
|
foreach (var item in updwmsinlist)
|
|
|
{
|
|
|
item.CHEDUIID = 车辆信息.CHEDUIID;
|
|
|
item.TRUCKNO = 车辆信息.TRUCKNO;
|
|
|
cdc.wms_in.AddOrUpdate(item);
|
|
|
}
|
|
|
}
|
|
|
if (newwmsinlist != null && newwmsinlist.Count > 0)
|
|
|
{
|
|
|
foreach (var item in newwmsinlist)
|
|
|
{
|
|
|
item.CHEDUIID = 车辆信息.CHEDUIID;
|
|
|
item.TRUCKNO = 车辆信息.TRUCKNO;
|
|
|
cdc.wms_in.AddOrUpdate(item);
|
|
|
}
|
|
|
}
|
|
|
cdc.SaveChanges();
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
result.SetErrorInfo(e.Message);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 库存锁定
|
|
|
/// 被锁定的库存不可出库和货转
|
|
|
/// </summary>
|
|
|
/// <param name="wmsno"></param>
|
|
|
/// <param name="type"></param>
|
|
|
/// <returns></returns>
|
|
|
public static bool LockWMS2(string wmsno, int type)
|
|
|
{
|
|
|
string sql = @" update wms set ISLOCK2 = " + type + " WHERE WMSNO in (" + wmsno + ")";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int rst = db.ExecuteNonQuery(CommandType.Text, sql);
|
|
|
if (rst > 0)
|
|
|
{
|
|
|
string sql2 = @"update wms_in set ISLOCK2 = " + type + " WHERE ASSOCIATEDNO in (SELECT GID FROM WMS WHERE WMSNO in (" + wmsno + ")) ";
|
|
|
rst += db.ExecuteNonQuery(CommandType.Text, sql2);
|
|
|
}
|
|
|
return rst > 0;
|
|
|
}
|
|
|
|
|
|
public static bool CheckHasExistWMSInWBLNO(string mblno)
|
|
|
{
|
|
|
string sql = @"select count(*) from wms where ASSOCIATEDNO = (select BSNO from op_seai where mblno = '" + mblno + "')";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
|
|
|
return rst > 0;
|
|
|
}
|
|
|
|
|
|
#region 箱型与箱号
|
|
|
/// <summary>
|
|
|
/// 获取提单号下录入的箱型
|
|
|
/// </summary>
|
|
|
/// <param name="mblno"></param>
|
|
|
/// <returns></returns>
|
|
|
static public List<CodeCtnModel> GetCodeCtnList(string mblno)
|
|
|
{
|
|
|
//根据参数设置判断箱号是否需要关联进口模块
|
|
|
string sqlcheck = @"SELECT [PARAMVALUE] FROM [sys_param_set] WHERE GID = '617FA648-45D9-489D-ADE9-D1E96D10D111'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
int flag = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlcheck));
|
|
|
if (flag == 0)
|
|
|
{
|
|
|
String strSql = @"SELECT DISTINCT CTN AS CTNALL FROM code_ctn";
|
|
|
return SetCodeCtnData(strSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
String strSql = @"SELECT DISTINCT CTNALL FROM [op_ctn]
|
|
|
WHERE BSNO in (SELECT BSNO FROM op_seai where MBLNO = '" + mblno + "') ";
|
|
|
|
|
|
return SetCodeCtnData(strSql);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private static List<CodeCtnModel> SetCodeCtnData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeCtnModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeCtnModel data = new CodeCtnModel();
|
|
|
#region Set DB data to Object
|
|
|
data.CTN = Convert.ToString(reader["CTNALL"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取提单号下录入的箱型关联的箱号
|
|
|
/// </summary>
|
|
|
/// <param name="mblno"></param>
|
|
|
/// <returns></returns>
|
|
|
static public List<CNTRNO> GetCNTRNOList(string mblno, string ctnall)
|
|
|
{
|
|
|
String strSql = @"SELECT DISTINCT CNTRNO FROM [op_ctn]
|
|
|
WHERE BSNO in (SELECT BSNO FROM op_seai where MBLNO = '" + mblno + "') AND CTNALL='" + ctnall + "' ";
|
|
|
|
|
|
return SetCNTRNOData(strSql);
|
|
|
}
|
|
|
private static List<CNTRNO> SetCNTRNOData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CNTRNO>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CNTRNO data = new CNTRNO();
|
|
|
#region Set DB data to Object
|
|
|
data.DATA = Convert.ToString(reader["CNTRNO"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
public static string GetSEALNOWithBLNOAndCNTRNO(string bsno, string cntrno, out int pkgs, out float cbm)
|
|
|
{
|
|
|
string sql = @"SELECT SEALNO,PKGS,CBM FROM [op_ctn]
|
|
|
WHERE BSNO in (SELECT BSNO FROM op_seai where MBLNO = '" + bsno + "') AND cntrno='" + cntrno + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string SEALNO = "";
|
|
|
int PKGS = 0;
|
|
|
float CBM = 0.00f;
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
SEALNO = reader["SEALNO"].ToString();
|
|
|
PKGS = reader["PKGS"].ToString() == "" ? 0 : Convert.ToInt32(reader["PKGS"]);
|
|
|
CBM = reader["CBM"].ToString() == "" ? 0 : Convert.ToInt32(reader["CBM"]);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
pkgs = PKGS;
|
|
|
cbm = CBM;
|
|
|
return SEALNO;
|
|
|
}
|
|
|
|
|
|
public static string GetGoodsInfoWithName(string goodsname, out string codeAndname)
|
|
|
{
|
|
|
|
|
|
if (goodsname == string.Empty)
|
|
|
{
|
|
|
codeAndname = "";
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
string codeandname = "";
|
|
|
string gid = "";
|
|
|
string sql = @"select (GOODCODE+'-'+GOODNAME) as CodeAndName,GID from code_goods where GID = '" + goodsname + "' ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
gid = reader["GID"].ToString();
|
|
|
codeandname = reader["CodeAndName"].ToString();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
codeAndname = codeandname;
|
|
|
return gid;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取费用状态的显示文字
|
|
|
/// </summary>
|
|
|
/// <param name="feestatusint"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string getfeestatus(string feestatusint)
|
|
|
{
|
|
|
var result = "";
|
|
|
if (feestatusint == "0:")
|
|
|
{
|
|
|
return "审核通过";
|
|
|
}
|
|
|
else if (feestatusint == "1:")
|
|
|
{
|
|
|
return "录入状态";
|
|
|
}
|
|
|
else if (feestatusint == "2:")
|
|
|
{
|
|
|
return "提交审核";
|
|
|
}
|
|
|
else if (feestatusint == "8:")
|
|
|
{
|
|
|
return "部分结算";
|
|
|
}
|
|
|
else if (feestatusint == "9:")
|
|
|
{
|
|
|
return "结算完毕";
|
|
|
}
|
|
|
else if (feestatusint == "")
|
|
|
{
|
|
|
return "未录入";
|
|
|
}
|
|
|
else if (feestatusint == "3:")
|
|
|
{
|
|
|
return "申请修改";
|
|
|
}
|
|
|
else if (feestatusint == "4:")
|
|
|
{
|
|
|
return "申请删除";
|
|
|
}
|
|
|
else if (feestatusint == "6:")
|
|
|
{
|
|
|
return "驳回提交";
|
|
|
}
|
|
|
else if (feestatusint == "7:")
|
|
|
{
|
|
|
return "驳回申请";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("9:") > -1)
|
|
|
{
|
|
|
return "部分结算";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("8:") > -1)
|
|
|
{
|
|
|
return "部分结算";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("0:") > -1)
|
|
|
{
|
|
|
return "部分审核";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("2:") > -1)
|
|
|
{
|
|
|
return "部分提交";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("6:") > -1)
|
|
|
{
|
|
|
return "驳回提交";
|
|
|
}
|
|
|
else if (feestatusint.IndexOf("7:") > -1)
|
|
|
{
|
|
|
return "驳回申请";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static List<Stevedores> GetZhuangXieGongList()
|
|
|
{
|
|
|
String strSql = @"select * from wms_stevedores where DELFLAG = 0";
|
|
|
return SetZhuangXieGongData(strSql);
|
|
|
}
|
|
|
|
|
|
public static List<Stevedores> SetZhuangXieGongData(string sql)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
List<Stevedores> list = new List<Stevedores>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
Stevedores s = new Stevedores();
|
|
|
s.GID = reader["GID"].ToString();
|
|
|
s.NAME = reader["NAME"].ToString();
|
|
|
s.CODE = reader["CODE"].ToString();
|
|
|
s.CODENAME = reader["CODE"].ToString() + "-" + reader["NAME"].ToString();
|
|
|
list.Add(s);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public static List<CheDui> GetCheDuiList()
|
|
|
{
|
|
|
String strSql = @"select GID,CODENAME CODE,SHORTNAME NAME from info_client where ISTRUCK = 1";
|
|
|
return SetCheDuiData(strSql);
|
|
|
}
|
|
|
|
|
|
public static List<CheDui> SetCheDuiData(string sql)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
List<CheDui> list = new List<CheDui>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CheDui s = new CheDui();
|
|
|
s.GID = reader["GID"].ToString();
|
|
|
s.NAME = reader["NAME"].ToString();
|
|
|
s.CODE = reader["CODE"].ToString();
|
|
|
s.CODENAME = reader["CODE"].ToString() + "-" + reader["NAME"].ToString();
|
|
|
list.Add(s);
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public static bool CreateCost(string wmsno, string userid, out string msg)
|
|
|
{
|
|
|
|
|
|
//判断该入库单是否已生成过费用
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string check = @"SELECT count(*) from ch_fee where WMSOUTBSNO = (select gid from wms where WMSNO= '" + wmsno + "') and REMARK = '入库生成费用' ";
|
|
|
if (Convert.ToInt32(db.ExecuteScalar(CommandType.Text, check)) > 0)
|
|
|
{
|
|
|
msg = "已经生成过费用,不允许重复生成!";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string sql = @"select w.ASSOCIATEDNO AS ASSOCIATEDNO,w.GID WMSGID,wi.GID WMSINGID,LUYUNFEI,DIAOTOUFEI,XIUXIXIANGFEI,DIAOZHUANGFEI,wi.TRUCKNO,IsNull((SELECT CODENAME+'-'+SHORTNAME as CODENAME from info_client where GID = wi.CHEDUIID),'') as CHEDUI ,ZHUANGXIEFEI,ZHUANGXIEGONGID,(select name from wms_stevedores where gid = zhuangxiegongid and DELFLAG = 0) as ZHUANGXIEGONG,wi.LOADERFEE,w.ARCLIENT from wms_in wi INNER JOIN wms w on wi.ASSOCIATEDNO = w.GID where w.WMSNO = '" + wmsno + "'";
|
|
|
|
|
|
var BSNO = "";
|
|
|
|
|
|
List<CostModel> list = new List<CostModel>();
|
|
|
|
|
|
bool rst = false;
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CostModel s = new CostModel();
|
|
|
s.WMSGID = reader["WMSGID"].ToString();
|
|
|
BSNO = s.WMSGID;
|
|
|
s.WMSINGID = reader["WMSINGID"].ToString();
|
|
|
s.BSNO = s.WMSGID;
|
|
|
if ((GetSysFeeConfig("") == "1") && (reader["WMSGID"].ToString() != reader["ASSOCIATEDNO"].ToString()))
|
|
|
s.BSNO = reader["ASSOCIATEDNO"].ToString();
|
|
|
s.LUYUNFEI = decimal.Parse(reader["LUYUNFEI"].ToString());
|
|
|
s.DIAOTOUFEI = decimal.Parse(reader["DIAOTOUFEI"].ToString());
|
|
|
s.XIUXIXIANGFEI = decimal.Parse(reader["XIUXIXIANGFEI"].ToString());
|
|
|
s.DIAOZHUANGFEI = decimal.Parse(reader["DIAOZHUANGFEI"].ToString());
|
|
|
s.TRUCKNO = reader["TRUCKNO"].ToString();
|
|
|
s.CHEDUI = reader["CHEDUI"].ToString();
|
|
|
s.ZhuangXieFei = decimal.Parse(reader["ZHUANGXIEFEI"].ToString());
|
|
|
s.ZHUANGXIEGONGID = reader["ZHUANGXIEGONG"].ToString();
|
|
|
s.ARCLIENT = reader["ARCLIENT"].ToString();
|
|
|
s.LOADERFEE = decimal.Parse(reader["LOADERFEE"].ToString());
|
|
|
|
|
|
|
|
|
list.Add(s);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var FeeList = new List<MsChFeeWMSINMake>();
|
|
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
foreach (var cm in list)
|
|
|
{
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
{
|
|
|
string feeName = "";
|
|
|
decimal feeValue=0;
|
|
|
string feeCustomerName = "";
|
|
|
decimal feeType = 1;
|
|
|
|
|
|
#region 只留下装卸费、陆运费
|
|
|
switch (i)
|
|
|
{
|
|
|
case 0:
|
|
|
feeName = "陆运费";
|
|
|
feeValue = cm.LUYUNFEI;
|
|
|
feeCustomerName = cm.CHEDUI;
|
|
|
feeType = 2;//"2";
|
|
|
break;
|
|
|
case 1:
|
|
|
feeName = "装卸费";
|
|
|
feeValue = cm.ZhuangXieFei;
|
|
|
feeCustomerName = cm.ZHUANGXIEGONGID;
|
|
|
feeType = 2;//"2";
|
|
|
break;
|
|
|
case 2:
|
|
|
feeName = "入库装卸费";
|
|
|
feeValue = cm.LOADERFEE;
|
|
|
feeCustomerName = cm.ARCLIENT;
|
|
|
feeType = 1;//"1";
|
|
|
break;
|
|
|
default:
|
|
|
feeName = "";
|
|
|
feeValue = 0;
|
|
|
feeType = 0;//"0";
|
|
|
break;
|
|
|
/*
|
|
|
case 2:
|
|
|
feeName = "掉头费";
|
|
|
feeValue = cm.DIAOTOUFEI;
|
|
|
break;
|
|
|
case 3:
|
|
|
feeName = "修洗箱费";
|
|
|
feeValue = cm.XIUXIXIANGFEI;
|
|
|
break;
|
|
|
case 4:
|
|
|
feeName = "吊装费";
|
|
|
feeValue = cm.DIAOZHUANGFEI;
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
feeName = "";
|
|
|
feeValue = 0;
|
|
|
break;
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//feeName = "装卸费";
|
|
|
//feeValue = cm.ZhuangXieFei;
|
|
|
if (feeValue != 0)
|
|
|
{
|
|
|
var chfee = new MsChFeeWMSINMake();
|
|
|
|
|
|
chfee.GId = Guid.NewGuid().ToString();
|
|
|
chfee.BsNo = "";
|
|
|
chfee.FeeType = feeType;
|
|
|
chfee.FeeName = feeName;
|
|
|
chfee.Remark = "'入库单号" + wmsno + "生成费用',";
|
|
|
chfee.CustomerType = "车队";
|
|
|
chfee.CustomerName = feeCustomerName;
|
|
|
chfee.Unit = "单票";
|
|
|
chfee.UnitPrice = feeValue;
|
|
|
chfee.Quantity = 1;
|
|
|
chfee.Amount = feeValue;
|
|
|
chfee.Currency = "RMB";
|
|
|
chfee.ExChangerate = 1;
|
|
|
chfee.FeeStatus = 1;
|
|
|
chfee.NoTaxAmount = feeValue;
|
|
|
chfee.TaxUnitPrice = feeValue;
|
|
|
chfee.WmsOutBsNo = cm.WMSGID;
|
|
|
chfee.EnteroPerator = userid;
|
|
|
|
|
|
if (FeeList.Count == 0)
|
|
|
{
|
|
|
FeeList.Add(chfee);
|
|
|
}
|
|
|
else {
|
|
|
var needinsert = true;
|
|
|
foreach (var infee in FeeList) {
|
|
|
//如果这条新的费用与原有费用有完全一致的 [结算对象 费用名称 收付方向], 则 将费用等数据合并,而非新建一条
|
|
|
if (infee.CustomerName == chfee.CustomerName && infee.FeeName == chfee.FeeName && infee.FeeType == chfee.FeeType) {
|
|
|
//infee.Remark += chfee.Remark;
|
|
|
infee.UnitPrice += chfee.UnitPrice;
|
|
|
infee.Amount += chfee.Amount;
|
|
|
infee.NoTaxAmount += chfee.NoTaxAmount;
|
|
|
infee.TaxUnitPrice += chfee.TaxUnitPrice;
|
|
|
}
|
|
|
needinsert = false;
|
|
|
break;
|
|
|
}
|
|
|
if (needinsert) {
|
|
|
FeeList.Add(chfee);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//StringBuilder sb = new StringBuilder();
|
|
|
//sb.Append(@"insert into ch_fee (GID,BSNO,FEETYPE,FEENAME,REMARK,CUSTOMERTYPE,CUSTOMERNAME");
|
|
|
//sb.Append(@",UNIT,UNITPRICE,QUANTITY,AMOUNT,CURRENCY,EXCHANGERATE,");
|
|
|
//sb.Append(@"FEESTATUS,NOTAXAMOUNT,TAXUNITPRICE,WMSOUTBSNO,ENTEROPERATOR) ");
|
|
|
//sb.Append(@" VALUES(");
|
|
|
//sb.Append("'" + Guid.NewGuid() + "',"); //GID
|
|
|
//sb.Append("'" + cm.BSNO + "',"); //BSNO
|
|
|
//sb.Append("'" + feeType + "' , "); //FEETYPE
|
|
|
//sb.Append("'" + feeName + "',"); //FEENAME
|
|
|
//sb.Append("'入库单号" + wmsno + "生成费用',"); //REMARK
|
|
|
//sb.Append("'" + "车队" + "',"); //CUSTOMERTYPE
|
|
|
//sb.Append("'" + feeCustomerName + "',"); //CUSTOMERNAME
|
|
|
//sb.Append("'" + + "',"); //UNIT
|
|
|
//sb.Append(feeValue + ","); //UNITPRICE
|
|
|
//sb.Append("1" + ","); //QUANTITY
|
|
|
//sb.Append(feeValue + ","); //AMOUNT
|
|
|
//sb.Append("'" + "RMB" + "',"); //CURRENCY
|
|
|
//sb.Append("1" + ","); //EXCHANGERATE
|
|
|
//sb.Append("1" + ","); //FEESTATUS
|
|
|
//sb.Append(feeValue + ","); //NOTAXAMOUNT
|
|
|
//sb.Append(feeValue + ","); //TAXUNITPRICE
|
|
|
//sb.Append("'" + cm.WMSGID + "',"); //WMSOUTBSNO
|
|
|
//sb.Append("'" + userid + "'"); //ENTEROPERATOR
|
|
|
|
|
|
//sb.Append(")");
|
|
|
//SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sb.ToString(), null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
DBResult result = modb.SaveComm("BsNo", BSNO,
|
|
|
ModelObjectConvert<MsChFeeWMSINMake>.ToModelObjectList(FeeList),
|
|
|
null
|
|
|
);
|
|
|
|
|
|
sqlTran.Commit();
|
|
|
msg = "生成成功!";
|
|
|
rst = true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
msg = "生成失败!";
|
|
|
sqlTran.Rollback();
|
|
|
rst = false;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
sqlTran.Dispose();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return rst;
|
|
|
}
|
|
|
|
|
|
static public List<WMSRATEmb> GetWMSRATE(string strCondition, string sort)
|
|
|
{ //库存信息
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" SELECT (select SHOWNAME from [user] where GID=wms_rate.CREATEUSER) CREATEUSER2,*,case feetype when 1 then '收' when 2 then '付' end as FEETYPEREF ");
|
|
|
strSql.Append(" FROM [wms_Rate] ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition.Replace("~", ""));
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by FEETYPE,FEEGRADE ");
|
|
|
}
|
|
|
return SetWMSRATEData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<WMSRATEmb> SetWMSRATEData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<WMSRATEmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WMSRATEmb data = new WMSRATEmb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
data.FEETYPE = Convert.ToString(reader["FEETYPE"]);
|
|
|
data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]);
|
|
|
data.FEEGRADE = Convert.ToString(reader["FEEGRADE"]);
|
|
|
data.FEESCALE = Convert.ToString(reader["FEESCALE"]);
|
|
|
data.FEEPRICE = Convert.ToString(reader["FEEPRICE"]);
|
|
|
data.FEEUNIT = Convert.ToString(reader["FEEUNIT"]);
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
|
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
data.ADDPRICE = Convert.ToString(reader["ADDPRICE"]);
|
|
|
data.ENDBILLINGDATE = Convert.ToString(reader["ENDBILLINGDATE"]);
|
|
|
data.RATETYPE = Convert.ToString(reader["RATETYPE"]);
|
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
|
data.ISCHANGE = Convert.ToString(reader["ISCHANGE"]);
|
|
|
data.CAPPRICE = Convert.ToString(reader["CAPPRICE"]);
|
|
|
data.CREATEUSER2 = Convert.ToString(reader["CREATEUSER2"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public string GetSysFeeConfig(string userid)
|
|
|
{
|
|
|
string sql = "select PARAMVALUE from sys_param_set where gid = '617FA649-45D9-489D-ADE9-D1E96D10D111' ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string value = "0";
|
|
|
var rst = db.ExecuteScalar(CommandType.Text, sql);
|
|
|
if (rst != null && rst != DBNull.Value && rst.ToString() != "")
|
|
|
{
|
|
|
value = rst.ToString();
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static List<WMSFeeModelDetails> GetImportFeeModel(string custname, string goodsnameid, string wmsdate, string storagename)
|
|
|
{
|
|
|
string condition = "";
|
|
|
condition = "PGID = (SELECT TOP 1 GID FROM WMS_FEEMODEL WHERE CUSTNAME = " + custname + " and '" + wmsdate + "' between VALIDITYFROM and VALIDITYTO AND (STORAGENAME = " + storagename + " or STORAGENAME='') order by STORAGENAME desc ) AND GGID = " + goodsnameid + " order by JiFeiDengJi asc";
|
|
|
/*
|
|
|
2019-07-25删掉,这个参数用的莫名其妙,用了还没用一样
|
|
|
var WMSGOODNAMEIMPORTTRADE = MsSysParamSetDAL.GetData("PARAMNAME='WMSGOODNAMEIMPORTTRADE'");
|
|
|
if (WMSGOODNAMEIMPORTTRADE.PARAMVALUE == "1")
|
|
|
{
|
|
|
condition = "PGID = (SELECT TOP 1 GID FROM WMS_FEEMODEL WHERE CUSTNAME = " + custname + " and '"+wmsdate+ "' between VALIDITYFROM and VALIDITYTO ) AND GGID = '" + goodsnameid + "' order by JiFeiDengJi";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = "PGID = (SELECT TOP 1 GID FROM WMS_FEEMODEL WHERE CUSTNAME = " + custname + " and '" + wmsdate + "' between VALIDITYFROM and VALIDITYTO) AND GGID = " + goodsnameid + " order by JiFeiDengJi";
|
|
|
|
|
|
}
|
|
|
*/
|
|
|
List<WMSFeeModelDetails> list = WMSFeeModelDAL.GetDataDetailsList(condition);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static List<LOADERFEEMODEL> GetLoaderFeeModel(string custname, string goodsnameid, string wmsdate, string feetype, string storagename)
|
|
|
{
|
|
|
string condition = "";
|
|
|
condition = "PGID = (SELECT TOP 1 GID FROM WMS_FEEMODEL WHERE CUSTNAME = '" + custname + "' and '" + wmsdate + "' between VALIDITYFROM and VALIDITYTO AND STORAGENAME = '" + storagename + "') AND GGID = '" + goodsnameid + "' and FEETYPE = '" + feetype + "' order by FEETYPE";
|
|
|
|
|
|
List<LOADERFEEMODEL> list = WMSFeeModelDAL.GetDataLoaderList(condition);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public static DBResult Modify(List<WMSNewList> bodyList, WMSNewList modifydata, string companyid)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var head = ChMonthCloseDAL.ChMonthCloseDAL.GetData("", companyid);
|
|
|
|
|
|
string errstr = "";
|
|
|
int i = 0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
var strSqlBL = new StringBuilder();
|
|
|
strSql.Append("update wms set GID=GID ");
|
|
|
if (modifydata.BLNO != "" && modifydata.BLNO != null)
|
|
|
strSql.Append(",BLNO=@BLNO");
|
|
|
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
|
|
|
|
|
|
var cmdupdate =
|
|
|
db.GetSqlStringCommand(strSql.ToString());
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
foreach (var enumValue in bodyList)
|
|
|
{
|
|
|
|
|
|
var isPost = true;
|
|
|
|
|
|
if (isPost)
|
|
|
{
|
|
|
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
|
if (modifydata.BLNO != "" && modifydata.BLNO != null)
|
|
|
db.AddInParameter(cmdupdate, "@BLNO", DbType.String, modifydata.BLNO);
|
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.GID);
|
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
i = i + 1;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
|
|
|
result.Success = false;
|
|
|
result.Message = "修改出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "修改成功" + i.ToString() + "票";
|
|
|
if (errstr != "")
|
|
|
{
|
|
|
result.Message = result.Message + "(其中" + errstr + " 无法修改)";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 权限范围
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='modWmsList' 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 = "1=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
|
|
|
str = " (WMSOP='" + username + "' OR CREATEUSER='" + userid + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptid = rangeDa.GetDEPTGID(userid);
|
|
|
str = " (WMSOP in (select showname from vw_user where deptgid='" + deptid + "') OR CREATEUSER in (select userid from vw_user where deptgid='" + deptid + "'))";
|
|
|
|
|
|
|
|
|
|
|
|
//var userstr = new StringBuilder();
|
|
|
//userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
//Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
//using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
//{
|
|
|
// str = "";
|
|
|
// while (reader.Read())
|
|
|
// {
|
|
|
// if (str == "")
|
|
|
// {
|
|
|
// str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
// };
|
|
|
// }
|
|
|
// str = str + ")";
|
|
|
// reader.Close();
|
|
|
//}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " UPPER(CORPID)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
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 = " (WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CREATEUSER='" + Convert.ToString(reader["OPID"]) + "' ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CREATEUSER='" + Convert.ToString(reader["OPID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 入库单号是否手动录入
|
|
|
/// </summary>
|
|
|
/// <param name="userid"></param>
|
|
|
/// <returns></returns>
|
|
|
static public string GetWMSNOManualConfig()
|
|
|
{
|
|
|
string sql = "select PARAMVALUE from sys_param_set where gid = '62447649-45D9-489D-ADE9-D1E96D10D111' ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string value = "0";
|
|
|
var rst = db.ExecuteScalar(CommandType.Text, sql);
|
|
|
if (rst != null && rst != DBNull.Value && rst.ToString() != "")
|
|
|
{
|
|
|
value = rst.ToString();
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
static public void GetZhuangXieFeiWithZhuangXieGongID(string gid, out float feeJian, out float feeTon)
|
|
|
{
|
|
|
|
|
|
string sql = "select PriceJian,PriceLiangTon from wms_stevedores where gid='" + gid + "'";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
float feejian = 0;
|
|
|
float feeton = 0;
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
feejian = float.Parse(reader["PriceJian"].ToString());
|
|
|
feeton = float.Parse(reader["PriceLiangTon"].ToString());
|
|
|
}
|
|
|
}
|
|
|
feeJian = feejian;
|
|
|
feeTon = feeton;
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 随机数
|
|
|
|
|
|
private static char[] constant =
|
|
|
{
|
|
|
'0','1','2','3','4','5','6','7','8','9'
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
public static string GenerateRandomNumber(int Length)
|
|
|
{
|
|
|
System.Text.StringBuilder newRandom = new System.Text.StringBuilder(62);
|
|
|
Random rd = new Random();
|
|
|
for (int i = 0; i < Length; i++)
|
|
|
{
|
|
|
newRandom.Append(constant[rd.Next(10)]);
|
|
|
}
|
|
|
return newRandom.ToString();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region app
|
|
|
public static DataTable GetWmsNoLockAndArea()
|
|
|
{
|
|
|
string sql = "select GID,WMSNO,CUSTOMERNAME,CONTRACTNO,GOODSNAME from wms where (islock=0 or islock is null) and (areaname is null or areaname='')";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
return db.ExecuteDataSet(CommandType.Text, sql).Tables[0];
|
|
|
}
|
|
|
|
|
|
public static DataTable GetWmsInWithAssociatedNO(string associatedNO)
|
|
|
{
|
|
|
string sql = $"select GOODSNAME,GOODSPACK,GOODSSTOCK,AREANAME,TrayNo from wms_in where ASSOCIATEDNO='{associatedNO}'";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
return db.ExecuteDataSet(CommandType.Text, sql).Tables[0];
|
|
|
}
|
|
|
|
|
|
public static string GetWmsInAreaNameAssociatedNO(string associatedNO)
|
|
|
{
|
|
|
StringBuilder sbSql = new StringBuilder("DECLARE @ASSOCIATEDNO VARCHAR(50),@CONTRACTNO VARCHAR(200)");
|
|
|
sbSql.AppendLine("BEGIN");
|
|
|
sbSql.AppendLine($"SET @ASSOCIATEDNO='{associatedNO}'");
|
|
|
sbSql.AppendLine("IF (SELECT charindex('-',CONTRACTNO) FROM WMS WHERE ASSOCIATEDNO=@ASSOCIATEDNO)=0");
|
|
|
sbSql.AppendLine("SET @CONTRACTNO=(SELECT CONTRACTNO FROM WMS WHERE ASSOCIATEDNO=@ASSOCIATEDNO)");
|
|
|
sbSql.AppendLine("ELSE");
|
|
|
sbSql.AppendLine("SET @CONTRACTNO=(SELECT substring(CONTRACTNO,0,charindex('-',CONTRACTNO)) FROM WMS WHERE ASSOCIATEDNO=@ASSOCIATEDNO)");
|
|
|
sbSql.AppendLine("SELECT DISTINCT I.AREANAME FROM WMS_IN I");
|
|
|
sbSql.AppendLine("JOIN WMS W ON W.ASSOCIATEDNO=I.ASSOCIATEDNO");
|
|
|
sbSql.AppendLine("WHERE W.CONTRACTNO=@CONTRACTNO OR W.CONTRACTNO LIKE (@CONTRACTNO+'-%')");
|
|
|
sbSql.AppendLine("AND I.AREANAME IS NOT NULL AND I.AREANAME!=''");
|
|
|
sbSql.AppendLine("END");
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
DataTable tb = db.ExecuteDataSet(CommandType.Text, sbSql.ToString()).Tables[0];
|
|
|
string str = string.Empty;
|
|
|
foreach (DataRow row in tb.Rows)
|
|
|
{
|
|
|
if (str.Length > 0)
|
|
|
{
|
|
|
str += ",";
|
|
|
}
|
|
|
str += row["AREANAME"].ToString();
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
public static void FillAreaName(string associatedNO, string trayNOStart, string trayNOEnd, string areaName)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(trayNOEnd))
|
|
|
{
|
|
|
trayNOEnd = trayNOStart;
|
|
|
}
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
db.ExecuteNonQuery("AppFillAreaName", new object[] { associatedNO, trayNOStart, trayNOEnd, areaName });
|
|
|
|
|
|
}
|
|
|
|
|
|
public static bool FilleAreaForTray(string trayNO, string areaName)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
var sql = $"select count(1) from wms_in where GOODSSTOCK<>0 and trayno='{trayNO}'";
|
|
|
var rtn = db.ExecuteScalar(CommandType.Text, sql);
|
|
|
if (rtn != DBNull.Value && Convert.ToInt32(rtn) > 0)
|
|
|
{
|
|
|
db.ExecuteNonQuery("AppAlterAreaName", new object[] { trayNO, areaName });
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
} |