|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Services;
|
|
|
using TradeModel;
|
|
|
using TradeData;
|
|
|
using NetLibrary.Data;
|
|
|
using System.Data;
|
|
|
using NetLibrary.ReportPrint;
|
|
|
using NetLibrary;
|
|
|
|
|
|
namespace TradeManageNew
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// CaiGouServiceNew 的摘要说明
|
|
|
/// </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 CaiGouServiceNew : System.Web.Services.WebService
|
|
|
{
|
|
|
|
|
|
[WebMethod]
|
|
|
public string HelloWorld()
|
|
|
{
|
|
|
return "Hello World";
|
|
|
}
|
|
|
|
|
|
#region 海外仓状态
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int UpdateChaseStateForHWC(int ChaseId, int PostState)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
|
|
|
DataNew.UpdateChaseStateForHWC(ChaseId, PostState);
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsHWCOutDetail> GetGoodsForHWCOutList2(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(base.Session);
|
|
|
|
|
|
return DataNew.GetPurchaseGoodsOutHWC(ChaseId);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsCGDetail> GetPurchaseInGoodsForHWC(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(base.Session);
|
|
|
|
|
|
return DataNew.GetPurchaseGoodsForHWC(ChaseId);
|
|
|
}
|
|
|
|
|
|
#region 查询海外仓货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsHWCOutDetailNew> GetPurchaseGoodsOut2(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
|
|
|
|
|
|
var list = DataNew.GetPurchaseGoodsOut2(ChaseId);
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<CG_PurchaseGoods> GetListGoodsNum(int Num,string ChaseCode, string GoodsCode)
|
|
|
{
|
|
|
PagesNew.Login(base.Session);
|
|
|
|
|
|
return DataNew.GetListGoodsNum(Num,ChaseCode, GoodsCode);
|
|
|
}
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public void UpdateCGStoreNum()
|
|
|
{
|
|
|
PagesNew.Login(base.Session);
|
|
|
|
|
|
DataNew.UpdateCGStoreNum();
|
|
|
}
|
|
|
#region 查询海外仓货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<HW_GoodsHWCOutDetailNew>> GetGoodsForHWCOut(int Type, string ids, string GoodsName, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Sort = "d.ChaseId,c.GoodsCode,b.TypeCode";
|
|
|
Param.Add("d.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
|
|
|
if (ids != "")
|
|
|
Param.Add("a.Id", "not in", ids.TrimEnd(','), DbType.String);
|
|
|
if (Type == 1 && GoodsName != "")
|
|
|
{
|
|
|
Param.Add("(c.GoodsName", "like", GoodsName, DbType.String);
|
|
|
Param.Add("c.GoodsCode", "like", GoodsName, "or", ")", DbType.String);
|
|
|
}
|
|
|
else if (Type == 2 && GoodsName != "")
|
|
|
{
|
|
|
|
|
|
Param.Add("d.ChaseCode", "like", GoodsName, DbType.String);
|
|
|
}
|
|
|
else if (Type == 3 && GoodsName != "")
|
|
|
{
|
|
|
|
|
|
Param.Add("d.BuyCode", "like", GoodsName, DbType.String);
|
|
|
}
|
|
|
Param.Add("a.GoodsNum-isnull(a.InGoodsNum,0)-isnull(a.TJOutNum,0)", ">", 0, DbType.Int32);
|
|
|
// Param.Add("isnull(SJOutNum,0)", "=", 0, DbType.Int32);
|
|
|
|
|
|
|
|
|
|
|
|
JsonModel<List<HW_GoodsHWCOutDetailNew>> resultModel = new JsonModel<List<HW_GoodsHWCOutDetailNew>>();
|
|
|
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListOutGoodsInfo2(Param, PageIndex, PageSize, Sort, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存海外仓
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int SaveChaseForHWC(CG_PurchaseNew model, List<HW_GoodsHWCOutDetailNew> Goodslist)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
var obj = new CG_ChaseData();
|
|
|
model.CompanyId = CompanyId;
|
|
|
model.InUserId = UserId;
|
|
|
if (model.InName == null || model.InName == "")
|
|
|
model.InName = Name;
|
|
|
else
|
|
|
if (model.InName != "" && model.InName.Contains(Name) == false)
|
|
|
model.InName = model.InName + "," + Name;
|
|
|
|
|
|
|
|
|
|
|
|
model.IsGJ = 1;
|
|
|
model.IsDelete = 0;
|
|
|
if (model.ChaseId == null || model.ChaseId == 0)
|
|
|
{
|
|
|
model.InDate = DateTime.Now;
|
|
|
|
|
|
}
|
|
|
|
|
|
int hj = 0;
|
|
|
decimal hjlf = 0;
|
|
|
if (Goodslist != null)
|
|
|
{
|
|
|
foreach (var md in Goodslist)
|
|
|
{
|
|
|
|
|
|
if (md.SJOutNum != null)
|
|
|
{
|
|
|
hj += md.SJOutNum.Value;
|
|
|
if (md.Solid != null)
|
|
|
hjlf += md.Solid.Value * md.SJOutNum.Value;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
model.GoodsNum = hj;
|
|
|
model.TSoild = hjlf;
|
|
|
int ChaseId = DataNew.SavePurchaseForTM2(model);
|
|
|
|
|
|
if (Goodslist != null)
|
|
|
{
|
|
|
foreach (var md in Goodslist)
|
|
|
{
|
|
|
|
|
|
|
|
|
md.PState = model.PostState;
|
|
|
md.GJChaseId = ChaseId;
|
|
|
if (md.IsAdd == 1)
|
|
|
DataNew.UpdateHWCGoods22(md);
|
|
|
// else
|
|
|
// DataNew.UpdateHWCGoods(md);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (model.PostState >= 6)
|
|
|
obj.UpdateHWCGoodsFee(ChaseId);
|
|
|
|
|
|
return ChaseId;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询采购单入库物品明细
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsCGDetailNew> GetPurchaseInGoodsForTM3(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
var list = DataNew.GetPurchaseGoodsForTM3(ChaseId);
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
#region 查询海外仓货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public void DeleteHWCGoods(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
|
|
|
|
|
|
DataNew.DeleteHWCGoods(ChaseId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
public string GetOutCode()
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
|
|
|
Random r = new Random();
|
|
|
string a = r.Next(10000, 99999).ToString();
|
|
|
string Code = DateTime.Now.ToString("yyyyMMddhhmmss") + a;
|
|
|
|
|
|
|
|
|
return Code;
|
|
|
|
|
|
}
|
|
|
#region 保存海外仓入库
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int SaveChaseInStoreForTM3(int ChaseId, string PostionCode, int PostState, int IsGC, int IsBH, List<CG_ChaseInStoreNew> list, int IsZJ, int IsDH)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
string Log = "";
|
|
|
if (list != null)
|
|
|
{
|
|
|
|
|
|
int Num = 0;
|
|
|
|
|
|
var obj1 = new HuoWuData();
|
|
|
HW_GoodsInRecord model = new HW_GoodsInRecord();
|
|
|
model.CompanyId = CompanyId;
|
|
|
model.InDate = DateTime.Now;
|
|
|
model.InUserId = UserId;
|
|
|
model.InName = Name;
|
|
|
model.InReason = "采购入库";
|
|
|
model.InCode = GetOutCode();
|
|
|
model.InNum = Num;
|
|
|
model.IsDelete = 0;
|
|
|
model.ChaseId = ChaseId;
|
|
|
var InId = obj1.SaveGoodsInRecordForTM(model);
|
|
|
Log = "入库单号:" + model.InCode + "采购入库";
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
|
|
|
HW_GoodsInRK rkmd = new HW_GoodsInRK();
|
|
|
rkmd.DetailId = md.GoodsDetailId;
|
|
|
rkmd.InId = InId;
|
|
|
rkmd.InNum = md.AddNum;
|
|
|
rkmd.StoreId = 0;
|
|
|
rkmd.PostionCode = md.PostionCode;
|
|
|
int RKId = obj1.SaveInRecordDetailForTM(rkmd);
|
|
|
//md.ChaseId = ChaseId;
|
|
|
//if (md.Id == null || md.Id.Value <= 0)
|
|
|
// md.InDate = DateTime.Now;
|
|
|
//md.InUserId = UserId;
|
|
|
//md.RKDetailId = RKId;
|
|
|
//obj.SaveChaseInStoreNewForTM(md);
|
|
|
|
|
|
if (md.AddNum > 0)
|
|
|
{
|
|
|
//Num += md.AddNum.Value;
|
|
|
|
|
|
//int InGoodsNum = md.AddNum.Value;
|
|
|
//if (IsGC == 1)
|
|
|
// InGoodsNum = 0;
|
|
|
//obj.UpdateGoodsNumForTM(md.GoodsDetailId.Value, md.AddNum.Value, InGoodsNum, 0);
|
|
|
DataNew.SaveInchaseGoodsForTM3(md.Id.Value,ChaseId, UserId, md.Price, md.PostPrice, md.GoodsDetailId.Value, md.AddNum.Value, RKId, md.ErrorDesc, md.PostionCode, PostState, md.GoodsRate);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
// int GoodsState = 1;
|
|
|
//if (IsDH == 1)
|
|
|
//{
|
|
|
// GoodsState = 2;
|
|
|
// IsDH = 3;
|
|
|
//}
|
|
|
//else
|
|
|
// IsDH = 2;
|
|
|
obj.UpdateChaseStateForTM2(ChaseId, PostState, IsDH, 1);
|
|
|
//if (IsDH == 1 && IsGC == 0)
|
|
|
// obj.UpdateGoodsInNum(ChaseId);
|
|
|
|
|
|
DataNew.UpdateGoodsNumNew4(ChaseId);
|
|
|
//if (IsGC == 1 || IsBH == 1)
|
|
|
//{
|
|
|
// var nolist = obj.UpdateOrderBuyDateForTM(ChaseId);//计算采购分配时间
|
|
|
// if (nolist != null)//查出参考<0的货物
|
|
|
// {
|
|
|
// string qxbuyids = "";
|
|
|
// string cgbuyids = "";
|
|
|
// foreach (var md in nolist)
|
|
|
// {
|
|
|
// int LeftNum = md.LeftNum.Value;
|
|
|
// var olist = obj.SelectOrderBuyForTM(md.DetailId.Value);//按等级和时间倒排订单
|
|
|
// if (olist != null && olist.Count>0)
|
|
|
// {
|
|
|
// foreach (var omd in olist)
|
|
|
// {
|
|
|
// if (LeftNum > 0) //原来有购买时间的取消时间
|
|
|
// {
|
|
|
// qxbuyids += omd.OrderId.Value.ToString() + ",";
|
|
|
// }
|
|
|
// else if (LeftNum <= 0 && omd.BuyDate == null)//原来没有购买时间的修改时间
|
|
|
// {
|
|
|
// cgbuyids += omd.OrderId.Value.ToString() + ",";
|
|
|
// }
|
|
|
|
|
|
// LeftNum = LeftNum - omd.GoodsNum.Value;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// if (cgbuyids != "")
|
|
|
// {
|
|
|
// obj.GetOrderBuyDate(cgbuyids.Trim(','));
|
|
|
// }
|
|
|
// if (qxbuyids != "")
|
|
|
// {
|
|
|
// obj.CancelBuyDate(qxbuyids.Trim(','));
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
PagesNew.SaveLog(UserId, "采购入库", ChaseId.ToString() + Log, ChaseId);
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询采购货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<HW_CGGoods>> GetListCGGoodsInfoNeed(string GoodsCode, string SKU, int PageIndex, int PageSize, string Sort)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
//if (DeptId > 0)
|
|
|
// Param.Add("a.DeptId", "=", DeptId, DbType.Int32);
|
|
|
|
|
|
if (GoodsCode != "")
|
|
|
{
|
|
|
|
|
|
GoodsCode = GoodsCode.Trim();
|
|
|
Param.Add("(a.GoodsCode", "=", GoodsCode, DbType.String);
|
|
|
Param.Add("a.GoodsName", "like", GoodsCode, "or", ")", DbType.String);
|
|
|
}
|
|
|
if (SKU != "")
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Param.Add("b.SKU1", "=", SKU, "or", DbType.String);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Param.Add("isnull(b.CGNum,0)", ">", 0, DbType.Int32);
|
|
|
|
|
|
JsonModel<List<HW_CGGoods>> resultModel = new JsonModel<List<HW_CGGoods>>();
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
string sorta = Sort;
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListCGGoodsInfoForNeed(Param, PageIndex, PageSize, sorta, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
|
|
|
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 查询采购物品明细
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsSPDetail> GetGoodsSPDetailForNees(string DetailIds)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new HuoWuData();
|
|
|
|
|
|
var list = DataNew.GetGoodsSPDetailForNeed(DetailIds.TrimEnd(','));
|
|
|
string Remark = "";
|
|
|
string dids = "";
|
|
|
if (list != null && list.Count > 0)
|
|
|
{
|
|
|
|
|
|
int GId = 0;
|
|
|
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
if (md.BuyNum > 0)
|
|
|
dids += md.GoodsId.ToString() + ",";
|
|
|
if (md.GoodsId != GId)
|
|
|
{
|
|
|
|
|
|
if (md.GRemark != null && md.GRemark != "")
|
|
|
Remark += md.GRemark + "\r\n";
|
|
|
if (md.DeptRemark != null && md.DeptRemark != "")
|
|
|
{
|
|
|
int days = 10;
|
|
|
if (md.NoticeDays != null)
|
|
|
days = md.NoticeDays.Value;
|
|
|
|
|
|
int a = obj.GetNowGoodsRemark(md.DetailId.Value, days);
|
|
|
if (a <= 0)
|
|
|
{
|
|
|
Remark += md.DeptRemark + "\r\n";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
GId = md.GoodsId.Value;
|
|
|
}
|
|
|
list[0].Remark = Remark;
|
|
|
|
|
|
}
|
|
|
if (dids != "")
|
|
|
{
|
|
|
var tlist = obj.GetChaseToday(dids.Trim(','), DateTime.Today);
|
|
|
if (tlist != null && list != null && list.Count > 0)
|
|
|
{
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
var tmd = tlist.Find(n => n.GoodsId == md.GoodsId);
|
|
|
if (tmd != null)
|
|
|
{
|
|
|
md.IsTotay = 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 保存采购数量
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public void SaveChaseCGNUm(List<HW_GoodsSPDetail> Goodslist, List<HW_GoodsSPDetail> Goodslist2,int ChaseId,string lscode)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
DataNew.update_ChaseLsCode(lscode, ChaseId);
|
|
|
if (Goodslist != null)
|
|
|
{
|
|
|
foreach (var md in Goodslist)
|
|
|
{
|
|
|
var ccmd = Goodslist2.Find(n => n.DetailId == md.DetailId);
|
|
|
int OldNum = 0;
|
|
|
if (ccmd != null && ccmd.OldBuyNum != null)
|
|
|
OldNum = ccmd.OldBuyNum.Value;
|
|
|
DataNew.UpdateBuyCGNum(md.DetailId.Value, OldNum, md.BuyNum.Value);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 分页查询海外仓采购单
|
|
|
[WebMethod(Description = "分页查询采购单入库", EnableSession = true)]
|
|
|
public JsonModel<List<CG_Purchase>> GetListCG_InchaseForHWC(string ChaseCode, int DHState, DateTime? SDate, DateTime? EDate, DateTime? SRKDate, DateTime? ERKDate, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
string Sort = "a.ChaseId desc";
|
|
|
if (ChaseCode != "")
|
|
|
{
|
|
|
Param.Add("(a.ChaseCode", "like", ChaseCode, DbType.String);
|
|
|
Param.Add("a.BuyCode", "like", ChaseCode, "or", ")", DbType.String);
|
|
|
|
|
|
}
|
|
|
if (DHState > -1)
|
|
|
Param.Add("a.PostState", "=", DHState, DbType.Int32);
|
|
|
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
Param.Add("a.IsGJ", "=", 1, DbType.Int32);
|
|
|
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
|
|
|
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
if (SRKDate != null)
|
|
|
Param.Add("a.DoneDate", ">=", SRKDate, DbType.DateTime);
|
|
|
if (ERKDate != null)
|
|
|
Param.Add("a.DoneDate", "<", ERKDate.Value.AddDays(1), DbType.DateTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JsonModel<List<CG_Purchase>> resultModel = new JsonModel<List<CG_Purchase>>();
|
|
|
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListCG_PurchaseForHWC(Param, PageIndex, PageSize, Sort, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
//if (IsDetail == 1 && resultModel.DataSource != null)
|
|
|
//{
|
|
|
// string Ids = "";
|
|
|
// foreach (var md in resultModel.DataSource)
|
|
|
// {
|
|
|
// Ids += md.ChaseId.ToString() + ",";
|
|
|
|
|
|
// }
|
|
|
// if (Ids != "")
|
|
|
// {
|
|
|
// var list1 = obj.GetchaseGoodsList(Ids.Trim(','));
|
|
|
// if (list1 != null)
|
|
|
// {
|
|
|
// foreach (var md in resultModel.DataSource)
|
|
|
// {
|
|
|
// var list2 = list1.FindAll(n => n.ChaseId == md.ChaseId);
|
|
|
// if (list2 != null)
|
|
|
// {
|
|
|
|
|
|
// md.GoodsList = list2;
|
|
|
|
|
|
|
|
|
// }
|
|
|
// if (md.ErrorInfo != null && md.ErrorInfo != "")
|
|
|
// {
|
|
|
// if (md.ErrorInfo.Length > 100)
|
|
|
// md.SimpErrorInfo = md.ErrorInfo.Substring(0, 100) + "...";
|
|
|
// else
|
|
|
// md.SimpErrorInfo = md.ErrorInfo;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
//else if (resultModel.DataSource != null)
|
|
|
//{
|
|
|
// foreach (var md in resultModel.DataSource)
|
|
|
// {
|
|
|
|
|
|
// if (md.ErrorInfo != null && md.ErrorInfo != "")
|
|
|
// {
|
|
|
// if (md.ErrorInfo.Length > 100)
|
|
|
// md.SimpErrorInfo = md.ErrorInfo.Substring(0, 100) + "...";
|
|
|
// else
|
|
|
// md.SimpErrorInfo = md.ErrorInfo;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 分页查询海外仓采购单
|
|
|
[WebMethod(Description = "分页查询采购单入库", EnableSession = true)]
|
|
|
public JsonModel<List<CG_PurchaseNew>> GetListCG_InchaseForHWC2(string ChaseCode, int StoreId, int DHState, DateTime? SDate, DateTime? EDate, DateTime? SRKDate, DateTime? ERKDate, string Code, string sort, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
string Sort = sort;// "a.PostState,a.BackDate";
|
|
|
if (ChaseCode != "")
|
|
|
{
|
|
|
Param.Add("(a.ChaseCode", "like", ChaseCode, DbType.String);
|
|
|
Param.Add("a.BuyCode", "like", ChaseCode, "or", ")", DbType.String);
|
|
|
|
|
|
}
|
|
|
if (DHState > -1)
|
|
|
Param.Add("a.PostState", "=", DHState, DbType.Int32);
|
|
|
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
if (StoreId > 0)
|
|
|
Param.Add("a.StoreId", "=", StoreId, DbType.Int32);
|
|
|
Param.Add("a.IsGJ", "=", 1, DbType.Int32);
|
|
|
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
|
|
|
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
if (SRKDate != null)
|
|
|
Param.Add("a.DoneDate", ">=", SRKDate, DbType.DateTime);
|
|
|
if (ERKDate != null)
|
|
|
Param.Add("a.DoneDate", "<", ERKDate.Value.AddDays(1), DbType.DateTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JsonModel<List<CG_PurchaseNew>> resultModel = new JsonModel<List<CG_PurchaseNew>>();
|
|
|
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListCG_PurchaseForHWC2(Code, Param, PageIndex, PageSize, Sort, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
#region 查询海外仓货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string GetPurchaseGoodsOutExcel(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
|
|
|
|
|
|
var list = DataNew.GetPurchaseGoodsOut2(ChaseId);
|
|
|
if (list == null)
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
TableColumnCollection listColumns = new TableColumnCollection();
|
|
|
listColumns.Add("GoodsCode", "货物编号", DbType.String, "");
|
|
|
listColumns.Add("GoodsName", "货物名称", DbType.String, "");
|
|
|
listColumns.Add("TypeDesc", "描述", DbType.String, "");
|
|
|
listColumns.Add("Solid", "单个体积", DbType.String, "");
|
|
|
listColumns.Add("GoodsPrice", "采购单价", DbType.String, "");
|
|
|
listColumns.Add("GoodsNum", "合同采购数量", DbType.String, "");
|
|
|
listColumns.Add("GoodsRate", "货物税率", DbType.String, "");
|
|
|
listColumns.Add("SJOutNum", "海外仓数量", DbType.String, "");
|
|
|
|
|
|
|
|
|
|
|
|
MicrosoftExcel obj2 = new MicrosoftExcel();
|
|
|
return obj2.Export(list, listColumns);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存采购入库
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int SaveChaseInStoreForTM2(int ChaseId, string PostionCode, int IsGC, int IsBH, List<CG_ChaseInStore> list, int IsZJ, int IsDH)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
string Log = "";
|
|
|
if (list != null)
|
|
|
{
|
|
|
|
|
|
int Num = 0;
|
|
|
|
|
|
var obj1 = new HuoWuData();
|
|
|
HW_GoodsInRecord model = new HW_GoodsInRecord();
|
|
|
model.CompanyId = CompanyId;
|
|
|
model.InDate = DateTime.Now;
|
|
|
model.InUserId = UserId;
|
|
|
model.InName = Name;
|
|
|
model.InReason = "采购入库";
|
|
|
model.InCode = GetOutCode();
|
|
|
model.InNum = Num;
|
|
|
model.IsDelete = 0;
|
|
|
model.ChaseId = ChaseId;
|
|
|
var InId = obj1.SaveGoodsInRecordForTM(model);
|
|
|
Log = "入库单号:" + model.InCode + "采购入库";
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
|
|
|
if (md.AddNum > 0)
|
|
|
{
|
|
|
HW_GoodsInRK rkmd = new HW_GoodsInRK();
|
|
|
rkmd.DetailId = md.GoodsDetailId;
|
|
|
rkmd.InId = InId;
|
|
|
rkmd.InNum = md.AddNum;
|
|
|
rkmd.StoreId = 0;
|
|
|
rkmd.PostionCode = md.PostionCode;
|
|
|
int RKId = obj1.SaveInRecordDetailForTM(rkmd);
|
|
|
|
|
|
//md.ChaseId = ChaseId;
|
|
|
//if (md.Id == null || md.Id.Value <= 0)
|
|
|
// md.InDate = DateTime.Now;
|
|
|
//md.InUserId = UserId;
|
|
|
//md.RKDetailId = RKId;
|
|
|
//obj.SaveChaseInStoreNewForTM(md);
|
|
|
|
|
|
|
|
|
//Num += md.AddNum.Value;
|
|
|
|
|
|
//int InGoodsNum = md.AddNum.Value;
|
|
|
//if (IsGC == 1)
|
|
|
// InGoodsNum = 0;
|
|
|
//obj.UpdateGoodsNumForTM(md.GoodsDetailId.Value, md.AddNum.Value, InGoodsNum, 0);
|
|
|
obj.SaveInchaseGoodsForTM(ChaseId, UserId, md.Price, md.PostPrice, md.GoodsDetailId.Value, md.AddNum.Value, RKId, md.ErrorDesc, md.PostionCode);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
if (md.OutNum >= 0)
|
|
|
{
|
|
|
obj.SaveInchaseGoodsForTM2(ChaseId, md.GoodsDetailId.Value, md.OutNum.Value);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
// int GoodsState = 1;
|
|
|
//if (IsDH == 1)
|
|
|
//{
|
|
|
// GoodsState = 2;
|
|
|
// IsDH = 3;
|
|
|
//}
|
|
|
//else
|
|
|
// IsDH = 2;
|
|
|
obj.UpdateChaseStateForTM(ChaseId, IsDH, 1);
|
|
|
//if (IsDH == 1 && IsGC == 0)
|
|
|
// obj.UpdateGoodsInNum(ChaseId);
|
|
|
|
|
|
// obj.UpdateChaseGoodsNum(ChaseId);
|
|
|
DataNew.UpdateGoodsNumNew4(ChaseId);
|
|
|
//if (IsGC == 1 || IsBH == 1)
|
|
|
//{
|
|
|
// var nolist = obj.UpdateOrderBuyDateForTM(ChaseId);//计算采购分配时间
|
|
|
// if (nolist != null)//查出参考<0的货物
|
|
|
// {
|
|
|
// string qxbuyids = "";
|
|
|
// string cgbuyids = "";
|
|
|
// foreach (var md in nolist)
|
|
|
// {
|
|
|
// int LeftNum = md.LeftNum.Value;
|
|
|
// var olist = obj.SelectOrderBuyForTM(md.DetailId.Value);//按等级和时间倒排订单
|
|
|
// if (olist != null && olist.Count>0)
|
|
|
// {
|
|
|
// foreach (var omd in olist)
|
|
|
// {
|
|
|
// if (LeftNum > 0) //原来有购买时间的取消时间
|
|
|
// {
|
|
|
// qxbuyids += omd.OrderId.Value.ToString() + ",";
|
|
|
// }
|
|
|
// else if (LeftNum <= 0 && omd.BuyDate == null)//原来没有购买时间的修改时间
|
|
|
// {
|
|
|
// cgbuyids += omd.OrderId.Value.ToString() + ",";
|
|
|
// }
|
|
|
|
|
|
// LeftNum = LeftNum - omd.GoodsNum.Value;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// if (cgbuyids != "")
|
|
|
// {
|
|
|
// obj.GetOrderBuyDate(cgbuyids.Trim(','));
|
|
|
// }
|
|
|
// if (qxbuyids != "")
|
|
|
// {
|
|
|
// obj.CancelBuyDate(qxbuyids.Trim(','));
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
PagesNew.SaveLog(UserId, "采购入库", ChaseId.ToString() + Log, ChaseId);
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 保存
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int Save_PurchaseGoods(CG_PurchaseGoods Model)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
return DataNew.Save_PurchaseGoods(Model);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<HW_GoodsHWCOutDetail>> GetGoodsForHWCOut2(int CompanyId, string GoodsName, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(base.Session);
|
|
|
CG_ChaseData data = new CG_ChaseData();
|
|
|
RefParameterCollection where = new RefParameterCollection();
|
|
|
// int num = Convert.ToInt32(base.Session["CompanyId"]);
|
|
|
// int UserId = Convert.ToInt32(base.Session["UserId"]);
|
|
|
string sort = "b.GoodsCode,a.TypeCode";
|
|
|
where.Add("b.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
if (GoodsName != "")
|
|
|
{
|
|
|
where.Add("(b.GoodsName", "like", GoodsName, DbType.String);
|
|
|
where.Add("a.SKU1", "like", GoodsName, "or", DbType.String);
|
|
|
where.Add("b.GoodsCode", "like", GoodsName, "or", ")", DbType.String);
|
|
|
}
|
|
|
JsonModel<List<HW_GoodsHWCOutDetail>> model = new JsonModel<List<HW_GoodsHWCOutDetail>>();
|
|
|
int rowCount = 0;
|
|
|
model.DataSource = DataNew.GetListOutGoodsInfo22(where, PageIndex, PageSize, sort, out rowCount);
|
|
|
model.RowCount = rowCount;
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
#region 返回采购Model
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string Get_ChaseLsCode(int ChaseId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
var md = DataNew.Get_ChaseLsCode(ChaseId);
|
|
|
|
|
|
|
|
|
|
|
|
return md;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 分页查询采购单
|
|
|
[WebMethod(Description = "分页查询采购单", EnableSession = true)]
|
|
|
public JsonModel<List<CG_Purchase>> GetListCG_PurchaseForTM(int IsDetail, int ChaseCodeType, string ChaseCode, int DateType, int SNum, int ENum, decimal SPrice, decimal EPrice, int DHState, int State, int PostState, int IsGC, int IsBH, int GHYC, string Supplier, string BuyAccount, DateTime? SDate, DateTime? EDate, int YCCL, int WLYC, int IsGJ, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
string Sort = "a.InDate desc";
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
|
|
|
int GoodsType = 0;
|
|
|
string Name = "";
|
|
|
string People = "";
|
|
|
if (ChaseCode.Trim() != "")
|
|
|
{
|
|
|
ChaseCode = ChaseCode.Trim();
|
|
|
switch (ChaseCodeType)
|
|
|
{
|
|
|
case 1:
|
|
|
Param.Add("a.BuyCode", "like", ChaseCode, DbType.String);
|
|
|
break;
|
|
|
case 2:
|
|
|
Param.Add("a.ChaseCode", "like", ChaseCode, DbType.String);
|
|
|
break;
|
|
|
case 3:
|
|
|
GoodsType = 3;
|
|
|
Name = ChaseCode;
|
|
|
break;
|
|
|
case 4:
|
|
|
GoodsType = 4;
|
|
|
Name = ChaseCode;
|
|
|
break;
|
|
|
case 5:
|
|
|
GoodsType = 5;
|
|
|
Name = ChaseCode;
|
|
|
break;
|
|
|
case 6:
|
|
|
Param.Add("a.InName", "like", ChaseCode, DbType.String);
|
|
|
// GoodsType = 7;
|
|
|
// Name = ChaseCode;
|
|
|
break;
|
|
|
case 7:
|
|
|
Param.Add("a.InName", "like right", ChaseCode, DbType.String);
|
|
|
// GoodsType = 8;
|
|
|
// Name = ChaseCode;
|
|
|
break;
|
|
|
case 8:
|
|
|
GoodsType = 6;
|
|
|
Name = ChaseCode;
|
|
|
break;
|
|
|
case 9:
|
|
|
Param.Add("a.LsCode", "like", ChaseCode, DbType.String);
|
|
|
// GoodsType = 8;
|
|
|
// Name = ChaseCode;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Param.Add("isnull(a.IsGJ,0)", "=", 0, DbType.Int32);
|
|
|
if (IsGC == 1)
|
|
|
{
|
|
|
Param.Add("a.IsFactory", "=", 1, DbType.Int32);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Param.Add("isnull(a.IsFactory,0)", "=", 0, DbType.Int32);
|
|
|
}
|
|
|
if (IsBH == 1)
|
|
|
Param.Add("a.IsBH", "=", 1, DbType.Int32);
|
|
|
else
|
|
|
{
|
|
|
Param.Add("isnull(a.IsBH,0)", "=", 0, DbType.Int32);
|
|
|
}
|
|
|
if (IsGJ == 1)
|
|
|
Param.Add("a.IsGJ", "=", 1, DbType.Int32);
|
|
|
//else
|
|
|
//{
|
|
|
// Param.Add("isnull(a.IsGJ,0)", "=", 0, DbType.Int32);
|
|
|
//}
|
|
|
if (Supplier.Trim() != "")
|
|
|
{
|
|
|
Supplier = Supplier.Trim();
|
|
|
Param.Add("a.Supplier", "like", Supplier, DbType.String);
|
|
|
|
|
|
}
|
|
|
if (BuyAccount != "0")
|
|
|
{
|
|
|
|
|
|
Param.Add("a.Account", "=", BuyAccount, DbType.String);
|
|
|
|
|
|
}
|
|
|
if (PostState > -1)
|
|
|
Param.Add("ISNULL(a.PostState,0)", "=", PostState, DbType.Int32);
|
|
|
// if (NameType == 1)
|
|
|
// Param.Add("a.InName", "like", Name, DbType.String);
|
|
|
// else if (NameType == 2)
|
|
|
// {
|
|
|
// Param.Add("a.Supplier", "like", Name, DbType.String);
|
|
|
|
|
|
// }
|
|
|
// //else if (NameType ==3)
|
|
|
// //{
|
|
|
// // Param.Add("a.Supplier", "like", Name, DbType.String);
|
|
|
|
|
|
// //}
|
|
|
//}
|
|
|
if (SNum > -1)
|
|
|
Param.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
|
|
|
if (ENum > -1)
|
|
|
Param.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
|
|
|
if (SPrice > -1)
|
|
|
Param.Add("a.GoodsMoney", ">=", SPrice, DbType.Decimal);
|
|
|
if (EPrice > -1)
|
|
|
Param.Add("a.GoodsMoney", "<=", EPrice, DbType.Decimal);
|
|
|
|
|
|
if (DateType == 1)
|
|
|
{
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.BuyDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.BuyDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
}
|
|
|
else if (DateType == 2)
|
|
|
{
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.DoneDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.DoneDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
}
|
|
|
else if (DateType == 3)
|
|
|
{
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
}
|
|
|
else if (DateType == 4)
|
|
|
{
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.BackDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.BackDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
}
|
|
|
if (DHState != -1)
|
|
|
Param.Add("a.GoodsState", "=", DHState, DbType.Int32);
|
|
|
if (State == 2)
|
|
|
{
|
|
|
Param.Add("a.State", ">=", 1, DbType.Int32);
|
|
|
Param.Add("a.State", "<=", 2, DbType.Int32);
|
|
|
}
|
|
|
else if (State > -1)
|
|
|
{
|
|
|
Param.Add("a.State", "=", State, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
if (YCCL > -1)
|
|
|
{
|
|
|
Param.Add("a.IsError", "=", YCCL, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
if (GHYC == 1)
|
|
|
{
|
|
|
Param.Add("a.DHError", "=", 1, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
//else
|
|
|
//{
|
|
|
// Param.Add("isnull(a.DHError,0)", "=", 0, DbType.Int32);
|
|
|
//}
|
|
|
if (WLYC == 1)
|
|
|
{
|
|
|
Param.Add("a.GoodsState", "=", 0, DbType.Int32);
|
|
|
Param.Add("a.State", "<", 3, DbType.Int32);
|
|
|
Param.Add("datediff(day,a.InDate,getdate())", ">", 3, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
JsonModel<List<CG_Purchase>> resultModel = new JsonModel<List<CG_Purchase>>();
|
|
|
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListCG_Purchase(GoodsType, Name, Param, PageIndex, PageSize, Sort, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
if (IsDetail == 1 && resultModel.DataSource != null)
|
|
|
{
|
|
|
string Ids = "";
|
|
|
foreach (var md in resultModel.DataSource)
|
|
|
{
|
|
|
Ids += md.ChaseId.ToString() + ",";
|
|
|
if (md.Account != null && md.Account.Contains("阿里巴巴"))
|
|
|
{
|
|
|
md.SupplierName = "http://trade.1688.com/order/unify_buyer_detail.htm?orderId=" + md.BuyCode;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
md.SupplierName = "http://trade.taobao.com/trade/detail/trade_item_detail.htm?bizOrderId=" + md.BuyCode;
|
|
|
}
|
|
|
}
|
|
|
if (Ids != "")
|
|
|
{
|
|
|
var list1 = obj.GetchaseGoodsList(Ids.Trim(','));
|
|
|
if (list1 != null)
|
|
|
{
|
|
|
foreach (var md in resultModel.DataSource)
|
|
|
{
|
|
|
var list2 = list1.FindAll(n => n.ChaseId == md.ChaseId);
|
|
|
if (list2 != null)
|
|
|
{
|
|
|
|
|
|
md.GoodsList = list2;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
#region 查询采购单号
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string GetCGGCodeForTM()
|
|
|
{
|
|
|
PagesNew.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 string ImportCXCotact(string FileName, int State)
|
|
|
{
|
|
|
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("1") == false) { error = error + "导入模板的 1 列不存在"; }
|
|
|
if (tb.Columns.Contains("13") == false) { error = error + "导入模板的 13 列不存在"; }
|
|
|
|
|
|
if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确,请在第一行加1,2,3,4...13,列名";
|
|
|
DD_OrderData obj = new DD_OrderData();
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
var cmd = new CG_Purchase();
|
|
|
var glist = new List<CG_PurchaseGoods>();
|
|
|
cmd.ChaseCode = GetCGGCodeForTM();
|
|
|
cmd.PostFee = 0;
|
|
|
cmd.PostState = 0;
|
|
|
cmd.State = 1;
|
|
|
cmd.GoodsState = 0;
|
|
|
cmd.IsDelete = 0;
|
|
|
cmd.IsBH = 0;
|
|
|
cmd.IsFactory = 0;
|
|
|
cmd.InDate = DateTime.Now;
|
|
|
cmd.InUserId = UserId;
|
|
|
cmd.InName = Name;
|
|
|
cmd.InGoodsNum = 0;
|
|
|
int Num = 0;
|
|
|
int hw = 0;
|
|
|
|
|
|
int GNum = 0;
|
|
|
decimal zje = 0;
|
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|
|
{
|
|
|
|
|
|
string row1 = tb.Rows[i]["1"].ToString().Trim();
|
|
|
string row4 = tb.Rows[i]["4"].ToString().Trim();
|
|
|
string row6 = tb.Rows[i]["6"].ToString().Trim();
|
|
|
string row7 = tb.Rows[i]["7"].ToString().Trim();
|
|
|
string row8 = tb.Rows[i]["8"].ToString().Trim();
|
|
|
string row9 = tb.Rows[i]["9"].ToString().Trim();
|
|
|
string row10 = tb.Rows[i]["10"].ToString().Trim();
|
|
|
string row11 = tb.Rows[i]["11"].ToString().Trim();
|
|
|
string row12 = tb.Rows[i]["12"].ToString().Trim();
|
|
|
string row13 = tb.Rows[i]["13"].ToString().Trim();
|
|
|
// string row14 = tb.Rows[i]["14"].ToString().Trim();
|
|
|
if (row11 != "" && row11.Contains("合同编号") == true)
|
|
|
{
|
|
|
cmd.BuyCode = row13;
|
|
|
}
|
|
|
|
|
|
|
|
|
//if (row1 == "")
|
|
|
//{
|
|
|
// hw = 1;
|
|
|
// continue;
|
|
|
//}
|
|
|
|
|
|
if (row1 != "" && row8 != "" && row9 != "" && row10 != "")
|
|
|
{
|
|
|
var gmd = new CG_PurchaseGoods();
|
|
|
gmd.GoodsCode = row1;
|
|
|
if (row1 != "")
|
|
|
{
|
|
|
var hmd = DataNew.GetGoodsDetailModel(row1);
|
|
|
if (hmd != null)
|
|
|
gmd.GoodsDetailId = hmd.DetailId;
|
|
|
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
gmd.GoodsNum = Convert.ToInt32(row8);
|
|
|
GNum += gmd.GoodsNum.Value;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
gmd.GoodsPrice = Convert.ToDecimal(row9);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
// error += row1 + "单价" + row12 + "不是金额格式";
|
|
|
continue;
|
|
|
}
|
|
|
if (gmd.GoodsDetailId > 0)
|
|
|
glist.Add(gmd);
|
|
|
else
|
|
|
error += row1 + "系统中没找到对应的编号";
|
|
|
if (row10 != "" && gmd.GoodsDetailId > 0)
|
|
|
{
|
|
|
|
|
|
try
|
|
|
{
|
|
|
zje += Convert.ToDecimal(row10);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
// error += "总价" + row12 + "不是金额格式";
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
cmd.GoodsMoney = zje;
|
|
|
cmd.GoodsNum = GNum;
|
|
|
if (error != "")
|
|
|
return error;
|
|
|
else
|
|
|
{
|
|
|
CG_ChaseData obj2 = new CG_ChaseData();
|
|
|
cmd.BuyDate = DateTime.Now;
|
|
|
cmd.CompanyId = CompanyId;
|
|
|
|
|
|
int ChaseId = obj2.SavePurchaseForTM2(cmd);
|
|
|
|
|
|
if (glist != null)
|
|
|
{
|
|
|
foreach (var md in glist)
|
|
|
{
|
|
|
md.ChaseId = ChaseId;
|
|
|
md.InGoodsNum = 0;
|
|
|
md.BuyNum = md.GoodsNum;
|
|
|
obj2.SavePurchaseGoods2(md);
|
|
|
DataNew.UpdateBuyCGNum(md.GoodsDetailId.Value, 0, md.BuyNum.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return "导入成功";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
|
|
|
}
|
|
|
return "导入成功";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 导入畅想合同
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string ImportCXCotact2(string FileName, int StoreId)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
|
|
|
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
|
|
|
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
MicrosoftExcel excel = new MicrosoftExcel();
|
|
|
DataTable tb = excel.ImportExcel(ServerFileName);
|
|
|
|
|
|
string error = "";
|
|
|
if (tb.Columns.Contains("1") == false) { error = error + "导入模板的 1 列不存在"; }
|
|
|
if (tb.Columns.Contains("13") == false) { error = error + "导入模板的 13 列不存在"; }
|
|
|
|
|
|
if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确,请在第一行加1,2,3,4...13,列名";
|
|
|
DD_OrderData obj = new DD_OrderData();
|
|
|
|
|
|
CG_PurchaseNew model = new CG_PurchaseNew();
|
|
|
List<HW_GoodsHWCOutDetailNew> Goodslist = new List<HW_GoodsHWCOutDetailNew>();
|
|
|
string mess = "";
|
|
|
string fhdh = "";
|
|
|
DateTime? BuyDate = null;
|
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|
|
{
|
|
|
string name = tb.Rows[i]["1"].ToString().Trim();
|
|
|
string cght = tb.Rows[i]["2"].ToString().Trim();
|
|
|
if (tb.Rows[i]["3"].ToString().Trim() != "")
|
|
|
fhdh = tb.Rows[i]["3"].ToString().Trim();
|
|
|
string sku = tb.Rows[i]["5"].ToString().Trim();
|
|
|
string num = tb.Rows[i]["12"].ToString().Trim();
|
|
|
if (name != "" && name == "出运日期" && cght != "")
|
|
|
{
|
|
|
BuyDate = Convert.ToDateTime(cght);
|
|
|
}
|
|
|
if (cght == "" || fhdh == "" || sku == "" || num == "")
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (sku.Contains("编号") == true)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
int did = DataNew.IsChaseCode(sku, cght);
|
|
|
if (did == 0)
|
|
|
{
|
|
|
mess += sku + "在ERP找不到";
|
|
|
continue;
|
|
|
}
|
|
|
else if (did == -1)
|
|
|
{
|
|
|
mess += cght + "采购单号在erp不存在";
|
|
|
continue;
|
|
|
}
|
|
|
var glist = DataNew.GetOutGoodsList(sku, cght, Convert.ToInt32(num), did);
|
|
|
if (glist == null)
|
|
|
{
|
|
|
mess += cght + "采购单号可以出运的数量小于你要出运的数量,不能出运";
|
|
|
continue;
|
|
|
}
|
|
|
HW_GoodsHWCOutDetailNew gmd = new HW_GoodsHWCOutDetailNew();
|
|
|
gmd = glist[0];
|
|
|
gmd.Chase_Code = cght;
|
|
|
gmd.SJOutNum = Convert.ToInt32(num);
|
|
|
Goodslist.Add(gmd);
|
|
|
}
|
|
|
if (Goodslist == null || Goodslist.Count == 0)
|
|
|
{
|
|
|
mess += "没有可以导入的出运明细";
|
|
|
}
|
|
|
if (mess != "")
|
|
|
return mess;
|
|
|
int hj = 0;
|
|
|
decimal hjlf = 0;
|
|
|
if (Goodslist != null)
|
|
|
{
|
|
|
foreach (var md in Goodslist)
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (md.SJOutNum != null)
|
|
|
{
|
|
|
hj += md.SJOutNum.Value;
|
|
|
if (md.Solid != null)
|
|
|
hjlf += md.Solid.Value * md.SJOutNum.Value;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
model.GoodsNum = hj;
|
|
|
model.TSoild = hjlf;
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
string Name = Convert.ToString(Session["Name"]);
|
|
|
model.ChaseId = 0;
|
|
|
model.ChaseCode = GetCGGCodeForTM();
|
|
|
model.BuyCode = fhdh;
|
|
|
|
|
|
model.GoodsState = 0;
|
|
|
model.Remark = "";
|
|
|
model.BuyDate = BuyDate;//出运日期
|
|
|
model.BackDate = null;//预计到货日期
|
|
|
|
|
|
model.PostFee = 0;
|
|
|
model.GoodsNum = hj;
|
|
|
model.TSoild = hjlf;
|
|
|
|
|
|
|
|
|
|
|
|
//model.BuyCode = $("#txtBuyCode").val();
|
|
|
// model.InName = $("#txtInName").val();
|
|
|
|
|
|
model.StoreId = StoreId;
|
|
|
|
|
|
model.IsDelete = 0;
|
|
|
model.PostState = 3;
|
|
|
model.IsGJ = 1;
|
|
|
|
|
|
model.CompanyId = CompanyId;
|
|
|
model.InUserId = UserId;
|
|
|
if (model.InName == null || model.InName == "")
|
|
|
model.InName = Name;
|
|
|
else
|
|
|
if (model.InName != "" && model.InName.Contains(Name) == false)
|
|
|
model.InName = model.InName + "," + Name;
|
|
|
|
|
|
|
|
|
|
|
|
model.IsGJ = 1;
|
|
|
model.IsDelete = 0;
|
|
|
if (model.ChaseId == null || model.ChaseId == 0)
|
|
|
{
|
|
|
model.InDate = DateTime.Now;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
int ChaseId = DataNew.SavePurchaseForTM2(model);
|
|
|
if (Goodslist != null)
|
|
|
{
|
|
|
foreach (var md in Goodslist)
|
|
|
{
|
|
|
|
|
|
|
|
|
md.PState = model.PostState;
|
|
|
md.GJChaseId = ChaseId;
|
|
|
if (md.IsAdd == 1)
|
|
|
DataNew.UpdateHWCGoods2222(md);
|
|
|
// else
|
|
|
// DataNew.UpdateHWCGoods(md);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
|
|
|
}
|
|
|
return "导入成功";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询采购物品明细根据供应商
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<HW_GoodsSPDetail> GetGoodsSPDetailFromSupplie(int SupplierId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new HuoWuData();
|
|
|
|
|
|
var list = DataNew.GetGoodsSPDetailFromSupplie(SupplierId);
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 查询采购货物
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<HW_CGGoods>> GetListCGGoodsInfoNeedYW(string GoodsCode, string SKU, int PageIndex, int PageSize, string Sort)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
//if (DeptId > 0)
|
|
|
// Param.Add("a.DeptId", "=", DeptId, DbType.Int32);
|
|
|
|
|
|
if (GoodsCode != "")
|
|
|
{
|
|
|
|
|
|
GoodsCode = GoodsCode.Trim();
|
|
|
Param.Add("(a.GoodsCode", "=", GoodsCode, DbType.String);
|
|
|
Param.Add("a.GoodsName", "like", GoodsCode, "or", ")", DbType.String);
|
|
|
}
|
|
|
if (SKU != "")
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Param.Add("b.SKU1", "=", SKU, "or", DbType.String);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Param.Add("(isnull(b.GoodsNum, 0)+isnull(b.GoodsInNum, 0)-isnull(b.GoodsPlanNum, 0))", "<", 0, DbType.Int32);
|
|
|
// Param.Add("isnull(b.CGNum,0)", ">", 0, DbType.Int32);
|
|
|
|
|
|
JsonModel<List<HW_CGGoods>> resultModel = new JsonModel<List<HW_CGGoods>>();
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
string sorta = Sort;
|
|
|
|
|
|
resultModel.DataSource = DataNew.GetListCGGoodsInfoForNeedYW(Param, PageIndex, PageSize, sorta, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
|
|
|
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出采购单
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string GetListBuyExcel(string ids)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new DD_OrderData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list = DataNew.GetBuyGoodsList(ids.Trim(','));
|
|
|
if (list != null)
|
|
|
{
|
|
|
string code = "";
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
|
|
|
if (code == md.ChaseCode)
|
|
|
{
|
|
|
md.ChaseCode = "";
|
|
|
md.ReveState = "";
|
|
|
md.ErrorInfo = "";
|
|
|
}
|
|
|
else
|
|
|
code = md.ChaseCode;
|
|
|
}
|
|
|
}
|
|
|
TableColumnCollection listColumns = new TableColumnCollection();
|
|
|
listColumns.Add("ChaseCode", "采购单号", DbType.String, "");
|
|
|
listColumns.Add("BuyCode", "采购订单号", DbType.String, "");
|
|
|
listColumns.Add("BuyDate", "采购日期", DbType.String, "");
|
|
|
listColumns.Add("ReveState", "收货状态", DbType.String, "");
|
|
|
listColumns.Add("ErrorInfo", "异常备注", DbType.String, "");
|
|
|
listColumns.Add("SKU1", "sku", DbType.String, "");
|
|
|
listColumns.Add("GoodsPrice", "单价", DbType.String, "");
|
|
|
listColumns.Add("GoodsNum", "数量", DbType.String, "");
|
|
|
listColumns.Add("PostFee", "运费", DbType.String, "");
|
|
|
listColumns.Add("GoodsMoney", "总金额", DbType.String, "");
|
|
|
MicrosoftExcel obj2 = new MicrosoftExcel();
|
|
|
return obj2.Export(list, listColumns);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存采购数量
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public void SaveChaseCGNum_New(int id)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
DataNew.Update_PurchaseGoodsDetail(id);
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 分页查询入库采购单
|
|
|
[WebMethod(Description = "分页查询采购单入库", EnableSession = true)]
|
|
|
public JsonModel<List<CG_Purchase>> GetListCG_InchaseForTM(string PostCode, int IsDetail, string ChaseCode, string BuyCode, string Goods, string Name, int DHState, int SNum, int ENum, DateTime? SDate, DateTime? EDate, DateTime? SRKDate, DateTime? ERKDate, string Supplier, int PostState, int IsGC, int IsBH, int GHYC, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var obj = new CG_ChaseData();
|
|
|
|
|
|
|
|
|
RefParameterCollection Param = new RefParameterCollection();
|
|
|
|
|
|
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
|
|
|
string Sort = "a.ChaseId";
|
|
|
if (DHState > 0)
|
|
|
Sort = "a.DoneDate desc";
|
|
|
if (PostState > -1)
|
|
|
Param.Add("a.PostState", "=", PostState, DbType.Int32);
|
|
|
if (Supplier != "")
|
|
|
{
|
|
|
Supplier = Supplier.Trim();
|
|
|
Param.Add("a.Supplier", "like", Supplier, DbType.String);
|
|
|
}
|
|
|
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
|
|
|
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
|
|
|
if (ChaseCode.Trim() != "")
|
|
|
{
|
|
|
//ChaseCode = ChaseCode.Trim();
|
|
|
Goods = ChaseCode.Trim();
|
|
|
//Param.Add("(a.ChaseCode", "like", ChaseCode, DbType.String);
|
|
|
// Param.Add("a.BuyCode", "like", ChaseCode, "or",")",DbType.String);
|
|
|
}
|
|
|
|
|
|
//if (BuyCode != "")
|
|
|
// Param.Add("a.BuyCode", "like", BuyCode, DbType.String);
|
|
|
|
|
|
if (Name != "0")
|
|
|
Param.Add("a.Account", "=", Name, DbType.String);
|
|
|
if (SDate != null)
|
|
|
Param.Add("a.BuyDate", ">=", SDate, DbType.DateTime);
|
|
|
if (EDate != null)
|
|
|
Param.Add("a.BuyDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
|
|
|
if (SRKDate != null)
|
|
|
Param.Add("a.DoneDate", ">=", SRKDate, DbType.DateTime);
|
|
|
if (ERKDate != null)
|
|
|
Param.Add("a.DoneDate", "<", ERKDate.Value.AddDays(1), DbType.DateTime);
|
|
|
Param.Add("isnull(a.IsGJ,0)", "=", 0, DbType.Int32);
|
|
|
if (IsGC == 1)
|
|
|
Param.Add("isnull(a.IsFactory,0)", "=", 1, DbType.Int32);
|
|
|
else
|
|
|
{
|
|
|
Param.Add("isnull(a.IsFactory,0)", "=", 0, DbType.Int32);
|
|
|
}
|
|
|
if (IsBH == 1)
|
|
|
Param.Add("isnull(a.IsBH,0)", "=", 1, DbType.Int32);
|
|
|
//else
|
|
|
//{
|
|
|
// Param.Add("isnull(a.IsBH,0)", "=", 0, DbType.Int32);
|
|
|
//}
|
|
|
if (DHState == 0)
|
|
|
{
|
|
|
// Param.Add("a.State", "=", 2, DbType.Int32);
|
|
|
Param.Add("a.GoodsState", "<", 2, DbType.Int32);
|
|
|
Param.Add("a.State", "<", 3, DbType.Int32);
|
|
|
// Param.Add("a.GoodsState", "<=", 1, DbType.Int32);
|
|
|
}
|
|
|
else if (DHState == 1)
|
|
|
{
|
|
|
Param.Add("a.GoodsState", "=", 2, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
else if (DHState == 3)
|
|
|
{
|
|
|
|
|
|
Param.Add("a.State", "=", 3, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
if (GHYC == 1)
|
|
|
{
|
|
|
Param.Add("a.GoodsState", "=", 0, DbType.Int32);
|
|
|
Param.Add("a.State", "<", 3, DbType.Int32);
|
|
|
Param.Add("datediff(day,a.InDate,getdate())", ">", 3, DbType.Int32);
|
|
|
|
|
|
}
|
|
|
if (SNum > 0)
|
|
|
{
|
|
|
Param.Add("(a.GoodsNum-b.InGoodsNum)", ">=", SNum, DbType.Int32);
|
|
|
|
|
|
|
|
|
}
|
|
|
if (ENum > 0)
|
|
|
{
|
|
|
Param.Add("(a.GoodsNum-b.InGoodsNum)", "<=", ENum, DbType.Int32);
|
|
|
|
|
|
|
|
|
}
|
|
|
//if (State == 0)
|
|
|
//{
|
|
|
// Param.Add("a.State", ">", 0, DbType.Int32);
|
|
|
// Param.Add("a.State", "<>", 2, DbType.Int32);
|
|
|
//}
|
|
|
//else
|
|
|
// if (State == 2)
|
|
|
// {
|
|
|
// Param.Add("a.State", "=", 1, DbType.Int32);
|
|
|
|
|
|
// }
|
|
|
// else if (State == 3)
|
|
|
// {
|
|
|
// Param.Add("a.State", "=", 3, DbType.Int32);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
JsonModel<List<CG_Purchase>> resultModel = new JsonModel<List<CG_Purchase>>();
|
|
|
|
|
|
|
|
|
int RowCount = 0;
|
|
|
|
|
|
//if (SRKDate != null || ERKDate != null)
|
|
|
//{
|
|
|
// string chaseids = "";
|
|
|
// var clist = obj.GetChaseIds(CompanyId, SRKDate, ERKDate);
|
|
|
// if (clist != null)
|
|
|
// {
|
|
|
// foreach (var md in clist)
|
|
|
// {
|
|
|
// chaseids += md.ChaseId + ",";
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// if (chaseids != "")
|
|
|
// Param.Add("a.ChaseId", "in", chaseids.Trim(','), DbType.String);
|
|
|
//}
|
|
|
|
|
|
resultModel.DataSource = obj.GetListCG_PurchaseForTM(CompanyId, PostCode, Goods.Trim(), Param, PageIndex, PageSize, Sort, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
|
|
|
if (IsDetail == 1 && resultModel.DataSource != null)
|
|
|
{
|
|
|
string Ids = "";
|
|
|
foreach (var md in resultModel.DataSource)
|
|
|
{
|
|
|
Ids += md.ChaseId.ToString() + ",";
|
|
|
|
|
|
}
|
|
|
if (Ids != "")
|
|
|
{
|
|
|
var list1 = DataNew.GetchaseGoodsList(Ids.Trim(','));
|
|
|
if (list1 != null)
|
|
|
{
|
|
|
foreach (var md in resultModel.DataSource)
|
|
|
{
|
|
|
var list2 = list1.FindAll(n => n.ChaseId == md.ChaseId);
|
|
|
if (list2 != null)
|
|
|
{
|
|
|
|
|
|
md.GoodsList = list2;
|
|
|
|
|
|
|
|
|
}
|
|
|
if (md.ErrorInfo != null && md.ErrorInfo != "")
|
|
|
{
|
|
|
if (md.ErrorInfo.Length > 100)
|
|
|
md.SimpErrorInfo = md.ErrorInfo.Substring(0, 100) + "...";
|
|
|
else
|
|
|
md.SimpErrorInfo = md.ErrorInfo;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (resultModel.DataSource != null)
|
|
|
{
|
|
|
foreach (var md in resultModel.DataSource)
|
|
|
{
|
|
|
|
|
|
if (md.ErrorInfo != null && md.ErrorInfo != "")
|
|
|
{
|
|
|
if (md.ErrorInfo.Length > 100)
|
|
|
md.SimpErrorInfo = md.ErrorInfo.Substring(0, 100) + "...";
|
|
|
else
|
|
|
md.SimpErrorInfo = md.ErrorInfo;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return resultModel;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 分页查询采购单商品详情列表
|
|
|
[WebMethod(Description = "分页查询采购单商品详情列表", EnableSession = true)]
|
|
|
public JsonModel<List<CG_PurchaseGoodsForCGPC>> GetListCG_GoodsCGPCForNewTM(int strType, string strValue, int state, int goodsState, string dateType, DateTime? startDate, DateTime? endDate, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
JsonModel<List<CG_PurchaseGoodsForCGPC>> resultModel = new JsonModel<List<CG_PurchaseGoodsForCGPC>>();
|
|
|
int rowCount = 0;
|
|
|
resultModel.DataSource = DataNew.GetCG_PurchaseGoodsCGPCList(strType, strValue, state, goodsState, dateType, startDate, endDate, PageIndex, PageSize, out rowCount);
|
|
|
resultModel.RowCount = rowCount;
|
|
|
return resultModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询采购单商品采购总金额和总立方
|
|
|
[WebMethod(Description = "查询采购单商品采购总金额和总立方", EnableSession = true)]
|
|
|
public object GetCG_GoodsCGPCPriceAndCube(int strType, string strValue, int state, int goodsState, string dateType, DateTime? startDate, DateTime? endDate)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
|
|
|
decimal totalPrice = 0, totalCube = 0;
|
|
|
DataNew.GetCG_GoodsCGPCPriceAndCube(strType, strValue, state, goodsState, dateType, startDate, endDate, out totalPrice, out totalCube);
|
|
|
|
|
|
var obj = new { totalPrice, totalCube };
|
|
|
return obj;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 海外仓状态,WMS出运空柜之后,调用这个接口,同步状态
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public APIReturnModel SaveChasePostState(string cyCode)
|
|
|
{
|
|
|
var rmodel = new APIReturnModel();
|
|
|
try
|
|
|
{
|
|
|
DataNew.UpdateCG_Purchase(cyCode, 7);
|
|
|
rmodel.Code = 1;
|
|
|
rmodel.Message = "成功";
|
|
|
return rmodel;
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
rmodel.Code = 0;
|
|
|
rmodel.Message = "失败:"+ex.Message;
|
|
|
return rmodel;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|