using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web ;
using System.Web.Services ;
using NetLibrary.Data ;
using TradeData ;
using TradeModel ;
using System.Data ;
using TradeManageNew ;
using NetLibrary ;
using System.IO ;
using NetLibrary.ReportPrint ;
using NPOI.HSSF.Record.Formula.Functions ;
using NetLibrary.Common.Configuration ;
using NPOI.HSSF.UserModel ;
using NPOI.SS.UserModel ;
using static NPOI . HSSF . Util . HSSFColor ;
using System.Net ;
using System.Security.Policy ;
using System.Text ;
namespace TradeManage
{
/// <summary>
/// HuoWuServiceNew 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class HuoWuServiceNew : System . Web . Services . WebService
{
[WebMethod]
public string HelloWorld ( )
{
return "Hello World" ;
}
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsDetail2 > > GetGoodsDetailList ( int TJ1 , int IsYC , int IsJQ , int StoreId , int AQNum , string Name , string Supplier , int TJ2 , int SNum , int ENum , int PageIndex , int PageSize , string Sort )
{
HuoWuData data = new HuoWuData ( ) ;
int num = Convert . ToInt32 ( base . Session [ "CompanyId" ] ) ;
RefParameterCollection where = new RefParameterCollection ( ) ;
where . Add ( "b.CompanyId" , "=" , num , DbType . Int32 ) ;
if ( IsYC = = 0 )
{
where . Add ( "isnull(a.IsYC,0)" , "=" , 0 , DbType . Int32 ) ;
}
if ( IsYC = = 2 )
{
where . Add ( "a.IsYC" , "=" , 1 , DbType . Int32 ) ;
}
if ( AQNum = = 1 )
{
where . Add ( "a.GoodsNum-isnull(a.GoodsHJNum2,0)" , "<" , 0 , DbType . Int32 ) ;
}
where . Add ( "b.State" , "=" , 1 , DbType . Int32 ) ;
if ( Supplier ! = "" )
{
where . Add ( "b.SupplierId" , "like" , Supplier , DbType . String ) ;
}
Name = Name . Trim ( ) ;
if ( ( Name ! = "" ) & & ( IsJQ = = 0 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "like" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "like" , Name , "or" , ")" , DbType . String ) ;
}
}
else if ( ( Name ! = "" ) & & ( IsJQ = = 1 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "=" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "=" , Name , "or" , ")" , DbType . String ) ;
}
}
if ( TJ2 = = 1 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 2 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 3 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum2" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum2" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 4 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum3" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum3" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 5 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum4" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum4" , "<=" , ENum , DbType . Int32 ) ;
}
}
JsonModel < List < HW_GoodsDetail2 > > model = new JsonModel < List < HW_GoodsDetail2 > > ( ) ;
int rowCount = 0 ;
model . DataSource = DataNew . GetListHW_GoodsDetailNew ( StoreId , where , PageIndex , PageSize , Sort , out rowCount ) ;
model . RowCount = rowCount ;
string gids = "" ;
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
gids + = detail . GoodsId + "," ;
}
}
List < HW_GoodsStar > slist = null ;
if ( gids ! = "" )
{
slist = DataNew . GetListGoodsStar ( gids . TrimEnd ( ',' ) ) ;
}
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
string html = "" ;
List < JC_Shop > czlist = new List < JC_Shop > ( ) ;
if ( slist ! = null )
{
var smd = slist . FindAll ( n = > n . GoodsId = = detail . GoodsId ) ;
if ( smd ! = null )
{
foreach ( var ssmd in smd )
{
var czmd = czlist . Find ( n = > n . ShopId = = ssmd . ShopId ) ;
if ( czmd = = null )
{
decimal score = Convert . ToDecimal ( ssmd . Star1 . Value * 1 / 100 + ssmd . Star2 . Value * 2 / 100 + ssmd . Star3 * 3 / 100 + ssmd . Star4 * 4 / 100 + ssmd . Star5 * 5 / 100 ) ;
string starhtml = "" ;
if ( score > = Convert . ToDecimal ( 4.5 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>" ;
else if ( score > = Convert . ToDecimal ( 4 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 3 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 2 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 1 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else
starhtml + = "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
html + = @"<div style='float:left'> " + ssmd . ShopName + ":" + starhtml + score . ToString ( "0.0" ) + " out of 5 Stars" + ssmd . Star6 + " " ;
html + = @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star5 . Value + "px;height:10px;'></div></div>" + ssmd . Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star4 . Value + "px;height:10px'></div></div>" + ssmd . Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star3 . Value + "px;height:10px'></div></div>" + ssmd . Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star2 . Value + "px;height:10px'></div></div>" + ssmd . Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star1 . Value + "px;height:10px'></div></div>" + ssmd . Star1 + @ "%
< / div > ";
}
var spmd = new JC_Shop ( ) ;
spmd . ShopId = ssmd . ShopId ;
czlist . Add ( spmd ) ;
}
}
}
detail . UpdateName = html ;
if ( detail . Solid . HasValue )
{
detail . TotalSolid = detail . Solid * detail . GoodsNum ;
}
else
{
detail . TotalSolid = 0 ;
}
}
}
return model ;
}
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsDetailNew2 > > GetGoodsDetailListNew2 ( int GNum , int TJ1 , int IsYC , int IsJQ , int StoreId , int AQNum , int AQNum2 , string Name , string Supplier , int TJ2 , int SNum , int ENum , int cgjh , int PageIndex , int PageSize , string Sort )
{
HuoWuData data = new HuoWuData ( ) ;
int num = Convert . ToInt32 ( base . Session [ "CompanyId" ] ) ;
RefParameterCollection where = new RefParameterCollection ( ) ;
if ( IsYC = = 0 )
{
where . Add ( "isnull(a.IsYC,0)" , "=" , 0 , DbType . Int32 ) ;
}
if ( cgjh > 0 )
where . Add ( "FHPlan" , "=" , cgjh , DbType . Int32 ) ;
if ( IsYC = = 2 )
{
where . Add ( "a.IsYC" , "=" , 1 , DbType . Int32 ) ;
}
where . Add ( "b.CompanyId" , "=" , num , DbType . Int32 ) ;
if ( AQNum = = 1 )
{
where . Add ( "isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)" , "<" , 0 , DbType . Int32 ) ;
}
if ( AQNum2 = = 1 )
{
where . Add ( "isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)" , "<" , 0 , DbType . Int32 ) ;
}
where . Add ( "b.State" , "=" , 1 , DbType . Int32 ) ;
if ( Supplier ! = "" )
{
where . Add ( "b.SupplierId" , "like" , Supplier , DbType . String ) ;
}
Name = Name . Trim ( ) ;
if ( ( Name ! = "" ) & & ( IsJQ = = 0 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "like" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "like" , Name , "or" , ")" , DbType . String ) ;
}
}
else if ( ( Name ! = "" ) & & ( IsJQ = = 1 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "=" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "=" , Name , "or" , ")" , DbType . String ) ;
}
}
if ( TJ2 = = 1 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 2 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 3 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum2" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum2" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 4 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum3" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum3" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 5 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum4" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum4" , "<=" , ENum , DbType . Int32 ) ;
}
}
if ( GNum = = 1 )
where . Add ( "a.CGNum" , ">" , 0 , DbType . Int32 ) ;
JsonModel < List < HW_GoodsDetailNew2 > > model = new JsonModel < List < HW_GoodsDetailNew2 > > ( ) ;
int rowCount = 0 ;
model . DataSource = DataNew . GetListHW_GoodsDetailNew2 ( StoreId , where , PageIndex , PageSize , Sort , out rowCount ) ;
model . RowCount = rowCount ;
string gids = "" ;
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
gids + = detail . GoodsId + "," ;
}
}
List < HW_GoodsStar > slist = null ;
if ( gids ! = "" )
{
slist = DataNew . GetListGoodsStar ( gids . TrimEnd ( ',' ) ) ;
}
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
string html = "" ;
List < JC_Shop > czlist = new List < JC_Shop > ( ) ;
if ( slist ! = null )
{
var smd = slist . FindAll ( n = > n . GoodsId = = detail . GoodsId ) ;
if ( smd ! = null )
{
foreach ( var ssmd in smd )
{
var czmd = czlist . Find ( n = > n . ShopId = = ssmd . ShopId ) ;
if ( czmd = = null )
{
decimal score = Convert . ToDecimal ( ssmd . Star1 . Value * 1.00 / 100 + ssmd . Star2 . Value * 2.00 / 100 + ssmd . Star3 * 3.00 / 100 + ssmd . Star4 * 4.00 / 100 + ssmd . Star5 * 5.00 / 100 ) ;
string starhtml = "" ;
if ( score > = Convert . ToDecimal ( 4.5 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>" ;
else if ( score > = Convert . ToDecimal ( 4 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 3 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 2 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 1 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else
starhtml + = "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
html + = @"<div style='float:left'> " + ssmd . ShopName + ":" + starhtml + score . ToString ( "0.0" ) + " out of 5 Stars" + ssmd . Star6 + " " ;
html + = @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star5 . Value + "px;height:10px;'></div></div>" + ssmd . Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star4 . Value + "px;height:10px'></div></div>" + ssmd . Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star3 . Value + "px;height:10px'></div></div>" + ssmd . Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star2 . Value + "px;height:10px'></div></div>" + ssmd . Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star1 . Value + "px;height:10px'></div></div>" + ssmd . Star1 + @ "%
< / div > ";
}
var spmd = new JC_Shop ( ) ;
spmd . ShopId = ssmd . ShopId ;
czlist . Add ( spmd ) ;
}
}
}
detail . UpdateName = html ;
if ( detail . Solid . HasValue )
{
detail . TotalSolid = detail . Solid * detail . GoodsNum ;
}
else
{
detail . TotalSolid = 0 ;
}
}
}
return model ;
}
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsDetailNew2 > > GetGoodsDetailListNew22 ( int platid , int MUserId , int cpzt , int GNum , int TJ1 , int IsYC , int IsJQ , int StoreId , int AQNum , int AQNum2 , string Name , string Supplier , int TJ2 , int SNum , int ENum , int cgjh , int kh , int PageIndex , int PageSize , string Sort )
{
HuoWuData data = new HuoWuData ( ) ;
int num = 0 ;
if ( base . Session [ "CompanyId" ] ! = null )
{
num = Convert . ToInt32 ( base . Session [ "CompanyId" ] ) ;
}
else
{
num = 1 ;
}
RefParameterCollection where = new RefParameterCollection ( ) ;
if ( IsYC = = 0 )
{
where . Add ( "isnull(a.IsYC,0)" , "=" , 0 , DbType . Int32 ) ;
}
if ( IsYC = = 2 )
{
where . Add ( "a.IsYC" , "=" , 1 , DbType . Int32 ) ;
}
where . Add ( "b.CompanyId" , "=" , num , DbType . Int32 ) ;
if ( cgjh > 0 )
where . Add ( "FHPlan" , "=" , cgjh , DbType . Int32 ) ;
if ( cgjh > 0 )
where . Add ( "FHPlan" , "=" , cgjh , DbType . Int32 ) ;
if ( MUserId ! = 0 & & platid = = 2 )
where . Add ( "b.muserid" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 3 )
where . Add ( "b.guserid_ebay" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 6 )
where . Add ( "b.guserid_wlmart" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 15 )
where . Add ( "b.guserid_shopify" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 18 )
where . Add ( "b.guserid_wayfair" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 21 )
where . Add ( "b.guserid_sheIn" , "=" , MUserId , DbType . Int32 ) ;
else if ( MUserId ! = 0 & & platid = = 23 )
where . Add ( "b.guserid_temu" , "=" , MUserId , DbType . Int32 ) ;
if ( AQNum = = 1 )
{
where . Add ( "isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)" , "<" , 0 , DbType . Int32 ) ;
}
if ( AQNum2 = = 1 )
{
where . Add ( "isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)" , "<" , 0 , DbType . Int32 ) ;
}
where . Add ( "b.State" , "=" , 1 , DbType . Int32 ) ;
if ( Supplier ! = "" )
{
where . Add ( "b.SupplierId" , "like" , Supplier , DbType . String ) ;
}
Name = Name . Trim ( ) ;
if ( ( Name ! = "" ) & & ( IsJQ = = 0 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "like" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "like" , Name , "or" , ")" , DbType . String ) ;
}
}
else if ( ( Name ! = "" ) & & ( IsJQ = = 1 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "=" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "=" , Name , "or" , ")" , DbType . String ) ;
}
}
if ( TJ2 = = 1 )
{
if ( StoreId = = 6 )
{
if ( SNum > 0 )
{
where . Add ( "a.WestNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.WestNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( StoreId = = 11 )
{
if ( SNum > 0 )
{
where . Add ( "a.EastNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.EastNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
}
else if ( TJ2 = = 2 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 3 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum2" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum2" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 4 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum3" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum3" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 5 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum4" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum4" , "<=" , ENum , DbType . Int32 ) ;
}
}
if ( GNum = = 1 )
where . Add ( "a.CGNum" , ">" , 0 , DbType . Int32 ) ;
if ( kh ! = - 1 )
where . Add ( "b.IsExamine" , "=" , kh , DbType . Int32 ) ;
JsonModel < List < HW_GoodsDetailNew2 > > model = new JsonModel < List < HW_GoodsDetailNew2 > > ( ) ;
int rowCount = 0 ;
model . DataSource = DataNew . GetListHW_GoodsDetailNew22 ( platid , StoreId , where , PageIndex , PageSize , Sort , out rowCount ) ;
model . RowCount = rowCount ;
string gids = "" ;
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
gids + = detail . GoodsId + "," ;
}
}
List < HW_GoodsStar > slist = null ;
if ( gids ! = "" )
{
slist = DataNew . GetListGoodsStar ( gids . TrimEnd ( ',' ) ) ;
}
if ( model . DataSource ! = null )
{
var saleNums = DataNew . GetStoreGoodsSaleNumsNowDay ( ) ;
foreach ( var detail in model . DataSource )
{
string html = "" ;
List < JC_Shop > czlist = new List < JC_Shop > ( ) ;
if ( slist ! = null )
{
var smd = slist . FindAll ( n = > n . GoodsId = = detail . GoodsId ) ;
if ( smd ! = null )
{
foreach ( var ssmd in smd )
{
var czmd = czlist . Find ( n = > n . ShopId = = ssmd . ShopId ) ;
if ( czmd = = null )
{
decimal score = Convert . ToDecimal ( ssmd . Star1 . Value * 1.00 / 100 + ssmd . Star2 . Value * 2.00 / 100 + ssmd . Star3 * 3.00 / 100 + ssmd . Star4 * 4.00 / 100 + ssmd . Star5 * 5.00 / 100 ) ;
string starhtml = "" ;
if ( score > = Convert . ToDecimal ( 4.5 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>" ;
else if ( score > = Convert . ToDecimal ( 4 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 3 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 2 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 1 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else
starhtml + = "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
html + = @"<div style='float:left'> " + ssmd . ShopName + ":" + starhtml + score . ToString ( "0.0" ) + " out of 5 Stars" + ssmd . Star6 + " " ;
html + = @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star5 . Value + "px;height:10px;'></div></div>" + ssmd . Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star4 . Value + "px;height:10px'></div></div>" + ssmd . Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star3 . Value + "px;height:10px'></div></div>" + ssmd . Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star2 . Value + "px;height:10px'></div></div>" + ssmd . Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star1 . Value + "px;height:10px'></div></div>" + ssmd . Star1 + @ "%
< / div > ";
}
var spmd = new JC_Shop ( ) ;
spmd . ShopId = ssmd . ShopId ;
czlist . Add ( spmd ) ;
}
}
}
detail . UpdateName = html ;
if ( detail . Solid . HasValue )
{
detail . TotalSolid = detail . Solid * detail . GoodsNum ;
}
else
{
detail . TotalSolid = 0 ;
}
if ( saleNums ! = null )
{
var _EsaleNum = saleNums . Where ( r = > r . StoreId = = 11 & & r . DetailId = = detail . DetailId ) . FirstOrDefault ( ) ;
detail . ENowDaySaleNum = _EsaleNum = = null ? 0 : _EsaleNum . SaleNum ;
var _WsaleNum = saleNums . Where ( r = > r . StoreId = = 6 & & r . DetailId = = detail . DetailId ) . FirstOrDefault ( ) ;
detail . WNowDaySaleNum = _WsaleNum = = null ? 0 : _WsaleNum . SaleNum ;
}
}
}
return model ;
}
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsDetailNew2 > > GetGoodsDetailListNew5 ( int GNum , int TJ1 , int IsYC , int IsJQ , int StoreId , int AQNum , int AQNum2 , string Name , string Supplier , int TJ2 , int SNum , int ENum , int PageIndex , int PageSize , string Sort )
{
HuoWuData data = new HuoWuData ( ) ;
int num = Convert . ToInt32 ( base . Session [ "CompanyId" ] ) ;
RefParameterCollection where = new RefParameterCollection ( ) ;
if ( Session [ "KTSKU" ] . ToString ( ) = = "" )
return null ;
string ktsku = Session [ "KTSKU" ] . ToString ( ) ;
if ( IsYC = = 0 )
{
where . Add ( "isnull(a.IsYC,0)" , "=" , 0 , DbType . Int32 ) ;
}
if ( IsYC = = 2 )
{
where . Add ( "a.IsYC" , "=" , 1 , DbType . Int32 ) ;
}
where . Add ( "b.CompanyId" , "=" , num , DbType . Int32 ) ;
if ( AQNum = = 1 )
{
where . Add ( "isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)" , "<" , 0 , DbType . Int32 ) ;
}
if ( AQNum2 = = 1 )
{
where . Add ( "isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)" , "<" , 0 , DbType . Int32 ) ;
}
where . Add ( "b.State" , "=" , 1 , DbType . Int32 ) ;
if ( Supplier ! = "" )
{
where . Add ( "b.SupplierId" , "like" , Supplier , DbType . String ) ;
}
Name = Name . Trim ( ) ;
where . Add ( "b.GoodsCode" , "like right" , ktsku , DbType . String ) ;
if ( ( Name ! = "" ) & & ( IsJQ = = 0 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "like" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "like" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "like" , Name , "or" , ")" , DbType . String ) ;
}
}
else if ( ( Name ! = "" ) & & ( IsJQ = = 1 ) )
{
if ( TJ1 = = 1 )
{
where . Add ( "b.GoodsName" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 2 )
{
where . Add ( "b.GoodsCode" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
where . Add ( "(a.SKU1" , "=" , Name , DbType . String ) ;
where . Add ( "a.SKU2" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU3" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU4" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU5" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU6" , "=" , Name , "or" , DbType . String ) ;
where . Add ( "a.SKU7" , "=" , Name , "or" , ")" , DbType . String ) ;
}
}
if ( TJ2 = = 1 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 2 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 3 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum2" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum2" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 4 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum3" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum3" , "<=" , ENum , DbType . Int32 ) ;
}
}
else if ( TJ2 = = 5 )
{
if ( SNum > 0 )
{
where . Add ( "a.GoodsHJNum4" , ">=" , SNum , DbType . Int32 ) ;
}
if ( ENum > 0 )
{
where . Add ( "a.GoodsHJNum4" , "<=" , ENum , DbType . Int32 ) ;
}
}
if ( GNum = = 1 )
where . Add ( "a.CGNum" , ">" , 0 , DbType . Int32 ) ;
JsonModel < List < HW_GoodsDetailNew2 > > model = new JsonModel < List < HW_GoodsDetailNew2 > > ( ) ;
int rowCount = 0 ;
model . DataSource = DataNew . GetListHW_GoodsDetailNew2 ( StoreId , where , PageIndex , PageSize , Sort , out rowCount ) ;
model . RowCount = rowCount ;
string gids = "" ;
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
gids + = detail . GoodsId + "," ;
}
}
List < HW_GoodsStar > slist = null ;
if ( gids ! = "" )
{
slist = DataNew . GetListGoodsStar ( gids . TrimEnd ( ',' ) ) ;
}
if ( model . DataSource ! = null )
{
foreach ( var detail in model . DataSource )
{
string html = "" ;
List < JC_Shop > czlist = new List < JC_Shop > ( ) ;
if ( slist ! = null )
{
var smd = slist . FindAll ( n = > n . GoodsId = = detail . GoodsId ) ;
if ( smd ! = null )
{
foreach ( var ssmd in smd )
{
var czmd = czlist . Find ( n = > n . ShopId = = ssmd . ShopId ) ;
if ( czmd = = null )
{
decimal score = Convert . ToDecimal ( ssmd . Star1 . Value * 1.00 / 100 + ssmd . Star2 . Value * 2.00 / 100 + ssmd . Star3 * 3.00 / 100 + ssmd . Star4 * 4.00 / 100 + ssmd . Star5 * 5.00 / 100 ) ;
string starhtml = "" ;
if ( score > = Convert . ToDecimal ( 4.5 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>" ;
else if ( score > = Convert . ToDecimal ( 4 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 3 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 2 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else if ( score > = Convert . ToDecimal ( 1 ) )
starhtml + = "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
else
starhtml + = "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>" ;
html + = @"<div style='float:left'> " + ssmd . ShopName + ":" + starhtml + score . ToString ( "0.0" ) + " out of 5 Stars" + ssmd . Star6 + " " ;
html + = @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star5 . Value + "px;height:10px;'></div></div>" + ssmd . Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star4 . Value + "px;height:10px'></div></div>" + ssmd . Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star3 . Value + "px;height:10px'></div></div>" + ssmd . Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star2 . Value + "px;height:10px'></div></div>" + ssmd . Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd . Star1 . Value + "px;height:10px'></div></div>" + ssmd . Star1 + @ "%
< / div > ";
}
var spmd = new JC_Shop ( ) ;
spmd . ShopId = ssmd . ShopId ;
czlist . Add ( spmd ) ;
}
}
}
detail . UpdateName = html ;
if ( detail . Solid . HasValue )
{
detail . TotalSolid = detail . Solid * detail . GoodsNum ;
}
else
{
detail . TotalSolid = 0 ;
}
}
}
return model ;
}
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFee ( int IsFG , string FileName )
{
Pages . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "Express or Ground Tracking ID" ) = = false ) { error = error + "导入模板的 Express or Ground Tracking ID 列不存在" ; }
if ( tb . Columns . Contains ( "Net Charge Amount" ) = = false ) { error = error + "导入模板的 Net Charge Amount 列不存在" ; }
if ( tb . Columns . Contains ( "Ground Tracking ID Prefix" ) = = false ) { error = error + "导入模板的 Ground Tracking ID Prefix 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Count = 0 ;
int Count2 = 0 ;
string trinfo = "" ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
string TrackCode = tb . Rows [ i ] [ "Ground Tracking ID Prefix" ] . ToString ( ) . Trim ( ) + tb . Rows [ i ] [ "Express or Ground Tracking ID" ] . ToString ( ) . Replace ( " " , "" ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "Net Charge Amount" ] . ToString ( ) . Trim ( ) = = "" | | TrackCode = = "" )
continue ;
decimal PostFee = 0 ;
try
{
PostFee = Convert . ToDecimal ( tb . Rows [ i ] [ "Net Charge Amount" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
continue ;
}
if ( IsFG = = 1 )
obj . ImportTrackCodeClear ( TrackCode ) ;
int a = DataNew . ImportTrackCode ( TrackCode , PostFee , 0 ) ;
if ( a > 0 )
{
Count + + ;
}
else
{
Count2 + + ;
trinfo + = tb . Rows [ i ] [ "Express or Ground Tracking ID" ] . ToString ( ) . Trim ( ) + "\r\n" ;
}
}
error = "导入成功" + Count . ToString ( ) + "条" ;
if ( Count2 > 0 )
error + = Count2 + "条数据运单号在系统找不对到\r\n" + trinfo ;
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSaveDT_FeeForYF ( int IsFG , string FileName )
{
Pages . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "订单号" ) = = false ) { error = error + "导入模板的 订单号 列不存在" ; }
if ( tb . Columns . Contains ( "运费" ) = = false ) { error = error + "导入模板的 运费 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Count = 0 ;
StringBuilder sb = new StringBuilder ( ) ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
string orderCode = tb . Rows [ i ] [ "订单号" ] . ToString ( ) . Trim ( ) ;
if ( string . IsNullOrEmpty ( orderCode ) )
{
sb . Append ( "第" + ( i + 1 ) + "行订单号为空;" ) ;
continue ;
}
decimal PostFee = 0 ;
try
{
PostFee = Convert . ToDecimal ( tb . Rows [ i ] [ "运费" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
sb . Append ( "第" + ( i + 1 ) + "行运费格式不正确;" ) ;
continue ;
}
var a = DataNew . UpdateDT_FeeYFByOrderCode ( orderCode , PostFee ) ;
if ( a > 0 )
Count + + ;
}
error = "导入成功" + Count . ToString ( ) + "条;" ;
error + = sb . ToString ( ) ;
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 导入货物
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsHWC ( string FileName , string SortName , int CompanyId )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "货物编号" ) = = false ) { error = error + "导入模板的 货物编号 列不存在" ; }
if ( tb . Columns . Contains ( "报关名称" ) = = false ) { error = error + "导入模板的 报关名称 列不存在" ; }
if ( tb . Columns . Contains ( "体积(立方)" ) = = false ) { error = error + "导入模板的 体积(立方) 列不存在" ; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
//if (tb.Columns.Contains("入库数量") == false) { error = error + "导入模板的 入库数量 列不存在"; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Num = 0 ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
var md = new HW_GoodsExcelModel2 ( ) ;
md . GoodsCode = tb . Rows [ i ] [ "货物编号" ] . ToString ( ) . Trim ( ) ;
if ( md . GoodsCode = = "" )
{
// error += "第" + (i + 2).ToString() + " 行的货物编号没填<br/>";
continue ;
}
md . GoodsName = tb . Rows [ i ] [ "报关名称" ] . ToString ( ) . Trim ( ) ;
if ( md . GoodsName = = "" )
{
md . GoodsName = md . GoodsCode ;
// error += "第" + (i + 2).ToString() + " 行的货物名称没填<br/>";
// continue;
}
md . SortName1 = SortName ;
md . SortId = 0 ;
md . SKU1 = "" ;
md . SKU2 = "" ;
md . SKU3 = "" ;
md . SKU4 = "" ;
md . SKU1 = tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) ;
if ( tb . Columns . Contains ( "SKU2" ) = = true )
md . SKU2 = tb . Rows [ i ] [ "SKU2" ] . ToString ( ) . Trim ( ) ;
if ( tb . Columns . Contains ( "SKU3" ) = = true )
md . SKU3 = tb . Rows [ i ] [ "SKU3" ] . ToString ( ) . Trim ( ) ;
if ( tb . Columns . Contains ( "SKU4" ) = = true )
md . SKU4 = tb . Rows [ i ] [ "SKU4" ] . ToString ( ) . Trim ( ) ;
md . GoodsEngLishName = tb . Rows [ i ] [ "报关英文名" ] . ToString ( ) . Trim ( ) . Replace ( "," , "" ) ;
if ( md . GoodsEngLishName = = "" )
md . GoodsEngLishName = "Goods" ;
if ( md . GoodsEngLishName . Length > 20 )
md . GoodsEngLishName = md . GoodsEngLishName . Substring ( 0 , 20 ) ;
//md.Link1 = tb.Rows[i]["购买链接1"].ToString().Trim();
//md.LinkName1 = tb.Rows[i]["购买链接1名称"].ToString().Trim();
//md.Link2 = tb.Rows[i]["购买链接2"].ToString().Trim();
//md.LinkName2 = tb.Rows[i]["购买链接2名称"].ToString().Trim();
//md.Link3 = tb.Rows[i]["购买链接3"].ToString().Trim();
//md.LinkName3 = tb.Rows[i]["购买链接3名称"].ToString().Trim();
//md.Link4 = tb.Rows[i]["购买链接4"].ToString().Trim();
//md.LinkName4 = tb.Rows[i]["购买链接4名称"].ToString().Trim();
try
{
if ( tb . Rows [ i ] [ "进价" ] . ToString ( ) . Trim ( ) ! = "" )
md . Price = Convert . ToDecimal ( tb . Rows [ i ] [ "进价" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的单价必须是数字<br/>";
md . Price = 0 ;
}
if ( tb . Rows [ i ] [ "重量(克)" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Weight = 0 ;
md . Weight2 = 0 ;
}
else
{
try
{
md . Weight = Convert . ToDecimal ( tb . Rows [ i ] [ "重量(克)" ] . ToString ( ) . Trim ( ) ) ;
md . Weight2 = md . Weight * Convert . ToDecimal ( 0.035274 ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "长(英寸)" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Long = 0 ;
}
else
{
try
{
md . Long = Convert . ToDecimal ( tb . Rows [ i ] [ "长(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "宽(英寸)" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Width = 0 ;
}
else
{
try
{
md . Width = Convert . ToDecimal ( tb . Rows [ i ] [ "宽(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "高(英寸)" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Height = 0 ;
}
else
{
try
{
md . Height = Convert . ToDecimal ( tb . Rows [ i ] [ "高(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "体积(立方)" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Solid = 0 ;
if ( md . Long > 0 & & md . Height > 0 & & md . Width > 0 )
md . Solid = md . Long * md . Height * md . Weight * Convert . ToDecimal ( 0.0283168 ) ;
}
else
{
try
{
md . Solid = Convert . ToDecimal ( tb . Rows [ i ] [ "体积(立方)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
md . CompanyId = CompanyId ;
md . InUserId = UserId ;
md . GoodsEg = md . GoodsCode ;
md . GoodsNo = 0 ;
md . GoodsNum = 0 ;
md . TypeDesc = tb . Rows [ i ] [ "描述" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "图片" ] . ToString ( ) . Trim ( ) ! = "" )
md . ImgUrl = "../attached/hwc" + CompanyId . ToString ( ) + "/" + tb . Rows [ i ] [ "图片" ] . ToString ( ) . Trim ( ) ;
int a = DataNew . ExcelSaveGoodsHWC ( md ) ;
if ( a = = 2 )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的SKU已经存在<br/>" ;
continue ;
}
else
Num + + ;
}
if ( error = = "" )
{
error = "数据导入成功;" + Num . ToString ( ) + "条" ;
}
else
{
error + = "其它数据导入成功;" ;
}
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public List < HW_GoodsDetailNew > GetGoodsDeatilListForTM ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
var obj1 = new BaseService ( ) ;
var list = DataNew . GetGoodsDetail ( GoodsId ) ;
//var list1 = obj.GetFirstGoodsInList(GoodsId);
int TypeNo = 0 ;
if ( list ! = null )
{
foreach ( var md in list )
{
if ( md . TypeCode ! = null & & md . TypeCode ! = "" )
{
int TypeNo1 = Convert . ToInt32 ( md . TypeCode ) ;
if ( TypeNo1 > TypeNo )
TypeNo = TypeNo1 ;
}
if ( md . GoodsImageIds ! = null & & md . GoodsImageIds ! = "" )
md . ImgList = obj1 . GetResourceList ( md . GoodsImageIds ) ;
}
}
//if (list != null && list1 != null)
//{
// foreach (var md in list)
// {
// md.GoodsPostion = list1.FindAll(n => n.DetailId == md.DetailId);
// if (md.GoodsPostion != null && md.GoodsPostion.Count > 0)
// md.PostPrice = md.GoodsPostion[0].PostPrice;
// else
// md.PostPrice = 0;
// }
//}
if ( list ! = null & & list . Count > 0 )
{
list [ 0 ] . TypeNo = TypeNo ;
}
return list ;
}
# endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForTM ( HW_Goods model , List < HW_GoodsDetailNew > DetailList , List < HW_BuyLink > LinkList , List < HW_Shop > shoplist )
{
try
{
PagesNew . Login ( this . Session ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
int InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var obj = new HuoWuData ( ) ;
if ( model . GoodsId = = null )
model . GoodsId = 0 ;
if ( model . XPId > 0 & & model . GoodsId = = 0 )
{
if ( obj . IsGoodsXP ( model . XPId . Value ) > 0 )
return "-1" ; //"这个选品货物已经加过编号,不能重复添加";
}
if ( model . GoodsId = = 0 & & obj . IsGoodsCode ( CompanyId , model . GoodsId . Value , model . GoodsCode ) > 0 )
{
return "-2" ; //"这个货物编号已经存在";
}
if ( model . SupplierId . Trim ( ) ! = "" )
{
int SId = BaseService . GetSupplierIdForTM ( CompanyId , model . SupplierId . Trim ( ) , model . IsGYS . Value , InUserId ) ;
if ( SId = = 0 )
return "-3" ; //"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model . Supplier = SId ;
}
// model.Solid = 1;
model . CompanyId = CompanyId ;
model . InDate = DateTime . Now ;
if ( model . GoodsId > 0 )
model . UpdateDate = DateTime . Now ;
if ( model . GoodsId = = 0 )
model . SortName = obj . GetGoodsSortName ( model . SortId . Value ) ;
string goodEg = model . GoodsCode . Substring ( 0 , 3 ) ;
string goodNo = model . GoodsCode . Substring ( 3 , model . GoodsCode . Length - 3 ) ;
try
{
model . GoodsEg = goodEg ;
model . GoodsNo = Convert . ToInt32 ( goodNo ) ;
}
catch
{
}
if ( model . UpdateName ! = null )
{
if ( ! model . UpdateName . Contains ( Session [ "Name" ] . ToString ( ) ) )
model . UpdateName = model . UpdateName + ";" + Session [ "Name" ] . ToString ( ) ;
}
else
{
model . UpdateName = Session [ "Name" ] . ToString ( ) ;
}
int GoodsId = DataNew . SaveGoodsInfoForTM ( model ) ;
if ( DetailList ! = null )
{
foreach ( var md in DetailList )
{
md . GoodsId = GoodsId ;
if ( md . GoodsInNum = = null )
md . GoodsInNum = 0 ;
if ( md . GoodsLockNum = = null )
md . GoodsLockNum = 0 ;
if ( md . GoodsOutNum = = null )
md . GoodsOutNum = 0 ;
if ( md . GoodsPlanNum = = null )
md . GoodsPlanNum = 0 ;
md . PostPrice = model . PostPrice ;
if ( md . Weight = = null )
md . Weight = model . Weight ;
md . Solid = 1 ;
int DetailId = DataNew . SaveGoodsDetail ( md ) ;
if ( md . GoodsPostion ! = null )
{
for ( int i = 0 ; i < md . GoodsPostion . Count ; i + + )
{
md . GoodsPostion [ i ] . DetailId = DetailId ;
md . GoodsPostion [ i ] . ChaseId = 0 ;
md . GoodsPostion [ i ] . InDate = DateTime . Now ;
md . GoodsPostion [ i ] . InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
md . GoodsPostion [ i ] . Price = md . Price ;
md . GoodsPostion [ i ] . PostPrice = model . PostPrice ;
md . GoodsPostion [ i ] . GoodsLockNum = 0 ;
obj . SaveGoodsInListNew ( md . GoodsPostion [ i ] ) ;
}
}
}
}
Pages . SaveLog ( InUserId , "货物信息" , "修改货物信息" , GoodsId ) ;
if ( LinkList ! = null )
{
foreach ( var md in LinkList )
{
md . GoodsId = GoodsId ;
obj . SaveBuyLink ( md ) ;
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert . ToString ( Session [ "Name" ] ) ;
string Ids = "" ;
if ( shoplist ! = null )
{
foreach ( var md1 in shoplist )
{
md1 . GoodsId = GoodsId ;
md1 . InName = InName ;
int Id = obj . SaveShopForTM ( md1 ) ;
Ids + = Id . ToString ( ) + "," ;
}
}
obj . DeleteShopForTM ( Ids . Trim ( ',' ) , GoodsId ) ;
return GoodsId . ToString ( ) ;
}
catch ( Exception ex )
{
return ex . Message ;
}
}
# endregion
#region 影藏
[WebMethod(EnableSession = true)]
public void Update_GoodsShow ( int Id , int IsYC )
{
DataNew . Update_GoodsShow ( Id , IsYC ) ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public void UpdateGoodsDays ( )
{
DataNew . UpdateGoodsDays ( ) ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsUserNew > > GetGoodsUser ( int UserId , string GoodsCode , int? Days , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
if ( UserId > 0 )
Param . Add ( "a.UserId" , "=" , UserId , DbType . Int32 ) ;
if ( GoodsCode ! = "" )
Param . Add ( "d.GoodsCode" , "like" , GoodsCode , DbType . String ) ;
JsonModel < List < HW_GoodsUserNew > > resultModel = new JsonModel < List < HW_GoodsUserNew > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListGoodsUser ( Days , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
return resultModel ;
}
# endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForHWC ( int CompanyId , HW_Goods model , List < HW_GoodsDetail > DetailList , List < HW_BuyLink > LinkList , List < HW_Shop > shoplist )
{
try
{
PagesNew . Login ( this . Session ) ;
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var obj = new HuoWuData ( ) ;
if ( model . GoodsId = = null )
model . GoodsId = 0 ;
//if (model.XPId > 0 && model.GoodsId == 0)
//{
// if (obj.IsGoodsXP(model.XPId.Value) > 0)
// return "-1";//"这个选品货物已经加过编号,不能重复添加";
//}
if ( model . GoodsId = = 0 & & obj . IsGoodsCode ( CompanyId , model . GoodsId . Value , model . GoodsCode ) > 0 )
{
return "-2" ; //"这个货物编号已经存在";
}
if ( model . SupplierId . Trim ( ) ! = "" )
{
int SId = BaseService . GetSupplierIdForTM ( CompanyId , model . SupplierId . Trim ( ) , model . IsGYS . Value , InUserId ) ;
if ( SId = = 0 )
return "-3" ; //"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model . Supplier = SId ;
}
// model.Solid = 1;
model . CompanyId = CompanyId ;
model . InDate = DateTime . Now ;
if ( model . GoodsId > 0 )
model . UpdateDate = DateTime . Now ;
// if (model.GoodsId == 0)
// model.SortName = obj.GetGoodsSortName(model.SortId.Value);
string goodEg = model . GoodsCode . Substring ( 0 , 3 ) ;
string goodNo = model . GoodsCode . Substring ( 3 , model . GoodsCode . Length - 3 ) ;
try
{
model . GoodsEg = goodEg ;
model . GoodsNo = Convert . ToInt32 ( goodNo ) ;
}
catch
{
}
if ( model . UpdateName ! = null )
{
if ( ! model . UpdateName . Contains ( Session [ "Name" ] . ToString ( ) ) )
model . UpdateName = model . UpdateName + ";" + Session [ "Name" ] . ToString ( ) ;
}
else
{
model . UpdateName = Session [ "Name" ] . ToString ( ) ;
}
int GoodsId = obj . SaveGoodsInfoForHWC ( model ) ;
if ( DetailList ! = null )
{
foreach ( var md in DetailList )
{
md . GoodsId = GoodsId ;
if ( md . GoodsInNum = = null )
md . GoodsInNum = 0 ;
if ( md . GoodsLockNum = = null )
md . GoodsLockNum = 0 ;
if ( md . GoodsOutNum = = null )
md . GoodsOutNum = 0 ;
if ( md . GoodsPlanNum = = null )
md . GoodsPlanNum = 0 ;
md . PostPrice = model . PostPrice ;
if ( md . Weight = = null )
md . Weight = model . Weight ;
md . Solid = 1 ;
int DetailId = obj . SaveGoodsDetail ( md ) ;
if ( md . GoodsPostion ! = null )
{
for ( int i = 0 ; i < md . GoodsPostion . Count ; i + + )
{
md . GoodsPostion [ i ] . DetailId = DetailId ;
md . GoodsPostion [ i ] . ChaseId = 0 ;
md . GoodsPostion [ i ] . InDate = DateTime . Now ;
md . GoodsPostion [ i ] . InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
md . GoodsPostion [ i ] . Price = md . Price ;
md . GoodsPostion [ i ] . PostPrice = model . PostPrice ;
md . GoodsPostion [ i ] . GoodsLockNum = 0 ;
obj . SaveGoodsInListNew ( md . GoodsPostion [ i ] ) ;
}
}
}
}
PagesNew . SaveLog ( InUserId , "货物信息" , "修改货物信息" , GoodsId ) ;
if ( LinkList ! = null )
{
foreach ( var md in LinkList )
{
md . GoodsId = GoodsId ;
obj . SaveBuyLink ( md ) ;
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert . ToString ( Session [ "Name" ] ) ;
string Ids = "" ;
if ( shoplist ! = null )
{
foreach ( var md1 in shoplist )
{
md1 . GoodsId = GoodsId ;
md1 . InName = InName ;
int Id = obj . SaveShopForTM ( md1 ) ;
Ids + = Id . ToString ( ) + "," ;
}
}
obj . DeleteShopForTM ( Ids . Trim ( ',' ) , GoodsId ) ;
return GoodsId . ToString ( ) ;
}
catch ( Exception ex )
{
return ex . Message ;
}
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public List < HW_GoodsUserNew > GetGoodsUser2 ( int Type , int UserId , DateTime ? SDate , DateTime ? EDate )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
var list = DataNew . GetListGoodsUser2 ( Type , UserId , SDate , EDate ) ;
return list ;
}
# endregion
#region 导入货物入库
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsRKHWC ( string FileName , int CompanyId )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "SKU" ) = = false ) { error = error + "导入模板的 SKU 列不存在" ; }
if ( tb . Columns . Contains ( "入库数量" ) = = false ) { error = error + "导入模板的 入库数量 列不存在" ; }
if ( tb . Columns . Contains ( "库位" ) = = false ) { error = error + "导入模板的 库位 列不存在" ; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
if ( tb . Columns . Contains ( "入库日期" ) = = false ) { error = error + "导入模板的 入库日期 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Num = 0 ;
HW_GoodsInRecord model = new HW_GoodsInRecord ( ) ;
model . CompanyId = CompanyId ;
model . InDate = DateTime . Now ;
model . InUserId = UserId ;
model . InNum = 0 ;
model . IsDelete = 0 ;
model . ChaseId = 0 ;
var InId = obj . SaveGoodsInRecordForTM ( model ) ;
DateTime ? st = null ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
var md = new HW_GoodsInDetailHWC ( ) ;
md . SKU = tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) ;
if ( md . SKU = = "" )
{
// error += "第" + (i + 2).ToString() + " 行的SKU没填<br/>";
continue ;
}
md . PostionCode = tb . Rows [ i ] [ "库位" ] . ToString ( ) . Trim ( ) ;
DateTime InDate = DateTime . Now ;
try
{
if ( tb . Rows [ i ] [ "入库日期" ] . ToString ( ) . Trim ( ) ! = "" )
md . InDate = Convert . ToDateTime ( tb . Rows [ i ] [ "入库日期" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的入库日期格式不正确<br/>" ;
md . InDate = InDate ;
}
try
{
if ( tb . Rows [ i ] [ "入库数量" ] . ToString ( ) . Trim ( ) ! = "" )
md . KCNum = Convert . ToInt32 ( tb . Rows [ i ] [ "入库数量" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的入库数量必须是数字<br/>" ;
md . KCNum = 0 ;
}
if ( tb . Rows [ i ] [ "单价" ] . ToString ( ) . Trim ( ) = = "" )
{
md . Price = 0 ;
}
else
{
try
{
md . Price = Convert . ToDecimal ( tb . Rows [ i ] [ "单价" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
md . Price = 0 ;
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
HW_GoodsInRK rmd = new HW_GoodsInRK ( ) ;
rmd . InId = InId ;
int rkid = obj . SaveInRecordDetail ( rmd ) ;
md . OrderGoodsId = 0 ;
md . ChaseId = 0 ;
md . CKDetailId = 0 ;
md . RKDetailId = rkid ;
md . CompanyId = CompanyId ;
md . InUserId = UserId ;
md . DetailId = 0 ;
md . PostionId = 0 ;
md . OldNum = md . KCNum ;
md . PostPrice = 0 ;
md . InDate = md . InDate ;
md . HWCFee = 0 ;
int a = obj . Save_GoodsInDetailHWC ( md ) ;
if ( a = = - 1 )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的sku不存在<br/>" ;
continue ;
}
else
if ( a = = - 2 )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的入库库位不存在<br/>" ;
continue ;
}
else
{
Num + + ;
if ( st ! = null & & md . InDate ! = st )
{
DataNew . SumInDoFee ( st . Value , CompanyId ) ;
}
st = md . InDate ;
}
}
if ( st ! = null )
{
DataNew . SumInDoFee ( st . Value , CompanyId ) ;
}
if ( error = = "" )
{
error = "数据导入成功;" + Num . ToString ( ) + "条" ;
}
else
{
error + = "其它数据导入成功;" ;
}
DataNew . SumKC ( CompanyId ) ; //库存合计
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNum ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
DataNew . UpdateGoodsNumHWC ( GoodsId ) ;
}
# endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC ( int CompanyId , int IsFG , string FileName )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "Express or Ground Tracking ID" ) = = false ) { error = error + "导入模板的 Express or Ground Tracking ID 列不存在" ; }
if ( tb . Columns . Contains ( "Net Charge Amount" ) = = false ) { error = error + "导入模板的 Net Charge Amount 列不存在" ; }
if ( tb . Columns . Contains ( "Ground Tracking ID Prefix" ) = = false ) { error = error + "导入模板的 Ground Tracking ID Prefix 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Count = 0 ;
int Count2 = 0 ;
string trinfo = "" ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
string TrackCode = tb . Rows [ i ] [ "Ground Tracking ID Prefix" ] . ToString ( ) . Trim ( ) + tb . Rows [ i ] [ "Express or Ground Tracking ID" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "Net Charge Amount" ] . ToString ( ) . Trim ( ) = = "" | | TrackCode = = "" )
continue ;
decimal PostFee = 0 ;
try
{
PostFee = Convert . ToDecimal ( tb . Rows [ i ] [ "Net Charge Amount" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
continue ;
}
if ( IsFG = = 1 )
DataNew . ImportTrackCodeClear ( TrackCode ) ;
int a = DataNew . ImportTrackCodeNew ( TrackCode , PostFee , 0 ) ;
if ( a > 0 )
{
Count + + ;
}
else
{
Count2 + + ;
trinfo + = tb . Rows [ i ] [ "Express or Ground Tracking ID" ] . ToString ( ) . Trim ( ) + "\r\n" ;
}
}
DataNew . SumPostFee ( CompanyId ) ;
error = "导入成功" + Count . ToString ( ) + "条" ;
if ( Count2 > 0 )
error + = Count2 + "条数据运单号在系统找不对到\r\n" + trinfo ;
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC2 ( int CompanyId , int IsFG , string FileName )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "order id" ) = = false ) { error = error + "导入模板的 order id 列不存在" ; }
if ( tb . Columns . Contains ( "fba fees" ) = = false ) { error = error + "导入模板的 fba fees 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Count = 0 ;
int Count2 = 0 ;
string trinfo = "" ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
string ordercode = tb . Rows [ i ] [ "order id" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "fba fees" ] . ToString ( ) . Trim ( ) = = "" | | ordercode = = "" )
continue ;
decimal PostFee = 0 ;
try
{
PostFee = Convert . ToDecimal ( tb . Rows [ i ] [ "fba fees" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
continue ;
}
if ( PostFee < 0 )
PostFee = PostFee * - 1 ;
if ( IsFG = = 1 )
DataNew . ImportTrackCode2Clear ( ordercode ) ;
string TrackCode = "FBA" + DateTime . Now . ToString ( "yyyyMMddHHmm" ) + i . ToString ( ) ;
int a = DataNew . ImportTrackCode2 ( ordercode , TrackCode , PostFee ) ;
if ( a > 0 )
{
Count + + ;
}
else
{
Count2 + + ;
trinfo + = ordercode + "\r\n" ;
}
}
error = "导入成功" + Count . ToString ( ) + "条" ;
DataNew . SumPostFee ( CompanyId ) ;
if ( Count2 > 0 )
error + = Count2 + "条数据订单在系统找不对到\r\n" + trinfo ;
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC3 ( int CompanyId , int IsFG , string FileName , int PostId )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert . ToString ( Session [ "Name" ] ) ;
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "订单号" ) = = false ) { error = error + "导入模板的 订单号 列不存在" ; }
if ( tb . Columns . Contains ( "跟踪码" ) = = false ) { error = error + "导入模板的 跟踪码 列不存在" ; }
if ( tb . Columns . Contains ( "SKU" ) = = false ) { error = error + "导入模板的 SKU 列不存在" ; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Count = 0 ;
int Count2 = 0 ;
string trinfo = "" ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
string ordercode = tb . Rows [ i ] [ "订单号" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "跟踪码" ] . ToString ( ) . Trim ( ) = = "" | | ordercode = = "" )
continue ;
string trackcode = tb . Rows [ i ] [ "跟踪码" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) = = "" )
continue ;
string sku = tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) ;
if ( IsFG = = 1 )
obj . ImportTrackCode3Clear ( ordercode ) ;
int a = obj . ImportTrackCode3 ( PostId , ordercode , trackcode , Name , sku ) ;
if ( a > 0 )
{
Count + + ;
}
else
{
Count2 + + ;
trinfo + = ordercode + "\r\n" ;
}
}
error = "导入成功" + Count . ToString ( ) + "条" ;
if ( Count2 > 0 )
error + = Count2 + "条数据订单在系统找不对到\r\n" + trinfo ;
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public HW_Goods GetGoodsInfoModelForHWC ( int GoodsId )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
var Model = DataNew . GetGoodsModel ( GoodsId ) ;
var obj1 = new BaseService ( ) ;
if ( Model . GoodsImageIds ! = null & & Model . GoodsImageIds ! = "" )
Model . ImgList = obj1 . GetResourceList ( Model . GoodsImageIds ) ;
return Model ;
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_GoodsSure ( int GoodsId , int IsSure )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
DataNew . Update_GoodsSure ( GoodsId , IsSure ) ;
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_GoodsSureList ( List < HW_GoodsDetail > list , int IsSure )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
foreach ( var md in list )
{
DataNew . Update_GoodsSure ( md . GoodsId . Value , IsSure ) ;
}
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsDetail > > GetGoodsDetailList2 ( int CompanyId , int TJ1 , int IsJQ , int StoreId , int AQNum , string Name , string Supplier , int TJ2 , int SNum , int ENum , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection ( ) ;
Param . Add ( "b.CompanyId" , "=" , CompanyId , DbType . Int32 ) ;
if ( AQNum = = 1 )
Param . Add ( "a.GoodsNum-a.SafeNum" , "<" , 0 , DbType . Int32 ) ;
Param . Add ( "b.State" , "=" , 1 , DbType . Int32 ) ;
if ( Supplier ! = "" )
Param . Add ( "b.SupplierId" , "like" , Supplier , DbType . String ) ;
Name = Name . Trim ( ) ;
if ( Name ! = "" & & IsJQ = = 0 )
{
if ( TJ1 = = 1 )
Param . Add ( "b.GoodsName" , "like" , Name , DbType . String ) ;
if ( TJ1 = = 2 )
{
Param . Add ( "b.GoodsCode" , "like" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
Param . Add ( "(a.SKU1" , "like" , Name , DbType . String ) ;
Param . Add ( "a.SKU2" , "like" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU3" , "like" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU4" , "like" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU5" , "like" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU6" , "like" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU7" , "like" , Name , "or" , ")" , DbType . String ) ;
}
}
else
if ( Name ! = "" & & IsJQ = = 1 )
{
if ( TJ1 = = 1 )
Param . Add ( "b.GoodsName" , "=" , Name , DbType . String ) ;
if ( TJ1 = = 2 )
{
Param . Add ( "b.GoodsCode" , "=" , Name , DbType . String ) ;
}
if ( TJ1 = = 4 )
{
Param . Add ( "(a.SKU1" , "=" , Name , DbType . String ) ;
Param . Add ( "a.SKU2" , "=" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU3" , "=" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU4" , "=" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU5" , "=" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU6" , "=" , Name , "or" , DbType . String ) ;
Param . Add ( "a.SKU7" , "=" , Name , "or" , ")" , DbType . String ) ;
}
}
if ( TJ2 = = 1 )
{
if ( SNum > 0 )
Param . Add ( "a.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "a.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
}
else if ( TJ2 = = 2 )
{
if ( SNum > 0 )
Param . Add ( "a.GoodsHJNum" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "a.GoodsHJNum" , "<=" , ENum , DbType . Int32 ) ;
}
else if ( TJ2 = = 3 )
{
if ( SNum > 0 )
Param . Add ( "a.GoodsHJNum2" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "a.GoodsHJNum2" , "<=" , ENum , DbType . Int32 ) ;
}
else if ( TJ2 = = 4 )
{
if ( SNum > 0 )
Param . Add ( "a.GoodsHJNum3" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "a.GoodsHJNum3" , "<=" , ENum , DbType . Int32 ) ;
}
else if ( TJ2 = = 5 )
{
if ( SNum > 0 )
Param . Add ( "a.GoodsHJNum4" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "a.GoodsHJNum4" , "<=" , ENum , DbType . Int32 ) ;
}
JsonModel < List < HW_GoodsDetail > > resultModel = new JsonModel < List < HW_GoodsDetail > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListHW_GoodsDetail ( StoreId , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
if ( resultModel . DataSource ! = null )
{
foreach ( var md in resultModel . DataSource )
{
if ( md . Solid ! = null )
md . TotalSolid = md . Solid * md . GoodsNum ;
else
md . TotalSolid = 0 ;
}
}
return resultModel ;
}
# endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode ( int Days )
{
PagesNew . Login ( this . Session ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
BaseService obj = new BaseService ( ) ;
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
// DateTime sdate = DateTime.Today.AddDays(-1);
//DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 08:00");
//DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 08:00");
DateTime sdate2 = Convert . ToDateTime ( DateTime . Today . AddDays ( - 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
DateTime edate2 = Convert . ToDateTime ( DateTime . Today . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
if ( Days = = 0 )
{
sdate2 = Convert . ToDateTime ( DateTime . Today . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
edate2 = Convert . ToDateTime ( DateTime . Today . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
}
var list = DataNew . GetDefaultDataForCode ( CompanyId , sdate2 , edate2 ) ;
string shtml = "" ;
if ( list ! = null )
{
foreach ( var md in list )
{
if ( md . Num2 ! = null & & md . Num2 ! = "" )
shtml + = "<img width='50px' height='50px' src=" + md . Num2 + " />" + md . Num1 + "销量:【" + md . Num3 + "】 " ;
else
shtml + = md . Num1 + " 销量:【" + md . Num3 + "】 " ;
}
}
return shtml ;
}
# endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode2 ( int Days )
{
PagesNew . Login ( this . Session ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
BaseService obj = new BaseService ( ) ;
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
DateTime sdate = DateTime . Today . AddDays ( - 1 ) ;
DateTime sdate2 = Convert . ToDateTime ( DateTime . Today . AddDays ( - 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
DateTime edate2 = Convert . ToDateTime ( DateTime . Today . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
if ( Days = = 0 )
{
sdate2 = Convert . ToDateTime ( DateTime . Today . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
edate2 = Convert . ToDateTime ( DateTime . Today . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00" ) ;
}
var list2 = DataNew . GetDefaultDataForCode2 ( CompanyId , sdate2 , edate2 ) ;
string shtml = "" ;
if ( list2 ! = null )
{
foreach ( var md in list2 )
{
if ( md . Num2 ! = null & & md . Num2 ! = "" )
shtml + = "<img width='50px' height='50px' src=" + md . Num2 + " />" + md . Num1 + "销售额:【" + md . Num4 . Value . ToString ( "0.00" ) + "$】 " ;
else
shtml + = md . Num1 + " 销售额:【" + md . Num4 . Value . ToString ( "0.00" ) + "$】 " ;
}
}
return shtml ;
}
# endregion
#region 导入货物图片
[WebMethod(EnableSession = true)]
public string ExcelPhoto ( int CompanyId , string FileName )
{
try
{
string unRarPath = AppDomain . CurrentDomain . BaseDirectory + "attached/hwc" + CompanyId . ToString ( ) ;
string unRarPath2 = AppDomain . CurrentDomain . BaseDirectory + "attached/rar" + CompanyId . ToString ( ) + DateTime . Now . ToString ( "yyyyMMddHHmmss" ) ;
if ( Directory . Exists ( unRarPath ) = = false ) Directory . CreateDirectory ( unRarPath ) ;
CustomIO . RarDecompress ( unRarPath2 , AppDomain . CurrentDomain . BaseDirectory + "ServerCookies" , System . IO . Path . GetFileName ( FileName ) ) ;
List < string > ListModel = new List < string > ( ) ;
CustomIO . GetListFile ( unRarPath2 , ListModel ) ;
foreach ( var PhotoUrl in ListModel )
{
string name = Path . GetFileName ( PhotoUrl ) ;
File . Copy ( PhotoUrl , unRarPath + "/" + name , true ) ;
}
Directory . Delete ( unRarPath2 , true ) ;
string error = "数据导入成功" ;
return error ;
}
catch ( Exception e )
{
return "导入失败;" + e . Message . ToString ( ) ;
}
}
# endregion
#region 查询入库记录
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsInRecord > > GetListHW_GoodsInListForTM ( int TJ , string RKType , string GoodsName , DateTime ? SDate , DateTime ? EDate , int IsDetail , int PageIndex , int PageSize , string Sort )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
Param . Add ( "a.CompanyId" , "=" , CompanyId , DbType . Int32 ) ;
Param . Add ( "a.IsDelete" , "=" , 0 , DbType . Int32 ) ;
// if (RKType == 1)
// Param.Add("a.ChaseId", ">", 0, DbType.String);
// else if (RKType == 2)
// Param.Add("a.ChaseId", "=", 0, DbType.String);
// if(RKType!="")
// Param.Add("a.InReason", "in", "'采购管理','库存调整'", DbType.String);
if ( SDate ! = null )
Param . Add ( "a.InDate" , ">=" , SDate , DbType . DateTime ) ;
if ( EDate ! = null )
Param . Add ( "a.InDate" , "<" , EDate . Value . AddDays ( 1 ) , DbType . DateTime ) ;
if ( TJ = = 6 )
{
Param . Add ( "a.InCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
else
if ( TJ = = 7 )
{
Param . Add ( "b.BuyCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
JsonModel < List < HW_GoodsInRecord > > resultModel = new JsonModel < List < HW_GoodsInRecord > > ( ) ;
int RowCount = 0 ;
if ( TJ > 4 )
GoodsName = "" ;
resultModel . DataSource = DataNew . GetListHW_GoodsInRecordForTM2 ( TJ , RKType . TrimEnd ( ',' ) , GoodsName . Trim ( ) , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
if ( IsDetail = = 1 & & resultModel . DataSource ! = null )
{
foreach ( var md in resultModel . DataSource )
{
var list = obj . GetRKDetailListForTM ( md . Id . Value ) ;
md . GoodsInRecordList = list ;
}
}
return resultModel ;
}
# endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsOutRecord > > GetListHW_GoodsOutListForTM ( int TJ , string GoodsName , DateTime ? SDate , DateTime ? EDate , int IsDetail , string CKType , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
Param . Add ( "a.CompanyId" , "=" , CompanyId , DbType . Int32 ) ;
Param . Add ( "a.IsDelete" , "=" , 0 , DbType . Int32 ) ;
//if (CKType == 1)
// Param.Add("a.OrderId", ">", 0, DbType.String);
//else if (CKType == 2)
// Param.Add("a.OrderId", "=", 0, DbType.String);
if ( SDate ! = null )
Param . Add ( "a.InDate" , ">=" , SDate , DbType . DateTime ) ;
if ( EDate ! = null )
Param . Add ( "a.InDate" , "<" , EDate . Value . AddDays ( 1 ) , DbType . DateTime ) ;
if ( TJ = = 6 )
{
Param . Add ( "a.OutCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
else
if ( TJ = = 7 )
{
Param . Add ( "b.PlatOrderCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
if ( TJ > 4 )
GoodsName = "" ;
JsonModel < List < HW_GoodsOutRecord > > resultModel = new JsonModel < List < HW_GoodsOutRecord > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListHW_GoodsOutListForTM ( TJ , CKType . TrimEnd ( ',' ) , GoodsName , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
if ( IsDetail = = 1 & & resultModel . DataSource ! = null )
{
foreach ( var md in resultModel . DataSource )
{
var list = obj . GetOutCKDetailListForTM ( md . OutId . Value ) ;
md . GoodsOutCKList = list ;
}
}
return resultModel ;
}
# endregion
#region 导出出库记录
[WebMethod(EnableSession = true)]
public APIReturnModel ImportListHW_GoodsOutListForTM ( int TJ , string GoodsName , DateTime ? SDate , DateTime ? EDate , string CKType )
{
Pages . Login ( this . Session ) ;
var rmodel = new APIReturnModel ( ) ;
try
{
var datas = DataNew . GetImportHW_GoodsOutList ( TJ , CKType , GoodsName , SDate , EDate ) ;
DataTable tb = new DataTable ( ) ;
tb . Columns . Add ( "订单号" , Type . GetType ( "System.String" ) ) ;
tb . Columns . Add ( "SKU" , Type . GetType ( "System.String" ) ) ;
tb . Columns . Add ( "出库时间" , Type . GetType ( "System.String" ) ) ;
tb . Columns . Add ( "出库原因" , Type . GetType ( "System.String" ) ) ;
tb . Columns . Add ( "出库库位" , Type . GetType ( "System.String" ) ) ;
tb . Columns . Add ( "出库数量" , Type . GetType ( "System.String" ) ) ;
if ( datas ! = null )
{
foreach ( var item in datas )
{
DataRow row = tb . NewRow ( ) ;
row [ "订单号" ] = item . OrderCode ;
row [ "SKU" ] = item . SKU ;
row [ "出库时间" ] = item . InDate . HasValue ? item . InDate . Value . ToString ( "yyyy-MM-dd hh:mm:ss" ) : "" ;
row [ "出库原因" ] = item . OutReason ;
row [ "出库库位" ] = item . PostionCode ;
row [ "出库数量" ] = item . OutNum . ToString ( ) ;
tb . Rows . Add ( row ) ;
}
}
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "订单号" , "订单号" , DbType . String , "" ) ;
listColumns . Add ( "SKU" , "SKU" , DbType . String , "" ) ;
listColumns . Add ( "出库时间" , "出库时间" , DbType . String , "" ) ;
listColumns . Add ( "出库原因" , "出库原因" , DbType . String , "" ) ;
listColumns . Add ( "出库库位" , "出库库位" , DbType . String , "" ) ;
listColumns . Add ( "出库数量" , "出库数量" , DbType . String , "" ) ;
MicrosoftExcel obj2 = new MicrosoftExcel ( ) ;
var filePath = obj2 . Export ( tb , listColumns ) ;
rmodel . Code = 1 ;
rmodel . Message = filePath ;
}
catch ( Exception ex )
{
rmodel . Code = 0 ;
rmodel . Message = ex . Message ;
}
return rmodel ;
}
# endregion
#region 修改数量
[WebMethod(EnableSession = true)]
public void UpdateGoodsOutNum ( )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
DataNew . UpdateGoodsOutNum ( ) ;
}
# endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNumNew ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
DataNew . UpdateGoodsNumNew ( GoodsId ) ;
}
# endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNumNew2 ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
DataNew . UpdateGoodsNumNew2 ( GoodsId ) ;
}
# endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee ( int PostId , string RevAddr , string RevPhone , string RevCity , string RevProvinceCode , string RevPostCode , string Width , string Height , string Long , string Weight , int Num , string PostType )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
JC_ExpressService service = new JC_ExpressService ( ) ;
JC_ExpressPost expressModel = service . GetExpressModel ( 1 , PostId ) ;
TradeManageNew . FedexRateNew2 rate = new TradeManageNew . FedexRateNew2 ( ) ;
TradeManageNew . FedexRateNew2 . Key = expressModel . UserCode ;
TradeManageNew . FedexRateNew2 . Password = expressModel . CheckCode ;
TradeManageNew . FedexRateNew2 . AccountNumber = expressModel . client_id ;
TradeManageNew . FedexRateNew2 . MeterNumber = expressModel . client_secret ;
TradeManageNew . FedexRateNew2 . PayAccountNumber = expressModel . refresh_token ;
TradeManageNew . FedexRateNew2 . HubId = expressModel . Code ;
TradeManageNew . FedexFeeMdNew md = new TradeManageNew . FedexFeeMdNew ( ) ;
TradeManageNew . FedexRateNew2 . Addr2 = 1 ;
md . RevName = "jack" ;
md . RevPhone = RevPhone ;
md . RevAddr = RevAddr ;
md . RevCity = RevCity ;
md . RevProv = RevProvinceCode ;
md . RevPostCode = RevPostCode ;
md . RevCountry = "US" ;
md . OrderId = 0 ;
md . SendAddr = "2611 E LINDSAY PRIVADO" ; // address.EnglishAddress;
md . SendCountry = "US" ; // address.countycode;
md . SendCity = "ONTARIO" ; // address.city;
md . SendProv = "CA" ; // address.provincecode;
md . SendPostCode = "91761" ; // address.PostCode;
//md.SendAddr = "480 W 83rd St";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "Hialeah";// address.city;
//md.SendProv = "FL";// address.provincecode;
//md.SendPostCode = "33166";// address.PostCode;3 1 JIDE TOYS CORP. JIDE TOYS CORP. 2611 E LINDSAY PRIVADO 2611 E LINDSAY PRIVADO 9012637906 91761 CA ONTARIO US 315000 CA ONTARIO US NULL
if ( Width ! = null & & Width ! = "" )
{
md . Width = ( Math . Ceiling ( Convert . ToDecimal ( Width ) * Num ) . ToString ( ) ) ;
}
if ( Height ! = null & & Height ! = "" )
{
md . Height = Math . Ceiling ( Convert . ToDecimal ( Height ) * Num ) . ToString ( ) ;
}
if ( Long ! = null & & Long ! = "" )
{
md . Lenght = Math . Ceiling ( Convert . ToDecimal ( Long ) * Num ) . ToString ( ) ;
}
md . Weight = Convert . ToDecimal ( Weight ) * 0.0625 M * Num ;
md . PostType = PostType ; // "SMART_POST";
string str = "" ;
string html = rate . GetFee ( md , out str ) ;
if ( str ! = "" )
return str ;
return html ;
}
# endregion
#region 货物运费model
[WebMethod(EnableSession = true)]
public HW_PostFee GetModelPostFee ( int GoodsId )
{
Pages . Login ( this . Session ) ;
var md = DataNew . GetModelPostFee ( GoodsId ) ;
List < JC_Money > list2 = new BaseService ( ) . GetMoneyList2 ( ) ;
if ( md ! = null & & list2 ! = null )
{
var fmd = list2 . Find ( n = > n . PlatId = = 2 & & n . MCode = = "USD" ) ;
if ( fmd ! = null )
md . FeeRate = fmd . MRate ;
}
return md ;
}
# endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee2 ( int GoodsId , string RevAddr , string RevPhone , string RevCity , string RevProvinceCode , string RevPostCode , string Width , string Height , string Long , string Weight , int Num )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
string str = GoodsFedexFee3 ( GoodsId , 237 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "SMART_POST" ) ;
string str2 = "" ;
string str3 = "" ;
string str4 = "" ;
string str5 = "" ;
if ( str ! = "" )
str2 = GoodsFedexFee3 ( GoodsId , 237 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "FEDEX_GROUND" ) ;
if ( str2 ! = "" )
str3 = GoodsFedexFee3 ( GoodsId , 237 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "GROUND_HOME_DELIVERY" ) ;
if ( str3 ! = "" )
str4 = GoodsFedexFee3 ( GoodsId , 228 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "SMART_POST" ) ;
if ( str4 ! = "" )
str5 = GoodsFedexFee3 ( GoodsId , 228 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "FEDEX_GROUND" ) ;
if ( str5 ! = "" )
GoodsFedexFee3 ( GoodsId , 228 , RevAddr , RevPhone , RevCity , RevProvinceCode , RevPostCode , Width , Height , Long , Weight , Num , "GROUND_HOME_DELIVERY" ) ;
return "ok" ;
}
# endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee3 ( int GoodsId , int PostId , string RevAddr , string RevPhone , string RevCity , string RevProvinceCode , string RevPostCode , string Width , string Height , string Long , string Weight , int Num , string PostType )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
JC_ExpressService service = new JC_ExpressService ( ) ;
JC_ExpressPost expressModel = service . GetExpressModel ( 1 , PostId ) ;
TradeManageNew . FedexRateNew2 rate = new TradeManageNew . FedexRateNew2 ( ) ;
TradeManageNew . FedexRateNew2 . Key = expressModel . UserCode ;
TradeManageNew . FedexRateNew2 . Password = expressModel . CheckCode ;
TradeManageNew . FedexRateNew2 . AccountNumber = expressModel . client_id ;
TradeManageNew . FedexRateNew2 . MeterNumber = expressModel . client_secret ;
TradeManageNew . FedexRateNew2 . PayAccountNumber = expressModel . refresh_token ;
TradeManageNew . FedexRateNew2 . HubId = expressModel . Code ;
TradeManageNew . FedexRateNew2 . PostId = PostId ;
TradeManageNew . FedexFeeMdNew md = new TradeManageNew . FedexFeeMdNew ( ) ;
TradeManageNew . FedexRateNew2 . Addr2 = 1 ;
md . OrderGoodsId = GoodsId ;
md . RevName = "jack" ;
md . RevPhone = RevPhone ;
md . RevAddr = RevAddr ;
md . RevCity = RevCity ;
md . RevProv = RevProvinceCode ;
md . RevPostCode = RevPostCode ;
md . RevCountry = "US" ;
md . OrderId = 0 ;
JC_PostAddress address = new BaseService ( ) . GetAddressModel2 ( PostId ) ;
md . SendAddr = address . EnglishAddress ;
md . SendAddr = address . EnglishAddress ;
md . SendCountry = address . countycode ;
md . SendCity = address . city ;
md . SendProv = address . provincecode ;
md . SendPostCode = address . PostCode ;
//md.SendAddr = "2611 E LINDSAY PRIVADO";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "ONTARIO";// address.city;
//md.SendProv = "CA";// address.provincecode;
//md.SendPostCode = "91761";// address.PostCode;
//md.SendAddr = "480 W 83rd St";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "Hialeah";// address.city;
//md.SendProv = "FL";// address.provincecode;
//md.SendPostCode = "33166";// address.PostCode;3 1 JIDE TOYS CORP. JIDE TOYS CORP. 2611 E LINDSAY PRIVADO 2611 E LINDSAY PRIVADO 9012637906 91761 CA ONTARIO US 315000 CA ONTARIO US NULL
if ( Width ! = null & & Width ! = "" )
{
md . Width = ( Math . Ceiling ( Convert . ToDecimal ( Width ) * Num ) . ToString ( ) ) ;
}
if ( Height ! = null & & Height ! = "" )
{
md . Height = Math . Ceiling ( Convert . ToDecimal ( Height ) * Num ) . ToString ( ) ;
}
if ( Long ! = null & & Long ! = "" )
{
md . Lenght = Math . Ceiling ( Convert . ToDecimal ( Long ) * Num ) . ToString ( ) ;
}
md . Weight = Convert . ToDecimal ( Weight ) * 0.0625 M * Num ;
md . PostType = PostType ; // "SMART_POST";
string str = "" ;
string html = rate . GetFee ( md , out str ) ;
if ( str ! = "" )
return str ;
return html ;
}
# endregion
#region 导出库存
[WebMethod(EnableSession = true)]
public string GetList_GoodsLeftExcel ( string PostionCode , string GoodsName , int StoreId )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
if ( PostionCode ! = "" )
Param . Add ( "d.PostionCode" , "=" , PostionCode , DbType . String ) ;
if ( StoreId > 0 )
Param . Add ( "d.StoreId" , "=" , StoreId , DbType . String ) ;
if ( GoodsName . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) , DbType . String ) ;
Param . Add ( "c.GoodsOldCode" , "=" , GoodsName . Trim ( ) , "or" , ")" , DbType . String ) ;
}
if ( GoodsName . Trim ( ) . Contains ( " " ) )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , DbType . String ) ;
Param . Add ( "c.GoodsOldCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , "or" , ")" , DbType . String ) ;
Param . Add ( "b.TypeCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 1 ] . Trim ( ) , DbType . String ) ;
}
string Sort = "c.GoodsCode,b.TypeCode" ;
DataTable tb = DataNew . GetList_GoodsLeftExcel ( Param , Sort ) ;
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "GoodsOldCode" , "编码" , DbType . String , "" ) ;
listColumns . Add ( "GoodsCode" , "新编码" , DbType . String , "" ) ;
listColumns . Add ( "GoodsName" , "名称" , DbType . String , "" ) ;
listColumns . Add ( "TypeCode" , "型号" , DbType . String , "" ) ;
listColumns . Add ( "TypeDesc" , "规格描述" , DbType . String , "" ) ;
listColumns . Add ( "GoodsNum" , "库存数量" , DbType . String , "" ) ;
listColumns . Add ( "LockNum" , "匹配锁定数量" , DbType . String , "" ) ;
listColumns . Add ( "LeftNum" , "剩余数量" , DbType . String , "" ) ;
listColumns . Add ( "PostionCode" , "库位" , DbType . String , "" ) ;
listColumns . Add ( "Solid" , "单个立方" , DbType . String , "" ) ;
listColumns . Add ( "Solid2" , "剩余总立方" , DbType . String , "" ) ;
listColumns . Add ( "pk" , "盘库" , DbType . String , "" ) ;
MicrosoftExcel obj2 = new MicrosoftExcel ( ) ;
return obj2 . Export ( tb , listColumns ) ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_JZLink ( List < HW_JZLink > list )
{
PagesNew . Login ( this . Session ) ;
if ( list = = null )
return 0 ;
foreach ( var md in list )
{
DataNew . Save_JZLink ( md ) ;
}
return 1 ;
}
# endregion
#region 删除
[WebMethod(EnableSession = true)]
public bool Delete_JZLink ( int Id )
{
PagesNew . Login ( this . Session ) ;
DataNew . Delete_JZLink ( Id ) ;
return true ;
}
# endregion
#region 多条件普通查询
[WebMethod(EnableSession = true)]
public List < HW_JZLink > GetListJZLink2 ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var ListModel = DataNew . GetListJZLink ( GoodsId , UserId ) ;
return ListModel ;
}
# endregion
#region 查询库存
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsLeft > > GetList_GoodsLeftForTM ( string PostionCode , string GoodsName , int StoreId , int PageIndex , int PageSize )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if ( PostionCode ! = "" )
Param . Add ( "d.PostionCode" , "=" , PostionCode , DbType . String ) ;
if ( StoreId > 0 )
Param . Add ( "d.StoreId" , "=" , StoreId , DbType . String ) ;
if ( GoodsName . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
Param . Add ( "b.SKU1" , "like" , GoodsName . Trim ( ) , "or" , ")" , DbType . String ) ;
}
JsonModel < List < HW_GoodsLeft > > resultModel = new JsonModel < List < HW_GoodsLeft > > ( ) ;
string Sort = "c.GoodsCode,b.TypeCode" ;
int RowCount = 0 ;
resultModel . DataSource = obj . GetList_GoodsLeftForTM ( Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
return resultModel ;
}
# endregion
#region 货物链接
[WebMethod(EnableSession = true)]
public List < HW_BuyLinkNew > GetGoodsLink ( int GoodsId )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var list = DataNew . GetGoodsBuyLink ( GoodsId , UserId ) ;
return list ;
}
# endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForTMNew ( HW_GoodsNew model , List < HW_GoodsDetailNew > DetailList , List < HW_BuyLinkNew > LinkList , List < HW_Shop > shoplist )
{
try
{
PagesNew . Login ( this . Session ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
int InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var obj = new HuoWuData ( ) ;
if ( model . GoodsId = = null )
model . GoodsId = 0 ;
if ( model . XPId > 0 & & model . GoodsId = = 0 )
{
if ( obj . IsGoodsXP ( model . XPId . Value ) > 0 )
return "-1" ; //"这个选品货物已经加过编号,不能重复添加";
}
if ( model . GoodsId = = 0 & & obj . IsGoodsCode ( CompanyId , model . GoodsId . Value , model . GoodsCode ) > 0 )
{
return "-2" ; //"这个货物编号已经存在";
}
if ( model . SupplierId . Trim ( ) ! = "" )
{
int SId = BaseService . GetSupplierIdForTM ( CompanyId , model . SupplierId . Trim ( ) , model . IsGYS . Value , InUserId ) ;
if ( SId = = 0 )
return "-3" ; //"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model . Supplier = SId ;
}
// model.Solid = 1;
model . CompanyId = CompanyId ;
model . InDate = DateTime . Now ;
if ( model . GoodsId > 0 )
model . UpdateDate = DateTime . Now ;
// if (model.GoodsId == 0)
// model.SortName = obj.GetGoodsSortName(model.SortId.Value);
string goodEg = model . GoodsCode . Substring ( 0 , 3 ) ;
string goodNo = model . GoodsCode . Substring ( 3 , model . GoodsCode . Length - 3 ) ;
try
{
model . GoodsEg = goodEg ;
model . GoodsNo = Convert . ToInt32 ( goodNo ) ;
}
catch
{
}
if ( model . UpdateName ! = null )
{
if ( ! model . UpdateName . Contains ( Session [ "Name" ] . ToString ( ) ) )
model . UpdateName = model . UpdateName + ";" + Session [ "Name" ] . ToString ( ) ;
}
else
{
model . UpdateName = Session [ "Name" ] . ToString ( ) ;
}
int GoodsId = DataNew . SaveGoodsInfoForTMNew ( model ) ;
if ( DetailList ! = null )
{
foreach ( var md in DetailList )
{
md . GoodsId = GoodsId ;
if ( md . GoodsInNum = = null )
md . GoodsInNum = 0 ;
if ( md . GoodsLockNum = = null )
md . GoodsLockNum = 0 ;
if ( md . GoodsOutNum = = null )
md . GoodsOutNum = 0 ;
if ( md . GoodsPlanNum = = null )
md . GoodsPlanNum = 0 ;
md . PostPrice = model . PostPrice ;
if ( md . Weight = = null )
md . Weight = model . Weight ;
md . Solid = 1 ;
int DetailId = DataNew . SaveGoodsDetail ( md ) ;
DataNew . Delete_CFSKU ( DetailId ) ; //删除拆分sku
if ( md . SKU14 ! = null & & md . SKU14 ! = "" ) //拆分sku
{
md . SKU14 = md . SKU14 . Replace ( ", " , "," ) . Trim ( ',' ) ;
string [ ] sks = md . SKU14 . Split ( ',' ) ;
for ( int m = 0 ; m < sks . Length ; m + + )
{
DataNew . Save_CFSKU ( DetailId , sks [ m ] . Trim ( ) , Session [ "Name" ] . ToString ( ) ) ;
}
}
if ( md . GoodsPostion ! = null )
{
for ( int i = 0 ; i < md . GoodsPostion . Count ; i + + )
{
md . GoodsPostion [ i ] . DetailId = DetailId ;
md . GoodsPostion [ i ] . ChaseId = 0 ;
md . GoodsPostion [ i ] . InDate = DateTime . Now ;
md . GoodsPostion [ i ] . InUserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
md . GoodsPostion [ i ] . Price = md . Price ;
md . GoodsPostion [ i ] . PostPrice = model . PostPrice ;
md . GoodsPostion [ i ] . GoodsLockNum = 0 ;
obj . SaveGoodsInListNew ( md . GoodsPostion [ i ] ) ;
}
}
}
}
PagesNew . SaveLog ( InUserId , "货物信息" , "修改货物信息" , GoodsId ) ;
if ( LinkList ! = null )
{
foreach ( var md in LinkList )
{
md . GoodsId = GoodsId ;
DataNew . SaveBuyLink ( md ) ;
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert . ToString ( Session [ "Name" ] ) ;
string Ids = "" ;
if ( shoplist ! = null )
{
foreach ( var md1 in shoplist )
{
md1 . GoodsId = GoodsId ;
md1 . InName = InName ;
int Id = DataNew . SaveShopForTM ( md1 ) ;
Ids + = Id . ToString ( ) + "," ;
}
}
DataNew . DeleteShopForTM ( Ids . Trim ( ',' ) , GoodsId , InName ) ;
return GoodsId . ToString ( ) ;
}
catch ( Exception ex )
{
return ex . Message ;
}
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public HW_GoodsNew GetGoodsInfoModelForTM ( int GoodsId )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
var Model = DataNew . GetGoodsModelNew ( GoodsId ) ;
var obj1 = new BaseService ( ) ;
//var list = obj1.GetSupplierListFromGoods(CompanyId, GoodsId);
//string sname = "";
//if (list != null)
//{
// foreach (var md in list)
// {
// sname += md.SupplierName + ",";
// }
//}
//Model.SupplierList = list;
//Model.SupplierId = sname.Trim(',');
if ( Model . GoodsImageIds ! = null & & Model . GoodsImageIds ! = "" )
Model . ImgList = obj1 . GetResourceList ( Model . GoodsImageIds ) ;
return Model ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsUserNew > > GetGoodsUser22 ( int UserId , string GoodsCode , int? Days , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
if ( UserId > 0 )
Param . Add ( "a.UserId" , "=" , UserId , DbType . Int32 ) ;
if ( GoodsCode ! = "" )
Param . Add ( "d.GoodsCode" , "like" , GoodsCode , DbType . String ) ;
JsonModel < List < HW_GoodsUserNew > > resultModel = new JsonModel < List < HW_GoodsUserNew > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListGoodsUser ( Days , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
return resultModel ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsUser > > GetGoodsUser ( int UserId , string GoodsCode , int ShopId , int PageIndex , int PageSize , string Sort )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
if ( UserId > 0 )
Param . Add ( "a.UserId" , "=" , UserId , DbType . Int32 ) ;
if ( GoodsCode ! = "" )
Param . Add ( "d.GoodsCode" , "like" , GoodsCode , DbType . String ) ;
if ( ShopId > 0 )
Param . Add ( "a.ShopId" , "=" , ShopId , DbType . Int32 ) ;
JsonModel < List < HW_GoodsUser > > resultModel = new JsonModel < List < HW_GoodsUser > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = obj . GetListGoodsUser ( Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
return resultModel ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public List < HW_GoodsStoreNumCount > GetListGoodsStoreCount ( int storeId , string sku )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
var list = DataNew . GetListGoodsStoreCount ( storeId , sku ) ;
int num = 0 ;
decimal tj = 0 ;
foreach ( var md in list )
{
num + = md . KCNum . Value ;
tj = md . TJSolid . Value ;
}
return list ;
}
# endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public string GetListGoodsStoreCountExcel ( int storeId , string sku )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
var list = DataNew . GetListGoodsStoreCount ( storeId , sku ) ;
int num = 0 ;
decimal tj = 0 M ;
decimal je = 0 M ;
foreach ( var md in list )
{
if ( md . KCNum ! = null )
num + = md . KCNum . Value ;
if ( md . TJSolid ! = null )
tj + = md . TJSolid . Value ;
if ( md . TJPrice ! = null )
je + = md . TJPrice . Value ;
}
if ( list ! = null )
{
HW_GoodsStoreNumCount md = new HW_GoodsStoreNumCount ( ) ;
md . GoodsCode = "合计:" ;
md . KCNum = num ;
md . TJPrice = je ;
md . TJSolid = tj ;
list . Add ( md ) ;
}
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "GoodsCode" , "货物SKU" , DbType . String , "" ) ;
listColumns . Add ( "KCNum" , "库存数" , DbType . String , "" ) ;
listColumns . Add ( "Solid" , "单个体积" , DbType . String , "" ) ;
listColumns . Add ( "TJSolid" , "合计体积" , DbType . String , "" ) ;
listColumns . Add ( "InPrice" , "单个价格" , DbType . String , "" ) ;
listColumns . Add ( "TJPrice" , "合计价格" , DbType . String , "" ) ;
MicrosoftExcel obj2 = new MicrosoftExcel ( ) ;
return obj2 . Export ( list , listColumns ) ;
}
# endregion
#region 查询库存
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsLeftNew > > GetList_GoodsLeftForTMNew ( string PostionCode , string GoodsName , string GoodsName2 , int StoreId , int sdays , int edays , int PageIndex , int PageSize )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if ( PostionCode ! = "" )
Param . Add ( "d.PostionCode" , "=" , PostionCode , DbType . String ) ;
if ( StoreId > 0 )
Param . Add ( "d.StoreId" , "=" , StoreId , DbType . String ) ;
if ( GoodsName . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) , DbType . String ) ;
Param . Add ( "b.sku1" , "=" , GoodsName . Trim ( ) , "or" , ")" , DbType . String ) ;
}
if ( GoodsName2 . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "like" , GoodsName2 . Trim ( ) , DbType . String ) ;
Param . Add ( "b.sku1" , "like" , GoodsName2 . Trim ( ) , "or" , ")" , DbType . String ) ;
}
if ( GoodsName . Trim ( ) . Contains ( " " ) )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , DbType . String ) ;
Param . Add ( "c.GoodsOldCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , "or" , ")" , DbType . String ) ;
Param . Add ( "b.TypeCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 1 ] . Trim ( ) , DbType . String ) ;
}
if ( sdays > = 0 )
{
Param . Add ( " DATEDIFF(DAY,a.indate,GETDATE())" , ">=" , sdays , DbType . Int32 ) ;
}
if ( edays > = 0 )
{
Param . Add ( " DATEDIFF(DAY,a.indate,GETDATE())" , "<=" , edays , DbType . Int32 ) ;
}
JsonModel < List < HW_GoodsLeftNew > > resultModel = new JsonModel < List < HW_GoodsLeftNew > > ( ) ;
string Sort = "c.GoodsCode,b.TypeCode" ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetList_GoodsLeftForTMNew ( Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
return resultModel ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpDoPrice ( List < HW_GoodsLeftNew > list , decimal doprice )
{
PagesNew . Login ( this . Session ) ;
if ( list ! = null )
{
foreach ( var md in list )
{
DataNew . UpDoPrice ( md . PostionId . Value , md . DetailId . Value , doprice ) ;
}
}
return 1 ;
}
# endregion
#region 导出库存
[WebMethod(EnableSession = true)]
public string GetList_GoodsLeftExcel2 ( string PostionCode , string GoodsName , string GoodsName2 , int StoreId , int sdays , int edays )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if ( PostionCode ! = "" )
Param . Add ( "d.PostionCode" , "=" , PostionCode , DbType . String ) ;
if ( StoreId > 0 )
Param . Add ( "d.StoreId" , "=" , StoreId , DbType . String ) ;
if ( GoodsName . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) , DbType . String ) ;
Param . Add ( "b.sku1" , "=" , GoodsName . Trim ( ) , "or" , ")" , DbType . String ) ;
}
if ( GoodsName2 . Trim ( ) ! = "" )
{
Param . Add ( "(c.GoodsCode" , "like" , GoodsName2 . Trim ( ) , DbType . String ) ;
Param . Add ( "b.sku1" , "like" , GoodsName2 . Trim ( ) , "or" , ")" , DbType . String ) ;
}
if ( GoodsName . Trim ( ) . Contains ( " " ) )
{
Param . Add ( "(c.GoodsCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , DbType . String ) ;
Param . Add ( "c.GoodsOldCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) , "or" , ")" , DbType . String ) ;
Param . Add ( "b.TypeCode" , "=" , GoodsName . Trim ( ) . Split ( ' ' ) [ 1 ] . Trim ( ) , DbType . String ) ;
}
if ( sdays > = 0 )
{
Param . Add ( " DATEDIFF(DAY,a.indate,GETDATE())" , ">=" , sdays , DbType . Int32 ) ;
}
if ( edays > = 0 )
{
Param . Add ( " DATEDIFF(DAY,a.indate,GETDATE())" , "<=" , edays , DbType . Int32 ) ;
}
JsonModel < List < HW_GoodsLeftNew > > resultModel = new JsonModel < List < HW_GoodsLeftNew > > ( ) ;
string Sort = "c.GoodsCode,b.TypeCode" ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetList_GoodsLeftForTMNew ( Param , 1 , 50000 , Sort , out RowCount ) ;
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "GoodsCode" , "编码" , DbType . String , "" ) ;
listColumns . Add ( "TypeCode" , "SKU" , DbType . String , "" ) ;
listColumns . Add ( "GoodsName" , "名称" , DbType . String , "" ) ;
listColumns . Add ( "TypeDesc" , "规格描述" , DbType . String , "" ) ;
listColumns . Add ( "GoodsNum" , "库存数量" , DbType . String , "" ) ;
listColumns . Add ( "LockNum" , "匹配锁定数量" , DbType . String , "" ) ;
listColumns . Add ( "StoreName" , "仓库" , DbType . String , "" ) ;
listColumns . Add ( "PostionCode" , "库位" , DbType . String , "" ) ;
listColumns . Add ( "LeftNum" , "库龄" , DbType . String , "" ) ;
listColumns . Add ( "DoPrice" , "处理价格$" , DbType . String , "" ) ;
MicrosoftExcel obj2 = new MicrosoftExcel ( ) ;
return obj2 . Export ( resultModel . DataSource , listColumns ) ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Update_Grade ( List < HW_GoodsUserNew > list , string grade )
{
PagesNew . Login ( this . Session ) ;
if ( list ! = null )
{
foreach ( var md in list )
{
DataNew . UpdateGoodsGrade ( md . Id . Value , grade ) ;
}
}
return 1 ;
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_CGGoodsNum ( int DetailId , int sjout , int Num , int Num2 , int pstate , string bhremark , List < HW_GoodsBFPlan > list )
{
Pages . Login ( this . Session ) ;
int Year = DateTime . Today . Year ;
DataNew . Delete_GoodsBFPlan ( Year , DetailId , sjout ) ;
DataNew . Update_CGGoodsNum2 ( DetailId , Num , Num2 , pstate , bhremark ) ;
if ( pstate = = 3 ) //审批通过
{
DataNew . Update_CGGoodsNum ( DetailId , Num2 ) ;
}
if ( list = = null )
return ;
foreach ( var md in list )
{
md . year = Year ;
if ( sjout = = 1 )
{
md . outdate = DateTime . Now ;
md . outname = Session [ "Name" ] . ToString ( ) ;
}
md . indate = DateTime . Now ;
md . inname = Session [ "Name" ] . ToString ( ) ;
DataNew . Save_GoodsBFPlan ( md ) ;
}
if ( pstate = = 1 )
{
DataNew . SaveIOpenMess ( 32 , "领导添加了产品需要采购,请尽快去货物信息那边确定" ) ;
}
if ( pstate = = 2 )
{
DataNew . SaveIOpenMess ( 1 , "采购已经确认了采购数量,请尽快去货物信息那边审批通过" ) ;
}
if ( pstate = = 3 )
{
DataNew . SaveIOpenMess ( 32 , "领导已经审批了你的采购,请尽快去下单采购" ) ;
}
//DataNew.UpdateGoodsBFPlan(DetailId, pstate);
}
# endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_CGGoodsNum2 ( int DetailId , int sjout , int Num , int Num2 , int pstate , List < HW_GoodsBFPlan > list )
{
Pages . Login ( this . Session ) ;
int Year = DateTime . Today . Year ;
DataNew . Delete_GoodsBFPlan ( Year , DetailId , sjout ) ;
if ( list = = null | | list . Count = = 0 )
return ;
foreach ( var md in list )
{
md . year = Year ;
if ( sjout = = 1 )
{
md . outdate = DateTime . Now ;
md . outname = Session [ "Name" ] . ToString ( ) ;
}
md . indate = DateTime . Now ;
md . inname = Session [ "Name" ] . ToString ( ) ;
DataNew . Save_GoodsBFPlan ( md ) ;
}
if ( pstate = = 3 ) //审批通过
{
DataNew . delete_ProductionDetail ( list [ 0 ] . detailid . Value ) ;
foreach ( var md in list )
{
HW_ProductionDetail Model = new HW_ProductionDetail ( ) ;
Model . mid = md . detailid ;
Model . weeknum = md . cgsl ;
Model . sdate = md . sdate ;
Model . edate = md . edate ;
Model . weekname = "Week" + md . weekno . ToString ( ) + "【" + md . sdate . Value . ToString ( "yyyy-MM-dd" ) + "---" + md . edate . Value . ToString ( "yyyy-MM-dd" ) + "】" ;
DataNew . Save_ProductionDetail2 ( Model ) ;
}
}
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_GoodsBFPlan ( List < HW_GoodsBFPlan > list , int pstate )
{
Pages . Login ( this . Session ) ;
if ( list = = null )
return 0 ;
int Year = DateTime . Today . Year ;
DataNew . Delete_GoodsBFPlan ( Year , list [ 0 ] . detailid . Value , list [ 0 ] . sjout . Value ) ;
foreach ( var md in list )
{
md . year = Year ;
DataNew . Save_GoodsBFPlan ( md ) ;
}
if ( pstate = = 3 ) //审批通过
{
DataNew . delete_ProductionDetail ( list [ 0 ] . detailid . Value ) ;
foreach ( var md in list )
{
HW_ProductionDetail Model = new HW_ProductionDetail ( ) ;
Model . mid = md . detailid ;
Model . weeknum = md . weekno ;
Model . sdate = md . sdate ;
Model . edate = md . edate ;
Model . weekname = "Week" + md . weekno . ToString ( ) + "【" + md . sdate . Value . ToString ( "yyyy-MM-dd" ) + "----" + md . edate . Value . ToString ( "yyyy-MM-dd" ) + "】" ;
DataNew . Save_ProductionDetail2 ( Model ) ;
}
}
return 1 ;
}
# endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List < HW_WeekName > GetPlanWeekList ( int detailid )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int Year = DateTime . Today . Year ;
System . DateTime fDt = DateTime . Parse ( Year . ToString ( ) + "-01-01" ) ;
int k = Convert . ToInt32 ( DateTime . Today . DayOfWeek ) ; //得到该年的第一天是周几
if ( k = = 0 )
k = 7 ;
DateTime sdt = DateTime . Today . AddDays ( - 1 * ( k - 1 ) ) ;
DateTime ssdt = sdt . AddDays ( - 56 ) ;
if ( ssdt > fDt )
{
k = Convert . ToInt32 ( fDt . DayOfWeek ) ; //得到该年的第一天是周几
if ( k = = 0 )
k = 7 ;
sdt = fDt . AddDays ( - 1 * ( k - 1 ) ) ;
}
else
sdt = ssdt ;
var slist = DataNew . GetListGoodsBFPlan ( Year , detailid , 0 ) ;
List < HW_WeekName > wlist = new List < HW_WeekName > ( ) ;
// int j = 1;
for ( int i = 0 ; i < 52 ; i + + )
{
HW_WeekName wmd = new HW_WeekName ( ) ;
//var md = GetWeekName2(sdt.AddDays(i * 7).Year, sdt.AddDays(i * 7));
wmd . SDate = sdt . AddDays ( i * 7 ) ;
wmd . EDate = wmd . SDate . Value . AddDays ( 6 ) ;
wmd . Num = i + 1 ;
if ( slist ! = null )
{
var smd = slist . Find ( n = > n . weekno = = wmd . Num ) ;
if ( smd ! = null )
wmd . cgsl = smd . cgsl ;
}
//if (md.SDate >= ssdt && md.SDate <= ssdt.AddDays(7))
// md.IsNow = 1;
//if (md.SDate <= DateTime.Today && md.EDate >= DateTime.Today)
// md.IsNow = 2;
wlist . Add ( wmd ) ;
}
return wlist ;
}
# endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List < HW_WeekName > GetPlanWeekList2 ( int detailid )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
int Year = DateTime . Today . Year ;
System . DateTime fDt = DateTime . Parse ( Year . ToString ( ) + "-01-01" ) ;
int k = Convert . ToInt32 ( DateTime . Today . DayOfWeek ) ; //得到该年的第一天是周几
if ( k = = 0 )
k = 7 ;
DateTime sdt = DateTime . Today . AddDays ( - 1 * ( k - 1 ) ) ;
DateTime ssdt = sdt . AddDays ( - 56 ) ;
if ( ssdt > fDt )
{
k = Convert . ToInt32 ( fDt . DayOfWeek ) ; //得到该年的第一天是周几
if ( k = = 0 )
k = 7 ;
sdt = fDt . AddDays ( - 1 * ( k - 1 ) ) ;
}
else
sdt = ssdt ;
var slist = DataNew . GetListGoodsBFPlan ( Year , detailid , 1 ) ;
List < HW_WeekName > wlist = new List < HW_WeekName > ( ) ;
// int j = 1;
for ( int i = 0 ; i < 52 ; i + + )
{
HW_WeekName wmd = new HW_WeekName ( ) ;
//var md = GetWeekName2(sdt.AddDays(i * 7).Year, sdt.AddDays(i * 7));
wmd . SDate = sdt . AddDays ( i * 7 ) ;
wmd . EDate = wmd . SDate . Value . AddDays ( 6 ) ;
wmd . Num = i + 1 ;
if ( slist ! = null )
{
var smd = slist . Find ( n = > n . weekno = = wmd . Num ) ;
if ( smd ! = null )
{
wmd . cgsl = smd . cgsl ;
wmd . remark = smd . remark ;
wmd . checknote = smd . checknote ;
}
}
//if (md.SDate >= ssdt && md.SDate <= ssdt.AddDays(7))
// md.IsNow = 1;
//if (md.SDate <= DateTime.Today && md.EDate >= DateTime.Today)
// md.IsNow = 2;
wlist . Add ( wmd ) ;
}
return wlist ;
}
# endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public HW_WeekName GetWeekName2 ( int Year , DateTime sdate )
{
var obj = new HuoWuData ( ) ;
System . DateTime fDt = DateTime . Parse ( Year . ToString ( ) + "-01-01" ) ;
int k = Convert . ToInt32 ( fDt . DayOfWeek ) ; //得到该年的第一天是周几
if ( k = = 0 )
k = 7 ;
DateTime sdt = fDt . AddDays ( - 1 * ( k - 1 ) ) ;
for ( int i = 0 ; i < 54 ; i + + )
{
HW_WeekName wmd = new HW_WeekName ( ) ;
wmd . SDate = sdt . AddDays ( i * 7 ) ;
wmd . EDate = wmd . SDate . Value . AddDays ( 6 ) ;
wmd . Num = i + 1 ;
if ( wmd . SDate . Value . Year ! = wmd . EDate . Value . Year )
{
wmd . WeekName = "Week1【" + wmd . SDate . Value . ToString ( "yyyy-MM-dd" ) + "----" + wmd . EDate . Value . ToString ( "yyyy-MM-dd" ) + "】" ;
wmd . WeekName2 = "Week1" ;
}
else
{
wmd . WeekName = "Week" + ( i + 1 ) . ToString ( ) + "【" + wmd . SDate . Value . ToString ( "yyyy-MM-dd" ) + "----" + wmd . EDate . Value . ToString ( "yyyy-MM-dd" ) + "】" ;
wmd . WeekName2 = "Week" + ( i + 1 ) . ToString ( ) ;
}
sdt . AddDays ( 7 ) ;
if ( wmd . SDate > = sdate & & sdate < = wmd . EDate )
return wmd ;
}
return null ;
}
# endregion
#region 查询货物
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_Goods_New > > GetGoodsInfoListForTM22 ( int SortId , int OffNum , string SortName , int TypeCode , string Name , string Supplier , int SNum , int ENum , decimal SPrice , decimal EPrice , int IsWH , int IsHW , int IsDH , int IsBH , int accurate , int jybh , int IsShowAll , int IsOnlyYC , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
Param . Add ( "CompanyId" , "=" , CompanyId , DbType . Int32 ) ;
if ( SortName ! = "" & & SortName ! = "-全部-" & & SortName ! = "全部" )
Param . Add ( "SortName" , "like" , SortName , DbType . String ) ;
if ( SortId ! = 0 )
Param . Add ( "SortId" , "=" , SortId , DbType . Int32 ) ;
//if (Edate != null)
// Param.Add("InDate", "<", Edate.Value.AddDays(1), DbType.DateTime);
Param . Add ( "State" , "=" , 1 , DbType . Int32 ) ;
if ( IsShowAll ! = 1 ) //不展示所有
{
if ( IsOnlyYC = = 1 ) //只展示隐藏
{
Param . Add ( "IsYC" , "=" , 1 , DbType . Int32 ) ;
}
else
{
Param . Add ( "IsNull(IsYC,0)" , "=" , 0 , DbType . Int32 ) ;
}
}
else //展示所有
{
if ( IsOnlyYC = = 1 ) //只展示隐藏
{
Param . Add ( "IsYC" , "=" , 1 , DbType . Int32 ) ;
}
}
if ( Supplier ! = "" )
Param . Add ( "SupplierId" , "like" , Supplier , DbType . String ) ;
Name = Name . Trim ( ) ;
if ( Name ! = "" & & accurate = = 0 )
{
//if (TypeCode == 1)
// Param.Add("GoodsName", "like", Name, DbType.String);
if ( TypeCode = = 2 )
{
Param . Add ( "(GoodsCode" , "like" , Name , DbType . String ) ;
Param . Add ( "GoodsOldCode" , "like" , Name , "or" , ")" , DbType . String ) ;
}
if ( TypeCode = = 3 )
Param . Add ( "GoodsSupplyCode" , "like" , Name , DbType . String ) ;
//if (TypeCode == 4)
// Param.Add("b.SKU1", "=", Name, DbType.String);
if ( TypeCode = = 5 )
Param . Add ( "GoodsSupplyCode" , "like" , Name , DbType . String ) ;
if ( TypeCode = = 6 )
Param . Add ( "UpdateName" , "like" , Name , DbType . String ) ;
}
if ( Name ! = "" & & accurate = = 1 )
{
//if (TypeCode == 1)
// Param.Add("GoodsName", "=", Name, DbType.String);
if ( TypeCode = = 2 )
{
Param . Add ( "(GoodsCode" , "=" , Name , DbType . String ) ;
Param . Add ( "GoodsOldCode" , "=" , Name , "or" , ")" , DbType . String ) ;
}
if ( TypeCode = = 3 )
Param . Add ( "GoodsSupplyCode" , "=" , Name , DbType . String ) ;
//if (TypeCode == 4)
// Param.Add("b.SKU1", "=", Name, DbType.String);
if ( TypeCode = = 5 )
Param . Add ( "GoodsSupplyCode" , "=" , Name , DbType . String ) ;
if ( TypeCode = = 6 )
Param . Add ( "UpdateName" , "=" , Name , DbType . String ) ;
}
string sku = "" ;
if ( Name ! = "" & & ( TypeCode = = 4 | | TypeCode = = 1 ) & & accurate = = 0 )
{
sku = Name ;
}
if ( OffNum ! = 99999 )
{
if ( OffNum > = 0 )
Param . Add ( "a.UpOff" , ">=" , OffNum , DbType . Int32 ) ;
else
Param . Add ( "a.UpOff" , "<=" , OffNum , DbType . Int32 ) ;
}
if ( SNum > 0 )
Param . Add ( "b.GoodsNum" , ">=" , SNum , DbType . Int32 ) ;
if ( ENum > 0 )
Param . Add ( "b.GoodsNum" , "<=" , ENum , DbType . Int32 ) ;
if ( SPrice > 0 )
Param . Add ( "NowPrice" , ">=" , SPrice , DbType . Decimal ) ;
if ( EPrice > 0 )
Param . Add ( "NowPrice" , "<=" , EPrice , DbType . Decimal ) ;
if ( IsWH = = 1 )
Param . Add ( "NoGoods" , "=" , 1 , DbType . Int32 ) ;
if ( jybh = = 1 )
Param . Add ( "b.GoodsHJNum2-isnull(b.GoodsNum,0)-isnull(b.GoodsInNum2,0)" , ">" , 0 , DbType . Int32 ) ;
JsonModel < List < HW_Goods_New > > resultModel = new JsonModel < List < HW_Goods_New > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListHW_GoodsInfoNewForTM ( CompanyId , sku , IsDH , IsBH , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
string Ids = "" ;
if ( resultModel . DataSource ! = null )
{
foreach ( var md in resultModel . DataSource )
{
Ids + = md . GoodsId . ToString ( ) + "," ;
if ( md . Solid ! = null )
md . TotalSolid = md . Solid * md . GoodsNum ;
}
}
if ( IsHW = = 1 & & resultModel . DataSource ! = null )
{
if ( Ids ! = "" )
{
var list1 = obj . GetGoodsDetailList ( Ids . Trim ( ',' ) ) ;
if ( list1 ! = null )
{
foreach ( var md in resultModel . DataSource )
{
var list2 = list1 . FindAll ( n = > n . GoodsId = = md . GoodsId ) ;
if ( list2 ! = null )
{
md . GoodsList = list2 ;
}
}
}
}
}
return resultModel ;
}
# endregion
#region 导入货物
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsSKUNew ( string FileName , string SortName )
{
PagesNew . Login ( this . Session ) ;
if ( string . IsNullOrEmpty ( FileName ) = = true ) return "要导入的文件路径不能为空" ;
string ServerFileName = AppDomain . CurrentDomain . BaseDirectory + FileName ;
if ( System . IO . File . Exists ( ServerFileName ) = = false ) return "要导入的文件路径不存在" ;
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel ( ) ;
DataTable tb = excel . ImportExcel ( ServerFileName ) ;
string error = "" ;
if ( tb . Columns . Contains ( "货物编号" ) = = false ) { error = error + "导入模板的 货物编号 列不存在" ; }
if ( tb . Columns . Contains ( "报关名称" ) = = false ) { error = error + "导入模板的 报关名称 列不存在" ; }
if ( tb . Columns . Contains ( "SKU" ) = = false ) { error = error + "导入模板的 SKU 列不存在" ; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
//if (tb.Columns.Contains("入库数量") == false) { error = error + "导入模板的 入库数量 列不存在"; }
if ( string . IsNullOrEmpty ( error ) = = false ) return error + ";请重新下载模板导入" ;
HuoWuData obj = new HuoWuData ( ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
int Num = 0 ;
HW_GoodsExcelModel2 omd = null ;
for ( int i = 0 ; i < tb . Rows . Count ; i + + )
{
var md = new HW_GoodsExcelModel2 ( ) ;
if ( omd ! = null )
md = omd ;
if ( tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) = = "" )
{
continue ;
}
md . SKU1 = tb . Rows [ i ] [ "SKU" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "货物编号" ] . ToString ( ) . Trim ( ) ! = "" )
md . GoodsCode = tb . Rows [ i ] [ "货物编号" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "报关名称" ] . ToString ( ) . Trim ( ) ! = "" )
md . GoodsName = tb . Rows [ i ] [ "报关名称" ] . ToString ( ) . Trim ( ) ;
md . SortName1 = SortName ;
md . SortId = 0 ;
md . SKU1 = "" ;
md . SKU2 = "" ;
md . SKU3 = "" ;
md . SKU4 = "" ;
//if (tb.Columns.Contains("SKU2") == true)
// md.SKU2 = tb.Rows[i]["SKU2"].ToString().Trim();
//if (tb.Columns.Contains("SKU3") == true)
// md.SKU3 = tb.Rows[i]["SKU3"].ToString().Trim();
//if (tb.Columns.Contains("SKU4") == true)
// md.SKU4 = tb.Rows[i]["SKU4"].ToString().Trim();
if ( tb . Rows [ i ] [ "报关英文名" ] . ToString ( ) . Trim ( ) ! = "" )
md . GoodsEngLishName = tb . Rows [ i ] [ "报关英文名" ] . ToString ( ) . Trim ( ) . Replace ( "," , "" ) ;
if ( md . GoodsEngLishName = = "" )
md . GoodsEngLishName = "Goods" ;
if ( md . GoodsEngLishName . Length > = 50 )
md . GoodsEngLishName = md . GoodsEngLishName . Substring ( 0 , 49 ) ;
// if (tb.Rows[i]["描述"].ToString().Trim() != "")
md . TypeDesc = tb . Rows [ i ] [ "描述" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "箱率" ] . ToString ( ) . Trim ( ) ! = "" )
md . BoxRate = Convert . ToDecimal ( tb . Rows [ i ] [ "箱率" ] . ToString ( ) . Trim ( ) ) ;
if ( tb . Rows [ i ] [ "单个毛重(克)" ] . ToString ( ) . Trim ( ) ! = "" )
md . Weight2 = Convert . ToDecimal ( tb . Rows [ i ] [ "单个毛重(克)" ] . ToString ( ) . Trim ( ) ) * 0.035274 M ;
if ( tb . Rows [ i ] [ "单个净重( g) " ] . ToString ( ) . Trim ( ) ! = "" )
md . NetWeight = Convert . ToDecimal ( tb . Rows [ i ] [ "单个净重( g) " ] . ToString ( ) . Trim ( ) ) ;
if ( tb . Rows [ i ] [ "外箱毛重( g) " ] . ToString ( ) . Trim ( ) ! = "" )
md . Weight = Convert . ToDecimal ( tb . Rows [ i ] [ "外箱毛重( g) " ] . ToString ( ) . Trim ( ) ) ;
//md.Link1 = tb.Rows[i]["购买链接1"].ToString().Trim();
//md.LinkName1 = tb.Rows[i]["购买链接1名称"].ToString().Trim();
//md.Link2 = tb.Rows[i]["购买链接2"].ToString().Trim();
//md.LinkName2 = tb.Rows[i]["购买链接2名称"].ToString().Trim();
//md.Link3 = tb.Rows[i]["购买链接3"].ToString().Trim();
//md.LinkName3 = tb.Rows[i]["购买链接3名称"].ToString().Trim();
//md.Link4 = tb.Rows[i]["购买链接4"].ToString().Trim();
//md.LinkName4 = tb.Rows[i]["购买链接4名称"].ToString().Trim();
try
{
if ( tb . Rows [ i ] [ "进价" ] . ToString ( ) . Trim ( ) ! = "" )
md . Price = Convert . ToDecimal ( tb . Rows [ i ] [ "进价" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的单价必须是数字<br/>";
md . Price = 0 ;
}
if ( tb . Rows [ i ] [ "外箱长(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Long = Convert . ToDecimal ( tb . Rows [ i ] [ "外箱长(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "外箱宽(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Width = Convert . ToDecimal ( tb . Rows [ i ] [ "外箱宽(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "外箱高(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Height = Convert . ToDecimal ( tb . Rows [ i ] [ "外箱高(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "单个长(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Long2 = Convert . ToDecimal ( tb . Rows [ i ] [ "单个长(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "单个宽(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Width2 = Convert . ToDecimal ( tb . Rows [ i ] [ "单个宽(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "单个宽(英寸)" ] . ToString ( ) . Trim ( ) ! = "" )
{
try
{
md . Height2 = Convert . ToDecimal ( tb . Rows [ i ] [ "单个宽(英寸)" ] . ToString ( ) . Trim ( ) ) ;
}
catch ( Exception ex )
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if ( tb . Rows [ i ] [ "产品开发人员" ] . ToString ( ) . Trim ( ) ! = "" )
md . KFName = tb . Rows [ i ] [ "产品开发人员" ] . ToString ( ) . Trim ( ) ;
if ( tb . Rows [ i ] [ "产品维护人员" ] . ToString ( ) . Trim ( ) ! = "" )
md . KFName2 = tb . Rows [ i ] [ "产品维护人员" ] . ToString ( ) . Trim ( ) ;
else
{
md . KFName2 = md . KFName ;
}
if ( tb . Rows [ i ] [ "税率" ] . ToString ( ) . Trim ( ) ! = "" )
md . FeeRate = Convert . ToDecimal ( tb . Rows [ i ] [ "税率" ] . ToString ( ) . Trim ( ) ) ;
if ( md . Long2 > 0 & & md . Height2 > 0 & & md . Width2 > 0 )
md . Solid = md . Long2 * md . Height2 * md . Width2 * 0.0000164 M ;
if ( tb . Rows [ i ] [ "备注" ] . ToString ( ) . Trim ( ) ! = "" )
md . GoodsInfo = tb . Rows [ i ] [ "备注" ] . ToString ( ) . Trim ( ) ;
md . CompanyId = 1 ;
md . InUserId = UserId ;
md . GoodsEg = md . GoodsCode ;
md . GoodsNo = 0 ;
md . GoodsNum = 0 ;
if ( tb . Rows [ i ] [ "图片" ] . ToString ( ) . Trim ( ) ! = "" )
md . ImgUrl = "../attached/gimg/" + tb . Rows [ i ] [ "图片" ] . ToString ( ) . Trim ( ) ;
omd = md ;
int a = DataNew . ExcelSaveGoodsSKUNEW ( md ) ;
if ( a = = 2 )
{
error + = "第" + ( i + 2 ) . ToString ( ) + " 行的SKU已经存在<br/>" ;
continue ;
}
else
Num + + ;
}
if ( error = = "" )
{
error = "数据导入成功;" + Num . ToString ( ) + "条" ;
}
else
{
error + = "其它数据导入成功;" ;
}
return error ;
}
catch ( Exception e )
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e . Message ;
}
return "导入成功" ;
}
# endregion
#region 查询采购单号
[WebMethod(EnableSession = true)]
public string GetCGGCodeForTM ( )
{
Pages . Login ( this . Session ) ;
var obj = new CG_ChaseData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
int num = obj . Get_CGOrderCode ( CompanyId ) + 1 ;
Random ran = new Random ( ) ;
int RandKey = ran . Next ( 0 , 9 ) ;
string Code = DateTime . Today . ToString ( "yyyyMMdd" ) + DateTime . Now . Hour . ToString ( ) + DateTime . Now . Minute . ToString ( ) + DateTime . Now . Second . ToString ( ) + num . ToString ( ) + RandKey . ToString ( ) ; ;
return Code ;
}
# endregion
#region 查询出库货物明细
[WebMethod(EnableSession = true)]
public List < HW_GoodsOutCKNew > GetGoodsOutDetailNew ( string GoodsCode , int StoreId )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
string TypeCode = "" ;
if ( GoodsCode . Trim ( ) . Contains ( " " ) )
{
TypeCode = GoodsCode . Trim ( ) . Split ( ' ' ) [ 1 ] . Trim ( ) ;
GoodsCode = GoodsCode . Trim ( ) . Split ( ' ' ) [ 0 ] . Trim ( ) ;
}
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
var list = DataNew . GetGoodsOutDetailNew ( CompanyId , GoodsCode , TypeCode , StoreId ) ;
return list ;
}
# endregion
#region 保存货物出库单
[WebMethod(EnableSession = true)]
public HW_GoodsOutRecordBuy SaveGoodsOutBuy ( HW_GoodsOutRecordBuy model , List < HW_GoodsOutCKNew > CKList , int state )
{
Pages . Login ( this . Session ) ;
// bool bk = BaseService.SyncLock3();
// if (bk == false)
// return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法出库";
HW_GoodsOutRecordBuy rmd = new HW_GoodsOutRecordBuy ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
int UserId = Convert . ToInt32 ( Session [ "UserId" ] ) ;
var obj = new HuoWuData ( ) ;
model . CompanyId = CompanyId ;
model . InDate = DateTime . Now ;
model . InUserId = UserId ;
model . IsDelete = state ;
int Num = 0 ;
if ( CKList ! = null )
{
foreach ( var md in CKList )
{
if ( md . OutNum ! = null )
Num + = md . OutNum . Value ;
}
}
model . OutNum = Num ;
if ( CKList ! = null )
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
string error = "" ;
foreach ( var md in CKList )
{
int kc = DataNew . iskc ( md . PostionId . Value , md . DetailId . Value ) ;
if ( md . OutNum > kc )
{
error + = md . SKU1 + "[" + md . PostionDesc + "] " ;
}
}
if ( error ! = "" )
{
rmd . OutReason = error + "Insufficient inventory,Please modify the quantity;" ;
return rmd ;
}
}
var OutId = DataNew . SaveGoodsOutBuy ( model ) ;
if ( CKList ! = null )
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
DataNew . DeleteGoodsOutDetailBuy ( OutId ) ;
foreach ( var md in CKList )
{
md . Id = 0 ;
md . OutId = OutId ;
int ckid = DataNew . SaveGoodsOutDetailBuy ( md , state ) ;
if ( md . OutNum ! = null & & md . OutNum . Value > 0 & & state = = 2 )
{
//for (int i = 0; i < md.OutNum.Value; i++)
//{
obj . SaveGoodsOutInnerForTM2 ( md . DetailId . Value , md . PostionId . Value , md . StoreId . Value , md . OutNum . Value , ckid ) ;
// }
}
}
// obj.SaveGoodsOutGoodsNum(OutId);
}
if ( state = = 2 )
Pages . SaveLog ( UserId , "出库调整" , model . OutCode + "出库单" , OutId ) ;
rmd . OutId = OutId ;
return rmd ;
}
# endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public JsonModel < List < HW_GoodsOutRecordBuy > > GetListHW_GoodsOutListBuy ( int TJ , string GoodsName , DateTime ? SDate , DateTime ? EDate , int IsDetail , string CKType , int PageIndex , int PageSize , string Sort )
{
var obj = new HuoWuData ( ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
RefParameterCollection Param = new RefParameterCollection ( ) ;
Param . Add ( "a.CompanyId" , "=" , CompanyId , DbType . Int32 ) ;
// Param.Add("a.IsDelete", "=", 0, DbType.Int32);
//if (CKType == 1)
// Param.Add("a.OrderId", ">", 0, DbType.String);
//else if (CKType == 2)
// Param.Add("a.OrderId", "=", 0, DbType.String);
if ( SDate ! = null )
Param . Add ( "a.InDate" , ">=" , SDate , DbType . DateTime ) ;
if ( EDate ! = null )
Param . Add ( "a.InDate" , "<" , EDate . Value . AddDays ( 1 ) , DbType . DateTime ) ;
if ( TJ = = 6 )
{
Param . Add ( "a.OutCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
else
if ( TJ = = 7 )
{
Param . Add ( "b.PlatOrderCode" , "like" , GoodsName . Trim ( ) , DbType . String ) ;
}
if ( TJ > 4 )
GoodsName = "" ;
JsonModel < List < HW_GoodsOutRecordBuy > > resultModel = new JsonModel < List < HW_GoodsOutRecordBuy > > ( ) ;
int RowCount = 0 ;
resultModel . DataSource = DataNew . GetListHW_GoodsOutListBuy ( TJ , CKType . TrimEnd ( ',' ) , GoodsName , Param , PageIndex , PageSize , Sort , out RowCount ) ;
resultModel . RowCount = RowCount ;
if ( IsDetail = = 1 & & resultModel . DataSource ! = null )
{
foreach ( var md in resultModel . DataSource )
{
var list = DataNew . GetOutCKDetailListForTM ( md . OutId . Value ) ;
md . GoodsOutCKList2 = list ;
}
}
return resultModel ;
}
# endregion
#region 返回出库Model
[WebMethod(EnableSession = true)]
public HW_GoodsOutRecordBuy GetOutCKModelBuy ( int OutId )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
return DataNew . GetOutCKModelBuy ( OutId ) ;
}
# endregion
#region 返回出库明细
[WebMethod(EnableSession = true)]
public List < HW_GoodsOutCKNew > GetOutCKDetailListBuy ( int OutId )
{
Pages . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
var list = DataNew . GetOutCKDetailListForTM ( OutId ) ;
return list ;
}
# endregion
#region 导出采购单
[WebMethod(EnableSession = true)]
public string GetListBuyOutExcel ( int outid )
{
Pages . Login ( this . Session ) ;
var obj = new DD_OrderData ( ) ;
var list = DataNew . GetOutCKDetailListBuyExcel ( outid ) ;
if ( list = = null )
return "" ;
int i = 0 ;
foreach ( var md in list )
{
if ( i = = 1 )
{
md . OutCode = "" ;
md . BuyName = "" ;
md . BuyPhone = "" ;
}
i + + ;
}
var md2 = new HW_GoodsOutCKNew ( ) ;
md2 . PostionDesc = "Total: " ;
md2 . FinalPrice = list [ 0 ] . Price ;
list . Add ( md2 ) ;
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "OutCode" , "OrderCode" , DbType . String , "" ) ;
listColumns . Add ( "BuyName" , "BuyName" , DbType . String , "" ) ;
listColumns . Add ( "BuyPhone" , "BuyPhone" , DbType . String , "" ) ;
listColumns . Add ( "GoodsCode" , "Products Code" , DbType . String , "" ) ;
listColumns . Add ( "SKU1" , "SKU" , DbType . String , "" ) ;
listColumns . Add ( "OutNum" , "Selling Quantity" , DbType . String , "" ) ;
listColumns . Add ( "Price" , "Unit Price" , DbType . String , "" ) ;
listColumns . Add ( "OffPrice" , "Discount" , DbType . String , "" ) ;
listColumns . Add ( "PostionDesc" , "Storage Location" , DbType . String , "" ) ;
listColumns . Add ( "FinalPrice" , "Total price" , DbType . String , "" ) ;
MicrosoftExcel obj2 = new MicrosoftExcel ( ) ;
return obj2 . Export ( list , listColumns ) ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_IsSp ( int detailid , Boolean issp )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdatetGoodsIsSP ( detailid , issp ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum1 ( int detailid , int num1 )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateBuyBFNum1 ( detailid , num1 ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum2 ( int detailid , int num2 )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateBuyBFNum2 ( detailid , num2 ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum4 ( int detailid , int num3 )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateBuyBFNum4 ( detailid , num3 ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum3 ( int detailid , DateTime ? JH_Date )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateBuyBFNum3 ( detailid , JH_Date ) ;
return 1 ;
}
# endregion
#region 保存分类
[WebMethod(EnableSession = true)]
public int SaveGoodsSort ( HW_GoodsSortModel model )
{
Pages . Login ( this . Session ) ;
int CompanyId = Convert . ToInt32 ( Session [ "CompanyId" ] ) ;
var obj = new HuoWuData ( ) ;
model . CompanyId = CompanyId ;
if ( model . ParentId > 0 )
{
model . SortCode = model . SortCode . ToUpper ( ) ;
var md = obj . GetSortModelModel ( model . ParentId . Value ) ;
if ( md ! = null )
{
model . Layer = md . Layer + 1 ;
model . ParentCode = md . EnglishCode + md . ParentCode ;
model . EnglishCode = model . SortCode ;
model . ParentSort = md . SortNo ;
}
}
int Pid = 0 ;
if ( model . ParentId ! = null )
Pid = model . ParentId . Value ;
//if (obj.IsGoodsEgCode(CompanyId, model.SortId.Value, model.EnglishCode, Pid) > 0)
//{
// return -1;
//}
model . SortNo = model . SortNo . PadLeft ( 3 , '0' ) ;
int SortId = obj . SaveGoodsSort ( model ) ;
return 0 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum ( int detailid , int num1 , int num2 )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateBuyBFNum ( detailid , num1 , num2 ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Clear_BFNum ( )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateClearBFNum ( ) ;
return 1 ;
}
# endregion
#region 导出备货
[WebMethod(EnableSession = true)]
public string GetList_GoodsBF ( int CK )
{
var obj = new HuoWuData ( ) ;
var list = DataNew . GetListBFNum ( CK ) ;
if ( list = = null )
return "" ;
var hjnum = list . Sum ( n = > n . BHNum ) ;
var hjtj = list . Sum ( n = > n . TSolid ) ;
var md = new HW_GoodsDetailNew ( ) ;
md . SKU1 = "合计:" ;
md . BHNum = hjnum ;
md . TSolid = hjtj ;
list . Add ( md ) ;
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "SKU1" , "货号" , DbType . String , "" ) ;
listColumns . Add ( "Solid" , "CMB" , DbType . Decimal , "" ) ;
listColumns . Add ( "BHNum" , "Number" , DbType . Int32 , "" ) ;
listColumns . Add ( "TSolid" , "Total立方" , DbType . Decimal , "" ) ;
listColumns . Add ( "JH_Date" , "交货日期" , DbType . String , "yyyy-MM-dd" ) ;
listColumns . Add ( "Cert" , "已经出" , DbType . Int32 , "" ) ;
MicrosoftExcelNew obj2 = new MicrosoftExcelNew ( ) ;
return obj2 . Export ( list , listColumns ) ;
}
# endregion
#region 导出库存总立方前一百/两百
[WebMethod(EnableSession = true)]
public string GetList_GoodsSolid ( int count )
{
var obj = new HuoWuData ( ) ;
var list = DataNew . GetGoodsSolidTopDatas ( count ) ;
if ( list = = null )
return "" ;
var hjObj = new GoodsSolidTopModel ( ) ;
hjObj . SKU = "合计" ;
hjObj . WestNum = list . Sum ( r = > r . WestNum ) ;
hjObj . WestSolids = list . Sum ( r = > r . WestSolids ) ;
hjObj . EastNum = list . Sum ( r = > r . EastNum ) ;
hjObj . EastSolids = list . Sum ( r = > r . EastSolids ) ;
hjObj . TotalNum = list . Sum ( r = > r . TotalNum ) ;
hjObj . TotalSolid = list . Sum ( r = > r . TotalSolid ) ;
list . Add ( hjObj ) ;
//创建工作薄
HSSFWorkbook workbook = new HSSFWorkbook ( ) ;
HSSFSheet sheet = ( HSSFSheet ) workbook . CreateSheet ( "Sheet1" ) ;
sheet . SetColumnWidth ( 0 , 18 * 256 ) ;
var drawing = sheet . CreateDrawingPatriarch ( ) ;
//填充列标题以及样式
int rowsNum = 0 ; //行号
HSSFRow headerRow = ( HSSFRow ) sheet . CreateRow ( rowsNum ) ;
headerRow . CreateCell ( 0 , CellType . STRING ) . SetCellValue ( "图片" ) ;
headerRow . CreateCell ( 1 , CellType . STRING ) . SetCellValue ( "SKU" ) ;
headerRow . CreateCell ( 2 , CellType . STRING ) . SetCellValue ( "编号" ) ;
headerRow . CreateCell ( 3 , CellType . STRING ) . SetCellValue ( "名称" ) ;
headerRow . CreateCell ( 4 , CellType . STRING ) . SetCellValue ( "人员" ) ;
headerRow . CreateCell ( 5 , CellType . STRING ) . SetCellValue ( "单个立方" ) ;
headerRow . CreateCell ( 6 , CellType . STRING ) . SetCellValue ( "西部库存数量" ) ;
headerRow . CreateCell ( 7 , CellType . STRING ) . SetCellValue ( "西部库存立方" ) ;
headerRow . CreateCell ( 8 , CellType . STRING ) . SetCellValue ( "东部库存数量" ) ;
headerRow . CreateCell ( 9 , CellType . STRING ) . SetCellValue ( "东部库存立方" ) ;
headerRow . CreateCell ( 10 , CellType . STRING ) . SetCellValue ( "总库存数量" ) ;
headerRow . CreateCell ( 11 , CellType . STRING ) . SetCellValue ( "总库存立方" ) ;
rowsNum = 1 ; //行号
foreach ( var link in list )
{
var pictureData = GetImageFromUrl ( link . FirstImgUrl ) ;
if ( pictureData ! = null )
{
var pictureIndex = workbook . AddPicture ( pictureData , PictureType . PNG ) ;
// 在每一行的第一列插入图片
var pictureCell = sheet . CreateRow ( rowsNum ) . CreateCell ( 0 ) ;
sheet . GetRow ( rowsNum ) . Height = 80 * 20 ;
pictureCell . CellStyle = workbook . CreateCellStyle ( ) ;
var anchor = new HSSFClientAnchor ( 0 , 0 , 0 , 0 , 0 , rowsNum , 1 , rowsNum + 1 ) ;
anchor . AnchorType = 2 ;
var picture = drawing . CreatePicture ( anchor , pictureIndex ) ;
}
else
{
var _dataCell = sheet . CreateRow ( rowsNum ) . CreateCell ( 0 ) ;
sheet . GetRow ( rowsNum ) . Height = 80 * 20 ;
_dataCell . SetCellValue ( "" ) ;
}
// 在每一行的第二列插入数据
sheet . GetRow ( rowsNum ) . CreateCell ( 1 ) . SetCellValue ( link . SKU ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 2 ) . SetCellValue ( link . GoodsCode ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 3 ) . SetCellValue ( link . GoodsName ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 4 ) . SetCellValue ( link . UserName ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 5 ) . SetCellValue ( link . SingleSolid . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 6 ) . SetCellValue ( link . WestNum . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 7 ) . SetCellValue ( link . WestSolids . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 8 ) . SetCellValue ( link . EastNum . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 9 ) . SetCellValue ( link . EastSolids . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 10 ) . SetCellValue ( link . TotalNum . ToString ( ) ) ;
sheet . GetRow ( rowsNum ) . CreateCell ( 11 ) . SetCellValue ( link . TotalSolid . ToString ( ) ) ;
rowsNum + + ;
}
string filename = Guid . NewGuid ( ) . ToString ( ) + ".xls" ;
string DirectoryName = AppDomain . CurrentDomain . BaseDirectory + "ServerCookies" ;
if ( System . IO . Directory . Exists ( DirectoryName ) = = false ) System . IO . Directory . CreateDirectory ( DirectoryName ) ;
string ServerFileName = DirectoryName + "/" + filename ;
//保存
using ( FileStream fs = new FileStream ( ServerFileName , FileMode . Create , FileAccess . Write ) )
{
workbook . Write ( fs ) ;
}
workbook . Dispose ( ) ;
return "ServerCookies/" + filename ;
}
// 从URL获取图片数据
public byte [ ] GetImageFromUrl ( string url )
{
try
{
using ( WebClient webClient = new WebClient ( ) )
{
return webClient . DownloadData ( new Uri ( url ) ) ;
}
}
catch ( Exception ex )
{
return null ;
}
}
# endregion
#region 返回
[WebMethod(EnableSession = true)]
public HW_GoodsDetailNew GetGoodsModelForBF ( int detailid )
{
PagesNew . Login ( this . Session ) ;
var obj = new HuoWuData ( ) ;
return DataNew . GetGoodsModelForBF ( detailid ) ;
}
# endregion
[WebMethod(EnableSession = true)]
public string GetGoodsCodeLabel ( string code , int num )
{
PagesNew . Login ( base . Session ) ;
OrderPrintData data = new OrderPrintData ( ) ;
DataTable table = new DataTable ( ) ;
table . Columns . Add ( "SKU2" ) ;
string str2 = "" ;
string wordTemplatePath = "" ;
for ( int i = 0 ; i < num ; i + + )
{
wordTemplatePath = "Scripts/code.doc" ;
DataRow row = table . NewRow ( ) ;
row [ "SKU2" ] = code ;
table . Rows . Add ( row ) ;
}
TableColumnCollection listColumns = new TableColumnCollection ( ) ;
listColumns . Add ( "SKU2" , "SKU2" , DbType . String , "" ) ;
MicrosoftWord word = new MicrosoftWord ( ) ;
if ( wordTemplatePath ! = null )
{
str2 = word . Export ( wordTemplatePath , table , listColumns , ".pdf" ) ;
}
return str2 ;
}
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateGoodsUser ( int shopid , string name , int userid )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateGoodsUser ( shopid , name , userid ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateSalesType ( int detailid , int SalesType )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateSalesType ( detailid , SalesType ) ;
return 1 ;
}
# endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateIsExamine ( int goodsId , int isExamine )
{
PagesNew . Login ( this . Session ) ;
DataNew . UpdateIsExamine ( goodsId , isExamine ) ;
return 1 ;
}
# endregion
#region 取消智能库存页面有计划未确认的采购数据
[WebMethod(EnableSession = true)]
public ApiResponseModel CancelCGPlanByDetailids ( string detailids )
{
PagesNew . Login ( base . Session ) ;
var robj = new ApiResponseModel ( ) ;
detailids = detailids . TrimEnd ( ',' ) ;
try
{
int count = DataNew . GetCancelCGPlanNoQueRen ( detailids ) ;
if ( count > 0 )
{
robj . Code = 0 ;
robj . Message = "取消失败:只能取消状态是有计划未确认的数据" ;
return robj ;
}
DataNew . CancelCGPlan ( detailids , DateTime . Now . Year ) ;
robj . Code = 1 ;
robj . Message = "Success" ;
}
catch ( Exception ex )
{
robj . Code = 0 ;
robj . Message = "取消失败:" + ex . Message ;
}
return robj ;
}
# endregion
#region 显示隐藏货物信息--商品信息页面的数据
[WebMethod(EnableSession = true)]
public ApiResponseModel XSYCGoodsInfoData ( int goodsId , int isyc )
{
PagesNew . Login ( base . Session ) ;
var robj = new ApiResponseModel ( ) ;
try
{
DataNew . UpdateGoodsInfoXSYC ( goodsId , isyc ) ;
robj . Code = 1 ;
robj . Message = "Success" ;
}
catch ( Exception ex )
{
robj . Code = 0 ;
robj . Message = "取消失败:" + ex . Message ;
}
return robj ;
}
# endregion
#region 保存产品补贴价格
[WebMethod(EnableSession = true)]
public APIReturnModel SaveGoodsBTPrice ( decimal? btPrice , int goodsid )
{
PagesNew . Login ( base . Session ) ;
var rmodel = new APIReturnModel ( ) ;
try
{
DataNew . SaveGoodsBTPrice ( goodsid , btPrice ) ;
rmodel . Code = 1 ;
rmodel . Message = "成功" ;
}
catch ( Exception ex )
{
rmodel . Code = 0 ;
rmodel . Message = "失败:" + ex . Message ;
}
return rmodel ;
}
# endregion
#region 刷新2024-04-01到2024-07-31的此产品订单补贴费用
[WebMethod(EnableSession = true)]
public APIReturnModel UpdateOrderBTPrice ( int goodsid , int platid )
{
PagesNew . Login ( base . Session ) ;
var rmodel = new APIReturnModel ( ) ;
try
{
DataNew . UpdateOrderBTPrice ( goodsid , platid ) ;
rmodel . Code = 1 ;
rmodel . Message = "成功" ;
}
catch ( Exception ex )
{
rmodel . Code = 0 ;
rmodel . Message = "失败:" + ex . Message ;
}
return rmodel ;
}
# endregion
}
}