diff --git a/Controller/CK.SCP.Controller.csproj b/Controller/CK.SCP.Controller.csproj
index 64d5a9a..b2f6237 100644
--- a/Controller/CK.SCP.Controller.csproj
+++ b/Controller/CK.SCP.Controller.csproj
@@ -59,6 +59,7 @@
+
diff --git a/Controller/SCP_ASK_CONTROLLER.cs b/Controller/SCP_ASK_CONTROLLER.cs
index 9b9b412..e86c066 100644
--- a/Controller/SCP_ASK_CONTROLLER.cs
+++ b/Controller/SCP_ASK_CONTROLLER.cs
@@ -31,7 +31,7 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.ErpBillNum))
{
- q = q.Where(p => p.ErpBillNum .Contains(p_entity.ErpBillNum));
+ q = q.Where(p => p.ErpBillNum.Contains(p_entity.ErpBillNum));
}
if (!string.IsNullOrEmpty(p_entity.AskBillNum))
{
@@ -61,10 +61,18 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.BeginTime >= p_entity.BeginTime);
}
+ if (p_entity.BeginTime_End != null)
+ {
+ q = q.Where(p => p.BeginTime <= p_entity.BeginTime_End);
+ }
if (p_entity.EndTime != null)
{
q = q.Where(p => p.EndTime <= p_entity.EndTime);
}
+ if (p_entity.EndTime_start != null)
+ {
+ q = q.Where(p => p.EndTime >= p_entity.EndTime_start);
+ }
if (!string.IsNullOrEmpty(p_entity.VendName))
{
q = q.Where(p => p.VendName.Contains(p_entity.VendName));
@@ -175,20 +183,20 @@ namespace CK.SCP.Controller
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
foreach (var itm in p_entitys)
- {
+ {
var _entity = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault();
- _entity.ReduceQty= itm.ReduceQty;
+ _entity.ReduceQty = itm.ReduceQty;
_entity.Remark = itm.Remark;
- var asn = db.V_TB_ASN_DETAIL.Where(p => p.PoBillNum == itm.PoBillNum &&p.AskBillNum==itm.AskBillNum && p.IsDeleted == false )
- .GroupBy(p => new { p.PoBillNum,p.AskBillNum, p.PoLine, p.PartCode })
- .Select(p => new { AsSum = p.Sum(item => item.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode,AskBillNum=p.Key.AskBillNum });
+ var asn = db.V_TB_ASN_DETAIL.Where(p => p.PoBillNum == itm.PoBillNum && p.AskBillNum == itm.AskBillNum && p.IsDeleted == false)
+ .GroupBy(p => new { p.PoBillNum, p.AskBillNum, p.PoLine, p.PartCode })
+ .Select(p => new { AsSum = p.Sum(item => item.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode, AskBillNum = p.Key.AskBillNum });
asn.ToList().ForEach(itm1 =>
{
- if (itm.PoBillNum == itm1.PoBillNum && itm.PoLine == itm1.PoLine && itm.PartCode == itm1.PartCode && itm.AskBillNum==itm1.AskBillNum)
+ if (itm.PoBillNum == itm1.PoBillNum && itm.PoLine == itm1.PoLine && itm.PartCode == itm1.PartCode && itm.AskBillNum == itm1.AskBillNum)
{
- if (itm.ReduceQty > itm.AskQty - itm1.AsSum )
+ if (itm.ReduceQty > itm.AskQty - itm1.AsSum)
{
- _ret.MessageList.Add(string.Format("零件编号{0}零件名称{1}减产数量>要货数量-发货数量",itm.PartCode,itm.PartDesc1+itm.PartDesc2));
+ _ret.MessageList.Add(string.Format("零件编号{0}零件名称{1}减产数量>要货数量-发货数量", itm.PartCode, itm.PartDesc1 + itm.PartDesc2));
}
}
});
@@ -273,7 +281,7 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
- var _list=p_list.Select(itm => itm.UID).ToList();
+ var _list = p_list.Select(itm => itm.UID).ToList();
var _ls = db.TB_ASK_DETAIL.Where(p => _list.Contains(p.UID)).ToList();
db.TB_ASK_DETAIL.RemoveRange(_ls);
if (db.SaveChanges() != -1)
@@ -480,15 +488,15 @@ namespace CK.SCP.Controller
{
//var _detail = p_list[0];
foreach (V_TB_INCOMPLETE_ASK _detail in p_list)
- {
- var reject = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK&&p.BillType==3).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
+ {
+ var reject = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.BillType == 3).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
reject.ToList().ForEach(itm =>
{
if (_detail.AskBillNum == itm.Remark && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
{
- _detail.Number = _detail.Number+Math.Abs( itm.RejectSum);
+ _detail.Number = _detail.Number + Math.Abs(itm.RejectSum);
}
- });
+ });
}
}
}
@@ -516,8 +524,8 @@ namespace CK.SCP.Controller
//退货数量
var back = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.Qty < 0).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
//开票数量
- var invoice = db.V_TB_INVOICE_ASK.Where(p => p.Remark == _detail.AskBillNum && p.State == (int)ReceiveState.Check && p.BillType == 0)
- .GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { InvoiceQty = p.Sum(itm => itm.InvoiceQty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
+ var invoice = db.V_TB_INVOICE_DETAIL.Where(p => p.AskBillNum == _detail.AskBillNum)
+ .GroupBy(p => new { p.AskBillNum, p.PoLineNum, p.PartCode }).Select(p => new { InvoiceQty = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLineNum, AskBillNum = p.Key.AskBillNum, PartCode = p.Key.PartCode });
//寄售退货
var reject = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.BillType == 3).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
reject.ToList().ForEach(itm =>
@@ -529,7 +537,7 @@ namespace CK.SCP.Controller
});
invoice.ToList().ForEach(itm =>
{
- if (_detail.AskBillNum == itm.Remark && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
+ if (_detail.AskBillNum == itm.AskBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
{
_detail.InvoiceQty = itm.InvoiceQty;
}
@@ -577,20 +585,20 @@ namespace CK.SCP.Controller
var rec = db.TB_RECEIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ReceiveState.Check && p.BillType == 0)
.GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ReceiveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
- // var reject = db.TB_RECEIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)RejectState.Check && p.BillType == 1).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark , PartCode = p.Key.PartCode });
- //发货
+ // var reject = db.TB_RECEIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)RejectState.Check && p.BillType == 1).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark , PartCode = p.Key.PartCode });
+ //发货
var asn = db.V_TB_ASN_DETAIL.Where(p => p.AskBillNum == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)AsnState.Ship)
.GroupBy(p => new { p.AskBillNum, p.PoLine, p.PartCode })
.Select(p => new { AsSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, AskBillNum = p.Key.AskBillNum, PartCode = p.Key.PartCode });
//var arrive = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.BillType == (int)ArriveBillType.Receive).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
//到货
- var arrive = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK &&p.Qty>0 ).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
+ var arrive = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.Qty > 0).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
//退货
var reject = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == _detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.Qty < 0).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
-
- var invoice = db.V_TB_INVOICE_ASK.Where(p => p.Remark == _detail.AskBillNum && p.State == (int)ReceiveState.Check && p.BillType == 0)
- .GroupBy(p => new { p.Remark, p.PoLine, p.PartCode }).Select(p => new { InvoiceQty = p.Sum(itm => itm.InvoiceQty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode });
+ //发票
+ var invoice = db.V_TB_INVOICE_DETAIL.Where(p => p.AskBillNum == _detail.AskBillNum)
+ .GroupBy(p => new { p.AskBillNum, p.PoLineNum, p.PartCode }).Select(p => new { InvoiceQty = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLineNum, AskBillNum = p.Key.AskBillNum, PartCode = p.Key.PartCode });
_detail.PartDesc1 = _detail.PartDesc1 + _detail.PartDesc2;
rec.ToList().ForEach(itm =>
@@ -634,13 +642,13 @@ namespace CK.SCP.Controller
invoice.ToList().ForEach(itm =>
{
- if (_detail.AskBillNum == itm.Remark && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
+ if (_detail.AskBillNum == itm.AskBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
{
_detail.InvoiceQty = itm.InvoiceQty;
}
});
- _detail.OnRoadQty = Convert.ToDecimal( _detail.ShippedQty) - _detail.ArriveQty;
+ _detail.OnRoadQty = Convert.ToDecimal(_detail.ShippedQty) - _detail.ArriveQty;
}
}
@@ -652,13 +660,13 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
-
+
if (p_list.ToList().Count > 0)
{
foreach (V_TB_ASK _detail in p_list)
{
_detail.Month = Convert.ToDateTime(_detail.EndTime).Month.ToString() + "月订单";
- if (_detail.State==0|| _detail.State==1|| _detail.State == 2)
+ if (_detail.State == 0 || _detail.State == 1 || _detail.State == 2)
{
continue;
@@ -668,7 +676,7 @@ namespace CK.SCP.Controller
continue;
}
var _ask = db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == _detail.AskBillNum && p.IsDeleted == false).ToList();
- var _ask_can= Get_CAN_SHIPQTY(_ask.ToList()).Where(p=>p.CanQty>0).ToList();
+ var _ask_can = Get_CAN_SHIPQTY(_ask.ToList()).Where(p => p.CanQty > 0).ToList();
if (_ask_can.Count != 0)
{
@@ -681,7 +689,7 @@ namespace CK.SCP.Controller
//_detail.Flag = (_ask_can.Count).ToString()+ "/" +(_ask.Count).ToString();
//_detail.Month = _detail.CreateTime.Month.ToString() + "月订单";
}
-
+
}
}
return p_list;
@@ -697,10 +705,10 @@ namespace CK.SCP.Controller
DateTime beginTime = DateTime.Now;
DateTime endTime = DateTime.Now;
foreach (var itm in p_entitys)
- {
+ {
var _entity = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault();
- askBill=_entity.AskBillNum;
- _entity.BeginTime =(DateTime) itm.BeginTime;
+ askBill = _entity.AskBillNum;
+ _entity.BeginTime = (DateTime)itm.BeginTime;
beginTime = (DateTime)itm.BeginTime;
_entity.EndTime = (DateTime)itm.EndTime;
endTime = (DateTime)itm.EndTime;
@@ -790,7 +798,7 @@ namespace CK.SCP.Controller
}
return _ret;
}
- public static ResultObject Save_TB_ASK_DETAIL(List p_entitys,AskState p_state)
+ public static ResultObject Save_TB_ASK_DETAIL(List p_entitys, AskState p_state)
{
ResultObject _ret = new ResultObject();
try
@@ -802,6 +810,10 @@ namespace CK.SCP.Controller
itm.State = (int)p_state;
var _entity = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault();
_entity.AskQty = itm.AskQty;
+ if (itm.EndTime != null)
+ {
+ _entity.EndTime = itm.EndTime;
+ }
db.TB_ASK_DETAIL.AddOrUpdate(p => p.UID, _entity);
}
if (_ret.MessageList.Count > 0)
@@ -821,14 +833,15 @@ namespace CK.SCP.Controller
{
var _entityList = db.V_TB_ASK_DETAIL.Where(p => _ls.Contains(p.UID)).ToList();
- var _item= _entityList.FirstOrDefault();
+ var _item = _entityList.FirstOrDefault();
if (_item.AskBillNum.Contains("U"))
{
- var _planList = db1.TB_PO_PLAN_EXTEND.Where(p => p.Domain == _item.Site && p.EndTime == _item.EndTime && p.PoBillNum == _item.PoBillNum).ToList();
- _planList.ForEach(p => {
+ var _planList = db1.TB_PO_PLAN_EXTEND.Where(p => p.Domain == _item.Site && p.EndTime == _item.EndTime && p.PoBillNum == _item.PoBillNum).ToList();
+ _planList.ForEach(p =>
+ {
- var _first = _entityList.Where(itm => itm.PoBillNum == p.PoBillNum && itm.PartCode == p.PartCode && itm.EndTime == p.EndTime).FirstOrDefault();
+ var _first = _entityList.Where(itm => itm.PoBillNum == p.PoBillNum && itm.PartCode == p.PartCode && itm.EndTime == p.EndTime).FirstOrDefault();
if (_first != null)
{
p.PlanQty = _first.AskQty;
@@ -866,7 +879,7 @@ namespace CK.SCP.Controller
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
- {
+ {
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
@@ -881,7 +894,7 @@ namespace CK.SCP.Controller
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_DETAIL", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
- var inner = (UpdateException)ex.InnerException;
+ var inner = (UpdateException)ex.InnerException;
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -947,7 +960,7 @@ namespace CK.SCP.Controller
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
@@ -956,7 +969,7 @@ namespace CK.SCP.Controller
}
catch (ScpException ex)
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
@@ -967,7 +980,7 @@ namespace CK.SCP.Controller
{
var inner = (UpdateException)ex.InnerException;
-
+
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -990,8 +1003,8 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
- var _list=db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_askBillNum && p.IsDeleted==false).ToList();
- var _lst=Get_CAN_SHIPQTY(_list);
+ var _list = db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_askBillNum && p.IsDeleted == false).ToList();
+ var _lst = Get_CAN_SHIPQTY(_list);
if (_lst.Select(p => p.CanQty).Sum() <= 0)
{
@@ -1008,8 +1021,8 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
- var _ask= db.TB_ASK.Where(p => p.AskBillNum == p_ask.AskBillNum).FirstOrDefault();
- _ask=ConvertHelper.GetObjectClone(_ask);
+ var _ask = db.TB_ASK.Where(p => p.AskBillNum == p_ask.AskBillNum).FirstOrDefault();
+ _ask = ConvertHelper.GetObjectClone(_ask);
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode();
_ask.GUID = Guid.NewGuid();
@@ -1029,7 +1042,7 @@ namespace CK.SCP.Controller
int state = db.SaveChanges();
if (state != -1)
{
- _ret.MessageList.Add("复制要货单号"+_ask.AskBillNum+",请去要货明细修改要货单订货日期和要货日期");
+ _ret.MessageList.Add("复制要货单号" + _ask.AskBillNum + ",请去要货明细修改要货单订货日期和要货日期");
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
@@ -1103,7 +1116,7 @@ namespace CK.SCP.Controller
- public static ResultObject Save_ASK_TO_ASN(V_TB_ASK p_ask, List p_order_list,string p_PlateNumber
+ public static ResultObject Save_ASK_TO_ASN(V_TB_ASK p_ask, List p_order_list, string p_PlateNumber
, string p_buyer, string p_buyerPhone)
{
ResultObject _ret = new ResultObject();
@@ -1115,7 +1128,7 @@ namespace CK.SCP.Controller
_t.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode();
_t.AskBillNum = p_ask.AskBillNum;
_t.PoBillNum = p_ask.PoBillNum;
- _t.ReceivedPort = p_ask.ReceivedPort;
+ _t.ReceivedPort = p_ask.ReceivedPort;
_t.CreateUser = p_buyer;
_t.CreateTime = DateTime.Now;
_t.UpdateUser = p_buyer;
@@ -1123,7 +1136,7 @@ namespace CK.SCP.Controller
_t.ReceiveUser = p_ask.Buyer;
_t.ReceiveTime = p_ask.BeginTime;
_t.VendId = p_ask.VendId;
- _t.IsDeleted= false;//操作员
+ _t.IsDeleted = false;//操作员
_t.CreateTime = DateTime.Now;
_t.CreateUser = p_buyer;
_t.Site = p_ask.Site;
@@ -1136,7 +1149,7 @@ namespace CK.SCP.Controller
_t.ShipTime = p_ask.ShipTime;
_t.ReceiveTime = p_ask.ReceiveTime;
db.TB_ASN.AddOrUpdate(p => p.AsnBillNum, _t);
- List _list = new List();
+ List _list = new List();
foreach (var itm in p_order_list)
{
TB_ASN_DETAIL _tDetail = new TB_ASN_DETAIL();
@@ -1152,21 +1165,21 @@ namespace CK.SCP.Controller
else
{
_tDetail.VendBatch = itm.Batch;
- }
- _tDetail.PackQty = itm.PackQty==0?1:itm.PackQty;
+ }
+ _tDetail.PackQty = itm.PackQty == 0 ? 1 : itm.PackQty;
_tDetail.PartCode = itm.PartCode;
_tDetail.State = (int)AsnState.New;
_tDetail.Qty = (decimal)itm.TempQty;
_tDetail.Price = itm.Price;
_tDetail.EndTime = itm.EndTime;
- _tDetail.CreateTime =_t.CreateTime;
- _tDetail.CreateUser =_t.CreateUser;
+ _tDetail.CreateTime = _t.CreateTime;
+ _tDetail.CreateUser = _t.CreateUser;
_tDetail.ProduceDate = itm.ProduceDate;
_tDetail.IsDeleted = false;
_tDetail.DockCode = itm.ReceivedPort;
_tDetail.LocUnit = itm.LocUnit;
_tDetail.UnConv = itm.UnConv;
- _tDetail.State =_t.State;
+ _tDetail.State = _t.State;
_tDetail.UpdateInfo = itm.UpdateInfo;
_tDetail.ReceivedPort = itm.ReceivedPort;
_tDetail.GUID = Guid.NewGuid();
@@ -1178,11 +1191,11 @@ namespace CK.SCP.Controller
int state = db.SaveChanges();
if (state != -1)
{
- var _askDetailList= db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted == false).ToList();//查询要货单明细
+ var _askDetailList = db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted == false).ToList();//查询要货单明细
var _lst = Get_CAN_SHIPQTY(_askDetailList);//算出可发数量
if (_lst.Select(p => p.CanQty).Sum() <= 0)//可发数量为零时,修改状态
{
- var _ary=db.TB_ASK.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted == false).ToList();
+ var _ary = db.TB_ASK.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted == false).ToList();
_ary.ForEach(p => p.State = (int)AskState.Ship);
if (_ary.Count() > 0)
{
@@ -1219,7 +1232,7 @@ namespace CK.SCP.Controller
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
@@ -1259,7 +1272,7 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
- var _ls = p_list.Select(p => p.AskBillNum);
+ var _ls = p_list.Select(p => p.AskBillNum);
StringBuilder _buffer = new StringBuilder();
_buffer.Append(" select distinct (C.AskBillNum)from V_TB_ASK_DETAIL C");
_buffer.Append(" left JOIN ");
@@ -1267,21 +1280,68 @@ namespace CK.SCP.Controller
_buffer.Append(" group by a.PoLine, a.AskBillNum, a.PartCode) AS D ");
_buffer.Append(" ON C.AskBillNum = D.AskBillNum AND C.PoLine = D.PoLine AND C.PartCode = D.PartCode ");
_buffer.Append(" WHERE C.AskQty>isnull(D.Qty,0)");
- _buffer.Append(" and c.AskBillNum in ('{0}')");
+ _buffer.Append(" and c.AskBillNum in ('{0}')");
var _str = string.Format(_buffer.ToString(), string.Join("','", _ls.ToArray()));
- var _list= db.Database.SqlQuery(_str).ToList();
-
- p_list.ForEach(p => {
- p.IsComplete = true;
- if (_list.Contains(p.AskBillNum))
- {
- p.IsComplete = false;
- }
- });
+ var _list = db.Database.SqlQuery(_str).ToList();
+
+ p_list.ForEach(p =>
+ {
+ p.IsComplete = true;
+ if (_list.Contains(p.AskBillNum))
+ {
+ p.IsComplete = false;
+ }
+ });
}
return p_list;
}
+ public static decimal Get_ASN_DETAIL_CAN(V_TB_ASK_DETAIL p_asn_detail)
+ {
+ decimal _canqty = 0;
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ if (p_asn_detail != null)
+ {
+ var ask = db.V_TB_ASK_DETAIL.FirstOrDefault(p => p.IsDeleted == false && p_asn_detail.AskBillNum == p.AskBillNum && p.PartCode == p_asn_detail.PartCode
+ && p.PoLine == p_asn_detail.PoLine && p.PoBillNum == p_asn_detail.PoBillNum);
+ if (ask != null)
+ {
+ p_asn_detail = ask;
+ var list = db.V_TB_ASN_DETAIL.Where(p => p.IsDeleted == false && p_asn_detail.AskBillNum == p.AskBillNum && p.PartCode == p_asn_detail.PartCode
+ && p.PoLine == p_asn_detail.PoLine && p.PoBillNum == p_asn_detail.PoBillNum).ToList();
+ var list_back = db.TB_ARRIVE_DETAIL.Where(p => p.Remark == p_asn_detail.AskBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.Qty < 0 && p.BillType == 3
+ && p.PartCode == p_asn_detail.PartCode && p.PoLine == p_asn_detail.PoLine && p.PoBillNum == p_asn_detail.PoBillNum).GroupBy(p => new { p.Remark, p.PoLine, p.PartCode, p.PoBillNum }).Select(p => new { BackSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, Remark = p.Key.Remark, PartCode = p.Key.PartCode, PoBillNum = p.Key.PoBillNum }).ToList();
+ var groupList = list.GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode, p.AskBillNum }).Select(
+ p => new
+ {
+ ShipSum = p.Sum(itm => itm.Qty),
+ PoLine = p.Key.PoLine,
+ PoBillNum = p.Key.PoBillNum,
+ PartCode = p.Key.PartCode,
+ AskBillNum = p.Key.AskBillNum
+ }).ToList();
+ groupList.ForEach(p =>
+ {
+ if (p.PoBillNum == p_asn_detail.PoBillNum && p.PoLine == p_asn_detail.PoLine && p.PartCode == p_asn_detail.PartCode)
+ {
+ p_asn_detail.ShippedQty = p.ShipSum;
+ }
+ });
+ list_back.ForEach(p =>
+ {
+ if (p.PoBillNum == p_asn_detail.PoBillNum && p.PoLine == p_asn_detail.PoLine && p.PartCode == p_asn_detail.PartCode)
+ {
+ p_asn_detail.RejectQty = Math.Abs(p.BackSum);//寄售退货数
+ }
+ });
+ decimal a = p_asn_detail.AskQty - (p_asn_detail.ShippedQty == null ? 0 : (decimal)p_asn_detail.ShippedQty) + p_asn_detail.RejectQty - (p_asn_detail.ReduceQty == null ? 0 : (decimal)p_asn_detail.ReduceQty);
+ _canqty = a;
+ }
+ }
+ }
+ return _canqty;
+ }
public static List Get_CAN_SHIPQTY(List p_list)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
@@ -1317,7 +1377,7 @@ namespace CK.SCP.Controller
if (p.PoBillNum == itm.PoBillNum && p.PoLine == itm.PoLine && p.PartCode == itm.PartCode)
{
itm.RejectQty = Math.Abs(p.BackSum);//寄售退货数
- }
+ }
});
decimal a = itm.AskQty - (itm.ShippedQty == null ? 0 : (decimal)itm.ShippedQty) + itm.RejectQty - (itm.ReduceQty == null ? 0 : (decimal)itm.ReduceQty);
itm.CanQty = a;
@@ -1326,7 +1386,7 @@ namespace CK.SCP.Controller
}
}
- if(p_list.Count>0)
+ if (p_list.Count > 0)
{
return p_list;
}
@@ -1349,7 +1409,7 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.PoBillNum))
{
- q = q.Where(p => p.PoBillNum==p_entity.PoBillNum);
+ q = q.Where(p => p.PoBillNum == p_entity.PoBillNum);
}
if (p_entity.PoLine != 0)
{
@@ -1357,7 +1417,7 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.PartCode))
{
- q = q.Where(p => p.PartCode==p_entity.PartCode);
+ q = q.Where(p => p.PartCode == p_entity.PartCode);
}
if (p_entity.ShippedQty != null && p_entity.ShippedQty != 0)
{
@@ -1372,9 +1432,9 @@ namespace CK.SCP.Controller
q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit));
}
- if (p_entity.EndTime!=null)
+ if (p_entity.EndTime != null)
{
- q = q.Where(p =>p_entity.EndTime< p.EndTime);
+ q = q.Where(p => p_entity.EndTime < p.EndTime);
}
if (!string.IsNullOrEmpty(p_entity.LocUnit))
{
@@ -1415,7 +1475,7 @@ namespace CK.SCP.Controller
if (!string.IsNullOrEmpty(p_entity.Site))
{
- q = q.Where(p => p.Site==p_entity.Site);
+ q = q.Where(p => p.Site == p_entity.Site);
}
if (!string.IsNullOrEmpty(p_entity.VendName))
{
@@ -1423,12 +1483,12 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.VendId))
{
- q = q.Where(p => p.VendId==p_entity.VendId);
+ q = q.Where(p => p.VendId == p_entity.VendId);
}
if (!string.IsNullOrEmpty(p_entity.AskBillNum))
{
- q = q.Where(p => p.AskBillNum==p_entity.AskBillNum);
+ q = q.Where(p => p.AskBillNum == p_entity.AskBillNum);
}
_ret.State = ReturnStatus.Succeed;
@@ -1491,9 +1551,9 @@ namespace CK.SCP.Controller
}
- public static void Get_V_TB_ASK_DETAIL_Sum(V_TB_ASK_DETAIL p_entity,Action>> p_action)
+ public static void Get_V_TB_ASK_DETAIL_Sum(V_TB_ASK_DETAIL p_entity, Action>> p_action)
{
-
+
ResultObject> _ret = new ResultObject>();
try
{
@@ -1502,7 +1562,7 @@ namespace CK.SCP.Controller
IQueryable q = db.V_TB_ASK_DETAIL;
if (p_entity.UID != 0)
{
-
+
q = q.Where(p => p.UID == p_entity.UID);
}
if (!string.IsNullOrEmpty(p_entity.PoBillNum))
@@ -1517,7 +1577,7 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
}
- if (p_entity.ShippedQty!=null && p_entity.ShippedQty != 0)
+ if (p_entity.ShippedQty != null && p_entity.ShippedQty != 0)
{
q = q.Where(p => p.ShippedQty == p_entity.ShippedQty);
}
@@ -1557,15 +1617,15 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.State == p_entity.State);
}
-
+
if (!string.IsNullOrEmpty(p_entity.CreateUser))
{
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
}
-
+
q = q.Where(p => p.IsDeleted == p_entity.IsDeleted);
-
-
+
+
if (!string.IsNullOrEmpty(p_entity.Site))
{
q = q.Where(p => p.Site.Contains(p_entity.Site));
@@ -1574,11 +1634,11 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.VendName.Contains(p_entity.VendName));
}
-
+
if (!string.IsNullOrEmpty(p_entity.AskBillNum))
{
q = q.Where(p => p.AskBillNum.Contains(p_entity.AskBillNum));
- }
+ }
_ret.State = ReturnStatus.Succeed;
_ret.Result = q;
p_action(_ret);
@@ -1603,7 +1663,7 @@ namespace CK.SCP.Controller
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Get_V_TB_ASK_DETAIL_List", ex.ToString());
@@ -1611,7 +1671,7 @@ namespace CK.SCP.Controller
}
catch (ScpException ex)
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
@@ -1621,7 +1681,7 @@ namespace CK.SCP.Controller
{
var inner = (UpdateException)ex.InnerException;
-
+
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -1632,16 +1692,106 @@ namespace CK.SCP.Controller
catch (Exception e)
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(e);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Get_V_TB_ASK_DETAIL_List", e.Message);
throw e;
- }
+ }
}
+ ///
+ /// 沈阳金杯
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject Save_TB_ASK(string _num, string p_remark)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ var _ls = db.TB_ASK.FirstOrDefault(p => p.AskBillNum == _num);
+ if (_ls != null)
+ {
+ _ls.Remark = p_remark;
+ db.TB_ASK.AddOrUpdate(_ls);
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "无法找到看板!";
+ }
+ if (string.IsNullOrEmpty(_ret.Message))
+ {
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "数据更新失败!";
+ }
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
-
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_STATE", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_STATE", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_STATE", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_STATE", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
public static ResultObject Save_TB_ASK_STATE(List p_list, AskState p_state)
{
@@ -1655,14 +1805,28 @@ namespace CK.SCP.Controller
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
if (_ls.Count > 0)
{
- _ls.ForEach(p => {
- p.State = (int)AskState.Close;
- var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- _list.ForEach(itm => itm.State = (int)AskState.Close);
- db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
+ _ls.ForEach(p =>
+ {
+ var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList();
+ if (_asnlist.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!");
+ }
+ else
+ {
+ p.State = (int)AskState.Close;
+ var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
+ _list.ForEach(itm => itm.State = (int)AskState.Close);
+ db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
+ }
}
);
- db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ if (_ret.MessageList.Count == 0)
+ {
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ }
}
else
{
@@ -1671,152 +1835,176 @@ namespace CK.SCP.Controller
_ret.Message = "选择的记录,不能关闭!";
}
}
- if (p_state == AskState.Confirm)
+ if (p_state == AskState.Complete)
+ {
+ var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
+ int count = _ls.Count(p => p.State == (int)AskState.Ship);
+ if (count == _ls.Count && _ls.Count > 0)
{
- var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
- int count = _ls.Count(p => p.State == (int)AskState.Release);
- if (count == _ls.Count && _ls.Count > 0)
+ _ls.ForEach(p =>
{
- _ls.ForEach(p => {
- p.State = (int)AskState.Confirm;
+ var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList();
+ if (_asnlist.Count > 0)
+ {
+ _ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!");
+ }
+ else
+ {
+ p.State = (int)AskState.Complete;
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- _list.ForEach(itm => {
-
- itm.State = (int)AskState.Confirm;
-
- itm.UpdateTime = DateTime.Now;
- }
-
- );
+ _list.ForEach(itm => itm.State = (int)AskState.Complete);
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
- #region 供应商确认要货状态完成
- //var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
- //_pendingList.ForEach(itm => {
- // itm.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
- // itm.ITEM_CONTENT = "要货看板已完成!";
- //}
- //);
- //db.TB_PENING_ITEMS.AddOrUpdate(itm => itm.GUID, _pendingList.ToArray());
- #endregion
}
- );
- db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
- }
- else
- {
- _ret.State = ReturnStatus.Failed;
- _ret.Result = false;
- _ret.Message = "选择的记录,有不是发布状态记录!";
}
+ );
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
}
- if (p_state == AskState.New)
+ else
{
- var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
- int count = _ls.Count(p => p.State == (int)AskState.Release);
- if (count == _ls.Count && _ls.Count > 0)
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录非已发货状态,不能关闭!";
+ }
+ }
+ if (p_state == AskState.Confirm)
+ {
+ var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
+ int count = _ls.Count(p => p.State == (int)AskState.Release);
+ if (count == _ls.Count && _ls.Count > 0)
+ {
+ _ls.ForEach(p =>
{
- _ls.ForEach(p => {
- p.State = (int)AskState.New;
- var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- _list.ForEach(itm => itm.State = (int)AskState.New);
- db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
-
+ p.State = (int)AskState.Confirm;
+ var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
+ _list.ForEach(itm =>
+ {
+ itm.State = (int)AskState.Confirm;
+
+ itm.UpdateTime = DateTime.Now;
}
- // #region 供应商要货代办取消
- // var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
- //if (_pendingList.Count > 0)
- //{
- // db.TB_PENING_ITEMS.RemoveRange(_pendingList);
- //}
- // #endregion
- );
- db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ );
+ db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
+ #region 供应商确认要货状态完成
+ //var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
+ //_pendingList.ForEach(itm => {
+ // itm.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
+ // itm.ITEM_CONTENT = "要货看板已完成!";
+ //}
+ //);
+ //db.TB_PENING_ITEMS.AddOrUpdate(itm => itm.GUID, _pendingList.ToArray());
+ #endregion
}
- else
+ );
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录,有不是发布状态记录!";
+ }
+ }
+ if (p_state == AskState.New)
+ {
+ var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
+ int count = _ls.Count(p => p.State == (int)AskState.Release);
+ if (count == _ls.Count && _ls.Count > 0)
+ {
+ _ls.ForEach(p =>
{
- _ret.State = ReturnStatus.Failed;
- _ret.Result = false;
- _ret.Message = "选择的记录,有不是发布状态记录!";
+ p.State = (int)AskState.New;
+ var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
+ _list.ForEach(itm => itm.State = (int)AskState.New);
+ db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
}
+ );
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录,有不是发布状态记录!";
}
- if (p_state == AskState.Release)
+ }
+ if (p_state == AskState.Release)
+ {
+ var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
+ int count = _ls.Count(p => p.State == (int)AskState.New);
+ if (count > 0)
{
- var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
- int count = _ls.Count(p => p.State == (int)AskState.New);
- if (count > 0)
+ _ls.ForEach(p =>
{
- _ls.ForEach(p =>
+ p.State = (int)AskState.Release;
+ var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
+ _list.ForEach(itm =>
{
- p.State = (int)AskState.Release;
- var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- _list.ForEach(itm =>
- {
- itm.State = (int)AskState.Release;
- }
- );
- db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
+ itm.State = (int)AskState.Release;
}
);
-
- db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
- }
- else
- {
- _ret.State = ReturnStatus.Failed;
- _ret.Result = false;
- _ret.Message = "选择的记录,有不是新建状态记录!";
+ db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
}
+ );
+
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
}
- if (p_state == AskState.Reject)
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录,有不是新建状态记录!";
+ }
+ }
+ if (p_state == AskState.Reject)
+ {
+ var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
+ int count = _ls.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release);
+ if (count == _ls.Count && _ls.Count > 0)
{
- var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
- int count = _ls.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release);
- if (count == _ls.Count && _ls.Count > 0)
+ _ls.ForEach(p =>
{
- _ls.ForEach(p =>
+ p.State = (int)AskState.Reject;
+ p.IsDeleted = true;
+ var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
+ _list.ForEach(itm =>
{
- p.State = (int)AskState.Reject;
- p.IsDeleted = true;
- var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- _list.ForEach(itm =>
- {
- itm.State = (int)AskState.Reject;
- itm.IsDeleted = true;
- }
- );
- db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
+ itm.State = (int)AskState.Reject;
+ itm.IsDeleted = true;
+ }
+ );
+ db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
//#region 供应商要货代办作废
//var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
//db.TB_PENING_ITEMS.RemoveRange(_pendingList);
//#endregion
}
- );
- db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
- }
- else
- {
- _ret.State = ReturnStatus.Failed;
- _ret.Result = false;
- _ret.Message = "选择的记录,有不是新建或发布状态记录!";
- }
-
+ );
+ db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录,有不是新建或发布状态记录!";
}
+
+ }
if (p_state == AskState.CompleteForce)
{
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList();
- int count = _ls.Count(p =>p.State == (int)AskState.Confirm || p.State == (int)AskState.Ship);
+ int count = _ls.Count(p => p.State == (int)AskState.Confirm || p.State == (int)AskState.Ship);
if (count == _ls.Count && _ls.Count > 0)
{
_ls.ForEach(p =>
{
- if(p.State==(int)AskState.Complete)
+ if (p.State == (int)AskState.Complete)
{
p.State = (int)AskState.Reject;
p.IsDeleted = true;
}
- // p.State = (int)AskState.CompleteForce;
+ // p.State = (int)AskState.CompleteForce;
#region 修改发货单
var _asnList = db.TB_ASN.Where(itm => itm.IsDeleted == false && itm.AskBillNum == p.AskBillNum && itm.State == 0).ToList();
_asnList.ForEach(itm =>
@@ -1841,7 +2029,7 @@ namespace CK.SCP.Controller
var asn = db.V_TB_ASN_DETAIL.Where(ask => ask.AskBillNum == itm.AskBillNum && ask.IsDeleted == false && (ask.State == (int)AsnState.Ship || ask.State == (int)AsnState.Receive))
.GroupBy(ask => new { ask.AskBillNum, ask.PoLine, ask.PartCode })
.Select(ask => new { AsSum = ask.Sum(itm1 => itm1.Qty), PoLine = ask.Key.PoLine, AskBillNum = ask.Key.AskBillNum, PartCode = ask.Key.PartCode }).ToList();
-
+
asn.ForEach(itm1 =>
{
if (itm1.AskBillNum == itm.AskBillNum && itm1.PoLine == itm.PoLine && itm1.PartCode == itm.PartCode)
@@ -1894,9 +2082,9 @@ namespace CK.SCP.Controller
}
}
- if(p_state == AskState.NoConfirm)
+ if (p_state == AskState.NoConfirm)
{
- var _ls = db.TB_ASN.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted==false ).ToList();
+ var _ls = db.TB_ASN.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList();
if (_ls.Count == 0)
{
var _askList = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList();
@@ -1919,39 +2107,14 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.Message = "选择的记录已经有发货单据不能取消!";
-
}
-
- //if (count > 0)
- //{
- // _ls.ForEach(p =>
- // {
- // p.State = (int)AskState.Receive;
- // var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- // _list.ForEach(itm =>
- // {
- // itm.State = (int)AskState.Receive;
-
- // }
- // );
- // db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
- // }
- // );
- // db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
- //}
- //else
- //{
- // _ret.State = ReturnStatus.Failed;
- // _ret.Result = false;
- // _ret.Message = "选择的记录,有不是新建或发布状态记录!";
- //}
-
}
if (string.IsNullOrEmpty(_ret.Message))
{
if (db.SaveChanges() != -1)
{
- if (p_state == AskState.CompleteForce) {
+ if (p_state == AskState.CompleteForce)
+ {
using (ScpEntities db1 = EntitiesFactory.CreateScpInstance())
{
@@ -1987,7 +2150,7 @@ namespace CK.SCP.Controller
_ret.Result = false;
_ret.Message = "数据更新失败!";
}
- }
+ }
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
@@ -2010,7 +2173,7 @@ namespace CK.SCP.Controller
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
@@ -2019,7 +2182,7 @@ namespace CK.SCP.Controller
}
catch (ScpException ex)
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
@@ -2030,7 +2193,7 @@ namespace CK.SCP.Controller
{
var inner = (UpdateException)ex.InnerException;
-
+
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -2048,13 +2211,6 @@ namespace CK.SCP.Controller
}
return _ret;
}
-
-
-
-
-
-
-
public static ResultObject Save_ASK_MODIF_QTY(V_TB_ASK p_ask, List p_list)
{
ResultObject _ret = new ResultObject();
@@ -2063,16 +2219,17 @@ namespace CK.SCP.Controller
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
- var _list= db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted==false).ToList();
- var _ls = Get_CAN_SHIPQTY(_list);
- _ls.ForEach(p => {
+ var _list = db.V_TB_ASK_DETAIL.Where(p => p.AskBillNum == p_ask.AskBillNum && p.IsDeleted == false).ToList();
+ var _ls = Get_CAN_SHIPQTY(_list);
+ _ls.ForEach(p =>
+ {
var _entity = p_list.Where(itm => itm.AskBillNum == p.AskBillNum && itm.PoLine == p.PoLine && itm.PartCode == p.PartCode && itm.PoBillNum == p.PoBillNum).FirstOrDefault();
if (_entity != null)
{
p.AskQty = _entity.AskQty;
- if(_entity.AskQty p.Domain == p_ask.Site && p.EndTime == p_ask.EndTime && p.PoBillNum == p_ask.PoBillNum).ToList();
- _planList.ForEach(p =>{
+ _planList.ForEach(p =>
+ {
- var _first=_ls.Where(itm => itm.PoBillNum==p.PoBillNum && itm.PartCode==p.PartCode && itm.EndTime==p.EndTime).FirstOrDefault();
+ var _first = _ls.Where(itm => itm.PoBillNum == p.PoBillNum && itm.PartCode == p.PartCode && itm.EndTime == p.EndTime).FirstOrDefault();
if (_first != null)
{
p.PlanQty = _first.AskQty;
@@ -2172,7 +2330,8 @@ namespace CK.SCP.Controller
}
return _ret;
}
- public static ResultObject Save_TB_ASK_STATE_CC(List p_list, AskState p_state, User p_user,string p_fail=null)
+
+ public static ResultObject Save_TB_ASK_STATE_CC(List p_list, AskState p_state, User p_user, string p_fail = null)
{
ResultObject _ret = new ResultObject();
try
@@ -2185,22 +2344,14 @@ namespace CK.SCP.Controller
int count = _ls.Count(p => p.State == (int)AskState.Release);
if (count == _ls.Count && _ls.Count > 0)
{
- _ls.ForEach(p => {
+ _ls.ForEach(p =>
+ {
p.UpdateUser = p_user.ChineseName;
p.UpdateTime = DateTime.Now;
p.State = (int)AskState.Confirm;
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
_list.ForEach(itm => itm.State = (int)AskState.Confirm);
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
- #region 供应商确认要货状态完成
- //var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
- //_pendingList.ForEach(itm => {
- // itm.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
- // itm.ITEM_CONTENT = "要货看板已完成!";
- //}
- //);
- //db.TB_PENING_ITEMS.AddOrUpdate(itm => itm.GUID, _pendingList.ToArray());
- #endregion
}
);
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
@@ -2218,25 +2369,16 @@ namespace CK.SCP.Controller
int count = _ls.Count(p => p.State == (int)AskState.Release);
if (count == _ls.Count && _ls.Count > 0)
{
- _ls.ForEach(p => {
+ _ls.ForEach(p =>
+ {
p.UpdateUser = p_user.ChineseName;
p.UpdateTime = DateTime.Now;
p.State = (int)AskState.New;
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
_list.ForEach(itm => itm.State = (int)AskState.New);
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
-
-
}
- // #region 供应商要货代办取消
- // var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
- //if (_pendingList.Count > 0)
- //{
- // db.TB_PENING_ITEMS.RemoveRange(_pendingList);
- //}
- // #endregion
-
- );
+ );
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
}
else
@@ -2246,8 +2388,6 @@ namespace CK.SCP.Controller
_ret.Message = "选择的记录,有不是发布状态记录!";
}
}
-
-
if (p_state == AskState.Back)
{
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
@@ -2270,8 +2410,6 @@ namespace CK.SCP.Controller
}
);
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
-
-
}
);
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
@@ -2315,10 +2453,8 @@ namespace CK.SCP.Controller
_item.GUID = Guid.NewGuid();
db.TB_PENING_ITEMS.Add(_item);
#endregion
-
}
);
-
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
}
else
@@ -2360,7 +2496,6 @@ namespace CK.SCP.Controller
_ret.Result = false;
_ret.Message = "选择的记录,有不是新建或发布状态记录!";
}
-
}
if (p_state == AskState.CompleteForce)
{
@@ -2400,7 +2535,6 @@ namespace CK.SCP.Controller
var asn = db.V_TB_ASN_DETAIL.Where(ask => ask.AskBillNum == itm.AskBillNum && ask.IsDeleted == false && (ask.State == (int)AsnState.Ship || ask.State == (int)AsnState.Receive))
.GroupBy(ask => new { ask.AskBillNum, ask.PoLine, ask.PartCode })
.Select(ask => new { AsSum = ask.Sum(itm1 => itm1.Qty), PoLine = ask.Key.PoLine, AskBillNum = ask.Key.AskBillNum, PartCode = ask.Key.PartCode }).ToList();
-
asn.ForEach(itm1 =>
{
if (itm1.AskBillNum == itm.AskBillNum && itm1.PoLine == itm.PoLine && itm1.PartCode == itm.PartCode)
@@ -2422,7 +2556,6 @@ namespace CK.SCP.Controller
_ret.Result = false;
_ret.Message = "选择的记录,有不是【已确认】或【已发货】状态,【发布状态】请用取消发布或看板作废!";
}
-
}
if (p_state == AskState.Receive)
{
@@ -2437,7 +2570,6 @@ namespace CK.SCP.Controller
_list.ForEach(itm =>
{
itm.State = (int)AskState.Receive;
-
}
);
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
@@ -2451,7 +2583,6 @@ namespace CK.SCP.Controller
_ret.Result = false;
_ret.Message = "选择的记录,有不是新建或发布状态记录!";
}
-
}
if (p_state == AskState.NoConfirm)
{
@@ -2478,33 +2609,7 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.Message = "选择的记录已经有发货单据不能取消!";
-
}
-
- //if (count > 0)
- //{
- // _ls.ForEach(p =>
- // {
- // p.State = (int)AskState.Receive;
- // var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList();
- // _list.ForEach(itm =>
- // {
- // itm.State = (int)AskState.Receive;
-
- // }
- // );
- // db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
- // }
- // );
- // db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
- //}
- //else
- //{
- // _ret.State = ReturnStatus.Failed;
- // _ret.Result = false;
- // _ret.Message = "选择的记录,有不是新建或发布状态记录!";
- //}
-
}
if (string.IsNullOrEmpty(_ret.Message))
{
@@ -2520,16 +2625,13 @@ namespace CK.SCP.Controller
_ret.Message = "数据更新失败!";
}
}
-
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
{
var sb = new StringBuilder();
-
foreach (var error in dbEx.EntityValidationErrors.ToList())
{
-
error.ValidationErrors.ToList().ForEach(i =>
{
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
@@ -2543,7 +2645,6 @@ namespace CK.SCP.Controller
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
@@ -2552,18 +2653,13 @@ namespace CK.SCP.Controller
}
catch (ScpException ex)
{
-
-
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_STATE", ex.ToString());
-
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
-
-
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -2584,6 +2680,5 @@ namespace CK.SCP.Controller
-
}
}
diff --git a/Controller/SCP_ASN_CONTROLLER.cs b/Controller/SCP_ASN_CONTROLLER.cs
index c2ae84f..a9b0bdd 100644
--- a/Controller/SCP_ASN_CONTROLLER.cs
+++ b/Controller/SCP_ASN_CONTROLLER.cs
@@ -14,6 +14,7 @@ using System.Data.Entity.Core;
using CK.SCP.Models.AppBoxEntity;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
using System.Data.SqlClient;
+using CK.SCP.Models.ScpEntity.ExcelImportEntity;
namespace CK.SCP.Controller
{
@@ -308,6 +309,72 @@ namespace CK.SCP.Controller
throw e;
}
}
+ public static void Get_V_TB_ASN_DETAIL_MODIFY(V_TB_ASN_DETAIL p_entity, Action>> p_action)
+ {
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ IQueryable q = db.V_TB_ASN_DETAIL;
+ if (p_entity.UID!=0)
+ {
+ q = q.Where(p => p.UID==p_entity.UID);
+ }
+ if (p_entity.IsDeleted != false)
+ {
+ q = q.Where(p => p.IsDeleted == p_entity.IsDeleted);
+ }
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Get_V_TB_ASN_DETAIL_List", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Get_V_TB_ASN_DETAIL_List", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Get_V_TB_ASN_DETAIL_List", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Get_V_TB_ASN_DETAIL_List", e.Message);
+ throw e;
+ }
+ }
public static void Get_V_TB_ASN_DETAIL_List(V_TB_ASN_DETAIL p_entity, Action>> p_action)
{
ResultObject> _ret = new ResultObject>();
@@ -471,6 +538,112 @@ namespace CK.SCP.Controller
}
+ public static ResultObject Save_TB_ASN_DETAIL_MODIFY(V_TB_ASN_DETAIL p_asn,string p_state)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ var _ls = db.TB_ASN_DETAIL.FirstOrDefault(p => p.UID==p_asn.UID);
+ if (p_state == "Modify")
+ {
+ if (_ls != null)
+ {
+ _ls.ProduceDate = p_asn.ProduceDate;
+ _ls.PackQty = p_asn.PackQty;
+ _ls.Qty = p_asn.Qty;
+ _ls.VendBatch = p_asn.VendBatch;
+ db.TB_ASN_DETAIL.AddOrUpdate(_ls);
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "数据不存在!";
+ }
+ }
+ if (p_state == "Delete")
+ {
+ if (_ls != null)
+ {
+ _ls.State =(int)AsnState.Reject;
+ _ls.IsDeleted = true;
+ db.TB_ASN_DETAIL.AddOrUpdate(_ls);
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "数据不存在!";
+ }
+ }
+ if (string.IsNullOrEmpty(_ret.Message))
+ {
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "数据更新失败!";
+ }
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_ASN_STATE", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_ASN_STATE", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_ASN_STATE", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_ASN_STATE", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
public static ResultObject Save_TB_ASN_STATE(List p_list, AsnState p_state)
{
ResultObject _ret = new ResultObject();
@@ -817,7 +990,8 @@ namespace CK.SCP.Controller
List _lsDetail = new List();
var _ls = retobj.Result.ToList();
_ls.ForEach(p => {
-
+ if (p.Qty > 0)
+ {
V_ARRIVE_PRINT_DETAIL _detail = new V_ARRIVE_PRINT_DETAIL();
_detail.PartNo = p.PartCode;
_detail.PartDesc = p.PartDesc1;
@@ -826,7 +1000,14 @@ namespace CK.SCP.Controller
_detail.Boxes = (Math.Truncate((p.Qty / p.PackQty)) + (((p.Qty % p.PackQty) > 0) ? 1 : 0)).ToString();
_detail.DeliverQty = p.Qty.ToString();
_detail.ReceiveQty = p.Qty.ToString();
- _detail.PoNo = _print.DeliveryNo+"("+p.PoBillNum+")";
+ if (p.Site == "0210")
+ {
+ _detail.PoNo = p.AskBillNum + "(" + p.PoBillNum + ")";
+ }
+ else
+ {
+ _detail.PoNo = _print.DeliveryNo + "(" + p.PoBillNum + ")";
+ }
_detail.LineNO = p.PoLine.ToString();
_detail.Memo = p.Remark;
_detail.DockCode = p.DockCode;
@@ -844,6 +1025,7 @@ namespace CK.SCP.Controller
// stdtemp +=_detail.Boxes;
stdtemp += Convert.ToDecimal( _detail.Boxes);
_lsDetail.Add(_detail);
+ }
});
ds.Tables[0].Rows[0]["STDCOUNT"] = stdtemp.ToString();
var tb = ConvertHelper.ToDataTable(_lsDetail);
@@ -2589,10 +2771,293 @@ namespace CK.SCP.Controller
}
return _ret;
}
-
-
-
-
+ ///
+ /// 数据导入
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject EXCEL_ASN(List p_order_list, string p_creator, string p_buyer, string p_site, DateTime p_time)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ int number = 1;
+ List lineError = new List();
+ List ErrorList = new List();
+ p_order_list.ForEach
+ (p =>
+ {
+ var _ls = CheckExcel(db, p);
+ if (_ls.Count > 0)
+ {
+ lineError.Add(number.ToString());
+ ErrorList.Add(string.Join("
", _ls.ToArray()));
+ }
+ number++;
+ });
+ if (lineError.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.MessageList.AddRange(ErrorList);
+ _ret.Result = false;
+ }
+ else
+ {
+ var GroupList = p_order_list.GroupBy(p => new { p.采购订单号, p.行号, p.零件编号, p.价格, p.供应商编码, p.单位 }).Select(p => new { 数量 = p.Sum(itm => decimal.Parse(itm.数量)), 行号 = p.Key.行号, 采购订单号 = p.Key.采购订单号, p.Key.零件编号, p.Key.价格, p.Key.供应商编码, p.Key.单位 }).ToList();
+ var OrderList = GroupList.GroupBy(p => p.采购订单号).ToList();
+ OrderList.ForEach((p) =>
+ {
+ var list_distinct = p.GroupBy(t => new { t.零件编号, t.行号 }).ToList();
+ var list = p.ToList();
+ if (list_distinct.Count < list.Count)
+ {
+ _ret.MessageList.Add("相同组号,存在同一编号、行号的数据");
+ return;
+ }
+ if (list.Count > 0)
+ {
+ var _entity = list.FirstOrDefault();
+ TB_ASK _ask = new TB_ASK();
+ _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode();
+ _ask.State = (int)AskState.Receive;
+ _ask.PoBillNum = _entity.采购订单号.ToUpper();
+ _ask.ModType = (int)BillModType.Contract;
+ _ask.Site = p_site;
+ _ask.BeginTime = p_time;
+ _ask.Buyer = p_creator;
+ _ask.BuyerPhone = "";
+ _ask.ErpBillNum = _entity.采购订单号.ToUpper();
+ _ask.EndTime = p_time;
+ _ask.CreateTime = p_time;
+ _ask.CreateUser = p_creator;
+ _ask.VendId = _entity.供应商编码.ToUpper();
+ _ask.GUID = Guid.NewGuid();
+ _ask.IsDeleted = false;
+ db.TB_ASK.Add(_ask);
+
+ TB_ASN _asn = new TB_ASN();
+ _asn.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode();
+ _asn.AskBillNum = _ask.AskBillNum;
+ _asn.VendId = _entity.供应商编码.ToUpper(); ;
+ _asn.State = (int)AsnState.Receive;
+ _asn.PoBillNum = _entity.采购订单号.ToUpper();
+ _asn.Site = p_site;
+ _asn.CreateTime = p_time;
+ _asn.CreateUser = p_creator;
+ _asn.UpdateTime = p_time;
+ _asn.UpdateUser = p_creator;
+ _asn.ShipTime = p_time;
+ _asn.ShipUser = p_creator;
+ _asn.ReceiveTime = p_time;
+ _asn.ReceiveUser = p_creator;
+ _asn.GUID = Guid.NewGuid();
+ _asn.IsDeleted = false;
+ db.TB_ASN.Add(_asn);
+
+ list.ForEach((itm) =>
+ {
+ TB_ASK_DETAIL _t_ASK_Detail = new TB_ASK_DETAIL();
+ _t_ASK_Detail.PoLine = Int32.Parse(itm.行号);
+ _t_ASK_Detail.Currency = "";
+ _t_ASK_Detail.AskBillNum = _ask.AskBillNum;
+ _t_ASK_Detail.PoBillNum = _ask.PoBillNum;
+ _t_ASK_Detail.PoUnit = itm.单位;
+ _t_ASK_Detail.CreateTime = DateTime.Now;
+ _t_ASK_Detail.CreateUser = _ask.CreateUser;
+ _t_ASK_Detail.PartCode = itm.零件编号.ToUpper();
+ _t_ASK_Detail.BeginTime = p_time;
+ _t_ASK_Detail.EndTime = p_time;
+ _t_ASK_Detail.TempQty = itm.数量;
+ _t_ASK_Detail.AskQty = itm.数量;
+ _t_ASK_Detail.IsDeleted = false;
+ _t_ASK_Detail.LocUnit = itm.单位;
+ _t_ASK_Detail.UnConv = 1;
+ _t_ASK_Detail.State = _ask.State;
+ _t_ASK_Detail.Price = string.IsNullOrEmpty(itm.价格) ? 0 : decimal.Parse(itm.价格);
+ _t_ASK_Detail.GUID = Guid.NewGuid();
+ db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
+
+ TB_ASN_DETAIL _t_ASN_Detail = new TB_ASN_DETAIL();
+ _t_ASN_Detail.AsnBillNum = _asn.AsnBillNum;
+ _t_ASN_Detail.PoLine = Int32.Parse(itm.行号);
+ _t_ASN_Detail.Currency = "";
+ _t_ASN_Detail.PoBillNum = _asn.PoBillNum;
+ _t_ASN_Detail.PoUnit = itm.单位;
+ _t_ASN_Detail.CreateTime = DateTime.Now;
+ _t_ASN_Detail.CreateUser = _asn.CreateUser;
+ _t_ASN_Detail.PartCode = itm.零件编号.ToUpper();
+ _t_ASN_Detail.Batch = p_time.ToString("yyyyMMdd");
+ _t_ASN_Detail.VendBatch = p_time.ToString("yyyyMMdd");
+ _t_ASN_Detail.Qty = itm.数量;
+ _t_ASN_Detail.State = (int)AsnState.Receive;
+ _t_ASN_Detail.CreateTime = p_time;
+ _t_ASN_Detail.CreateUser = p_creator;
+ _t_ASN_Detail.IsDeleted = false;
+ _t_ASN_Detail.GUID = Guid.NewGuid();
+ _t_ASN_Detail.PoUnit = itm.单位;
+ _t_ASN_Detail.ProduceDate = p_time;
+ db.TB_ASN_DETAIL.Add(_t_ASN_Detail);
+
+ var _reclist = p_order_list.Where(t => t.零件编号 == itm.零件编号 && t.采购订单号 == itm.采购订单号 && t.行号 == itm.行号).GroupBy(t => t.收货单号).ToList();
+ _reclist.ForEach((q) =>
+ {
+ var reclist = q.FirstOrDefault();
+ TB_RECEIVE _rec = new TB_RECEIVE();
+ _rec.RecvBillNum = reclist.收货单号;
+ _rec.State = (int)FormState.开放;
+ _rec.Remark = _ask.AskBillNum;
+ _rec.CreateTime = p_time;
+ _rec.CreateUser = p_creator;
+ _rec.IsDeleted = false;
+ _rec.GUID = System.Guid.NewGuid();
+ _rec.BillType = 0;
+ _rec.PoBillNum = reclist.采购订单号.ToUpper();
+ _rec.AsnBillNum = reclist.采购订单号.ToUpper();
+ _rec.Site = p_site;
+ _rec.VendId = reclist.供应商编码.ToUpper();
+ _rec.ShipTime = p_time;
+ db.TB_RECEIVE.Add(_rec);
+ var _recdetaillist = p_order_list.Where(f => f.收货单号 == reclist.收货单号).ToList();
+ _recdetaillist.ForEach((n) =>
+ {
+ TB_RECEIVE_DETAIL _t_RECEIVE_Detail = new TB_RECEIVE_DETAIL();
+ _t_RECEIVE_Detail.RecvBillNum = n.收货单号;
+ _t_RECEIVE_Detail.PoBillNum = n.采购订单号.ToUpper();
+ _t_RECEIVE_Detail.PoLine = Int32.Parse(n.行号);
+ _t_RECEIVE_Detail.PartCode = n.零件编号.ToUpper();
+ _t_RECEIVE_Detail.Batch = n.批次;
+ _t_RECEIVE_Detail.VendBatch = n.供应商批次;
+ _t_RECEIVE_Detail.PoUnit = n.单位;
+ _t_RECEIVE_Detail.LocUnit = "";
+ _t_RECEIVE_Detail.Qty = decimal.Parse(n.数量);
+ _t_RECEIVE_Detail.State = (int)FormState.开放;
+ _t_RECEIVE_Detail.Remark = _ask.AskBillNum;
+ _t_RECEIVE_Detail.CreateTime = p_time;
+ _t_RECEIVE_Detail.CreateUser = p_creator;
+ _t_RECEIVE_Detail.IsDeleted = false;
+ _t_RECEIVE_Detail.GUID = System.Guid.NewGuid();
+ _t_RECEIVE_Detail.BillType = 0;
+ db.TB_RECEIVE_DETAIL.Add(_t_RECEIVE_Detail);
+ });
+ });
+ });
}
+ else
+ {
+ _ret.MessageList.Add("请检查数据后,重新导入!");
+ return;
+ }
+ if (_ret.MessageList.Count == 0)
+ {
+ int state = db.SaveChanges();
+ if (state != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ );
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "EXCEL_ASN", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "EXCEL_ASN", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "EXCEL_ASN", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "EXCEL_ASN", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
+ private static List CheckExcel(ScpEntities db, SCP_ASN_EXCEL p_excel)
+ {
+ List ErrorList = new List();
+ if (!string.IsNullOrEmpty(p_excel.采购订单号))
+ {
+ int count = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.采购订单号&&p.PartCode== p_excel.零件编号&&p.PoLine== Int32.Parse( p_excel.行号));
+ if (count == 0)
+ {
+ ErrorList.Add(string.Format("订单编号{0}零件号{1}行号{2}不存在!", p_excel.采购订单号,p_excel.零件编号, p_excel.行号));
+ }
+ }
+ else
+ {
+ ErrorList.Add(string.Format("订单编号为空!"));
+ }
+ if (
+ string.IsNullOrEmpty(p_excel.收货单号) ||
+ string.IsNullOrEmpty(p_excel.采购订单号) ||
+ string.IsNullOrEmpty(p_excel.供应商编码) ||
+ string.IsNullOrEmpty(p_excel.价格) ||
+ string.IsNullOrEmpty(p_excel.零件编号) ||
+ string.IsNullOrEmpty(p_excel.行号) ||
+ string.IsNullOrEmpty(p_excel.批次) ||
+ string.IsNullOrEmpty(p_excel.数量) ||
+ string.IsNullOrEmpty(p_excel.单位) ||
+ string.IsNullOrEmpty(p_excel.价格))
+ {
+ ErrorList.Add(string.Format("收货单号【{1}】零件号【{0}】有填写为空!", p_excel.零件编号, p_excel.收货单号));
+ }
+ return ErrorList;
+ }
+ }
}
diff --git a/Controller/SCP_BARCODE_CONTROLLER.cs b/Controller/SCP_BARCODE_CONTROLLER.cs
index 5ba7830..5f3544b 100644
--- a/Controller/SCP_BARCODE_CONTROLLER.cs
+++ b/Controller/SCP_BARCODE_CONTROLLER.cs
@@ -267,6 +267,10 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.LocUnit.Contains(p_entity.LocUnit));
}
+ if (p_entity.IsScanned)
+ {
+ q = q.Where(p => p.IsScanned==false);
+ }
//if (!string.IsNullOrEmpty(p_entity.PartName))
//{
// q = q.Where(p => p.PartName.Contains(p_entity.PartName));
@@ -648,7 +652,8 @@ namespace CK.SCP.Controller
State = 0,
Remark = p_entity.UpdateInfo,
PackQty = p_entity.PackQty,
- Site = p_entity.Site
+ Site = p_entity.Site,
+ IsScanned = false
};
diff --git a/Controller/SCP_BILLCODE_CONTROLLER.cs b/Controller/SCP_BILLCODE_CONTROLLER.cs
index dd31204..bfe208d 100644
--- a/Controller/SCP_BILLCODE_CONTROLLER.cs
+++ b/Controller/SCP_BILLCODE_CONTROLLER.cs
@@ -66,7 +66,16 @@ namespace CK.SCP.Controller
return GetTablePK("E", "TB_ASK", "AskBillNum", "yyMMdd", 4);
}
+ ///
+ /// 生成收货单码
+ ///
+ ///
+ public static string MakeReviceCode_ASN()
+ {
+ return GetTablePK("C", "TB_RECEIVE", "RecvBillNum", "yyMMdd", 4);
+
+ }
public static string MakePLAN_EXTEND_ASKCode()
{
diff --git a/Controller/SCP_FORECAST_CONTROLLER.cs b/Controller/SCP_FORECAST_CONTROLLER.cs
index 12b2110..39c37e1 100644
--- a/Controller/SCP_FORECAST_CONTROLLER.cs
+++ b/Controller/SCP_FORECAST_CONTROLLER.cs
@@ -45,10 +45,10 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.State_DESC.Contains(p_entity.State_DESC));
}
- //if (!string.IsNullOrEmpty(p_entity.Month))
- //{
- // q = q.Where(p => p.Month == p_entity.Month);
- //}
+ if (!string.IsNullOrEmpty(p_entity.Month))
+ {
+ q = q.Where(p => p.Month == p_entity.Month);
+ }
q = q.Where(p => p.IsDeleted == p_entity.IsDeleted);
if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
{
@@ -288,7 +288,163 @@ namespace CK.SCP.Controller
}
return ErrorList;
}
+ ///
+ /// EXCEL导入(沈阳金杯)
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject EXCEL_FORECAST_MOD_SYJB(List p_order_list, string p_creator, string site)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ int number = 1;
+ List lineError = new List();
+ List ErrorList = new List();
+ var _lst = p_order_list;
+ _lst.ForEach
+ (p =>
+ {
+ var _ls = CheckExcelMode_Forecast_SYJB(db, p);
+ if (_ls.Count > 0)
+ {
+ lineError.Add(number.ToString());
+ ErrorList.Add(string.Join("
", _ls.ToArray()));
+ }
+ number++;
+ });
+ if (lineError.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.MessageList.AddRange(ErrorList);
+ _ret.Result = false;
+ }
+ else
+ {
+ _lst.ForEach(p =>
+ {
+ var _item = db.TB_FORECAST.SingleOrDefault(t => t.PartCode == p.零件编号.ToUpper() && t.VendId == p.供应商编码 && t.Month == p.月份&&t.State!=(int)ForecastState.Reject) ??
+ new TB_FORECAST { PartCode = p.零件编号.ToUpper(), VendId = p.供应商编码, Month = p.月份, GUID = System.Guid.NewGuid() };
+ _item.MonthQty1 = decimal.Parse(p.预测1);
+ _item.MonthQty2 = decimal.Parse(p.预测2);
+ _item.MonthQty3 = decimal.Parse(p.预测3);
+ _item.IsDeleted = false;
+ _item.CreateUser = p_creator;
+ _item.CreateTime = DateTime.Now;
+ _item.State = (int)ForecastState.New;
+ _item.UpdateInfo = "";
+ _item.Site = site;
+ db.TB_FORECAST.AddOrUpdate(_item);
+ });
+ if (_ret.MessageList.Count == 0)
+ {
+ int state = db.SaveChanges();
+ if (state != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
+ ///
+ /// 导入验证(沈阳金杯)
+ ///
+ ///
+ ///
+ ///
+ private static List CheckExcelMode_Forecast_SYJB(ScpEntities db, SCP_FORECAST_EXPORT_SYJB p_excel)
+ {
+ List ErrorList = new List();
+ var _item = db.TB_FORECAST.SingleOrDefault(t => t.PartCode == p_excel.零件编号.ToUpper() && t.VendId == p_excel.供应商编码 && t.Month == p_excel.月份 && t.State == (int)ForecastState.Confirm);
+ if (_item != null)
+ {
+ ErrorList.Add(string.Format("零件编号【{0}】,月份【{1}】,供应商【{2}】的数据供应商已确认无法修改", p_excel.零件编号, p_excel.月份, p_excel.供应商编码));
+ }
+ if (
+ string.IsNullOrEmpty(p_excel.零件编号) ||
+ string.IsNullOrEmpty(p_excel.供应商编码) ||
+ string.IsNullOrEmpty((p_excel.月份).ToString()) ||
+ string.IsNullOrEmpty(p_excel.预测1) ||
+ string.IsNullOrEmpty(p_excel.预测2) ||
+ string.IsNullOrEmpty(p_excel.预测3))
+ {
+ ErrorList.Add(string.Format("零件编号【{0}】有填写为空!", p_excel.零件编号));
+ }
+ return ErrorList;
+ }
public static ResultObject Save_TB_FORECAST_STATE(List p_list, string p_user, ForecastState State)
{
ResultObject _ret = new ResultObject();
diff --git a/Controller/SCP_INVOICE_CONTROLLER.cs b/Controller/SCP_INVOICE_CONTROLLER.cs
index 981ea96..2afc114 100644
--- a/Controller/SCP_INVOICE_CONTROLLER.cs
+++ b/Controller/SCP_INVOICE_CONTROLLER.cs
@@ -167,9 +167,6 @@ namespace CK.SCP.Controller
}
-
-
-
public static List Get_V_TB_INVOICE_BY_TIME(string p_begin,string p_end,string p_po,string p_asn)
{
List _list = new List();
@@ -201,7 +198,6 @@ namespace CK.SCP.Controller
return _list;
}
-
public static void Get_V_TB_INVOICE_List(V_TB_INVOICE p_entity, Action>> p_action)
{
ResultObject> _ret = new ResultObject>();
@@ -272,6 +268,10 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
}
+ if (!string.IsNullOrEmpty(p_entity.AskCreateUser))
+ {
+ q = q.Where(p => p.AskCreateUser==p_entity.AskCreateUser);
+ }
if (p_entity.InvoiceList!=null && p_entity.InvoiceList.Count>0)
{
q = q.Where(p => p_entity.InvoiceList.Contains(p.InvcBillNum));
@@ -335,11 +335,8 @@ namespace CK.SCP.Controller
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "Get_V_TB_INVOICE_List", e.Message);
throw e;
}
-
}
-
-
public static void Get_V_TB_INVOICE_ERP_List(V_TB_INVOICE p_entity, Action>> p_action)
{
ResultObject> _ret = new ResultObject>();
@@ -940,7 +937,6 @@ namespace CK.SCP.Controller
}
-
public static ResultObject CREATE_TB_INVOICE(V_TB_INVOICE p_entity,List p_list)
{
ResultObject _ret = new ResultObject();
@@ -1090,6 +1086,166 @@ namespace CK.SCP.Controller
return _ret;
}
+ ///
+ /// 创建发票(模具分摊计数)
+ ///
+ ///
+ ///
+ /// 是否限额验证
+ ///
+ public static ResultObject CREATE_TB_INVOICE_MOLDSHARING(V_TB_INVOICE p_entity, List p_list)
+ {
+ ResultObject _ret = new ResultObject();
+ List _list = new List();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ decimal _total = 0;
+ TB_INVOICE invoice = new TB_INVOICE();
+ invoice.InvcBillNum = SCP_BILLCODE_CONTROLLER.MakeInvoiceCode();
+ invoice.VendId = p_entity.VendId;
+ invoice.CreateTime = DateTime.Now;
+ invoice.InvoiceNum = "";
+ invoice.ExpressNum = "";
+ invoice.Remark = p_entity.Remark;
+ invoice.CreateUser = p_entity.CreateUser;
+ invoice.CreateTime = DateTime.Now;
+ invoice.Site = p_entity.Site;
+ invoice.State = (int)InvoiceState.New;
+ invoice.IsDeleted = false;
+ invoice.GUID = Guid.NewGuid();
+ invoice.Tax = p_entity.Tax;
+ invoice.IsRed = false;
+ db.TB_INVOICE.AddOrUpdate(invoice);
+ p_list.ForEach(p => {
+
+ TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL();
+ invocieDetail.InvcBillNum = invoice.InvcBillNum;
+ invocieDetail.AsnBillNum = p.AsnBillNum;
+ invocieDetail.AskBillNum = p.Remark;
+ invocieDetail.PoBillNum = p.PoBillNum;
+ invocieDetail.PoLineNum = p.PoLine;
+ invocieDetail.RecvBillNum = p.RecvBillNum;
+ invocieDetail.ErpRecvBillNum = p.ErpRecvBillNum;
+ invocieDetail.CreateUser = invoice.CreateUser;
+ invocieDetail.CreateTime = invoice.CreateTime;
+ invocieDetail.PoUnit = p.PoUnit; //自己改数据库
+ invocieDetail.PartCode = p.PartCode;
+ invocieDetail.Price = p.Price;//自己改数据库
+ invocieDetail.Batch = p.Batch;
+ invocieDetail.VendBatch = p.VendBatch;
+ invocieDetail.Qty = p.Qty;
+ invocieDetail.Currency = p.Currency;//自己改数据库
+ invocieDetail.IsDeleted = false;
+ invocieDetail.State = (int)InvoiceState.New;
+ invocieDetail.GUID = Guid.NewGuid();
+ invocieDetail.Remark ="";
+ invocieDetail.IsRed = false;
+ invocieDetail.BlancePrice = p.BlancePrice;//模具分摊价格
+ invocieDetail.DiscountPrice = p.DiscountPrice;//供应商价格
+ db.TB_INVOICE_DETAIL.AddOrUpdate(invocieDetail);
+ var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.VendId == p.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper()&&t.Qty!=t.Count);
+ if(_moldsharing!=null )
+ {
+ var _num = _moldsharing.Count + p.Qty;
+ if (_moldsharing.Qty < _num)
+ {
+ string _str ="供应商"+ _moldsharing .VendId+ "零件名称"+ _moldsharing.PartCode+"超过分摊数量"+ (_num- _moldsharing.Qty).ToString();
+ _list.Add(_str);
+ }
+ else
+ {
+ _moldsharing.Count = _num;
+ db.TA_MoldSharing.AddOrUpdate(_moldsharing);
+ }
+ TA_MOLDSHARING_INVOICE MoldSharingInvoice = new TA_MOLDSHARING_INVOICE();
+ MoldSharingInvoice.InvcBillNum = invoice.InvcBillNum;
+ MoldSharingInvoice.MoldSharingId = _moldsharing.UID;
+ MoldSharingInvoice.PoLineNum = p.PoLine;
+ MoldSharingInvoice.PartCode = p.PartCode;
+ MoldSharingInvoice.Batch = p.Batch;
+ MoldSharingInvoice.ErpRecvBillNum = p.ErpRecvBillNum;
+ MoldSharingInvoice.RecvBillNum = p.RecvBillNum;
+ MoldSharingInvoice.Price = p.Price;
+ MoldSharingInvoice.Qty = p.Qty;
+ MoldSharingInvoice.InvcGUID = invocieDetail.GUID;
+ db.TA_MoldSharing_Invoice.Add(MoldSharingInvoice);
+ }
+ _total += Convert.ToDecimal(p.Qty * p.Price);
+ });
+ if (_list.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.MessageList = _list;
+ }
+ else
+ {
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE_MOLDSHARING", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE_MOLDSHARING", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE_MOLDSHARING", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE_MOLDSHARING", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
+
public static ResultObject SAVE_TB_INVOICE_STATE(string p_billno, InvoiceState p_state)
{
ResultObject _ret = new ResultObject();
@@ -1330,10 +1486,7 @@ namespace CK.SCP.Controller
return _ret;
}
-
-
-
- public static ResultObject SAVE_TB_INVOICE_STATE(V_TB_INVOICE invoice, InvoiceState p_state,string p_username="")
+ public static ResultObject SAVE_TB_INVOICE_STATE(V_TB_INVOICE invoice, InvoiceState p_state,string p_username="", string p_flag = "")
{
ResultObject _ret = new ResultObject();
try
@@ -1365,7 +1518,7 @@ namespace CK.SCP.Controller
_entity.ContractPrice = invoice.ContractPrice;
_entity.BlancePrice = invoice.BlancePrice;
- _entity.DiscountPrice = invoice.DiscountPrice;
+ _entity.DiscountPrice = invoice.DiscountPrice;//问题
}
if (p_state == InvoiceState.CheckFail)
{
@@ -1490,7 +1643,7 @@ namespace CK.SCP.Controller
}
_entity.ContractPrice = invoice.ContractPrice;
_entity.BlancePrice = invoice.BlancePrice;
- _entity.DiscountPrice = invoice.DiscountPrice;
+ _entity.DiscountPrice = invoice.DiscountPrice;//问题
}
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList();
@@ -1510,6 +1663,18 @@ namespace CK.SCP.Controller
_list.ForEach(p => {
p.State = (int)p_state;
p.IsDeleted = true;
+ if (!string.IsNullOrEmpty(p_flag))//修改分摊数量
+ {
+ var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.VendId == invoice.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper());
+ var _ms_detail = db.TA_MoldSharing_Invoice.SingleOrDefault(t =>t.InvcGUID==p.GUID);
+ if (_moldsharing != null&& _ms_detail!=null)
+ {
+ db.TA_MoldSharing_Invoice.Remove(_ms_detail);
+ var _num = _moldsharing.Count - p.Qty;
+ _moldsharing.Count = _num;
+ db.TA_MoldSharing.AddOrUpdate(_moldsharing);
+ }
+ }
});
}
@@ -1673,9 +1838,10 @@ namespace CK.SCP.Controller
return _ret;
}
- public static ResultObject SAVE_TB_INVOICE_APPLY(V_TB_INVOICE p_invoice, List p_list)
+ public static ResultObject SAVE_TB_INVOICE_APPLY(V_TB_INVOICE p_invoice, List p_list,string p_flag="")
{
ResultObject _ret = new ResultObject();
+ List _list = new List();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
@@ -1697,6 +1863,7 @@ namespace CK.SCP.Controller
db.TB_INVOICE.AddOrUpdate(p => p.InvcBillNum, _bill);
p_list.ForEach(p => {
var _detail=db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault();
+ var _qty = _detail.Qty - p.Qty;
_detail.State =(int)p.State;
_detail.Qty = p.Qty;
_detail.Price = p.Price;
@@ -1711,6 +1878,26 @@ namespace CK.SCP.Controller
}
_detail.Remark = p.Remark;
db.TB_INVOICE_DETAIL.AddOrUpdate(itm=>itm.UID,_detail);
+ if(!string.IsNullOrEmpty(p_flag))//修改发票数量对分摊数修改
+ {
+ var _ms = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.PartCode == _detail.PartCode && t.VendId == _bill.VendId);
+ var _ms_detail= db.TA_MoldSharing_Invoice.SingleOrDefault(t =>t.InvcGUID== _detail.GUID);
+ if (_ms != null&& _ms_detail!=null)
+ {
+ _ms.Count = _ms.Count - _qty;
+ if (_ms.Count > _ms.Qty)
+ {
+ string _str = "供应商" + _ms.VendId + "零件名称" + _ms.PartCode + "超出分摊数量" + (_ms.Count - _ms.Qty).ToString();
+ _list.Add(_str);
+ }
+ else
+ {
+ _ms_detail.Qty = p.Qty;
+ }
+ db.TA_MoldSharing.AddOrUpdate(_ms);
+ db.TA_MoldSharing_Invoice.AddOrUpdate(_ms_detail);
+ }
+ }
});
#region 供应商代办采购退回任务新
@@ -1728,6 +1915,14 @@ namespace CK.SCP.Controller
db.TB_PENING_ITEMS.Add(_item);
#endregion
+ if (_list.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.MessageList = _list;
+ }
+ else
+ {
if (db.SaveChanges() != -1)
{
_ret.State = ReturnStatus.Succeed;
@@ -1737,6 +1932,7 @@ namespace CK.SCP.Controller
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
+ }
}
}
}
@@ -1798,6 +1994,7 @@ namespace CK.SCP.Controller
}
return _ret;
}
+
public static ResultObject SAVE_TB_INVOICE_APPLY2(V_TB_INVOICE_RED p_invoice, List p_list)
{
ResultObject _ret = new ResultObject();
@@ -2079,7 +2276,6 @@ namespace CK.SCP.Controller
return _ret;
}
-
public ResultObject Del_TB_INVOICE_DETAIL(List p_entitys)
{
ResultObject _ret = new ResultObject();
@@ -2160,7 +2356,6 @@ namespace CK.SCP.Controller
}
return _ret;
}
-
public static ResultObject CaiWu_Return_Reason(string p_InvcBillNum,string p_Memo)
{
ResultObject _ret = new ResultObject();
@@ -2279,8 +2474,7 @@ namespace CK.SCP.Controller
}
return _ret;
}
-
- public static ResultObject UpdateMemoByInvcBillNum(string p_InvcBillNum, string p_Memo)
+ public static ResultObject UpdateMemoByInvcBillNum_SYJB(string p_InvcBillNum, string p_Memo, DateTime updatetime, decimal p_blan = 0, decimal p_contranctprice = 0, string p_InvoiceNumber = null)
{
ResultObject _ret = new ResultObject();
try
@@ -2288,10 +2482,11 @@ namespace CK.SCP.Controller
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
TB_INVOICE invoice = db.TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault();
-
+ invoice.InvoiceNum = p_InvoiceNumber;
+ invoice.BlancePrice = p_blan;
+ invoice.ContractPrice = p_contranctprice;
invoice.Remark = p_Memo;
-
-
+ invoice.UpdateTime = updatetime;
db.TB_INVOICE.AddOrUpdate(invoice);
if (db.SaveChanges() != -1)
@@ -2321,32 +2516,32 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(dbEx);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum", sb.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum_SYJB", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum_SYJB", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
-
+
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum_SYJB", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
-
+
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
@@ -2359,12 +2554,11 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(e);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum", e.Message); throw e;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "UpdateMemoByInvcBillNum_SYJB", e.Message); throw e;
}
return _ret;
}
-
public static ResultObject UpdateMemoByInvcBillNum(string p_InvcBillNum, string p_Memo, decimal p_blan, string p_inv,DateTime p_time)
{
ResultObject _ret = new ResultObject();
@@ -2451,9 +2645,141 @@ namespace CK.SCP.Controller
return _ret;
}
+ public static ResultObject SET_INVOICE_STATE_SYJB(string p_InvcBillNum, InvoiceState p_state, string datetime = null)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ TB_INVOICE invoice = db.TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault();
+ if (invoice != null)
+ {
+ invoice.State = (int)p_state;
+ db.TB_INVOICE.AddOrUpdate(invoice);
+
+ if (p_state == InvoiceState.Mail)
+ {
+ List invoicedetail = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList();
+
+ foreach (TB_INVOICE_DETAIL det in invoicedetail)
+ {
+ det.State = (int)p_state;
+ }
+ }
+
+ //财务审核通过,把所有代办信息设为已办状态
+ if (p_state == InvoiceState.FinanceReceive)
+ {
+ if (string.IsNullOrEmpty(datetime))
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "请填写确认收票时间";
+ return _ret;
+ }
+ DateTime updatetime = DateTime.Parse(datetime);
+ invoice.UpdateTime = updatetime;//确认收票时间
+
+ List items = db.TB_PENING_ITEMS.Where(p => p.ITEM_NO == p_InvcBillNum).ToList();
+ foreach (TB_PENING_ITEMS item in items)
+ {
+ item.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
+ }
+
+ List _ls = db.V_TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList();
+ V_TB_INVOICE _bill = db.V_TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault();
+ foreach (V_TB_INVOICE_DETAIL itm in _ls)
+ {
+ _bill.UpdateTime = updatetime;//确认收票时间
+ itm.UpdateTime = updatetime;//确认收票时间
+ TS_UNI_API _api = UniApiController.CreateBy(_bill, itm, UniApiType.Invoice);
+ _api.State = 1;
+ db.TS_UNI_API.AddOrUpdate(_api);
+ itm.State = (int)p_state;
+ }
+ }
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ _ret.Message = invoice.VendId;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = invoice.VendId;
+ }
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = invoice.VendId;
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_SYJB", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_SYJB", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_SYJB", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_SYJB", e.Message); throw e;
+ }
+ return _ret;
+ }
public static ResultObject SET_INVOICE_STATE(string p_InvcBillNum, InvoiceState p_state)
{
ResultObject _ret = new ResultObject();
@@ -2689,7 +3015,7 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(dbEx);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE", sb.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "Add_New_Red_Invoice", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
@@ -2698,7 +3024,7 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "Add_New_Red_Invoice", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
@@ -2708,7 +3034,7 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "Add_New_Red_Invoice", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
@@ -2725,7 +3051,7 @@ namespace CK.SCP.Controller
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "CREATE_TB_INVOICE", e.Message);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "Add_New_Red_Invoice", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
diff --git a/Controller/SCP_MoldSharing_Controller.cs b/Controller/SCP_MoldSharing_Controller.cs
new file mode 100644
index 0000000..c578f30
--- /dev/null
+++ b/Controller/SCP_MoldSharing_Controller.cs
@@ -0,0 +1,524 @@
+using System;
+using System.Linq;
+using CK.SCP.Models.Enums;
+using CK.SCP.Models.ScpEntity;
+using CK.SCP.Utils;
+using CK.SCP.Models;
+using System.Data;
+using System.Data.Entity.Core;
+using System.Text;
+using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
+using System.Collections.Generic;
+using System.Data.Entity.Migrations;
+
+namespace CK.SCP.Controller
+{
+ public class SCP_MoldSharing_Controller
+ {
+ ///
+ /// 获取模具分摊列表
+ ///
+ ///
+ ///
+ public static void Get_V_TA_MoldSharing_List(TA_MOLDSHARING p_entity, Action>> p_action)
+ {
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ IQueryable q = db.TA_MoldSharing;
+ if (p_entity.UID!=0)
+ {
+ q = q.Where(p => p.UID == p_entity.UID);
+ }
+ if (!string.IsNullOrEmpty(p_entity.PartCode))
+ {
+ q = q.Where(p => p.PartCode == p_entity.PartCode);
+ }
+ if (!string.IsNullOrEmpty(p_entity.VendId))
+ {
+ q = q.Where(p => p.VendId == p_entity.VendId);
+ }
+ q = q.Where(p => p.IsDeleted == p_entity.IsDeleted);
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MoldSharing_List", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MoldSharing_List", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MoldSharing_List", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MoldSharing_List", e.Message);
+ throw e;
+ }
+
+ }
+
+
+ public static void Get_V_TA_MOLDSHARING_INVOICE_List(TA_MOLDSHARING_INVOICE p_entity, Action>> p_action)
+ {
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ IQueryable q = db.TA_MoldSharing_Invoice;
+ if (p_entity.MoldSharingId != 0)
+ {
+ q = q.Where(p => p.MoldSharingId == p_entity.MoldSharingId);
+ }
+ if (!string.IsNullOrEmpty(p_entity.PartCode))
+ {
+ q = q.Where(p => p.PartCode == p_entity.PartCode);
+ }
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MOLDSHARING_INVOICE_List", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MOLDSHARING_INVOICE_List", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MOLDSHARING_INVOICE_List", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Get_V_TA_MOLDSHARING_INVOICE_List", e.Message);
+ throw e;
+ }
+
+ }
+ ///
+ /// 模具分摊导入
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject EXCEL_MOLDSHARING_MOD(List p_order_list, string site, string p_creator)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ int number = 1;
+ List lineError = new List();
+ List ErrorList = new List();
+ var _lst = p_order_list;
+ _lst.ForEach(p =>
+ {
+ var _ls = CheckExcelMode_MoldSharing(db, p, site);
+ if (_ls.Count > 0)
+ {
+ lineError.Add(number.ToString());
+ ErrorList.Add(string.Join("
", _ls.ToArray()));
+ }
+ number++;
+ });
+ if (lineError.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.MessageList.AddRange(ErrorList);
+ _ret.Result = false;
+ }
+ else
+ {
+ _lst.ForEach(p =>
+ {
+ var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t => t.VendId == p.供应商编码.ToUpper() && t.PartCode == p.零件编码.ToUpper()) ??
+ new TA_MOLDSHARING
+ {
+ VendId = p.供应商编码.ToUpper(),
+ PartCode = p.零件编码.ToUpper(),
+ CreateTime = DateTime.Now,
+ CreateUser = p_creator,
+ IsDeleted = false,
+ Count = 0,
+ };
+ _moldsharing.Price = decimal.Parse(p.价格);
+ _moldsharing.TotalCount = decimal.Parse(p.分摊总量);
+ _moldsharing.InitialQty = decimal.Parse(p.初始已分摊数量);
+ _moldsharing.Qty = (_moldsharing.TotalCount - _moldsharing.InitialQty);
+ _moldsharing.UpdateTime = DateTime.Now;
+ _moldsharing.UpdateUser = p_creator;
+ _moldsharing.Site = site;
+ if(_moldsharing.Qty< _moldsharing.Count)
+ {
+ _ret.MessageList.Add(string.Format("零件号{0}(分摊总量-初始已分摊数量)小于已累计数量!", _moldsharing.PartCode));
+ }
+ else
+ {
+ db.TA_MoldSharing.AddOrUpdate(_moldsharing);
+ }
+ });
+ if (_ret.MessageList.Count == 0)
+ {
+ int state = db.SaveChanges();
+ if (state != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ }
+
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "EXCEL_MOLDSHARING_MOD", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "EXCEL_MOLDSHARING_MOD", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "EXCEL_MOLDSHARING_MOD", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "EXCEL_MOLDSHARING_MOD", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
+ ///
+ /// 数据检验
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static List CheckExcelMode_MoldSharing(ScpEntities db, SCP_MOLDSHARING_EXPORT p_excel, string site)
+ {
+ List ErrorList = new List();
+ if (!string.IsNullOrEmpty(p_excel.供应商编码))
+ {
+ int count = db.TA_VENDER.Count(p => p.VendId == p_excel.供应商编码 && p.Site == site);
+ if (count <= 0)
+ {
+ ErrorList.Add(string.Format("供应商{0}不存在!", p_excel.供应商编码));
+ }
+ }
+ else
+ {
+ ErrorList.Add(string.Format("供应商代码为空!"));
+ }
+ if (!string.IsNullOrEmpty(p_excel.零件编码))
+ {
+ int count = db.TA_PART.Count(p => p.PartCode == p_excel.零件编码 && p.Site == site);
+ if (count <= 0)
+ {
+ ErrorList.Add(string.Format("零件编号{0}不存在!", p_excel.零件编码));
+ }
+ }
+ else
+ {
+ ErrorList.Add(string.Format("零件号为空!"));
+ }
+ if (
+ string.IsNullOrEmpty(p_excel.供应商编码) ||
+ string.IsNullOrEmpty(p_excel.零件编码) ||
+ string.IsNullOrEmpty(p_excel.价格) ||
+ string.IsNullOrEmpty(p_excel.分摊总量)||
+ string.IsNullOrEmpty(p_excel.初始已分摊数量))
+ {
+ ErrorList.Add(string.Format("供应商代码【{0}】零件编号【{1}】有填写为空!", p_excel.供应商编码, p_excel.零件编码));
+ }
+ return ErrorList;
+ }
+ ///
+ /// 获取模具分摊价格(沈阳模具分摊)
+ ///
+ ///
+ ///
+ public static List GET_MoldSharing_LIST_SYJB(List p_list)
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ if (p_list.Count > 0)
+ {
+ p_list.ForEach(p =>
+ {
+ //var entity_price = db.V_TB_PRICE.Where(t => t.VendId == p.VendId && t.PartCode == p.PartCode && t.StartTime <= DateTime.Now).FirstOrDefault();
+ //if (entity_price != null)
+ //{
+ // p.Price = entity_price.Amt;
+ //}
+ var _entity = db.TA_MoldSharing.Where(itm => itm.Qty!= itm.Count && itm.PartCode == p.PartCode && itm.VendId == p.VendId &&itm.IsDeleted==false).FirstOrDefault();
+ if (_entity != null)
+ {
+ p.Price += decimal.Parse(_entity.Price.ToString());
+ }
+ });
+ }
+ }
+ return p_list;
+ }
+ ///
+ /// 获取模具分摊价格
+ ///
+ ///
+ ///
+ public static List GET_MoldSharing_LIST(List p_list)
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ if (p_list.Count > 0)
+ {
+ p_list.ForEach(p =>
+ {
+ var _entity = db.TA_MoldSharing.Where(itm => itm.Qty > itm.Count && itm.PartCode == p.PartCode && itm.VendId == p.VendId &&itm.IsDeleted==false).FirstOrDefault();
+ if (_entity != null)
+ {
+ p.BlancePrice = decimal.Parse(_entity.Price.ToString());
+ }
+ else
+ {
+ p.BlancePrice = 0;
+ }
+ });
+ }
+ }
+ return p_list;
+ }
+ public static ResultObject Save_TA_MOLDSHARING_STATE (List p_list, string p_user, bool p_isdelete)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+
+ if (p_isdelete == true)
+ {
+ var _ls = db.TA_MoldSharing.Where(p => p_list.Contains(p.UID)&& p.Count <= 0).ToList();
+ if (_ls.Count > 0)
+ {
+ _ls.ForEach(p =>
+ {
+ p.IsDeleted = true;
+ p.UpdateTime = DateTime.Now;
+ p.UpdateUser = p_user;
+ }
+ );
+ db.TA_MoldSharing.AddOrUpdate(p => p.UID, _ls.ToArray());
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "选择的记录,已经开始计数不能删除!";
+ }
+ }
+ if (string.IsNullOrEmpty(_ret.Message))
+ {
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.Message = "数据更新失败!";
+ }
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Save_TA_MOLDSHARING_STATE", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Save_TA_MOLDSHARING_STATE", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Save_TA_MOLDSHARING_STATE", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MoldSharing_Controller), "Save_TA_MOLDSHARING_STATE", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+
+ return _ret;
+ }
+ }
+}
diff --git a/Controller/SCP_PLAN_CONTROLLER.cs b/Controller/SCP_PLAN_CONTROLLER.cs
index d50df0e..7598f01 100644
--- a/Controller/SCP_PLAN_CONTROLLER.cs
+++ b/Controller/SCP_PLAN_CONTROLLER.cs
@@ -1004,6 +1004,7 @@ namespace CK.SCP.Controller
_extend.VendId = dr["供应商编码"].ToString();
_extend.CreateTime = DateTime.Now;
_extend.Site = dr["域"].ToString();
+
_extend.PoUnit = dr["单位"].ToString();
_ls.Add(_extend);
}
@@ -1603,6 +1604,7 @@ namespace CK.SCP.Controller
_ask.BuyerPhone = p_user.CellPhone;
_ask.ErpBillNum = _entity.PoBillNum;
_ask.EndTime = _entity.EndTime;
+ _ask.SubSite = _entity.Site;
_ask.CreateTime = DateTime.Now;
_ask.CreateUser = p_user.Name;
_ask.VendId = _entity.VendId;
@@ -1649,7 +1651,8 @@ namespace CK.SCP.Controller
_t_ASK_Detail.IsDeleted = false;
_t_ASK_Detail.LocUnit = itm.PoUnit;
_t_ASK_Detail.UnConv = 1;
- _t_ASK_Detail.Remark =_ask.Site;
+ _t_ASK_Detail.Site =_ask.Site;
+ _t_ASK_Detail.SubSite = _ask.SubSite;
_t_ASK_Detail.State = _ask.State;
// _t_ASK_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.价格);
_t_ASK_Detail.GUID = Guid.NewGuid();
diff --git a/Controller/SCP_PO_CONTROLLER.cs b/Controller/SCP_PO_CONTROLLER.cs
index 6a81dee..d366f22 100644
--- a/Controller/SCP_PO_CONTROLLER.cs
+++ b/Controller/SCP_PO_CONTROLLER.cs
@@ -32,7 +32,7 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.PoBillNum))
{
- q = q.Where(p => p.PoBillNum.Contains( p_entity.PoBillNum));
+ q = q.Where(p => p.PoBillNum == p_entity.PoBillNum);
}
if (!string.IsNullOrEmpty(p_entity.ErpBillNum))
{
@@ -607,28 +607,29 @@ namespace CK.SCP.Controller
}
- var _count = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.QAD订单号 && p.PartCode == p_excel.零件号 && p.PoLine.ToString() == p_excel.行号);
+ var _list = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.QAD订单号 && p.PartCode == p_excel.零件号).ToList();
if (
string.IsNullOrEmpty(p_excel.分组编号) ||
string.IsNullOrEmpty(p_excel.QAD订单号) ||
string.IsNullOrEmpty(p_excel.供应商编号) ||
- string.IsNullOrEmpty(p_excel.订货日期) ||
string.IsNullOrEmpty(p_excel.要求到货日期) ||
string.IsNullOrEmpty(p_excel.零件号) ||
- string.IsNullOrEmpty(p_excel.要货地点) ||
string.IsNullOrEmpty(p_excel.交货联系人) ||
- string.IsNullOrEmpty(p_excel.交货联系人电话) ||
- string.IsNullOrEmpty(p_excel.数量) ||
- string.IsNullOrEmpty(p_excel.单位) ||
- string.IsNullOrEmpty(p_excel.价格) ||
- string.IsNullOrEmpty(p_excel.币种))
+ string.IsNullOrEmpty(p_excel.数量))
{
ErrorList.Add(string.Format("分组【{1}】零件号【{0}】有填写为空!", p_excel.零件号, p_excel.分组编号));
}
- if (_count == 0)
+ if (_list.Count == 0)
{
ErrorList.Add(string.Format("分组【{2}】零件号【{0}】行号【{1}】不存在!", p_excel.零件号, p_excel.行号, p_excel.分组编号));
}
+ else
+ {
+ p_excel.行号 = _list[0].PoLine.ToString();
+ p_excel.价格= _list[0].Price.ToString();
+ p_excel.单位 = _list[0].PoUnit.ToString();
+ p_excel.币种 = _list[0].Currency.ToString();
+ }
return ErrorList;
@@ -1011,9 +1012,6 @@ namespace CK.SCP.Controller
_t_ASK_Detail.GUID = Guid.NewGuid();
_t_ASK_Detail.Remark = _ask.Site;
_t_ASK_Detail.UpdateInfo = itm.备注;
- _t_ASK_Detail.Extend1 = itm.预测一;
- _t_ASK_Detail.Extend2 = itm.预测二;
- _t_ASK_Detail.Extend3 = itm.预测三;
db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
_ls.Add(_t_ASK_Detail);
// _number++;
@@ -1895,7 +1893,7 @@ namespace CK.SCP.Controller
}
return ErrorList;
}
- public static ResultObject EXCEL_PO_TO_ASK(List p_order_list, string p_creator, string p_buyer, DateTime p_time, BillModType p_modtype, bool IsAutoPublish = false)
+ public static ResultObject EXCEL_PO_TO_ASK(List p_order_list, string p_creator, string p_buyer, DateTime p_time, BillModType p_modtype, string p_site, bool IsAutoPublish = false)
{
ResultObject _ret = new ResultObject();
try
@@ -1928,9 +1926,9 @@ namespace CK.SCP.Controller
p_order_list = p_order_list.Where(p => int.Parse(p.数量) != 0).ToList();
- var VenderList = p_order_list.Select(p => p.供应商编号).Distinct();
- var PartCodeList = p_order_list.Select(p => p.零件号).Distinct();
- var OrderList = p_order_list.GroupBy(p => p.分组编号).ToList();
+ //var VenderList = p_order_list.Select(p => p.供应商编号).Distinct();
+ //var PartCodeList = p_order_list.Select(p => p.零件号).Distinct();
+ var OrderList = p_order_list.GroupBy(p =>new { p.分组编号, p.供应商编号 }).ToList();
OrderList.ForEach((p) =>
{
var list_distinct = p.GroupBy(t => new { t.零件号, t.行号 }).ToList();
@@ -1946,11 +1944,10 @@ namespace CK.SCP.Controller
var _entity = list.FirstOrDefault();
TB_ASK _ask = new TB_ASK();
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode();
- _ask.VendId = _entity.要货地点;
_ask.State = (int)AskState.New;
_ask.PoBillNum = _entity.QAD订单号.ToUpper();
_ask.ModType = (int)BillModType.Contract;
- _ask.Site = _entity.要货地点;
+ _ask.Site = p_site;
if (IsAutoPublish)
{
_ask.State = (int)AskState.Release;
@@ -1959,12 +1956,12 @@ namespace CK.SCP.Controller
{
_ask.State = (int)AskState.New;
}
- _ask.BeginTime = DateTime.Parse(_entity.订货日期);
+ _ask.BeginTime = DateTime.Now;
_ask.Buyer = _entity.交货联系人;
_ask.BuyerPhone = _entity.交货联系人电话;
_ask.ErpBillNum = _entity.QAD订单号.ToUpper();
_ask.EndTime = DateTime.Parse(_entity.要求到货日期);
- _ask.CreateTime = DateTime.Parse(_entity.订货日期);
+ _ask.CreateTime = DateTime.Now;
_ask.CreateUser = p_creator;
_ask.VendId = _entity.供应商编号.ToUpper();
_ask.GUID = Guid.NewGuid();
@@ -1996,8 +1993,8 @@ namespace CK.SCP.Controller
_t_ASK_Detail.PoUnit = itm.单位;
_t_ASK_Detail.CreateTime = DateTime.Now;
_t_ASK_Detail.CreateUser = _ask.CreateUser;
- _t_ASK_Detail.PartCode = itm.零件号.ToUpper();
- _t_ASK_Detail.BeginTime = DateTime.Parse(itm.订货日期);
+ _t_ASK_Detail.PartCode = (itm.零件号.ToUpper()).TrimEnd();
+ _t_ASK_Detail.BeginTime = _ask.BeginTime;
_t_ASK_Detail.EndTime = DateTime.Parse(itm.要求到货日期);
_t_ASK_Detail.TempQty = decimal.Parse(itm.数量);
_t_ASK_Detail.AskQty = decimal.Parse(itm.数量);
@@ -2007,6 +2004,7 @@ namespace CK.SCP.Controller
_t_ASK_Detail.State = _ask.State;
_t_ASK_Detail.Price = string.IsNullOrEmpty(itm.价格) ? 0 : decimal.Parse(itm.价格);
_t_ASK_Detail.GUID = Guid.NewGuid();
+ _t_ASK_Detail.Remark = itm.备注;
db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
// _number++;
@@ -2096,7 +2094,14 @@ namespace CK.SCP.Controller
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_TO_ASK", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
- throw e;
+ if (e.InnerException != null)
+ {
+ _ret.MessageList.Add(e.InnerException.Message);
+ }
+ else
+ {
+ _ret.MessageList.Add(e.Message);
+ }
}
return _ret;
@@ -2599,114 +2604,6 @@ namespace CK.SCP.Controller
return _ret;
}
- public static void Get_V_TB_PO_DETAIL_List_STATISTICS(V_TB_PO_DETAIL p_entity, Action>> p_action)
- {
- ResultObject> _ret = new ResultObject>();
- try
- {
- using (ScpEntities db = EntitiesFactory.CreateScpInstance())
- {
- IQueryable q = db.V_TB_PO_DETAIL;
-
- if (!string.IsNullOrEmpty(p_entity.PoBillNum))
- {
- q = q.Where(p => p.PoBillNum.Contains(p_entity.PoBillNum));
- }
- if (!string.IsNullOrEmpty(p_entity.ErpBillNum))
- {
- q = q.Where(p => p.ErpBillNum.Contains(p_entity.ErpBillNum));
- }
- if (p_entity.BeginTime != null)
- {
- q = q.Where(p => p.BeginTime >= p_entity.BeginTime);
- }
- if (p_entity.EndTime != null)
- {
- q = q.Where(p => p.BeginTime <= p_entity.EndTime);
- }
- if (!string.IsNullOrEmpty(p_entity.VendName))
- {
- q = q.Where(p => p.VendName.Contains(p_entity.VendName));
- }
- if (!string.IsNullOrEmpty(p_entity.PartCode))
- {
- q = q.Where(p => p.PartCode == p_entity.PartCode);
- }
- if (p_entity.State != null)
- {
- q = q.Where(p => p.State == p_entity.State);
- }
- q = q.Where(p => p.IsDeleted == p_entity.IsDeleted);
- if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0)
- {
- q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId));
- }
- //IQueryable _aq = db.TB_ASK_DETAIL;
- //_aq = _aq.Where(p => p.PoBillNum == p_entity.PoBillNum);
- //var _a=_aq.GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode }).Select(p => new { AskSum = p.Max(itm=>itm .AskQty),PoLine=p.Key });
- //if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
- //{
- // q = q.Where(p => p_entity.UserInAddress.Contains(p.Address));
- //}
- _ret.State = ReturnStatus.Succeed;
- _ret.Result = q;
- p_action(_ret);
- }
- }
- catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
- {
- var sb = new StringBuilder();
-
- foreach (var error in dbEx.EntityValidationErrors.ToList())
- {
-
- error.ValidationErrors.ToList().ForEach(i =>
- {
- sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
- });
- }
- _ret.State = ReturnStatus.Failed;
- _ret.ErrorList.Add(dbEx);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_PO_DETAIL_List", sb.ToString());
- throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
- }
- catch (OptimisticConcurrencyException ex)//并发冲突异常
- {
-
- _ret.State = ReturnStatus.Failed;
- _ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_PO_DETAIL_List", ex.ToString());
- throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
- }
- catch (ScpException ex)
- {
-
-
- _ret.State = ReturnStatus.Failed;
- _ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_PO_DETAIL_List", ex.ToString());
-
- if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
- {
- var inner = (UpdateException)ex.InnerException;
-
-
- throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
- }
- else
- {
- if (ex.InnerException != null) throw ex.InnerException;
- }
- }
- catch (Exception e)
- {
- _ret.State = ReturnStatus.Failed;
- _ret.ErrorList.Add(e);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_PO_DETAIL_List", e.Message);
- throw e;
- }
-
- }
public static void Get_V_TA_VENDER(V_TB_PO_DETAIL p_entity, Action>> p_action)
{
diff --git a/Controller/SCP_RECEIVE_CONTROLLER.cs b/Controller/SCP_RECEIVE_CONTROLLER.cs
index dbf63d4..ea6c4c7 100644
--- a/Controller/SCP_RECEIVE_CONTROLLER.cs
+++ b/Controller/SCP_RECEIVE_CONTROLLER.cs
@@ -15,6 +15,7 @@ using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
+using CK.SCP.Models.ScpEntity.ExcelImportEntity;
namespace CK.SCP.Controller
{
@@ -33,6 +34,14 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.RecvBillNum.Contains(p_entity.RecvBillNum));
}
+ if (!string.IsNullOrEmpty(p_entity.ErpRecvBillNum))
+ {
+ q = q.Where(p => p.ErpRecvBillNum.Contains(p_entity.ErpRecvBillNum));
+ }
+ if (!string.IsNullOrEmpty(p_entity.VendId))
+ {
+ q = q.Where(p => p.VendId==p_entity.VendId);
+ }
if (!string.IsNullOrEmpty(p_entity.PoBillNum))
{
q = q.Where(p => p.PoBillNum.Contains(p_entity.PoBillNum));
@@ -60,7 +69,14 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.CreateUser))
{
- q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)||p.CreateUser==null);
+ if (p_entity.CreateUser == "无")
+ {
+ q = q.Where(p => string.IsNullOrEmpty(p.CreateUser));
+ }
+ else
+ {
+ q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
+ }
}
if (p_entity.IsDeleted != false)
{
@@ -86,6 +102,14 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
}
+ if (p_entity.ShipTimeStart != null && !p_entity.ShipTimeStart.ToString().Contains("0001/1/1"))
+ {
+ q = q.Where(p => p.ShipTime >= p_entity.ShipTimeStart);
+ }
+ if (p_entity.ShipTimeEnd != null && !p_entity.ShipTimeEnd.ToString().Contains("0001/1/1"))
+ {
+ q = q.Where(p => p.ShipTime <= p_entity.ShipTimeEnd);
+ }
_ret.State = ReturnStatus.Succeed;
_ret.Result = q;
@@ -798,7 +822,41 @@ namespace CK.SCP.Controller
return p_list;
}
+ public static List Get_V_TB_INVOICE_LIST_SYJB(List p_list)
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ p_list.ForEach(itm =>
+ {
+ try
+ {
+ var _recSum = db.V_TB_RECEIVE_DETAIL.Where(p => p.Remark== itm.AskBillNum && p.RecvBillNum == itm.RecvBillNum && p.PartCode == itm.PartCode && p.Batch == itm.Batch && p.IsDeleted == false).Select(p => p.Qty).Sum();
+
+ if (itm.RecvBillNum.Substring(0, 1) == "R")
+ {
+ _recSum = 0 - Math.Abs(_recSum);
+ }
+ var _sum = db.V_TB_INVOICE_DETAIL.Where(p =>p.AskBillNum==itm.AskBillNum && p.RecvBillNum == itm.RecvBillNum && p.PartCode == itm.PartCode && p.Batch == itm.Batch && p.IsDeleted == false).Select(p => p.Qty).Sum();
+ if (_recSum - _sum <= 0)
+ {
+ itm.CanQty = 0;
+ }
+ else
+ {
+ itm.CanQty = _recSum - _sum;
+ }
+ }
+ catch
+ {
+ itm.CanQty = 0;
+ }
+
+ });
+
+ }
+ return p_list;
+ }
public static List Get_V_TB_INVOICE_LIST(List p_list)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
@@ -854,10 +912,29 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.RecvBillNum == p_entity.RecvBillNum);
}
+ if (!string.IsNullOrEmpty(p_entity.ErpRecvBillNum))
+ {
+ if (p_entity.ErpRecvBillNum == "可开票")
+ {
+ q = q.Where(p => !string.IsNullOrEmpty(p.ErpRecvBillNum));
+ }
+ else if(p_entity.ErpRecvBillNum == "不可开票")
+ {
+ q = q.Where(p => string.IsNullOrEmpty( p.ErpRecvBillNum) );
+ }
+ else
+ {
+ q = q.Where(p => p.ErpRecvBillNum == p_entity.ErpRecvBillNum);
+ }
+ }
if (p_entity.PoLine != 0)
{
q = q.Where(p => p.PoLine == p_entity.PoLine);
}
+ if (!string.IsNullOrEmpty(p_entity.AskCreateUser))
+ {
+ q = q.Where(p => p.AskCreateUser.Contains(p_entity.AskCreateUser));
+ }
if (!string.IsNullOrEmpty(p_entity.PartCode))
{
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
@@ -892,7 +969,7 @@ namespace CK.SCP.Controller
}
if (!string.IsNullOrEmpty(p_entity.Site))
{
- q = q.Where(p => p.Site.Contains(p_entity.Site));
+ q = q.Where(p => p.Site==p_entity.Site);
}
if (!string.IsNullOrEmpty(p_entity.VendId))
{
@@ -1802,7 +1879,329 @@ namespace CK.SCP.Controller
return _ds;
}
+ ///
+ /// 数据导入
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject EXCEL_RECEIVE(List p_order_list, string p_creator, string p_buyer, string p_site, DateTime p_time)
+ {
+ ResultObject _ret = new ResultObject();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ int number = 1;
+ List lineError = new List();
+ List ErrorList = new List();
+ p_order_list.ForEach
+ (p =>
+ {
+ var _ls = CheckExcel(db, p);
+ if (_ls.Count > 0)
+ {
+ lineError.Add(number.ToString());
+ ErrorList.Add(string.Join("
", _ls.ToArray()));
+ }
+ number++;
+ });
+ if (lineError.Count > 0)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.MessageList.AddRange(ErrorList);
+ _ret.Result = false;
+ }
+ else
+ {
+ var Ask_list = p_order_list.Where(f => decimal.Parse(f.数量) > 0);
+ var GroupList = Ask_list.GroupBy(p => new { p.采购订单号, p.行号, p.零件编号, p.价格, p.供应商编码, p.单位 }).Select(p => new { 数量 = p.Sum(itm => decimal.Parse(itm.数量)), 行号 = p.Key.行号, 采购订单号 = p.Key.采购订单号, p.Key.零件编号, p.Key.价格, p.Key.供应商编码, p.Key.单位 }).ToList();
+ var OrderList = GroupList.GroupBy(p => p.采购订单号).ToList();
+ List _list = new List();
+ OrderList.ForEach((p) =>
+ {
+ var list_distinct = p.GroupBy(t => new { t.零件编号, t.行号 }).ToList();
+ var list = p.ToList();
+ if (list_distinct.Count < list.Count)
+ {
+ _ret.MessageList.Add("相同组号,存在同一编号、行号的数据");
+ return;
+ }
+ if (list.Count > 0)
+ {
+ var _entity = list.FirstOrDefault();
+ TB_ASK _ask = new TB_ASK();
+ _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode();
+ _ask.State = (int)AskState.Receive;
+ _ask.PoBillNum = _entity.采购订单号.ToUpper();
+ _ask.ModType = (int)BillModType.Contract;
+ _ask.Site = p_site;
+ _ask.BeginTime = p_time;
+ _ask.Buyer = p_creator;
+ _ask.BuyerPhone = "";
+ _ask.ErpBillNum = _entity.采购订单号.ToUpper();
+ _ask.EndTime = p_time;
+ _ask.CreateTime = p_time;
+ _ask.CreateUser = p_creator;
+ _ask.VendId = _entity.供应商编码.ToUpper();
+ _ask.GUID = Guid.NewGuid();
+ _ask.IsDeleted = false;
+ db.TB_ASK.Add(_ask);
+
+ TB_ASN _asn = new TB_ASN();
+ _asn.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode();
+ _asn.AskBillNum = _ask.AskBillNum;
+ _asn.VendId = _entity.供应商编码.ToUpper(); ;
+ _asn.State = (int)AsnState.Receive;
+ _asn.PoBillNum = _entity.采购订单号.ToUpper();
+ _asn.Site = p_site;
+ _asn.CreateTime = p_time;
+ _asn.CreateUser = p_creator;
+ _asn.UpdateTime = p_time;
+ _asn.UpdateUser = p_creator;
+ _asn.ShipTime = p_time;
+ _asn.ShipUser = p_creator;
+ _asn.ReceiveTime = p_time;
+ _asn.ReceiveUser = p_creator;
+ _asn.GUID = Guid.NewGuid();
+ _asn.IsDeleted = false;
+ db.TB_ASN.Add(_asn);
+
+ list.ForEach((itm) =>
+ {
+ TB_ASK_DETAIL _t_ASK_Detail = new TB_ASK_DETAIL();
+ _t_ASK_Detail.PoLine = Int32.Parse(itm.行号);
+ _t_ASK_Detail.Currency = "";
+ _t_ASK_Detail.AskBillNum = _ask.AskBillNum;
+ _t_ASK_Detail.PoBillNum = _ask.PoBillNum;
+ _t_ASK_Detail.PoUnit = itm.单位;
+ _t_ASK_Detail.CreateTime = DateTime.Now;
+ _t_ASK_Detail.CreateUser = _ask.CreateUser;
+ _t_ASK_Detail.PartCode = itm.零件编号.ToUpper();
+ _t_ASK_Detail.BeginTime = p_time;
+ _t_ASK_Detail.EndTime = p_time;
+ _t_ASK_Detail.TempQty = itm.数量;
+ _t_ASK_Detail.AskQty = itm.数量;
+ _t_ASK_Detail.IsDeleted = false;
+ _t_ASK_Detail.LocUnit = itm.单位;
+ _t_ASK_Detail.UnConv = 1;
+ _t_ASK_Detail.State = _ask.State;
+ _t_ASK_Detail.Price = string.IsNullOrEmpty(itm.价格) ? 0 : decimal.Parse(itm.价格);
+ _t_ASK_Detail.GUID = Guid.NewGuid();
+ db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
+
+ TB_ASN_DETAIL _t_ASN_Detail = new TB_ASN_DETAIL();
+ _t_ASN_Detail.AsnBillNum = _asn.AsnBillNum;
+ _t_ASN_Detail.PoLine = Int32.Parse(itm.行号);
+ _t_ASN_Detail.Currency = "";
+ _t_ASN_Detail.PoBillNum = _asn.PoBillNum;
+ _t_ASN_Detail.PoUnit = itm.单位;
+ _t_ASN_Detail.CreateTime = DateTime.Now;
+ _t_ASN_Detail.CreateUser = _asn.CreateUser;
+ _t_ASN_Detail.PartCode = itm.零件编号.ToUpper();
+ _t_ASN_Detail.Batch = p_time.ToString("yyyyMMdd");
+ _t_ASN_Detail.VendBatch = p_time.ToString("yyyyMMdd");
+ _t_ASN_Detail.Qty = itm.数量;
+ _t_ASN_Detail.State = (int)AsnState.Receive;
+ _t_ASN_Detail.CreateTime = p_time;
+ _t_ASN_Detail.CreateUser = p_creator;
+ _t_ASN_Detail.IsDeleted = false;
+ _t_ASN_Detail.GUID = Guid.NewGuid();
+ _t_ASN_Detail.PoUnit = itm.单位;
+ _t_ASN_Detail.ProduceDate = p_time;
+ db.TB_ASN_DETAIL.Add(_t_ASN_Detail);
+
+ var _reclist = p_order_list.Where(t => t.零件编号 == itm.零件编号 && t.采购订单号 == itm.采购订单号 && t.行号 == itm.行号).GroupBy(t => t.收货单号).ToList();
+ _reclist.ForEach((q) =>
+ {
+ var reclist = q.FirstOrDefault();
+ TB_RECEIVE _rec = new TB_RECEIVE();
+ _rec.RecvBillNum = reclist.收货单号;
+ _rec.State = (int)FormState.开放;
+ _rec.Remark = _ask.AskBillNum;
+ _rec.CreateTime = p_time;
+ _rec.CreateUser = p_creator;
+ _rec.IsDeleted = false;
+ _rec.GUID = System.Guid.NewGuid();
+ if (Convert.ToInt32(reclist.数量) < 0)
+ {
+ _rec.RecvBillNum = "R." + _rec.RecvBillNum;
+ _rec.BillType = 1;
+ }
+ else
+ {
+ _rec.BillType = 0;
+ }
+ _rec.PoBillNum = reclist.采购订单号.ToUpper();
+ _rec.AsnBillNum = reclist.采购订单号.ToUpper();
+ _rec.Site = p_site;
+ _rec.VendId = reclist.供应商编码.ToUpper();
+ _rec.ShipTime = p_time;
+
+ if (!_list.Contains(reclist.收货单号))
+ {
+ _list.Add(reclist.收货单号);
+ db.TB_RECEIVE.Add(_rec);
+ }
+ var _recdetaillist = p_order_list.Where(f => f.收货单号 == reclist.收货单号 && f.零件编号 == reclist.零件编号 && f.采购订单号 == reclist.采购订单号 && f.行号 == reclist.行号).ToList();
+ _recdetaillist.ForEach((n) =>
+ {
+ TB_RECEIVE_DETAIL _t_RECEIVE_Detail = new TB_RECEIVE_DETAIL();
+ _t_RECEIVE_Detail.RecvBillNum = n.收货单号;
+ _t_RECEIVE_Detail.PoBillNum = n.采购订单号.ToUpper();
+ _t_RECEIVE_Detail.PoLine = Int32.Parse(n.行号);
+ _t_RECEIVE_Detail.PartCode = n.零件编号.ToUpper();
+ _t_RECEIVE_Detail.Batch = n.批次;
+ _t_RECEIVE_Detail.VendBatch = n.供应商批次;
+ _t_RECEIVE_Detail.PoUnit = n.单位;
+ _t_RECEIVE_Detail.LocUnit = "";
+ _t_RECEIVE_Detail.Qty = decimal.Parse(n.数量);
+ _t_RECEIVE_Detail.State = (int)FormState.开放;
+ _t_RECEIVE_Detail.Remark = _ask.AskBillNum;
+ _t_RECEIVE_Detail.CreateTime = p_time;
+ _t_RECEIVE_Detail.CreateUser = p_creator;
+ _t_RECEIVE_Detail.IsDeleted = false;
+ _t_RECEIVE_Detail.GUID = System.Guid.NewGuid();
+ if (_t_RECEIVE_Detail.Qty < 0)
+ {
+ // _t_RECEIVE_Detail.RecvBillNum = "R." + _t_RECEIVE_Detail.RecvBillNum;
+ _t_RECEIVE_Detail.Qty = System.Math.Abs(_t_RECEIVE_Detail.Qty);
+ _t_RECEIVE_Detail.BillType = 1;
+
+ }
+ else
+ {
+ _t_RECEIVE_Detail.BillType = 0;
+ }
+ db.TB_RECEIVE_DETAIL.Add(_t_RECEIVE_Detail);
+ });
+
+ });
+ });
+ }
+ else
+ {
+ _ret.MessageList.Add("请检查数据后,重新导入!");
+ return;
+ }
+
+ if (_ret.MessageList.Count == 0)
+ {
+ int state = db.SaveChanges();
+ if (state != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ );
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "EXCEL_RECEIVE", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "EXCEL_RECEIVE", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "EXCEL_RECEIVE", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "EXCEL_RECEIVE", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+
+ }
+ private static List CheckExcel(ScpEntities db, SCP_ASN_EXCEL p_excel)
+ {
+ List ErrorList = new List();
+ if (!string.IsNullOrEmpty(p_excel.采购订单号))
+ {
+ int count = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.采购订单号 && p.PartCode == p_excel.零件编号 && p.PoLine.ToString() == p_excel.行号);
+ if (count == 0)
+ {
+ ErrorList.Add(string.Format("订单编号{0}零件号{1}行号{2}不存在!", p_excel.采购订单号, p_excel.零件编号, p_excel.行号));
+ }
+ }
+ else
+ {
+ ErrorList.Add(string.Format("订单编号为空!"));
+ }
+ if (
+ string.IsNullOrEmpty(p_excel.收货单号) ||
+ string.IsNullOrEmpty(p_excel.采购订单号) ||
+ string.IsNullOrEmpty(p_excel.供应商编码) ||
+ string.IsNullOrEmpty(p_excel.价格) ||
+ string.IsNullOrEmpty(p_excel.零件编号) ||
+ string.IsNullOrEmpty(p_excel.行号) ||
+ string.IsNullOrEmpty(p_excel.批次) ||
+ string.IsNullOrEmpty(p_excel.数量) ||
+ string.IsNullOrEmpty(p_excel.单位) ||
+ string.IsNullOrEmpty(p_excel.价格))
+ {
+ ErrorList.Add(string.Format("收货单号【{1}】零件号【{0}】有填写为空!", p_excel.零件编号, p_excel.收货单号));
+ }
+ return ErrorList;
+ }
}
}
diff --git a/Controller/SCP_REJECT_CONTROLLER.cs b/Controller/SCP_REJECT_CONTROLLER.cs
index fbe0e48..0903105 100644
--- a/Controller/SCP_REJECT_CONTROLLER.cs
+++ b/Controller/SCP_REJECT_CONTROLLER.cs
@@ -9,6 +9,7 @@ using CK.SCP.Models.ScpEntity;
using CK.SCP.Utils;
using CK.SCP.Controller;
using CK.SCP.Models.Enums;
+using System.Data.Entity.Core;
namespace CK.SCP.Controller
{
@@ -243,5 +244,121 @@ namespace CK.SCP.Controller
}
return _ret;
}
+ ///
+ /// 保存退货
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ResultObject Save_TB_REJECT(V_TB_ASN_DETAIL p_entity, List p_list, string currentuser)
+ {
+ ResultObject _ret = new ResultObject();
+ var scpRcvList = new List();
+ var scpRcveDetailList = new List();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ TB_RECEIVE scpRcv = new TB_RECEIVE();
+ scpRcv.RecvBillNum = SCP_BILLCODE_CONTROLLER.MakeReviceCode();//退货单号
+ scpRcv.State = (int)FormState.开放;
+ scpRcv.Remark = "";
+ scpRcv.CreateTime = DateTime.Now;//创建日期
+ scpRcv.CreateUser = currentuser;//创建用户
+ scpRcv.IsDeleted = false;
+ scpRcv.GUID = System.Guid.NewGuid();
+ scpRcv.BillType = 1;
+ scpRcv.PoBillNum = p_entity.PoBillNum;//采购单
+ scpRcv.AsnBillNum = p_entity.AsnBillNum;//发货单号
+ scpRcv.Site = p_entity.Site;//地点
+ scpRcv.VendId = p_entity.VendId;//供货商名称
+ scpRcv.ShipTime = DateTime.Now;//收货日期
+ scpRcvList.Add(scpRcv);
+ db.TB_RECEIVE.AddOrUpdate(p => p.UID, scpRcvList.ToArray());
+ p_list.ForEach(item =>
+ {
+ TB_RECEIVE_DETAIL scpRcvDetail = new TB_RECEIVE_DETAIL();
+ scpRcvDetail.RecvBillNum = SCP_BILLCODE_CONTROLLER.MakeReviceCode();//退货单号
+ scpRcvDetail.PoBillNum = item.PoBillNum;//采购单
+ scpRcvDetail.PoLine = item.PoLine;//订单行
+ scpRcvDetail.PartCode = item.PartCode;//零件号
+ scpRcvDetail.Batch = item.Batch;//批次
+ scpRcvDetail.VendBatch = item.VendBatch;//供应商批号
+ scpRcvDetail.PoUnit = item.PoUnit;//采购单位
+ scpRcvDetail.LocUnit = item.LocUnit;//基本单位
+ scpRcvDetail.Qty = item.RejectQty;//退货数量
+ scpRcvDetail.State = (int)FormState.开放;// (int)FormState.关闭,
+ scpRcvDetail.Remark = item.Remark;
+ scpRcvDetail.CreateTime = DateTime.Now;//创建日期
+ scpRcvDetail.CreateUser = currentuser;//创建用户
+ scpRcvDetail.IsDeleted = false;
+ scpRcvDetail.GUID = System.Guid.NewGuid();
+ scpRcvDetail.BillType = 1;
+ scpRcveDetailList.Add(scpRcvDetail);
+ });
+ db.TB_RECEIVE_DETAIL.AddOrUpdate(p => p.UID, scpRcveDetailList.ToArray());
+ if (db.SaveChanges() != -1)
+ {
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = true;
+ }
+ else
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ }
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "Save_TB_RECEIVE", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "Save_TB_RECEIVE", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.Result = false;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "Save_TB_RECEIVE", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_RECIVECE_CONTROLLER), "Save_TB_RECEIVE", e.Message);
+ _ret.Result = false;
+ _ret.ErrorList.Add(e);
+ throw e;
+ }
+ return _ret;
+ }
}
}
diff --git a/Controller/SCP_REPORT_CONTROLLER.cs b/Controller/SCP_REPORT_CONTROLLER.cs
index 235a021..4755dca 100644
--- a/Controller/SCP_REPORT_CONTROLLER.cs
+++ b/Controller/SCP_REPORT_CONTROLLER.cs
@@ -19,85 +19,6 @@ namespace CK.SCP.Controller
public class SCP_REPORT_CONTROLLER
{
- // public static DataTable GET_SCP_UNPAIED(V_SUPPLIERS_REGUALARLY p_entity)
- // {
- // StringBuilder _buffer = new StringBuilder();
- //// SELECT VendId AS 供应商编码, VendName AS 供应商名称, Site AS 域, 税前金额, 税额, 税后金额
- //// FROM(SELECT VendId, VendName, Site, SUM(ROUND(Qty * Price, 2)) AS 税前金额, SUM(ROUND(ROUND(Qty * Price, 2)
- //// * 0.13, 2)) AS 税额, SUM(ROUND(Qty * Price, 2)) + SUM(ROUND(ROUND(Qty * Price, 2) * 0.13, 2))
- //// AS 税后金额
- //// FROM dbo.V_TB_RECEIVE_LIST
- //// WHERE(State = 1) AND(Qty < 0)
- //// GROUP BY VendId, VendName, Site) AS a
- // }
-
-
-
-
-
-
- //public override DataTable GetPagedDataTable(int pageIndex, int pageSize)
- //{
- // //SetWhere();
-
- // //if (StrOrder == "") StrOrder = "UserType desc, UserName asc";
-
- // int rowbegin = (pageIndex * pageSize) + 1;
- // int rowend = (pageIndex + 1) * pageSize;
-
- // return GetDataLimit(rowbegin, rowend, "", StrWhere + " and " + StrSearch, StrOrder);
- //}
-
-
- //public virtual DataTable GetDataLimit(int rows1, int rows2, string fields, string strwhere, string orderby,string p_tableview)
- //{
-
- // var dbSetting = GlobalConfig.ScpDatabase;
- // try
- // {
-
- // if (fields == "")
- // { fields = "*"; }
-
- // string sql = @"
- // select {0} from (
- // select ROW_NUMBER() over(order by {1}) as rows_number_9999999, {0} from {2} where {5}
- // ) as query_temp_table_9999999 where rows_number_9999999 between {3} and {4} and ({5})
- // ";
- // object[] obj = new object[6];
- // obj[0] = fields;
- // obj[1] = orderby;
- // obj[2] = p_tableview;
- // obj[3] = rows1;
- // obj[4] = rows2;
- // obj[5] = strwhere;
- // sql = string.Format(sql, obj);
-
- // DataTable dt = new DataTable();
- // var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
- // SqlConnection conn = new System.Data.SqlClient.SqlConnection();
- // conn.ConnectionString = strConn;
- // if (conn.State != ConnectionState.Open)
- // {
- // conn.Open();
- // }
- // #region 结束时间范围
- // SqlCommand cmd = new SqlCommand();
- // cmd.Connection = conn;
-
- // cmd.CommandText = sql;
- // SqlDataAdapter adapter = new SqlDataAdapter(cmd);
- // adapter.Fill(dt);
-
-
- // return dt;
- // }
- // catch
- // { }
- //}
-
-
-
public static string GET_V_SUPPLIERS_REGUALARLY_LIST_SQL(V_SUPPLIERS_REGUALARLY p_entity)
{
StringBuilder _buffer = new StringBuilder();
@@ -133,7 +54,6 @@ namespace CK.SCP.Controller
}
-
public static DataTable Get_RECEIVE_YEAR(V_TB_RECEIVE_DETAIL p_detail, string p_year)
{
string _sql = "SELECT D.*,E.VENDNAME,F.PROJECTID FROM({0}) c pivot(sum(c.数量) for c.M in (一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月)) as d LEFT JOIN TA_VENDER E on D.vendid=E.VENDID AND D.SITE=E.SITE LEFT JOIN TA_PART F ON f.partcode =d.partcode and f.site=e.site where {1}";
@@ -283,8 +203,6 @@ namespace CK.SCP.Controller
return dt;
}
-
-
public static DataTable Get_PART_LIFE(V_TB_PO_DETAIL p_detail)
{
DataTable dt = new DataTable();
@@ -531,65 +449,6 @@ namespace CK.SCP.Controller
}
-
-
- public string GetASN_REC_REPORT(V_TB_ASK_DETAIL p_detail)
- {
-
- string sqlString = "SELECT a.PartCode,a.PoLine,a.AskBillNum,AskQty,isnull(sum(b.Qty),0) asnQty,isNull(SUM(c.Qty),0) as RecQty,a.PoBillNum FROM TB_ASK_DETAIL A\n" +
- "LEFT JOIN\n" +
- "\n" +
- "(select\n" +
- "TB_ASN_DETAIL.Qty,\n" +
- "TB_ASN.AsnBillNum,\n" +
- "TB_ASN.AskBillNum,\n" +
- "TB_ASN_DETAIL.PartCode,\n" +
- "TB_ASN_DETAIL.PoLine\n" +
- "from TB_ASN_DETAIL inner join TB_ASN on TB_ASN_DETAIL.AsnBillNum=tb_asn.AsnBillNum and TB_ASN.State<>-1) as\n" +
- " B on a.AskBillNum=b.AskBillNum and a.PartCode=b.PartCode and a.PoLine=b.PoLine\n" +
- "Left join\n" +
- "(\n" +
- "select\n" +
- "TB_RECEIVE_DETAIL.Qty,\n" +
- "TB_RECEIVE.AsnBillNum,\n" +
- "TB_RECEIVE_DETAIL.PartCode,\n" +
- "TB_RECEIVE_DETAIL.PoLine\n" +
- "from TB_RECEIVE_DETAIL inner join TB_RECEIVE on TB_RECEIVE_DETAIL.RecvBillNum=TB_RECEIVE.RecvBillNum and TB_RECEIVE.State<>-1) as\n" +
- "\n" +
- " C on B.AsnBillNum=C.AsnBillNum and B.PartCode=C.PartCode and B.PoLine=C.PoLine\n" +
- " where a.State<>-1 {0}" +
- "\n" +
- " GROUP BY a.PartCode,a.PoLine,a.AskBillNum,a.AskQty,a.PoBillNum";
-
-
-
- if (!string.IsNullOrEmpty(p_detail.PartCode))
- {
-
- }
- if (!string.IsNullOrEmpty(p_detail.VendId))
- {
-
- }
- if (!string.IsNullOrEmpty(p_detail.AskBillNum))
- {
-
- }
- if (!string.IsNullOrEmpty(p_detail.PoBillNum))
- {
-
- }
- if (!string.IsNullOrEmpty(p_detail.PoBillNum))
- {
-
- }
-
- return sqlString;
-
-
- }
-
-
public static string GET_SQE(V_TB_ASN_DETAIL p_entity)
{
StringBuilder _buffer = new StringBuilder();
@@ -793,8 +652,8 @@ namespace CK.SCP.Controller
_builder.Append(" select h.Site, h.AskBillNum,h.EndTime, h.VendId, h.PartCode ,sum (h.Qty) as ArriveQty , AskQty ,(AskQty -sum (h.Qty)) as Qty ,sum(h.NntimelyQty) as NntimelyQty , ");
_builder.Append(" (CASE WHEN AskQty=0 Then 0 ELSE (sum (NntimelyQty)/AskQty) END) as OTD ,( CASE WHEN AskQty=0 Then 0 ELSE (sum (h.Qty)/AskQty) END ) AS ArriveOTD from ( SELECT p.Site, p.VendId, p.AskBillNum, p.PartCode, ISNULL(A.Qty,0) as Qty, ");
- _builder.Append(" (p.AskQty- ISNULL(p.ReduceQty,0)) as AskQty , (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) >= -1 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN ");
- _builder.Append(" V_TB_ASN AS B on p.AskBillNum=b.AskBillNum LEFT OUTER JOIN dbo.V_TB_ARRIVE_DETAIL AS A ON b.AsnBillNum=A.AsnBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode where p.IsDeleted=0 ");
+ _builder.Append(" (p.AskQty- ISNULL(p.ReduceQty,0)) as AskQty , (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) >= -1 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN ");
+ _builder.Append(" dbo.V_TB_ARRIVE_DETAIL AS A ON A.Remark = p.AskBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode LEFT OUTER JOIN dbo.V_TB_ARRIVE AS B ON A.ArrvBillNum = B.ArrvBillNum where p.IsDeleted=0 ");
if (p_entity.BeginTime != null)
{
_builder.AppendFormat(" AND p.EndTime>='{0}'", p_entity.BeginTime);
@@ -1133,6 +992,88 @@ namespace CK.SCP.Controller
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TB_ASK_RECEIVE_List", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TB_ASK_RECEIVE_List", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TB_ASK_RECEIVE_List", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TB_ASK_RECEIVE_List", e.Message);
+ throw e;
+ }
+ }
+ public static void Get_V_TIMELY_DELIVERY_List(V_TIMELY_DELIVERY p_entity, Action>> p_action)
+ {
+
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ string _sql = GetV_TIMELY_DELIVERY_SQL(p_entity);
+
+ IQueryable q = db.Database.SqlQuery(_sql).AsQueryable();
+ if (p_entity.RecvBeginTime != null)
+ {
+ q = q.Where(p => p.RecvTime >= p_entity.RecvBeginTime);
+ }
+ if (p_entity.RecvEndTime != null)
+ {
+ q = q.Where(p => p.RecvTime <= p_entity.RecvEndTime);
+ }
+ if (!string.IsNullOrEmpty(p_entity.PartCode))
+ {
+ var _ls = p_entity.PartCode.Split(new char[] { ',' });
+
+ q = q.Where(p => _ls.Contains(p.PartCode));
+ }
+ if (!string.IsNullOrEmpty(p_entity.PartDesc1))
+ {
+
+ q = q.Where(p => p.PartDesc1.Contains(p.PartDesc1));
+ }
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
{
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
@@ -1179,7 +1120,6 @@ namespace CK.SCP.Controller
throw e;
}
}
-
public static void Get_TB_ASK_UNCOMPLETE_List(TB_UNCOMPLETE_TEMPASK p_entity, Action>> p_action)
{
@@ -1269,7 +1209,7 @@ namespace CK.SCP.Controller
}
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(dbEx);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TIMELY_DELIVERY_List", sb.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_TB_ASK_UNCOMPLETE_List", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
@@ -1277,14 +1217,14 @@ namespace CK.SCP.Controller
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TIMELY_DELIVERY_List", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_TB_ASK_UNCOMPLETE_List", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TIMELY_DELIVERY_List", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_TB_ASK_UNCOMPLETE_List", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
@@ -1300,7 +1240,7 @@ namespace CK.SCP.Controller
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(e);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_TIMELY_DELIVERY_List", e.Message);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_TB_ASK_UNCOMPLETE_List", e.Message);
throw e;
}
}
diff --git a/Controller/SCP_TB_PRICE_CONTROLLER.cs b/Controller/SCP_TB_PRICE_CONTROLLER.cs
index 570460a..46c54a8 100644
--- a/Controller/SCP_TB_PRICE_CONTROLLER.cs
+++ b/Controller/SCP_TB_PRICE_CONTROLLER.cs
@@ -17,7 +17,6 @@ namespace CK.SCP.Controller
return db.TB_PRICE.ToList();
}
- }
-
+ }
}
}
diff --git a/Controller/SCP_TB_VENDER_CONTROLLER.cs b/Controller/SCP_TB_VENDER_CONTROLLER.cs
index ecaa6ec..8759e26 100644
--- a/Controller/SCP_TB_VENDER_CONTROLLER.cs
+++ b/Controller/SCP_TB_VENDER_CONTROLLER.cs
@@ -86,6 +86,88 @@ namespace CK.SCP.Controller
}
+ //public static ResultObject Save_TA_VENDER(List p_entitys)
+ //{
+ // ResultObject _ret = new ResultObject();
+ // try
+ // {
+ // using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ // {
+ // foreach (var itm in p_entitys)
+ // {
+ // var _entity = db.TA_VENDER.Where(p => p.UID == itm.UID).FirstOrDefault();
+ // _entity.Quota = itm.Quota;
+ // db.TA_VENDER.AddOrUpdate(p => p.UID, _entity);
+ // }
+ // if (_ret.MessageList.Count > 0)
+ // {
+ // _ret.State = ReturnStatus.Failed;
+ // }
+ // else
+ // {
+ // if (db.SaveChanges() != -1)
+ // {
+ // _ret.State = ReturnStatus.Succeed;
+ // _ret.Result = true;
+ // }
+ // else
+ // {
+ // _ret.State = ReturnStatus.Failed;
+ // _ret.Result = false;
+ // }
+ // }
+ // }
+ // }
+ // catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ // {
+ // var sb = new StringBuilder();
+ // foreach (var error in dbEx.EntityValidationErrors.ToList())
+ // {
+ // error.ValidationErrors.ToList().ForEach(i =>
+ // {
+ // sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ // });
+ // }
+ // _ret.State = ReturnStatus.Failed;
+ // _ret.Result = false;
+ // _ret.ErrorList.Add(dbEx);
+ // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", sb.ToString());
+ // throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ // }
+ // catch (OptimisticConcurrencyException ex)//并发冲突异常
+ // {
+ // _ret.State = ReturnStatus.Failed;
+ // _ret.Result = false;
+ // _ret.ErrorList.Add(ex);
+ // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", ex.ToString());
+ // throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ // }
+ // catch (ScpException ex)
+ // {
+ // _ret.State = ReturnStatus.Failed;
+ // _ret.Result = false;
+ // _ret.ErrorList.Add(ex);
+ // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", ex.ToString());
+ // if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ // {
+ // var inner = (UpdateException)ex.InnerException;
+ // throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ // }
+ // else
+ // {
+ // if (ex.InnerException != null) throw ex.InnerException;
+ // }
+ // }
+ // catch (Exception e)
+ // {
+ // _ret.State = ReturnStatus.Failed;
+ // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", e.Message);
+ // _ret.Result = false;
+ // _ret.ErrorList.Add(e);
+ // throw e;
+ // }
+ // return _ret;
+ //}
}
}
diff --git a/Controller/SCP_TS_BARCODE_CONTROLLER.cs b/Controller/SCP_TS_BARCODE_CONTROLLER.cs
index 5aaf3e7..b5b14b8 100644
--- a/Controller/SCP_TS_BARCODE_CONTROLLER.cs
+++ b/Controller/SCP_TS_BARCODE_CONTROLLER.cs
@@ -158,6 +158,103 @@ namespace CK.SCP.Controller
throw e;
}
+ }
+ public static void Get_V_TS_BARCODE_List(V_TS_BARCODE p_entity, Action>> p_action)
+ {
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ IQueryable q = db.V_TS_BARCODE;
+ if (!string.IsNullOrEmpty(p_entity.BarCode))
+ {
+ q = q.Where(p => p.BarCode.Contains(p_entity.BarCode));
+ }
+ if (!string.IsNullOrEmpty(p_entity.PartCode))
+ {
+ q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
+ }
+
+ if (!string.IsNullOrEmpty(p_entity.Batch))
+ {
+ q = q.Where(p => p.Batch.Contains(p_entity.Batch));
+ }
+ if (!string.IsNullOrEmpty(p_entity.BillNum))
+ {
+ q = q.Where(p => p.BillNum.Contains(p_entity.BillNum));
+ }
+ if (p_entity.PoBillLine != 0)
+ {
+ q = q.Where(p => p.PoBillLine == p_entity.PoBillLine);
+ }
+ if (!string.IsNullOrEmpty(p_entity.VendBatch))
+ {
+ q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch));
+ }
+ if (p_entity.PackQty != 0)
+ {
+ q = q.Where(p => p.PackQty == p_entity.PackQty);
+ }
+ if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
+ {
+ q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
+ }
+ if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0)
+ {
+ q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId));
+ }
+ q = q.Where(p => p.IsScanned == p_entity.IsScanned);
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", ex.ToString());
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", e.Message);
+ throw e;
+ }
+
}
public static void Get_TS_BARCODE_CUSTOM_List(TS_BARCODE_CUSTOM p_entity, Action>> p_action)
{
@@ -269,21 +366,21 @@ namespace CK.SCP.Controller
}
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(dbEx);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", sb.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(ex);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", ex.ToString());
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
@@ -298,7 +395,7 @@ namespace CK.SCP.Controller
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(e);
- LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", e.Message);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", e.Message);
throw e;
}
diff --git a/Controller/SCP_WMS_CONTROLLER.cs b/Controller/SCP_WMS_CONTROLLER.cs
index 7f33685..cddace8 100644
--- a/Controller/SCP_WMS_CONTROLLER.cs
+++ b/Controller/SCP_WMS_CONTROLLER.cs
@@ -103,6 +103,98 @@ namespace CK.SCP.Controller
throw e;
}
+ }
+ public static List GET_INVOICE_CANQTY(List p_list)
+ {
+ using (ScpEntities db = EntitiesFactory.CreateScpInstance())
+ {
+ if (p_list.Count > 0)
+ {
+ p_list.ForEach(p =>
+ {
+ var entity = db.V_TB_RECEIVE_LIST.Where(itm => itm.PartCode == p.PartCode&&itm.VendId==p.VendId ).ToList();
+ decimal canqty = entity.Sum(t => t.CanQty);
+ p.InvoiceQty = canqty;
+ });
+ }
+ }
+ return p_list;
+ }
+ public static void Get_VIEW_STOCK_REPORT(VIEW_STOCK_REPORT p_entity, Action>> p_action)
+ {
+ ResultObject> _ret = new ResultObject>();
+ try
+ {
+ using (WmsEntities db = EntitiesFactory.CreateWmsInstance())
+ {
+ IQueryable q = db.VIEW_STOCK_REPORT;
+
+ if (!string.IsNullOrEmpty(p_entity.PartCode))
+ {
+ q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
+ }
+ if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0)
+ {
+ q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId));
+ }
+ _ret.State = ReturnStatus.Succeed;
+ _ret.Result = q;
+ p_action(_ret);
+ }
+ }
+ catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
+ {
+ var sb = new StringBuilder();
+
+ foreach (var error in dbEx.EntityValidationErrors.ToList())
+ {
+
+ error.ValidationErrors.ToList().ForEach(i =>
+ {
+ sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
+ });
+ }
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(dbEx);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_REPORT", sb.ToString());
+ throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
+ }
+ catch (OptimisticConcurrencyException ex)//并发冲突异常
+ {
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_REPORT", ex.ToString());
+ throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
+ }
+ catch (ScpException ex)
+ {
+
+
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(ex);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_REPORT", ex.ToString());
+
+ if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
+ {
+ var inner = (UpdateException)ex.InnerException;
+
+
+ throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
+ }
+ else
+ {
+ if (ex.InnerException != null) throw ex.InnerException;
+ }
+ }
+ catch (Exception e)
+ {
+ _ret.State = ReturnStatus.Failed;
+ _ret.ErrorList.Add(e);
+ LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_REPORT", e.Message);
+ throw e;
+ }
+
}
public static void Get_VIEW_STOCK_DETAIL(VIEW_STOCK_QTY p_entity, Action>> p_action)
{
diff --git a/Controller/UniApiController.cs b/Controller/UniApiController.cs
index 1aa15ee..b7e1171 100644
--- a/Controller/UniApiController.cs
+++ b/Controller/UniApiController.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Data;
using System.Data.Entity.Core;
+using System.Data.SqlClient;
using System.Linq;
using System.Text;
using CK.SCP.Models;
@@ -13,6 +15,7 @@ namespace CK.SCP.Controller
{
public static class UniApiController
{
+
public static void Get_TS_UNI_API_List(TS_UNI_API p_entity, Action>> p_action)
{
ResultObject> _ret = new ResultObject>();
@@ -218,6 +221,53 @@ namespace CK.SCP.Controller
return asp;
}
+ public static DataTable FindUniapi(string p_type, string p_billNum, string p_domain)
+ {
+ string sql = string.Empty;
+ switch (p_type)
+ {
+ case "xxqad_pod_det":
+ sql ="SELECT * FROM[xxqad_pod_det] a inner join xxqad_ctrl b on a.xxqad_pod_seq = b.xxqad_seq where xxqad_domain = '{1}' and xxqad_pod_nbr in ({0}) order by xxqad_pod_nbr, b.xxqad_seq ";
+ break;
+ case "xxqad_prh_det":
+ sql = "SELECT * FROM[xxqad_prh_det] a inner join xxqad_ctrl b on a.xxqad_prh_seq = b.xxqad_seq where xxqad_domain = '{1}' and (xxqad_prh_psnbr in ({0}) or xxqad_prh_receiver in ({0})) order by xxqad_prh_psnbr, b.xxqad_seq ";
+ break;
+ case "xxwms_rc_det":
+ sql = "select * from xxwms_rc_det a inner join xxwms_ctrl b on a.xxwms_rc_seq = b.xxwms_seq where xxwms_domain = '{1}' and (xxwms_rc_nbr in ({0}) order by xxwms_rc_nbr, b.xxwms_seq";
+ break;
+ case "xxscm_tx_mstr":
+ sql = "select * from xxscm_tx_mstr a inner join xxscm_ctrl b on a.xxscm_tx_seq = b.xxscm_seq where xxscm_domain = '{1}' and xxscm_tx_nbr in ({0}) order by xxscm_tx_nbr, b.xxscm_seq";
+ break;
+ case "xxscm_inv_det":
+ sql = "select * from xxscm_inv_det a inner join xxscm_ctrl b on a.xxscm_inv_seq = b.xxscm_seq where xxscm_domain = '{1}' and xxscm_inv_nbr IN({0}) order by xxscm_inv_nbr,b.xxscm_seq";
+ break;
+ }
+ DataTable _dt = new DataTable();
+ var dbSetting = GlobalConfig.UniApiDatabase;
+ var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
+ SqlConnection conn = new System.Data.SqlClient.SqlConnection();
+ try
+ {
+
+ conn.ConnectionString = strConn;
+ if (conn.State != ConnectionState.Open)
+ {
+ conn.Open();
+ }
+ SqlCommand cmd = new SqlCommand();
+ cmd.Connection = conn;
+ cmd.CommandText = string.Format(sql, p_billNum, p_domain);
+ SqlDataAdapter adapter = new SqlDataAdapter(cmd);
+ adapter.Fill(_dt);
+ conn.Close();
+
+ }
+ catch (Exception e)
+ {
+ conn.Close();
+ }
+ return _dt;
+ }
//创建发货单
public static TS_UNI_API CreateBy(V_TB_ASN bill, V_TB_ASN_DETAIL detail, UniApiType uniApiType)
diff --git a/Models/CK.SCP.Models.csproj b/Models/CK.SCP.Models.csproj
index aba732a..de1bb5e 100644
--- a/Models/CK.SCP.Models.csproj
+++ b/Models/CK.SCP.Models.csproj
@@ -332,11 +332,16 @@
+
+
+
+
+
@@ -442,6 +447,7 @@
+
@@ -701,6 +707,7 @@
+
diff --git a/Models/ScpEntities.cs b/Models/ScpEntities.cs
index a37a887..35b4ec1 100644
--- a/Models/ScpEntities.cs
+++ b/Models/ScpEntities.cs
@@ -52,6 +52,7 @@ namespace CK.SCP.Models
public virtual DbSet TL_BILL { get; set; }
public virtual DbSet TL_OPER { get; set; }
public virtual DbSet TS_BARCODE { get; set; }
+ public virtual DbSet V_TS_BARCODE { get; set; }
public virtual DbSet TS_BARCODE_SMALL { get; set; }
public virtual DbSet TS_STOCK { get; set; }
public virtual DbSet TS_UNI_API { get; set; }
@@ -123,33 +124,30 @@ namespace CK.SCP.Models
public virtual DbSet TB_PRICE { get; set; }
public virtual DbSet TB_FORECAST { get; set; }
public virtual DbSet V_TB_FORECAST { get; set; }
+ public virtual DbSet TA_MoldSharing { get; set; }
+ public virtual DbSet TA_MoldSharing_Invoice { get; set; }
public virtual DbSet TB_RECEIVE_DETAIL_QAD { get; set; }
public virtual DbSet TB_RECEIVE_QAD { get; set; }
-
public virtual DbSet TM_HYANTOLIN_REVIEW { get; set; }
-
public virtual DbSet TB_CLAIM_APPEND { get; set; }
-
public virtual DbSet V_TM_HYANTOLIN_REVIEW { get; set; }
public virtual DbSet TB_PLAN_CUSTOM { get; set; }
public virtual DbSet TB_PO_PLAN { get; set; }
public virtual DbSet V_TB_PO_PLAN { get; set; }
public virtual DbSet V_TB_PO_PLAN_DETAIL { get; set; }
public virtual DbSet TB_PO_PLAN_EXTEND { get; set; }
-
public virtual DbSet V_TB_PO_PLAN_EXTEND { get; set; }
-
-
public virtual DbSet