Browse Source

BJBQ

master
mingliang.tang 1 year ago
parent
commit
12f2025fe9
  1. 7
      .vs/VSWorkspaceState.json
  2. BIN
      .vs/slnx.sqlite
  3. BIN
      .vs/新建文件夹 (2)/v16/.suo
  4. 1
      北京北汽/Common/CK.SCP.Common.csproj
  5. 4
      北京北汽/Common/app.config
  6. 5
      北京北汽/Controller/CK.SCP.Controller.csproj
  7. 41
      北京北汽/Controller/SCP_ASK_CONTROLLER.cs
  8. 4
      北京北汽/Controller/SCP_ASN_CONTROLLER.cs
  9. 7
      北京北汽/Controller/SCP_BARCODE_CONTROLLER.cs
  10. 6
      北京北汽/Controller/SCP_BILLCODE_CONTROLLER.cs
  11. 217
      北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs
  12. 6
      北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs
  13. 155
      北京北汽/Controller/SCP_LOGINNUMBER_CONTROLLER.cs
  14. 502
      北京北汽/Controller/SCP_PO_CONTROLLER.cs
  15. 8
      北京北汽/Controller/SCP_RECEIVE_CONTROLLER.cs
  16. 122
      北京北汽/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs
  17. 317
      北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs
  18. 16
      北京北汽/Controller/SCP_TB_VENDER_CONTROLLER.cs
  19. 4
      北京北汽/Controller/app.config
  20. 4
      北京北汽/Models/App.config
  21. 3
      北京北汽/Models/CK.SCP.Models.csproj
  22. 10
      北京北汽/Models/Enums/SCP_ENUM.cs.cs
  23. 2
      北京北汽/Models/ScpEntities.cs
  24. 3
      北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs
  25. 5
      北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs
  26. 2
      北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_VENDER_EXPORT.cs
  27. 12
      北京北汽/Models/ScpEntity/SCP_OTD_EXPORT.cs
  28. 23
      北京北汽/Models/ScpEntity/TA_LOGINNUMBER.cs
  29. 9
      北京北汽/Models/ScpEntity/V_TB_PRICE.cs
  30. 62
      北京北汽/Models/ScpEntity/V_TB_PRICE_TemporaryPrice.cs
  31. 10
      北京北汽/Models/WmsEntity/TableSchema1.cs
  32. 4
      北京北汽/SCP/Business/PageBase.cs
  33. 43
      北京北汽/SCP/CK.SCP.Controller/ASNController.cs
  34. 114
      北京北汽/SCP/CK.SCP.Controller/BaseDocContoller.cs
  35. 99
      北京北汽/SCP/CK.SCP.Controller/CK.SCP.Controller.csproj
  36. 12
      北京北汽/SCP/CK.SCP.Controller/Class1.cs
  37. 59
      北京北汽/SCP/CK.SCP.Controller/InfoController.cs
  38. 85
      北京北汽/SCP/CK.SCP.Controller/InvoiceController.cs
  39. 37
      北京北汽/SCP/CK.SCP.Controller/InvoiceDetailController.cs
  40. 33
      北京北汽/SCP/CK.SCP.Controller/OadOrderController.cs
  41. 115
      北京北汽/SCP/CK.SCP.Controller/POController.cs
  42. 68
      北京北汽/SCP/CK.SCP.Controller/PODetailController.cs
  43. 29
      北京北汽/SCP/CK.SCP.Controller/PartController.cs
  44. 60
      北京北汽/SCP/CK.SCP.Controller/PlanMonthController.cs
  45. 36
      北京北汽/SCP/CK.SCP.Controller/Properties/AssemblyInfo.cs
  46. 54
      北京北汽/SCP/CK.SCP.Controller/PublicDataController.cs
  47. 22
      北京北汽/SCP/CK.SCP.Controller/ReceiveController.cs
  48. 33
      北京北汽/SCP/CK.SCP.Controller/ReceiveDetailController.cs
  49. 42
      北京北汽/SCP/CK.SCP.Controller/ResultObject.cs
  50. 23
      北京北汽/SCP/CK.SCP.Controller/ShipController.cs
  51. 57
      北京北汽/SCP/CK.SCP.Controller/ShipDetailController.cs
  52. 32
      北京北汽/SCP/CK.SCP.Controller/SupplierController.cs
  53. 29
      北京北汽/SCP/CK.SCP.Controller/SupplierPartController.cs
  54. 253
      北京北汽/SCP/CK.SCP.Controller/UniApiController.cs
  55. 14
      北京北汽/SCP/CK.SCP.Controller/UserController.cs
  56. 21
      北京北汽/SCP/CK.SCP.Controller/VEND_USERController.cs
  57. 25
      北京北汽/SCP/CK.SCP.Controller/app.config
  58. 5
      北京北汽/SCP/CK.SCP.Controller/packages.config
  59. 6
      北京北汽/SCP/CK.SCP.DCUNI/App.config
  60. 87
      北京北汽/SCP/CK.SCP.DCUNI/CK.SCP.DCUNI.csproj
  61. 39
      北京北汽/SCP/CK.SCP.DCUNI/Form1.Designer.cs
  62. 20
      北京北汽/SCP/CK.SCP.DCUNI/Form1.cs
  63. 22
      北京北汽/SCP/CK.SCP.DCUNI/Program.cs
  64. 36
      北京北汽/SCP/CK.SCP.DCUNI/Properties/AssemblyInfo.cs
  65. 71
      北京北汽/SCP/CK.SCP.DCUNI/Properties/Resources.Designer.cs
  66. 117
      北京北汽/SCP/CK.SCP.DCUNI/Properties/Resources.resx
  67. 30
      北京北汽/SCP/CK.SCP.DCUNI/Properties/Settings.Designer.cs
  68. 7
      北京北汽/SCP/CK.SCP.DCUNI/Properties/Settings.settings
  69. 20
      北京北汽/SCP/CK.SCP.Models/App.config
  70. 94
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/AppBoxContext.cs
  71. 686
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/AppBoxDatabaseInitializer.cs
  72. 19
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Config.cs
  73. 67
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Dept.cs
  74. 25
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/ICustomTree.cs
  75. 8
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/IKeyID.cs
  76. 26
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Log.cs
  77. 74
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Menu.cs
  78. 23
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Online.cs
  79. 119
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/PasswordUtil.cs
  80. 27
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Power.cs
  81. 24
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Role.cs
  82. 23
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Title.cs
  83. 85
      北京北汽/SCP/CK.SCP.Models/AppBoxEntity/User.cs
  84. 252
      北京北汽/SCP/CK.SCP.Models/CK.SCP.Models.csproj
  85. 28
      北京北汽/SCP/CK.SCP.Models/DbSetting.cs
  86. 148
      北京北汽/SCP/CK.SCP.Models/EntitiesFactory.cs
  87. 162
      北京北汽/SCP/CK.SCP.Models/EntitiesHelper.cs
  88. 158
      北京北汽/SCP/CK.SCP.Models/Enums/BillType.cs
  89. 11
      北京北汽/SCP/CK.SCP.Models/Enums/CollectionStepFinish.cs
  90. 16
      北京北汽/SCP/CK.SCP.Models/Enums/ControlType.cs
  91. 10
      北京北汽/SCP/CK.SCP.Models/Enums/DataBaseType.cs
  92. 29
      北京北汽/SCP/CK.SCP.Models/Enums/DataState.cs
  93. 11
      北京北汽/SCP/CK.SCP.Models/Enums/EquipmentState.cs
  94. 19
      北京北汽/SCP/CK.SCP.Models/Enums/ErpInterfaceType.cs
  95. 15
      北京北汽/SCP/CK.SCP.Models/Enums/GroupType.cs
  96. 14
      北京北汽/SCP/CK.SCP.Models/Enums/InspectType.cs
  97. 14
      北京北汽/SCP/CK.SCP.Models/Enums/InspectionType.cs
  98. 19
      北京北汽/SCP/CK.SCP.Models/Enums/InventoryState.cs
  99. 24
      北京北汽/SCP/CK.SCP.Models/Enums/InvoiceState.cs
  100. 15
      北京北汽/SCP/CK.SCP.Models/Enums/LocType.cs

7
.vs/VSWorkspaceState.json

@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\SCP.sln",
"PreviewInSolutionExplorer": false
}

BIN
.vs/slnx.sqlite

Binary file not shown.

BIN
.vs/新建文件夹 (2)/v16/.suo

Binary file not shown.

1
北京北汽/Common/CK.SCP.Common.csproj

@ -11,7 +11,6 @@
<AssemblyName>CK.SCP.Common</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

4
北京北汽/Common/app.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@ -8,4 +8,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
</configuration>

5
北京北汽/Controller/CK.SCP.Controller.csproj

@ -11,7 +11,6 @@
<AssemblyName>CK.SCP.Controller</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -54,6 +53,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Z.EntityFramework.Extensions">
<HintPath>..\SCP\bin\Z.EntityFramework.Extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EC_CONTROLLER.cs" />
@ -72,6 +74,7 @@
<Compile Include="SCP_BARCODE_CONTROLLER_CUSTOM.cs" />
<Compile Include="SCP_BARCODE_CONTROLLER _SYJB.cs" />
<Compile Include="SCP_COM_CONTROLLER.cs" />
<Compile Include="SCP_LOGINNUMBER_CONTROLLER.cs" />
<Compile Include="SCP_DC_UNI_CONTROLLER.cs" />
<Compile Include="SCP_FORECAST_CONTROLLER.cs" />
<Compile Include="SCP_INTERFACE_CONTROLLER.cs" />

41
北京北汽/Controller/SCP_ASK_CONTROLLER.cs

@ -157,7 +157,14 @@ namespace CK.SCP.Controller
throw e;
}
}
public static TB_ASK Getask(string ASK)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var site=db.TB_ASK.FirstOrDefault(p=>p.AskBillNum==ASK);
return site;
}
}
/// <summary>
/// 要货看板减产数量
/// </summary>
@ -1234,7 +1241,8 @@ namespace CK.SCP.Controller
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
TB_ASN _t = new TB_ASN();
_t.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode();
string str1 = "N" + p_ask.VendId;
_t.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode_BJBQ(str1);
_t.AskBillNum = p_ask.AskBillNum;
_t.PoBillNum = p_ask.PoBillNum;
_t.ReceivedPort = p_ask.ReceivedPort;
@ -1301,6 +1309,11 @@ namespace CK.SCP.Controller
{
_tDetail.Batch = "000000";
}
String str2 = itm.PartCode.Substring(0, 5);
if(str2== "SPABJ"&&_t.Site== "BJBMPT")
{
_tDetail.Batch = "000000";
}
db.TB_ASN_DETAIL.Add(_tDetail);
var _order_detail = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault();
_order_detail.ShippedQty = (decimal)itm.ShippedQty;
@ -2602,7 +2615,7 @@ namespace CK.SCP.Controller
return _ret;
}
public static ResultObject<bool> Save_TB_ASK_STATE_BJBQ(List<string> p_list, AskState p_state)
public static ResultObject<bool> Save_TB_ASK_STATE_BMPT(List<string> p_list, AskState p_state,string site)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
@ -2751,7 +2764,7 @@ namespace CK.SCP.Controller
}
if (p_state == AskState.CompleteForce)
{
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList();
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false&&p.Site==site).ToList();
int count = _ls.Count(p => p.State == (int)AskState.Confirm || p.State == (int)AskState.Ship);
if (count == _ls.Count && _ls.Count > 0)
{
@ -2764,12 +2777,12 @@ namespace CK.SCP.Controller
}
// p.State = (int)AskState.CompleteForce;
#region 修改发货单
var _asnList = db.TB_ASN.Where(itm => itm.IsDeleted == false && itm.AskBillNum == p.AskBillNum && itm.State == 0).ToList();
var _asnList = db.TB_ASN.Where(itm => itm.IsDeleted == false && itm.AskBillNum == p.AskBillNum && itm.State == 0 && p.Site == site).ToList();
_asnList.ForEach(itm =>
{
itm.State = (int)AsnState.Reject;
itm.IsDeleted = true;
var _asnDetailList = db.TB_ASN_DETAIL.Where(asn => asn.IsDeleted == false && asn.AsnBillNum == itm.AsnBillNum).ToList();
var _asnDetailList = db.TB_ASN_DETAIL.Where(asn => asn.IsDeleted == false && asn.AsnBillNum == itm.AsnBillNum && asn.Site == site).ToList();
_asnDetailList.ForEach(ad =>
{
itm.State = (int)AsnState.Reject;
@ -2780,13 +2793,13 @@ namespace CK.SCP.Controller
});
db.TB_ASN.AddOrUpdate(_asnList.ToArray());
#endregion
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum && itm.IsDeleted == false).ToList();
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum && itm.IsDeleted == false && itm.Site == site).ToList();
_list.ForEach(itm =>
{
itm.AskQty = 0;
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();
var asn = db.V_TB_ASN_DETAIL.Where(ask => ask.AskBillNum == itm.AskBillNum && ask.IsDeleted == false && ask.Site == site && (ask.State == (int)AsnState.Ship || ask.State == (int)AsnState.Receive))
.GroupBy(ask => new { ask.AskBillNum, ask.PoLine, ask.PartCode,ask.Site })
.Select(ask => new { AsSum = ask.Sum(itm1 => itm1.Qty), PoLine = ask.Key.PoLine, AskBillNum = ask.Key.AskBillNum, PartCode = ask.Key.PartCode, Site=ask.Key.Site}).ToList();
asn.ForEach(itm1 =>
{
@ -2801,7 +2814,7 @@ namespace CK.SCP.Controller
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray());
}
);
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray());
db.TB_ASK.AddOrUpdate(p => p.UID, _ls.ToArray());
}
else
{
@ -3075,9 +3088,9 @@ namespace CK.SCP.Controller
}
if (p_state == AskState.Release)
{
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList();
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)&&p.State== (int)AskState.New).ToList();
int count = _ls.Count(p => p.State == (int)AskState.New);
if (count == _ls.Count && _ls.Count > 0)
if (count > 0)
{
_ls.ForEach(p =>
{
@ -3115,7 +3128,7 @@ namespace CK.SCP.Controller
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.Message = "选择的记录,不是新建状态记录!";
_ret.Message = "选择的记录,不是新建状态记录!";
}
}
if (p_state == AskState.Reject)

4
北京北汽/Controller/SCP_ASN_CONTROLLER.cs

@ -741,7 +741,7 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var ask = db.TB_ASK.SingleOrDefault(t => t.AskBillNum == _asn.AskBillNum);
var ask = db.TB_ASK.SingleOrDefault(t => t.AskBillNum == _asn.AskBillNum&&t.Site==_asn.Site);
_print.EnglishAddress = ask.Extend1;
var phone1 = db.TB_ADDRESS.Count(t => t.Address == ask.Extend1);
if (phone1 > 0)
@ -749,7 +749,7 @@ namespace CK.SCP.Controller
var phone = db.TB_ADDRESS.SingleOrDefault(t => t.Address == ask.Extend1);
_print.CAAIPhone = phone.NamePone;
}
_print.CAAIFax = ask.Remark;
}
}
var dt = ConvertHelper.ToDataTable(new List<V_ASN_PRINT> { _print });

7
北京北汽/Controller/SCP_BARCODE_CONTROLLER.cs

@ -188,6 +188,13 @@ namespace CK.SCP.Controller
return db.TB_ASN.Where(p => p.AsnBillNum==asn).FirstOrDefault();
}
}
public static List<TS_BARCODE> GetBacode(string asn)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TS_BARCODE.Where(p => p.BillNum == asn).ToList();
}
}
public static void Get_TS_BARCODE_List(TS_BARCODE p_entity, Action<ResultObject<IQueryable<TS_BARCODE>>> p_action)
{
ResultObject<IQueryable<TS_BARCODE>> _ret = new ResultObject<IQueryable<TS_BARCODE>>();

6
北京北汽/Controller/SCP_BILLCODE_CONTROLLER.cs

@ -42,6 +42,12 @@ namespace CK.SCP.Controller
return GetTablePK("N", "TB_ASN", "AsnBillNum", "yyMMdd", 4);
}
public static string MakeASNCode_BJBQ(string str)
{
return GetTablePK(str, "TB_ASN", "AsnBillNum", "yyMMdd", 4);
}
public static string MakePalletCode()
{

217
北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs

@ -400,11 +400,6 @@ namespace CK.SCP.Controller
// break;
case "TED_RECEIPT_MSTR":
if (_task.Creator == "QAD")
{
TimeSpan nowDt = DateTime.Now.TimeOfDay;
TimeSpan workstartDT = DateTime.Parse("1:00").TimeOfDay;
TimeSpan workendDT = DateTime.Parse("4:00").TimeOfDay;
if (nowDt < workstartDT || nowDt > workendDT)
{
result = UpdateRecive(db, scpdb, _task);
Update_TEA_TASK_SUB(db, _task);
@ -414,7 +409,6 @@ namespace CK.SCP.Controller
scope.Complete();
result.Message = _task.TaskID.ToString();
}
}
else
{
result = UpdateARRIVE(db, scpdb, _task);
@ -447,9 +441,6 @@ namespace CK.SCP.Controller
scope.Complete();
UpdateSupplierExtend(_supplierlist);
break;
//case "TES_SUPPLIER_PART":
// result = UpdateSupplierPart(dc, db, scpdb, _task);
// break;
case "TES_PART_MSTR":
result = UpdatePart(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
@ -528,8 +519,8 @@ namespace CK.SCP.Controller
{
ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
var _list = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled&&p.Domain== "CQBMPT").OrderBy(p => p.UID).ToList();
var _list1 = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled && p.Domain == "CQBMPT" && p.InterfaceType== "Price").OrderBy(p => p.UID).ToList();
var _list = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled&&p.Domain== "BJBMPT").OrderBy(p => p.UID).ToList();
var _list1 = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled && p.Domain == "BJBMPT" && p.InterfaceType== "Price").OrderBy(p => p.UID).ToList();
var apiii = _list1.Count();
if (apiii > 0) {
@ -1081,6 +1072,7 @@ namespace CK.SCP.Controller
_entity.Site = _po.Site;
_entity.Scheduleweeks = 2;
_entity.DueDate = detail.PutTime;
_entity.PoType = detail.ModType;
db.TED_POD_DET.Add(_entity);
_ls.Add(_entity);
detail.State = (int)BillState.Finish;
@ -2033,14 +2025,20 @@ namespace CK.SCP.Controller
/// <returns></returns>
public static ResultObject<bool> UpdateSupplier(List<TES_SUPPLIER> p_list, ScpEntities scpdb, AppBoxContext authdb, TEA_TASK_SUB p_entity)
{
Dictionary<string, string> _dic = new Dictionary<string, string>();
_dic.Add("BJBMPT", "BJ01");
_dic.Add("CQBMPT", "CQ01");
_dic.Add("ZZBMPT", "ZZ01");
_dic.Add("HFBMPT", "HF01");
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
var _venderlist = new List<TA_VENDER>();
foreach (var supplier in p_list)
{
var _supplier = scpdb.TA_VENDER.SingleOrDefault(p => p.VendId == supplier.SupplierCode );
foreach (var item in _dic)
{
var _supplier = scpdb.TA_VENDER.FirstOrDefault(p => p.VendId == supplier.SupplierCode && p.Site == item.Key);
if (_supplier == null)
{
_supplier = new TA_VENDER
@ -2050,20 +2048,10 @@ namespace CK.SCP.Controller
State = 1,
};
}
_supplier.VendName = string.IsNullOrEmpty(supplier.SupplierName) ? supplier.SupplierName : supplier.SupplierName;//供应商名称
//_supplier.VendType = supplier.SupplierType.ToUpper().ToString();//供应商类型
//_supplier.Country = supplier.Country;//国家
//_supplier.City = supplier.City;//城市
//_supplier.Currency = supplier.Currency.ToUpper();//币总
//_supplier.Address = supplier.Address1 + supplier.Address2 + supplier.Address3;//地址
//_supplier.ZipCode = supplier.ZipCode.ToString();//邮编
//_supplier.Contacter = supplier.ContactName;//联系人
//_supplier.Phone = supplier.Telephone.ToString();//电话
//_supplier.Fax = supplier.Fax.ToString();//传真
_supplier.SubSite = string.IsNullOrEmpty(supplier.Site)?"BJ01" : supplier.Site;//域
_supplier.Site = string.IsNullOrEmpty(supplier.Domain)?"BJBMPT": supplier.Domain;//域
//_supplier.Tax = Convert.ToDecimal(supplier.TaxInCity);//税率
_supplier.VendName = string.IsNullOrEmpty(supplier.SupplierName) ? supplier.SupplierName : supplier.SupplierName;
_supplier.SubSite = item.Value;//地点
_supplier.Site = item.Key;//域
_supplier.Remark = supplier.TaskID.ToString();//任务ID
var vendname = string.Format("{0}@{1}", _supplier.VendId.ToUpper(), _supplier.Site.ToUpper());
@ -2100,6 +2088,7 @@ namespace CK.SCP.Controller
}
_venderlist.Add(_supplier);
}
}
scpdb.TA_VENDER.AddOrUpdate(_venderlist.ToArray());
_ret.State = ReturnStatus.Succeed;
_ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_SUPPLIER", p_entity.TaskID));
@ -2223,11 +2212,14 @@ namespace CK.SCP.Controller
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
var _partmstrlist = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID).ToList();
var _partmstrlist = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID&&p.CommandType!="D").ToList();
var _partmstrlistD = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID&&p.CommandType=="D").ToList();
var _partlist = new List<TA_PART>();
var _partlistD = new List<TA_PART>();
foreach (var part in _partmstrlist)
{
var _part = scpdb.TA_PART.SingleOrDefault(p => p.PartCode == part.PartCode && p.Site == part.Domain );
if (_part == null)
{
_part = new TA_PART
@ -2273,10 +2265,26 @@ namespace CK.SCP.Controller
_part.Remark = part.TaskID.ToString();
_partlist.Add(_part);
}
if (_partmstrlistD.Count() > 0)
{
foreach (var depart in _partmstrlistD)
{
var _part = scpdb.TA_PART.FirstOrDefault(p => p.PartCode == depart.PartCode && p.Site == depart.Domain);
if (_part != null)
{
_partlistD.Add(_part);
}
}
}
var str= JsonHelper.GetJson<List<TA_PART>>(_partlist);
scpdb.TA_PART.AddOrUpdate(_partlist.ToArray());
if (_partlistD.Count() > 0)
{
scpdb.TA_PART.DeleteRangeByKey(_partlistD.ToArray());
}
_ret.State = ReturnStatus.Succeed;
_ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_PART_MSTR", p_entity.TaskID));
}
@ -2429,22 +2437,102 @@ namespace CK.SCP.Controller
_item.PoUnit = _price.Unit;//单位
}
//_item.CreateUser = "scp";//_price.CreateUser;//创建人
// _item.CreateTime = DateTime.Now;//_price.CreateTime;//创建时间
// _item.GUID = Guid.NewGuid();//GUID
// _item.PriceList = (_vend + _site.Substring(1, 1) + _site.Substring(3, 1)).Trim(); //价目表代码
if(_domain == "BJBMPT")
{
// }
////说明
// _item.ProductLine = "";//产品类
var po = scpdb.V_TB_PO_DETAIL.Count(p => p.PartCode == _partCode&&p.Site== "BJBMPT"&&p.VendId== _vend.Trim());
if (po > 0)
{
var _list = scpdb.V_TB_PO_DETAIL.Where(p => p.PartCode == _partCode && p.Site == "BJBMPT" && p.VendId == _vend.Trim()).ToList();
foreach(var b in _list)
{
var PP = scpdb.TB_PO_DETAIL.FirstOrDefault(p => p.PartCode == b.PartCode && p.Site == "BJBMPT" && p.PoBillNum == b.PoBillNum);
PP.Price = _item.Price;
scpdb.TB_PO_DETAIL.AddOrUpdate(PP);
}
}
}
_teslist.Add(_item);
}
scpdb.TS_UNI_API.AddOrUpdate(_teslist.ToArray());
if (scpdb.SaveChanges() != -1)
{
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.Message = "数据更新失败!";
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.Message =e.InnerException.Message;
}
return _ret;
}
public static ResultObject<bool> UpdateTES_PURCHASE_PRICE_TemporaryPrice(List<long> p_list, string domain, string site, string name, bool flag)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
List<TS_UNI_API> _teslist = new List<TS_UNI_API>();
var _ls = scpdb.V_TB_PRICE_TemporaryPrice.Where(p => p_list.Contains(p.UID)).ToList();
foreach (var _price in _ls)
{
Guid _taskguid = Guid.NewGuid();
TS_UNI_API _item = new TS_UNI_API();
var _vend = _price.VendId.Trim();
var _partCode = _price.PartCode.Trim();
var _domain = _price.Site.Trim();
var _site = _price.SubSite.Trim();
_item.BillNum = (_vend + _site.Substring(1, 1) + _site.Substring(3, 1)).Trim();
_item.InterfaceType = "Price";
_item.Batch = "No";
_item.Qty = _price.Amt + _price.SharingPrice;
_item.Price = _price.Amt;
_item.State = 1;
_item.ValidDate = DateTime.Now;
_item.ErpLineNum = 1;
_item.PartCode = _partCode;//零件编号
_item.Domain = _domain;//域
_item.Site = _site;//地点
_item.Extend1 = _price.Remarks;
_item.CreateTime = Convert.ToDateTime(_price.StartTime);//开始时间
_item.PutTime = Convert.ToDateTime(_price.EndTime);//结束时间
_item.CreateOper = _price.Creator;
_item.Currency = _price.Curr;//货币
var _first = scpdb.TA_PART.Where(itm => itm.PartCode == _partCode).FirstOrDefault();
if (_first != null)
{
_item.PoUnit = _first.Unit;
}
else
{
_item.PoUnit = _price.Unit;//单位
}
// _item.AmountType = "P";//金额类型
// _item.Amount = _price.Amt+_price.SharingPrice;//金额(零件单价—+分摊单价)
// _item.TaskID = _taskguid;//任务编号
// _item.Remark = _price.Remarks;//备注
// _item.SupplierCode = _vend;//供应商
// _item.VendAmount = _price.Amt;//供应商金额
_teslist.Add(_item);
}
@ -2510,6 +2598,7 @@ namespace CK.SCP.Controller
_po.BuyerPhone = p_buyerPhone;
_po.Remark = _entity.;
_po.IsDeleted = false;
_po.State = (int)PoState.Open;
_po.CreateTime = DateTime.Now;
_po.CreateUser = p_creator;
_po.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
@ -2524,7 +2613,7 @@ namespace CK.SCP.Controller
TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL();
_PO_Detail.Currency = "CNY";
_PO_Detail.PoBillNum = _po.PoBillNum;
_PO_Detail.PartCode = itm.;
_PO_Detail.PartCode = itm..Trim();
var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm. && t.Site == _po.Site);
_PO_Detail.PoLine =int.Parse(itm.);
_PO_Detail.PoUnit = part.Unit;
@ -2536,6 +2625,7 @@ namespace CK.SCP.Controller
_PO_Detail.IsDeleted = false;
_PO_Detail.LocUnit = part.Unit;
_PO_Detail.UnConv = 1;
_PO_Detail.State= (int)PoState.Open;
_PO_Detail.Remark = itm.;
_PO_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
_PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.) ? 0 : int.Parse(itm.);
@ -2555,17 +2645,17 @@ namespace CK.SCP.Controller
TS_UNI_API Ts = new TS_UNI_API();
Ts.InterfaceType = "PO";
Ts.TableName = "TS_UNI_API";
Ts.Batch = _entity.;
Ts.Batch = _entity..Trim().ToUpper();
Ts.BillType = 702;
Ts.SubBillType = 1;
Ts.BillNum = _entity..Trim().ToUpper();
Ts.PartCode = _PO_Detail.PartCode;
Ts.PartCode = _PO_Detail.PartCode.Trim();
Ts.Qty = decimal.Parse(_entity.);
Ts.State = 1;
Ts.CreateOper = _entity.;
Ts.CreateTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.PutTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.VendId = _entity.;
Ts.VendId = _entity..Trim().ToUpper();
Ts.PoUnit = part.Unit;
Ts.LocUnit = part.Unit;
Ts.ValidDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
@ -2580,6 +2670,10 @@ namespace CK.SCP.Controller
Ts.CreateOper= _entity.;
Ts.VendBatch= p_creator;
Ts.ErpLineNum = _PO_Detail.PoLine;
if (_entity..ToUpper() == "S")
{
Ts.ModType = _entity..ToUpper();
}
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
scpdb.TS_UNI_API.Add(Ts);
});
@ -2699,17 +2793,17 @@ namespace CK.SCP.Controller
TS_UNI_API Ts = new TS_UNI_API();
Ts.InterfaceType = "PO";
Ts.TableName = "TS_UNI_API";
Ts.Batch = _entity.;
Ts.Batch = _entity..Trim().ToUpper();
Ts.BillType = 702;
Ts.SubBillType = 2;
Ts.BillNum = _po.PoBillNum.Trim().ToUpper();
Ts.PartCode = _tDetail.PartCode;
Ts.PartCode = _tDetail.PartCode.Trim().ToUpper();
Ts.Qty = _tDetail.AskQty;
Ts.State = 1;
Ts.CreateOper = _entity.;
Ts.CreateTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.PutTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.VendId = _entity.;
Ts.VendId = _entity..Trim().ToUpper();
Ts.PoUnit = part.Unit;
Ts.LocUnit = part.Unit;
Ts.ValidDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
@ -2724,6 +2818,14 @@ namespace CK.SCP.Controller
Ts.VendBatch = p_creator;
Ts.ErpBillNum= _po.PoBillNum;
Ts.ErpLineNum = _PO_Detail.PoLine;
if (!string.IsNullOrEmpty(_entity.))
{
if (_entity..ToUpper() == "S")
{
Ts.ModType = _entity..ToUpper();
}
}
scpdb.TB_ASK_DETAIL.Add(_tDetail);
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
scpdb.TS_UNI_API.Add(Ts);
@ -2804,6 +2906,7 @@ namespace CK.SCP.Controller
_po.Contacter = p_chineseName;// _entity.联系人;
_po.Buyer = p_chineseName;// _entity.联系人;
_po.Site = site.Trim().ToUpper();
_po.State= (int)PoState.Open;
_po.BuyerPhone = p_buyerPhone;
_po.Remark = _entity.;
_po.IsDeleted = false;
@ -2853,21 +2956,21 @@ namespace CK.SCP.Controller
TS_UNI_API Ts = new TS_UNI_API();
Ts.InterfaceType = "PO";
Ts.TableName = "TS_UNI_API";
Ts.Batch = _entity.;
Ts.Batch = _entity..Trim();
Ts.BillType = 702;
Ts.SubBillType = 1;
Ts.BillNum = _entity..Trim().ToUpper();
Ts.PartCode = _PO_Detail.PartCode;
Ts.PartCode = _PO_Detail.PartCode.Trim();
Ts.Qty = decimal.Parse(_entity.);
Ts.State = 1;
Ts.CreateOper = _entity.;
Ts.CreateTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.PutTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.VendId = _entity.;
Ts.VendId = _entity..Trim();
Ts.PoUnit = part.Unit;
Ts.LocUnit = part.Unit;
Ts.ValidDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
Ts.ErpBillNum = _entity.;
Ts.ErpBillNum = _entity..Trim();
Ts.Buyer = _entity.;
Ts.BuyerPhone = _entity.;
Ts.Price = decimal.Parse(_entity.);
@ -2920,7 +3023,7 @@ namespace CK.SCP.Controller
_PO_Detail.PartCode = itm..Trim().ToUpper();
var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm. && t.Site == _po.Site);
_PO_Detail.PoLine = _number;
_PO_Detail.PoBillNum = _po.PoBillNum;
_PO_Detail.PoBillNum = _po.PoBillNum.Trim();
_PO_Detail.State = (int)PoState.Open;
_PO_Detail.Site = site.Trim().ToUpper();
_PO_Detail.SubSite = subsite.Trim().ToUpper();
@ -2954,17 +3057,17 @@ namespace CK.SCP.Controller
TS_UNI_API Ts = new TS_UNI_API();
Ts.InterfaceType = "PO";
Ts.TableName = "TS_UNI_API";
Ts.Batch = _entity.;
Ts.Batch = _entity..Trim();
Ts.BillType = 702;
Ts.SubBillType = 2;
Ts.BillNum = _po.PoBillNum.Trim().ToUpper();
Ts.PartCode = _PO_Detail.PartCode;
Ts.PartCode = _PO_Detail.PartCode.Trim();
Ts.Qty = _PO_Detail.PlanQty;
Ts.State = 1;
Ts.CreateOper = _entity.;
Ts.CreateTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.PutTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
Ts.VendId = _entity.;
Ts.VendId = _entity..Trim();
Ts.PoUnit = part.Unit;
Ts.LocUnit = part.Unit;
Ts.ValidDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
@ -2977,13 +3080,13 @@ namespace CK.SCP.Controller
Ts.Extend2 = _entity.;
Ts.CreateOper = _entity.;
Ts.VendBatch = p_creator;
Ts.ErpBillNum = _po.PoBillNum;
Ts.ErpBillNum = _po.PoBillNum.Trim();
Ts.ErpLineNum = _number;
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
scpdb.TS_UNI_API.Add(Ts);
_number++;
});
_polist = _polist + _po.PoBillNum + ",";
_polist = _polist + _po.PoBillNum.Trim() + ",";
}
#endregion
}

6
北京北汽/Controller/SCP_EXCEL_CONTROLLER.cs

@ -53,6 +53,8 @@ namespace CK.SCP.Controller
{
var po_detail = new SCP_PO_DETAIL_EXPORT();
po_detail. = itm.PoBillNum;
po_detail. = itm.VendId;
po_detail. = itm.VendName;
po_detail. = itm.State_DESC;
po_detail. = itm.PoLine.ToString();
po_detail. = itm.PartDesc1;
@ -200,6 +202,7 @@ namespace CK.SCP.Controller
_entity. = itm.Price.ToString();
_entity. = itm.AskQty.ToString();
_entity. = string.IsNullOrEmpty(itm.Remark)?string.Empty:itm.Remark.ToString();
_entity. = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
_exportDetailList.Add(_entity);
});
@ -267,10 +270,7 @@ namespace CK.SCP.Controller
var _po = db.TB_PRICE.Where(p => p_lst.Contains(p.UID.ToString())).ToList();
var _po1 = _po.Select(p => p_lst.Contains(p.UID.ToString())).ToList();
//var _ls = polist.Where(itm => partlist.Contains(itm));
_po.ForEach(itm =>
{

155
北京北汽/Controller/SCP_LOGINNUMBER_CONTROLLER.cs

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Utils;
using System.Data.Entity.Core;
using CK.SCP.Models.Enums;
using CK.SCP.Models.AppBoxEntity;
namespace CK.SCP.Controller
{
public class SCP_LOGINNUMBER_CONTROLLER
{
public static TA_LOGINNUMBER GetlistUserNumber(string username)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_LOGINNUMBER.Where(p => p.Name == username).FirstOrDefault();
}
}
public static ResultObject<bool> Save_TA_LOGINNUMBER(string username, LoginNumer p_state,string date)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
using (AppBoxContext _appdb = EntitiesFactory.CreateAppBoxInstance())
{
var user = _appdb.Users.FirstOrDefault(t => t.Name == username);
if (user == null)
{
_ret.MessageList.Add("用户名"+ username+"不存在,请输入正确用户名");
}
else
{
var login = db.TA_LOGINNUMBER.FirstOrDefault(p => p.Name == username);
if (p_state == LoginNumer.Sussess && login != null)
{
db.TA_LOGINNUMBER.Remove(login);
}
if (login != null && p_state == LoginNumer.Faile)
{
if (login.Number == 4&&login.Time==date)
{
login.Number = 5;
db.TA_LOGINNUMBER.AddOrUpdate(login);
user.Enabled = false;
_appdb.Users.AddOrUpdate(user);
_appdb.SaveChanges();
_ret.MessageList.Add("因您连续五次输入密码错误,该账号已经被设为未启用状态,请联系系统管理员");
}
else if(login.Number <4 && login.Time == date)
{
login.Number = login.Number + 1;
db.TA_LOGINNUMBER.AddOrUpdate(login);
}else if(login.Time != date)
{
login.Time = date;
login.Number = 1;
db.TA_LOGINNUMBER.AddOrUpdate(login);
}
}
else if (login == null && p_state == LoginNumer.Faile)
{
TA_LOGINNUMBER log = new TA_LOGINNUMBER();
log.Name = username;
log.Number = 1;
log.Time = DateTime.Now.ToShortDateString();
db.TA_LOGINNUMBER.AddOrUpdate(log);
}
}
}
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_LOGINNUMBER_CONTROLLER), "Save_TA_LOGINNUMBER", 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_LOGINNUMBER_CONTROLLER), "Save_TA_LOGINNUMBER", 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_LOGINNUMBER_CONTROLLER), "Save_TA_LOGINNUMBER", 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_LOGINNUMBER_CONTROLLER), "Save_TA_LOGINNUMBER", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
}
}

502
北京北汽/Controller/SCP_PO_CONTROLLER.cs

@ -96,10 +96,10 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p.BeginTime <= p_entity.EndTime);
}
if (p_entity.UserInAddress.FirstOrDefault() != null && p_entity.UserInAddress.Count > 0)
{
q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
}
//if (p_entity.UserInAddress.FirstOrDefault() != 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));
@ -1071,7 +1071,7 @@ namespace CK.SCP.Controller
DateTime dd1 = st1.AddYears(10);
int b = int.Parse(p_excel.);
var Th = db.TB_PRICE.SingleOrDefault(p => p.UID.ToString() == p_excel. && p.VendId == p_excel. && p.PartCode == p_excel.
&& p.Amt == st4 && p.SubSite == p_excel. && p.EndTime == st6 && p.StartTime == st5&&p.Curr==p_excel.&&p.Unit==p_excel.
&& p.Amt == st4 && p.SubSite == p_excel. &&p.Curr==p_excel.&&p.Unit==p_excel.
);
if (Th == null)
{
@ -1079,6 +1079,15 @@ namespace CK.SCP.Controller
}
else
{
if ((DateTime.Parse(Th.StartTime.ToString())).ToShortDateString()!=st3.ToShortDateString()|| (DateTime.Parse(Th.EndTime.ToString())).ToShortDateString() != st2.ToShortDateString())
{
ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】的导出数据不能修改!", p_excel., p_excel.));
}
DateTime STA =DateTime.Parse(Th.StartTime.ToString());
if(DateTime.Parse(STA.ToShortDateString())!= st3)
{
ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】的导出数据不能修改!", p_excel., p_excel.));
}
if (Th.State != (int)PriceState.FConfirm)
{
ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】不是财务已审核的数据,不能导入!", p_excel., p_excel.));
@ -1140,10 +1149,10 @@ namespace CK.SCP.Controller
{
if (p_excel. != "CNY"&& p_excel. != "EUR" && p_excel. != "USD")
{
ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】币种填写错误,只能是CNY!", p_excel., p_excel.));
ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】币种填写错误,只能是CNY或者EUR或者USD!", p_excel., p_excel.));
}
var Site = db.TB_FACTORY.Where(p=>p.ErpSite== p_excel.).FirstOrDefault();
var _first = db.TA_PART.Where(p => p.PartCode == p_excel. && p.State.ToUpper() != "SP"&&p.Site== p_excel.).FirstOrDefault();
var _first = db.TA_PART.Where(p => p.PartCode == p_excel. &&p.Site== p_excel.).FirstOrDefault();
if (_first == null)
{
ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel., p_excel.));
@ -1151,6 +1160,10 @@ namespace CK.SCP.Controller
else
{
p_excel. = _first.Unit;
if (_first.State == "SP")
{
ErrorList.Add(string.Format("零件编号【{0}】状态为SP,无法导入!", p_excel.));
}
}
p_excel. = !string.IsNullOrEmpty(p_excel.) ? p_excel..Trim() : string.Empty;
@ -1170,6 +1183,15 @@ namespace CK.SCP.Controller
var _SubSite = new SqlParameter("@SubSite", p_excel.);
var _VendId = new SqlParameter("@VendId", p_excel.);
var _PartCode = new SqlParameter("@PartCode", p_excel.);
if (st > et)
{
ErrorList.Add(string.Format("供应商{0}零件编号{1}的结束时间需要大于开始时间!", p_excel., p_excel.));
}
//var price = db.TB_PRICE.Count(p => p.PartCode == p_excel.零件编码.Trim() && p.VendId == p_excel.供应商编号.Trim() && p.StartTime == st && p.EndTime == et && p.Site == p_excel.域&&p.State!=-1);
//if (price > 0)
//{
// ErrorList.Add(string.Format("供应商{0}零件编号{1}价格单已经存在!", p_excel.供应商编号, p_excel.零件编码));
//}
string check = "select * from tb_price where uid in\n" +
"(\n" +
" select max(uid) uid\n" +
@ -1178,40 +1200,30 @@ namespace CK.SCP.Controller
" group by vendid,partcode,subsite,site\n" +
") ";
var _price = db.Database.SqlQuery<TB_PRICE>(check, _Site, _SubSite, _VendId, _PartCode).FirstOrDefault();
if (_price != null)
{
if (st_st < Convert.ToDateTime(_price.StartTime.Value.ToShortDateString()) || st_st > et_st || st_st == et_st)//更新价格时间判断
{
ErrorList.Add(string.Format("供应商{0}零件编号{1}开始时间结束时间不正确!", p_excel., p_excel.));
}
if (st_st > Convert.ToDateTime(_price.StartTime.Value.ToShortDateString()))//添加价格记录时间判断
{
if (st.ToShortDateString() != (_price.EndTime.Value.AddDays(1)).ToShortDateString())
{
ErrorList.Add(string.Format("供应商{0}零件编号{1}开始日期必须为{2}", p_excel., p_excel., _price.EndTime.Value.AddDays(1).ToShortDateString().Replace("-", "/")));
}
if (_price.State != (int)PriceState.FConfirm)
{
ErrorList.Add(string.Format("供应商{0}零件编号{1},新添价格的上期价格不是审批状态", p_excel., p_excel.));
}
//if (_price.EndTime.ToString() == p_excel.结束时间)
ErrorList.Add(string.Format("供应商{0}零件编号{1}价格单已经存在,如要修改价格单信息请到价格单修改菜单进行操作!", p_excel., p_excel.));
//if (st_st < Convert.ToDateTime(_price.StartTime.Value.ToShortDateString()) || st_st > et_st || st_st == et_st)//更新价格时间判断
//{
// ErrorList.Add(string.Format("供应商{0}零件编号{1}结束时间不正确,结束时间应大于现有最新结束时间!", p_excel.供应商编号, p_excel.零件编码));
// ErrorList.Add(string.Format("供应商{0}零件编号{1}开始时间结束时间不正确!", p_excel.供应商编号, p_excel.零件编码));
//}
//if (et < _price.EndTime)
//if (st_st > Convert.ToDateTime(_price.StartTime.Value.ToShortDateString()))//添加价格记录时间判断
//{
// if (st.ToShortDateString() != (_price.EndTime.Value.AddDays(1)).ToShortDateString())
// {
// ErrorList.Add(string.Format("供应商{0}零件编号{1}结束日期和!", p_excel.供应商编号, p_excel.零件编码));
// ErrorList.Add(string.Format("供应商{0}零件编号{1}开始日期必须为{2}", p_excel.供应商编号, p_excel.零件编码, _price.EndTime.Value.AddDays(1).ToShortDateString().Replace("-", "/")));
// }
}
}
//var _ls = db.TB_PRICE.Where(p => p.State != (int)PriceState.Reject && p.Site == p_excel.域 && p.SubSite == p_excel.地点 && p.VendId == p_excel.供应商编号 && p.PartCode == p_excel.零件编码 &&
//p.EndTime > st && p.StartTime < et && (p.StartTime != st || p.EndTime != et)).ToList();
//if (_ls.Count > 0)
// if (_price.State != (int)PriceState.FConfirm)
// {
// ErrorList.Add(string.Format("供应商{0}零件编号{1}开始时间{2}结束时间{3}存在时间重复,请修改为开始时间:{4} 结束时间:{5}!", p_excel.供应商编号, p_excel.零件编码, p_excel.开始时间, p_excel.结束时间, Convert.ToDateTime(_ls[0].StartTime).ToString("yyyy/MM/dd"), Convert.ToDateTime(_ls[0].EndTime).ToString("yyyy/MM/dd")));
// ErrorList.Add(string.Format("供应商{0}零件编号{1},新添价格的上期价格不是审批状态", p_excel.供应商编号, p_excel.零件编码));
// }
//}
}
}
return ErrorList;
}
/// <summary>
@ -1352,7 +1364,10 @@ namespace CK.SCP.Controller
p_excel. = checkcount[0].Unit;
p_excel. = checkcount[0].Curr;
}
if (string.IsNullOrEmpty(p_excel.))
{
ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】订单类型为空,委外订单填 S,普通订单填 M!", p_excel., p_excel.));
}
if (p_excel. != "0")
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的要货数量应该为零!", p_excel., p_excel., p_excel.));
@ -1385,26 +1400,26 @@ namespace CK.SCP.Controller
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大应为2位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.))
{
if (p_excel..ToUpper() == "S")
{
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,8}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel., p_excel., p_excel.));
}
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,6}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel., p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.));
}
//注释结束
//if (!string.IsNullOrEmpty(p_excel.订单类型))
//{
// if (p_excel.订单类型.ToUpper() == "S")
// {
// if (string.IsNullOrEmpty(p_excel.加工单号) || !Regex.IsMatch(p_excel.加工单号, "^[0-9]{1,8}$"))
// {
// ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号));
// }
// if (string.IsNullOrEmpty(p_excel.工序) || !Regex.IsMatch(p_excel.工序, "^[0-9]{1,6}$"))
// {
// ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号));
// }
// }
// else
// {
// ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.订单编号));
// }
// //注释结束
}
//}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 8)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel., p_excel., p_excel.));
@ -1703,26 +1718,26 @@ namespace CK.SCP.Controller
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大应为2位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.))
{
if (p_excel..ToUpper() == "S")
{
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,8}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel., p_excel., p_excel.));
}
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,6}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel., p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.));
}
//注释结束
//if (!string.IsNullOrEmpty(p_excel.订单类型))
//{
// if (p_excel.订单类型.ToUpper() == "S")
// {
// if (string.IsNullOrEmpty(p_excel.加工单号) || !Regex.IsMatch(p_excel.加工单号, "^[0-9]{1,8}$"))
// {
// ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号));
// }
// if (string.IsNullOrEmpty(p_excel.工序) || !Regex.IsMatch(p_excel.工序, "^[0-9]{1,6}$"))
// {
// ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号));
// }
// }
// else
// {
// ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.订单编号));
// }
// //注释结束
}
//}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 8)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel., p_excel., p_excel.));
@ -2108,6 +2123,236 @@ namespace CK.SCP.Controller
return _ret;
}
/// <summary>
/// 北汽模塑
/// </summary>
/// <param name="p_order_list"></param>
/// <param name="p_creator"></param>
/// <param name="p_time"></param>
/// <param name="p_modtype"></param>
/// <param name="IsAutoPublish"></param>
/// <returns></returns>
public static ResultObject<bool> EXCEL_PO_TO_ASK_MOD_BJMS(List<SCP_PO_DETAIL_EXPORT_MODEL> p_order_list, string p_creator, string str1, string p_buyer, DateTime p_time, BillModType p_modtype, bool IsAutoPublish = false)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
p_order_list.ForEach(p =>
{
if (string.IsNullOrEmpty(p.))
{
p. = "0";
}
});
int number = 1;
List<string> lineError = new List<string>();
List<string> ErrorList = new List<string>();
var _lst = p_order_list.Where(p => p. != "0").ToList();
_lst.ForEach
(p =>
{
var _ls = CheckExcelMode(db, p);
if (_ls.Count > 0)
{
lineError.Add(number.ToString());
ErrorList.Add(string.Join("<br>", _ls.ToArray()));
}
number++;
});
if (lineError.Count > 0)
{
_ret.State = ReturnStatus.Failed;
_ret.MessageList.AddRange(ErrorList);
_ret.Result = false;
}
else
{
var VenderList = _lst.Select(p => p.).Distinct();
var PartCodeList = _lst.Select(p => p.).Distinct();
var OrderList = _lst.GroupBy(p => new { p., p. }).ToList();
OrderList.ForEach((p) =>
{
var list = p.ToList();
if (list.Count > 0)
{
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.;
_ask.ModType = (int)BillModType.Contract;
_ask.Site = _entity.;
_ask.SubSite = _entity.;
if (IsAutoPublish)
{
_ask.State = (int)AskState.Release;
}
else
{
_ask.State = (int)AskState.New;
}
_ask.BeginTime = DateTime.Parse(_entity.);
_ask.Buyer = p_buyer;
_ask.BuyerPhone = _entity.;
_ask.ErpBillNum = _entity.;
_ask.EndTime = DateTime.Parse(_entity.);
_ask.CreateTime = DateTime.Now;
_ask.CreateUser = p_creator;
_ask.VendId = _entity.;
_ask.GUID = Guid.NewGuid();
_ask.ReceivedPort = _entity.;
_ask.IsDeleted = false;
_ask.Extend1 = str1;
_ask.Remark = _entity.;
db.TB_ASK.Add(_ask);
#region 供应商新任务代办接口
TB_PENING_ITEMS _item = new TB_PENING_ITEMS();
_item.ROLE_NAME = "供应商";
_item.ITEM_NO = _ask.AskBillNum;
_item.ITEM_CONTENT = "要货看盘有信息";
_item.ITEM_TYPE = (int)PENDING_MESSAGE_TYPE.NEW_ASK;
_item.VEND_ID = _ask.VendId;
_item.ITEM_STATE = (int)PENDING_STATE.WAITING;
_item.SENDER = _entity.;
_item.SENDING_TIME = DateTime.Now;
db.TB_PENING_ITEMS.Add(_item);
#endregion
// int _number = 1;
List<TB_ASK_DETAIL> _ls = new List<TB_ASK_DETAIL>();
list.ForEach((itm) =>
{
var _number = _ls.Count(p1 => p1.PoBillNum == _ask.PoBillNum
&& p1.PoLine == Int32.Parse(itm.) && p1.PartCode == itm. && itm. == p1.Remark);
if (_number > 0)
{
_ret.MessageList.Add(string.Format("已经存在订单为{0}行号为{1}零件编码为{2}", itm., itm., itm.));
}
TB_ASK_DETAIL _t_ASK_Detail = new TB_ASK_DETAIL();
//_t_ASK_Detail.PoLine = _number;
_t_ASK_Detail.PoLine = Int32.Parse(itm.);
_t_ASK_Detail.Currency = itm.;
_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.;
_t_ASK_Detail.BeginTime = DateTime.Parse(itm.);
_t_ASK_Detail.EndTime = DateTime.Parse(itm.);
_t_ASK_Detail.TempQty = decimal.Parse(itm.);
_t_ASK_Detail.AskQty = decimal.Parse(itm.);
_t_ASK_Detail.IsDeleted = false;
_t_ASK_Detail.LocUnit = itm.;
_t_ASK_Detail.UnConv = 1;
_t_ASK_Detail.Site = _ask.Site;
_t_ASK_Detail.SubSite = _ask.SubSite;
_t_ASK_Detail.DockCode = itm.;
_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 = _ask.Site;
db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
_ls.Add(_t_ASK_Detail);
// _number++;
});
}
else
{
_ret.MessageList.Add("ERP订单编号已存在,请重新导入!");
}
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_PO_CONTROLLER), "EXCEL_PO_TO_ASK", 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_PO_CONTROLLER), "EXCEL_PO_TO_ASK", 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_PO_CONTROLLER), "EXCEL_PO_TO_ASK", 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_PO_CONTROLLER), "EXCEL_PO_TO_ASK", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
/// <summary>
/// 供应商零件导入
/// </summary>
@ -2475,7 +2720,10 @@ namespace CK.SCP.Controller
_lst.ForEach(p =>
{
var _price = new TB_PRICE();
string starttime = DateTime.Parse(p.).ToShortDateString();
string endtime = DateTime.Parse(p.).ToShortDateString();
DateTime st = DateTime.Parse(p.);
DateTime et = DateTime.Parse(p.);
#region 201909011修改
var _Site = new SqlParameter("@Site", p.);
@ -2498,8 +2746,8 @@ namespace CK.SCP.Controller
_price.State = _state;
_price.VendId = p..Trim();
_price.PartCode = p..Trim();
_price.StartTime = DateTime.Parse(p.);
_price.EndTime = DateTime.Parse(p.);
_price.StartTime = DateTime.Parse(starttime);
_price.EndTime = DateTime.Parse(endtime);
_price.Curr = p.;
_price.Unit = p.;
_price.Amt = decimal.Parse(p.);
@ -2796,6 +3044,8 @@ namespace CK.SCP.Controller
_lst.ForEach(p =>
{
string starttime = Convert.ToDateTime(p.).ToShortDateString();
string endtime = Convert.ToDateTime(p.).ToShortDateString();
var _vender = db.TB_PRICE.SingleOrDefault(t => t.VendId == p..ToUpper() && t.PartCode == p. && t.UID.ToString() == p. && t.SubSite == p. && t.Site == p.);
if (_vender == null)
{
@ -2805,11 +3055,49 @@ namespace CK.SCP.Controller
if (DateTime.Parse(p.)< DateTime.Parse(p.) && DateTime.Parse(p.) >DateTime.Parse(p.))
{
_vender.EndTime = Convert.ToDateTime(DateTime.Parse(p.).AddDays(-1));
_vender.EndTime = Convert.ToDateTime(DateTime.Parse(starttime).AddDays(-1));
_vender.Extend3 = "价格表修改";
var _PR = db.V_TB_PRICE.FirstOrDefault(t => t.VendId == p..ToUpper() && t.PartCode == p. && t.UID.ToString() == p. && t.SubSite == p. && t.Site == p.);
if (_PR != null)
{
TS_UNI_API TS = new TS_UNI_API();
TS.InterfaceType = "Price";
TS.BillNum = (_PR.VendId + _PR.SubSite.Substring(1, 1) + _PR.SubSite.Substring(3, 1)).Trim();
TS.PartCode = _PR.PartCode;
if (_PR.TemporaryPrice == 0)
{
TS.Batch = "No";
}
else
{
TS.Batch = "Yes";
}
TS.Qty = _PR.Amt + _PR.SharingPrice;
TS.Price = _PR.Amt;
TS.State = 1;
TS.ValidDate = DateTime.Now;
TS.ErpLineNum = 1;
TS.Domain = _PR.Site;//域
TS.Site = _PR.SubSite;//地点
TS.Extend1 = _PR.Remarks;
TS.CreateTime = Convert.ToDateTime(_PR.StartTime);//开始时间
TS.PutTime = Convert.ToDateTime(DateTime.Parse(starttime).AddDays(-1));//结束时间
TS.CreateOper = _PR.Creator;
TS.Currency = _PR.Curr;//货币
var _first = db.TA_PART.Where(itm => itm.PartCode == p.).FirstOrDefault();
if (_first != null)
{
TS.PoUnit = _first.Unit;
}
else
{
TS.PoUnit = _PR.Unit;//单位
}
db.TS_UNI_API.Add(TS);
}
db.TB_PRICE.AddOrUpdate(_vender);
}
// var sr = p.零件最新价格.ToString().Trim();
TB_PRICE tb = new TB_PRICE();
tb.State = 0;
tb.Extend3 = "价格表修改增加";
@ -2821,8 +3109,8 @@ namespace CK.SCP.Controller
tb.Amt = Convert.ToDecimal(p.);
tb.Site = p.;
tb.SubSite = p.;
tb.StartTime = Convert.ToDateTime(p.);
tb.EndTime = Convert.ToDateTime(p.);
tb.StartTime = Convert.ToDateTime(starttime);
tb.EndTime = Convert.ToDateTime(endtime);
tb.Creator = p_createuser;
tb.IsPost = 0;
tb.TemporaryPrice = Int32.Parse(p.);
@ -2833,17 +3121,16 @@ namespace CK.SCP.Controller
if (_ret.MessageList.Count == 0)
{
int state = db.SaveChanges();
if (state != -1)
{
db.BulkSaveChanges();
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
}
//}
//else
//{
// _ret.State = ReturnStatus.Failed;
// _ret.Result = false;
//}
}
else
{
@ -3383,7 +3670,7 @@ namespace CK.SCP.Controller
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
int number = 1;
//int number = 1;
List<string> lineError = new List<string>();
List<string> ErrorList = new List<string>();
@ -3399,6 +3686,16 @@ namespace CK.SCP.Controller
//}
//注释结束
var _lst = p_order_list;
var PoList = _lst.Select(itm => itm.).Distinct().ToList();
foreach (var po in PoList)
{
var vendcount = _lst.Where(itm => itm. == po).Select(itm => itm.).Distinct().ToList();
if (vendcount.Count() > 1)
{
lineError.Add(string.Format("导入订单编号【{0}】对应两个供应商了,麻烦修改", po));
ErrorList = lineError;
}
}
p_order_list.ForEach(p =>
{
var _count1 = _lst.Count(itm => itm. == p. && itm. == p.);
@ -3413,6 +3710,8 @@ namespace CK.SCP.Controller
lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p., p.));
ErrorList = lineError;
}
});
p_order_list.ForEach
(p =>
@ -3420,12 +3719,10 @@ namespace CK.SCP.Controller
var _ls = CheckExcelMode_Po(db, p, p_modtype, site, subsite);
if (_ls.Count > 0)
{
lineError.Add(number.ToString());
ErrorList.Add(string.Join("<br>", _ls.ToArray()));
}
number++;
});
if (lineError.Count > 0)
if (ErrorList.Count > 0)
{
_ret.State = ReturnStatus.Failed;
_ret.MessageList.AddRange(ErrorList);
@ -3520,11 +3817,19 @@ namespace CK.SCP.Controller
//}
//注释结束
var _lst = p_order_list;
var VenderList = _lst.Select(itm => itm.).Distinct().ToList();
var PartCodeList = _lst.Select(itm => itm.).Distinct().ToList();
if (VenderList.Count != PartCodeList.Count)
{
lineError.Add(string.Format("存在多个供应商编号对应一个订单号"));
ErrorList = lineError;
}
p_order_list.ForEach(p =>
{
var _count1 = _lst.Count(itm => itm. == p. && itm. == p.);
var _count2 = _lst.Count(itm => itm. == p. && itm. == p.);
//var _count3 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.供应商编号 == p.供应商编号);
if (_count1 > 1 && p_modtype == BillModType.Contract)
{
lineError.Add(string.Format("导入订单编号【{0}】行号【{1}】有重复", p., p.));
@ -3536,11 +3841,6 @@ namespace CK.SCP.Controller
ErrorList = lineError;
}
//if (_count3 > 1)
//{
// lineError.Add(string.Format("导入订单编号【{0}】供应商编号【{1}】有重复", p.订单编号, p.供应商编号));
// ErrorList = lineError;
//}
});
p_order_list.ForEach
(p =>
@ -4348,7 +4648,17 @@ namespace CK.SCP.Controller
_tDetail.State = (int)p_order.State;
_tDetail.SubSite = itm.SubSite;
_tDetail.Site = itm.Site;
if (itm.Site == "BJBMPT")
{
var price = db.TB_PRICE.Where(p => p.PartCode == itm.PartCode&&p.State>-1&&p.VendId== p_order.VendId).Max(p => p.UID);
var pri = db.TB_PRICE.FirstOrDefault(t=>t.UID==price);
_tDetail.Price = pri.Amt;
}
else
{
_tDetail.Price = itm.Price;
}
_tDetail.Remark = itm.Remark;
_tDetail.GUID = Guid.NewGuid();
_tDetail.Currency = itm.Currency;

8
北京北汽/Controller/SCP_RECEIVE_CONTROLLER.cs

@ -1091,10 +1091,10 @@ namespace CK.SCP.Controller
{
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
}
if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
{
q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
}
//if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
//{
// q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
//}
if (p_entity.UserInSubSite != null && p_entity.UserInSubSite.Count > 0)
{
q = q.Where(p => p_entity.UserInSubSite.Contains(p.SubSite));

122
北京北汽/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs

@ -10,6 +10,7 @@ using CK.SCP.Models.ScpEntity;
using CK.SCP.Utils;
using System.Data.Entity.Core;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
namespace CK.SCP.Controller
{
@ -123,7 +124,128 @@ namespace CK.SCP.Controller
return _ret;
}
public static ResultObject<bool> EXCEL_ADRESS_LIST_CQ(List<SCP_VENDER_EXPORT> p_order_list, string site, string p_creator)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
int number = 1;
List<string> lineError = new List<string>();
List<string> ErrorList = new List<string>();
var _lst = p_order_list;
if (lineError.Count > 0)
{
_ret.State = ReturnStatus.Failed;
_ret.MessageList.AddRange(ErrorList);
_ret.Result = false;
}
else
{
_lst.ForEach(p =>
{
var _Sitelist = db.TB_ADDRESS.Count(t => t.Address == p.);
if (_Sitelist == 0)
{
TB_ADDRESS Price = new TB_ADDRESS();
Price.Address = p.;
Price.NamePone = p.;
db.TB_ADDRESS.AddOrUpdate(Price);
}
else if (_Sitelist == 1)
{
var _PAlist = db.TB_ADDRESS.SingleOrDefault(t => t.Address == p.);
_PAlist.NamePone = p.;
db.TB_ADDRESS.AddOrUpdate(_PAlist);
}
});
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_PO_CONTROLLER), "EXCEL_VENDER_PART_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_PO_CONTROLLER), "EXCEL_VENDER_PART_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_PO_CONTROLLER), "EXCEL_VENDER_PART_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_PO_CONTROLLER), "EXCEL_VENDER_PART_MOD", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
public static ResultObject<bool> Save_TA_LANGUAGE(List<TA_LANGUAGE> p_entitys)
{
ResultObject<bool> _ret = new ResultObject<bool>();

317
北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs

@ -145,6 +145,224 @@ namespace CK.SCP.Controller
if (p_entity.UID!=0)
{
q = q.Where(p => p.UID==p_entity.UID);
}
if (!string.IsNullOrEmpty(p_entity.VendId))
{
q = q.Where(p => p.VendId.Contains(p_entity.VendId));
}
if (!string.IsNullOrEmpty(p_entity.PartCode))
{
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
}
if (p_entity.Amt>0)
{
q = q.Where(p => p.Amt==p_entity.Amt);
}
if (p_entity.TemporaryPrice > 0)
{
q = q.Where(p => p.TemporaryPrice == p_entity.TemporaryPrice);
}
if (p_entity.SharingPrice > 0)
{
q = q.Where(p => p.SharingPrice == p_entity.SharingPrice);
}
if (!string.IsNullOrEmpty(p_entity.Extend3))
{
q = q.Where(p => p.Extend3.Contains(p_entity.Extend3));
}
if (!string.IsNullOrEmpty(p_entity.Extend2))
{
q = q.Where(p => p.Extend2.Contains(p_entity.Extend2));
}
if (!string.IsNullOrEmpty(p_entity.Extend3))
{
q = q.Where(p => p.Extend3.Contains(p_entity.Extend3));
}
if (!string.IsNullOrEmpty(p_entity.PartName))
{
q = q.Where(p => p.PartName.Contains(p_entity.PartName));
}
if (!string.IsNullOrEmpty(p_entity.Creator))
{
q = q.Where(p => p.Creator== p_entity.Creator);
}
if (p_entity.StartTime != null)
{
q = q.Where(p => p.StartTime >= p_entity.StartTime);
}
if (p_entity.EndTime != null)
{
q = q.Where(p => p.EndTime <= p_entity.EndTime);
}
if (p_entity.State!=3)//3是查询所有
{
q = q.Where(p => p.State == p_entity.State);
}
if (!string.IsNullOrEmpty(p_entity.SubSite))
{
q = q.Where(p => p.SubSite == p_entity.SubSite);
}
if (p_entity.UIDList != null && p_entity.UIDList.Count > 0)
{
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
}
if (p_entity.UserInSubSite != null && p_entity.UserInSubSite.Count > 0)
{
q = q.Where(p => p_entity.UserInSubSite.Contains(p.SubSite));
}
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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_List", e.Message);
throw e;
}
}
public static void Get_TB_PRICEDC_List( V_TB_PRICE p_entity, Action<ResultObject<IQueryable<V_TB_PRICE>>> p_action)
{
ResultObject<IQueryable<V_TB_PRICE>> _ret = new ResultObject<IQueryable<V_TB_PRICE>>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
IQueryable<V_TB_PRICE> q = db.V_TB_PRICE;
if (p_entity.UIDList != null && p_entity.UIDList.Count > 0)
{
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
}
_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_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_TB_PRICE_CONTROLLER), "Get_TB_PRICE_List", e.Message);
throw e;
}
}
public static void Get_TB_PRICE_TemporaryPrice_CQ_List(bool p_flag, V_TB_PRICE_TemporaryPrice p_entity, Action<ResultObject<IQueryable<V_TB_PRICE_TemporaryPrice>>> p_action)
{
ResultObject<IQueryable<V_TB_PRICE_TemporaryPrice>> _ret = new ResultObject<IQueryable<V_TB_PRICE_TemporaryPrice>>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
IQueryable<V_TB_PRICE_TemporaryPrice> q = db.V_TB_PRICE_TemporaryPrice;
if (p_flag)
{
q = q.Where(p => p.Amt == 0);
}
if (p_entity.UID != 0)
{
q = q.Where(p => p.UID == p_entity.UID);
@ -278,7 +496,6 @@ namespace CK.SCP.Controller
}
}
public static ResultObject<bool> Save_TB_PRICE(List<TB_PRICE> p_entitys,PriceState p_state)
{
ResultObject<bool> _ret = new ResultObject<bool>();
@ -394,7 +611,7 @@ namespace CK.SCP.Controller
_entity.TemporaryPrice = itm.TemporaryPrice;
_entity.Creator = itm.Creator;
_entity.EndTime = itm.EndTime;
_entity.StartTime = DateTime.Now;
_entity.StartTime = itm.StartTime;
//_entity.UpdateTime = itm.UpdateTime;
//_entity.UpdateUser = itm.UpdateUser;
//_entity.UpdateInfo = itm.UpdateInfo;
@ -489,6 +706,102 @@ namespace CK.SCP.Controller
}
return p_entitys;
}
public static ResultObject<bool> Save_TB_PRICE_TemporaryPrice(List<long> p_list, string p_user)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.TB_PRICE.Where(p => p_list.Contains(p.UID)).ToList();
_ls.ForEach(p =>
{
p.TemporaryPrice=0;
}
);
db.TB_PRICE.AddOrUpdate(p => p.UID, _ls.ToArray());
if (_ret.MessageList.Count == 0)
{
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_FORECAST_CONTROLLER), "Save_TB_FORECAST_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_FORECAST_CONTROLLER), "Save_TB_FORECAST_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_FORECAST_CONTROLLER), "Save_TB_FORECAST_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_FORECAST_CONTROLLER), "Save_TB_FORECAST_STATE", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
public static ResultObject<bool> Save_TB_PRICE_STATE(List<long> p_list, string p_user, int State)
{
ResultObject<bool> _ret = new ResultObject<bool>();

16
北京北汽/Controller/SCP_TB_VENDER_CONTROLLER.cs

@ -30,6 +30,22 @@ namespace CK.SCP.Controller
return db.TA_VENDER.ToList();
}
}
public static TB_FACTORY GetFactory(string site)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TB_FACTORY.Where(p=>p.ErpSite== site).FirstOrDefault();
}
}
public static List<TA_VENDER> Getlist1(string site)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.Where(p=>p.Site== site).ToList();
}
}
public static List<TA_VENDER> Getlist(List<string> lsVenderID )
{

4
北京北汽/Controller/app.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@ -36,4 +36,4 @@
</setting>
</WebSrvAPITest.Properties.Settings>
</applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
</configuration>

4
北京北汽/Models/App.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
@ -25,4 +25,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
</configuration>

3
北京北汽/Models/CK.SCP.Models.csproj

@ -11,7 +11,6 @@
<AssemblyName>CK.SCP.Models</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -348,6 +347,7 @@
<Compile Include="ScpEntity\ExcelExportEnttity\SCP_VENDER_PART_EXPORT.cs" />
<Compile Include="ScpEntity\ExcelImportEntity\SCP_ASN_EXCEL.cs" />
<Compile Include="ScpEntity\ExcelImportEntity\SCP_PRICE_EXCEL.cs" />
<Compile Include="ScpEntity\TA_LOGINNUMBER.cs" />
<Compile Include="ScpEntity\TA_MoldSharing.cs" />
<Compile Include="ScpEntity\TA_MOLDSHARING_INVOICE.cs" />
<Compile Include="ScpEntity\TB_ADDRESS.cs" />
@ -444,6 +444,7 @@
<Compile Include="ScpEntity\V_TB_PO_DETAIL_CQ.cs" />
<Compile Include="ScpEntity\V_TB_PRICE_DETAIL.cs" />
<Compile Include="ScpEntity\V_TB_PRICE.cs" />
<Compile Include="ScpEntity\V_TB_PRICE_TemporaryPrice.cs" />
<Compile Include="ScpEntity\V_TB_RETURN.cs" />
<Compile Include="ScpEntity\V_TB_QUALITY.cs" />
<Compile Include="ScpEntity\V_TB_RECEIVE.cs" />

10
北京北汽/Models/Enums/SCP_ENUM.cs.cs

@ -194,10 +194,18 @@ namespace CK.SCP.Models.Enums
FinanceReceive = 5,
[Description("财务退回")]
FinanceFail = 6,
[Description("财务手工收票")]
CustomReceive = 8,
[Description("发票作废")]
Reject = -1,
}
public enum LoginNumer
{
[Description("成功登录")]
Sussess = 0,
[Description("登录失败")]
Faile = 1,
}
public enum ConfigState
{

2
北京北汽/Models/ScpEntities.cs

@ -88,6 +88,7 @@ namespace CK.SCP.Models
public virtual DbSet<V_TB_ASN> V_TB_ASN { get; set; }
public virtual DbSet<V_TB_ASN_DETAIL> V_TB_ASN_DETAIL { get; set; }
public virtual DbSet<TA_LANGUAGE> TA_LANGUAGE { get; set; }
public virtual DbSet<TA_LOGINNUMBER> TA_LOGINNUMBER { get; set; }
public virtual DbSet<TB_CONTRACT> TB_CONTRACT { get; set; }
public virtual DbSet<TB_CONTRACT_DETAIL> TB_CONTRACT_DETAIL { get; set; }
public virtual DbSet<TB_CONTRACT_DETAIL_PRICE> TB_CONTRACT_DETAIL_PRICE { get; set; }
@ -127,6 +128,7 @@ namespace CK.SCP.Models
public virtual DbSet<V_TA_VEND_PART> V_TA_VEND_PART { get; set; }
public virtual DbSet<TB_PRICE> TB_PRICE { get; set; }
public virtual DbSet<V_TB_PRICE> V_TB_PRICE { get; set; }
public virtual DbSet<V_TB_PRICE_TemporaryPrice> V_TB_PRICE_TemporaryPrice { get; set; }
public virtual DbSet<TB_FORECAST> TB_FORECAST { get; set; }
public virtual DbSet<V_TB_PRICE_DETAIL> V_TB_PRICE_DETAIL { get; set; }

3
北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs

@ -19,7 +19,8 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity
public string { get; set; } //"Price"
public string {get;set;} //"AskQty"
public string { get; set; } //"ReMark"
public string { get; set; }
public string { get; set; }
}
}

5
北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs

@ -21,7 +21,8 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity
public string 退 { get; set; } //RejectQty"
public string { get; set; } //EndTime"
public string {get;set; } //PoUnit"
public string { get; set; }
public string { get; set; }
}
public class SCP_PO_DETAIL_EXPORT_MODEL
@ -46,7 +47,7 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity
public string { get; set; }
public string { get; set; }

2
北京北汽/Models/ScpEntity/ExcelExportEnttity/SCP_VENDER_EXPORT.cs

@ -25,5 +25,7 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
}
}

12
北京北汽/Models/ScpEntity/SCP_OTD_EXPORT.cs

@ -6,6 +6,18 @@ using System.Threading.Tasks;
namespace CK.SCP.Models.ScpEntity
{
public class InvoiceCreateQueryParm
{
public string ReceiveID { set; get; }
public string VendId { set; get; }
public string Modify { set; get; }
public string IsAll { set; get; }
public string Tax { set; get; }
public string CJ { set; get; }
public string TZ { set; get; }
}
public class SCP_OTD_EXPORT
{
public string VendId { get; set; } //供应商编号

23
北京北汽/Models/ScpEntity/TA_LOGINNUMBER.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Models.ScpEntity
{
public partial class TA_LOGINNUMBER
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long UID { get; set; }
[Key]
public string Name { get; set; }
public string Time { get; set; }
public int Number { get; set; }
}
}

9
北京北汽/Models/ScpEntity/V_TB_PRICE.cs

@ -57,6 +57,15 @@ namespace CK.SCP.Models.ScpEntity
public List<string> UserInVendIds { set; get; }
[NotMapped]
public List<string> UserInSubSite { set; get; }
[NotMapped]
public List<long> UIDList { set; get; }
public string Flag { get; set; }
[NotMapped]
public string NewStartTime { get; set; }
[NotMapped]
public string NewEndTime { get; set; }
[NotMapped]
public string NewPrice { get; set; }
}
}

62
北京北汽/Models/ScpEntity/V_TB_PRICE_TemporaryPrice.cs

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ChangKeTec.Wms.Models;
namespace CK.SCP.Models.ScpEntity
{
public partial class V_TB_PRICE_TemporaryPrice
{
[Key]
public int UID { get; set; }
public string VendId { get; set; }
public string Site { get; set; }
public string SubSite { get; set; }
public string PartCode { get; set; }
public Nullable<System.DateTime> StartTime { get; set; }
public Nullable<System.DateTime> EndTime { get; set; }
public string Curr { get; set; }
public string Unit { get; set; }
[DecimalPrecision(18, 5)]
public decimal Amt { get; set; }
public string Remarks { get; set; }
/// <summary>
/// 状态(已用)
/// </summary>
public string Extend1 { get; set; }
/// <summary>
/// 是否是临时价格(0:否 1:是)
/// </summary>
public string Extend2 { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
public string Extend3 { get; set; }
[DecimalPrecision(18, 5)]
public decimal SharingPrice { get; set; }
public int TemporaryPrice { get; set; }
public string PartName { get; set; }
/// <summary>
/// 状态
/// </summary>
public int State { get; set; }
/// <summary>
/// 是否传接口 1是
/// </summary>
public int IsPost { get; set; }
public string Creator { get; set; }
[NotMapped]
public List<string> UserInAddress { set; get; }
[NotMapped]
public List<string> UserInVendIds { set; get; }
[NotMapped]
public List<string> UserInSubSite { set; get; }
public string Flag { get; set; }
}
}

10
北京北汽/Models/WmsEntity/TableSchema1.cs

@ -1 +1,9 @@

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码已从模板生成。
//
// 手动更改此文件可能导致应用程序出现意外的行为。
// 如果重新生成代码,将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------

4
北京北汽/SCP/Business/PageBase.cs

@ -613,6 +613,10 @@ namespace SCP
_currentUser.VenderList = _userVerders;
_currentUser.ConfigList = new Dictionary<string, string>();
if (_currentUser.FactoryList.Count > 0)
{
_currentUser.UsedDomain = string.IsNullOrEmpty(_currentUser.Remark) ? _currentUser.FactoryList.FirstOrDefault() : _currentUser.Remark.Trim();
}
if (_currentUser.FactoryList.Count > 0)
{
if (SCPDB.TA_FACTORY_CONFIG != null)
{

43
北京北汽/SCP/CK.SCP.Controller/ASNController.cs

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class ASNController
{
public static TF_ASN GetDetaillistByuid(int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN.SingleOrDefault(p => p.UID == uid);
}
}
public static TF_ASN GetASNlist(string billnum, string vendid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN.SingleOrDefault(p => p.PoBillNum == billnum && p.VendId == vendid);
}
}
public static TF_ASN_DETAIL GetASNlistDetail(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN_DETAIL.SingleOrDefault(p => p.PoBillNum == billnum);
}
}
public static TF_ASN_DETAIL GetASNlistDetailByLine(string billnum, int linenum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN_DETAIL.SingleOrDefault(p => p.BillNum == billnum && p.PoLineNum == linenum);
}
}
}
}

114
北京北汽/SCP/CK.SCP.Controller/BaseDocContoller.cs

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Core.Common.CommandTrees;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;
using System.Linq.Expressions;
using CK.SCP.Models;
namespace CK.SCP.Controller
{
public static class EntitiesHelper
{
public static List<dynamic> GetModeList_genaral<T, TKey>(Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, out int count)
where T : class
{
List<dynamic> list = null;
count = 0;
using (DbContext db = EntitiesFactory.CreateScpInstance())
{
count = db.Set<T>().Where(where).Count();
list =
db.Set<T>()
.Where(where)
.OrderBy(order)
.Select(select).ToList();
}
return list;
}
public static List<dynamic> GetPagedModelListAsc<T, TKey>(Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
List<dynamic> list = null;
total = 0;
using (DbContext db = EntitiesFactory.CreateScpInstance())
{
total = db.Set<T>().Where(where).Count();
list =
db.Set<T>()
.Where(where)
.OrderBy(order)
.Select(select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
}
return list;
}
public static List<T> GetPagedDataAsc<T, TKey>(Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
List<T> list = null;
total = 0;
using (DbContext db = EntitiesFactory.CreateScpInstance())
{
total = db.Set<T>().Where(where.Compile()).AsQueryable().Count();
list =
db.Set<T>()
.Where(where.Compile()).AsQueryable()
.OrderBy(order)
.Select(select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
}
return list;
}
//TODO 分页 原来 pageIndex-1
public static List<dynamic> GetPagedDataDesc<T, TKey>(DbContext db, Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
List<dynamic> list = null;
total = 0;
total = db.Set<T>().Where(where).Count();
list =
db.Set<T>()
.Where(where)
.OrderByDescending(order)
.Select(select)
.Skip((pageIndex) * pageSize)
.Take(pageSize).ToList();
return list;
}
public static List<T> GetPagedList<T, TKey>(DbContext db, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
List<T> list = null;
total = 0;
total = db.Set<T>().Count();
list =
db.Set<T>()
.OrderByDescending(order)
.Skip((pageIndex) * pageSize)
.Take(pageSize).ToList();
return list;
}
}
}

99
北京北汽/SCP/CK.SCP.Controller/CK.SCP.Controller.csproj

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0C706E36-C79D-467C-91CA-DDF39BC43113}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CK.SCP.Controller</RootNamespace>
<AssemblyName>CK.SCP.Controller</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\DLL\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.Extensions">
<HintPath>..\packages\EntityFramework.Extensions.0.0.2\lib\net40\EntityFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ASNController.cs" />
<Compile Include="BaseDocContoller.cs" />
<Compile Include="Class1.cs" />
<Compile Include="InfoController.cs" />
<Compile Include="InvoiceController.cs" />
<Compile Include="InvoiceDetailController.cs" />
<Compile Include="OadOrderController.cs" />
<Compile Include="PartController.cs" />
<Compile Include="PlanMonthController.cs" />
<Compile Include="POController.cs" />
<Compile Include="PODetailController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PublicDataController.cs" />
<Compile Include="ReceiveController.cs" />
<Compile Include="ReceiveDetailController.cs" />
<Compile Include="ResultObject.cs" />
<Compile Include="ShipController.cs" />
<Compile Include="ShipDetailController.cs" />
<Compile Include="SupplierController.cs" />
<Compile Include="SupplierPartController.cs" />
<Compile Include="UniApiController.cs" />
<Compile Include="UserController.cs" />
<Compile Include="VEND_USERController.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CK.SCP.Models\CK.SCP.Models.csproj">
<Project>{dd7c0def-71e7-443f-b0b7-db2f5b12a506}</Project>
<Name>CK.SCP.Models</Name>
</ProjectReference>
<ProjectReference Include="..\Models\Models.csproj">
<Project>{74DCE5F2-A501-45F2-B4F9-494AA1867226}</Project>
<Name>Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

12
北京北汽/SCP/CK.SCP.Controller/Class1.cs

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Controller
{
public class Class1
{
}
}

59
北京北汽/SCP/CK.SCP.Controller/InfoController.cs

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class InfoController
{
public static bool SaveInfo(TA_Info model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TA_Info.AddOrUpdate(model);
db.SaveChanges();
}
return true;
}
public static bool UpdateInfo(TA_Info model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TA_Info.AddOrUpdate(p => p.ID, model);
db.SaveChanges();
}
return true;
}
public static TA_Info GetlistByBillNo(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_Info.SingleOrDefault(p => p.ID == id);
}
}
public static V_Info GetInfoByBillNo(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_Info.SingleOrDefault(p => p.ID == id);
}
}
public static void DeleteById(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var info = db.TA_Info.SingleOrDefault(p => p.ID == id);
if (info != null) db.TA_Info.Remove(info);
db.SaveChanges();
}
}
}
}

85
北京北汽/SCP/CK.SCP.Controller/InvoiceController.cs

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class InvoiceController
{
public static List<V_BillInvoice> GetDataByBillInvoice( string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoice.Where(p => p.BillNum == billnum).ToList();
}
}
public static V_BillInvoice GetDataByBillInvoiceDetailModel(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoice.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static bool UpdateData(int state, TB_INVOICE model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
model.State = state;
db.TB_INVOICE.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
public static bool UpdateDataRemark(string remark, TB_INVOICE model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
model.Remark = remark;
db.TB_INVOICE.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
public static bool UpdateDataReason(string remark, string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
TB_INVOICE model = new TB_INVOICE
{
Remark = remark,
BillNum = billnum
};
db.TB_INVOICE.AddOrUpdate(p => p.BillNum, model);
}
return true;
}
public static TB_INVOICE GetDataByBillInvoiceBillNum(string id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TB_INVOICE.SingleOrDefault(p => p.BillNum == id);
}
}
public static V_BillInvoice GetBillInvoiceByBillNum(string id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoice.SingleOrDefault(p => p.BillNum == id);
}
}
}
}

37
北京北汽/SCP/CK.SCP.Controller/InvoiceDetailController.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class InvoiceDetailController
{
public static List<V_BillInvoiceDetail> GetDataByBillInvoiceDetail(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoiceDetail.Where(p => p.BillNum == billnum).ToList();
}
}
public static V_BillInvoiceDetail GetDataByBillInvoiceDetailModel(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoiceDetail.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static V_BillInvoiceDetail GetDataByBillInvoiceDetailBillNum(string id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillInvoiceDetail.SingleOrDefault(p => p.BillNum == id);
}
}
}
}

33
北京北汽/SCP/CK.SCP.Controller/OadOrderController.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class OadOrderController
{
// public List<QadOrder> GetList()
// {
// using (ScpEntities db = EntitiesFactory.CreateScpInstance())
// {
// // db.TB_QadOrder.Where(p=>p.BillNo==db.)
// var query = db.TB_QadOrder.Join(db.TB_QadOrderDetail, a => a.BillNo, g => g.BillNo, (a, g) => new
// {
// a.BillNo,
// a.SupplierCode,
// a.StartDate,
// a.Address,
// a.ProductCode,
// a.Qty,
// }).ToList();
//// return query;
// // return db.V_BillInvoice.Where(p => p.BillNum == billnum).ToList();
//
// }
// }
}
}

115
北京北汽/SCP/CK.SCP.Controller/POController.cs

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Migrations;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class POController
{
public static List<V_POAll> Getlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.ToList();
}
}
public static bool UpdatePOState(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_PO.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
public static TF_PO GetlistByID(int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.UID == uid);
}
}
public static TF_PO GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static V_POAll GetPOAlllistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static void UpdateOrderByUID(int state, int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
TF_PO model = new TF_PO();
model.State = state;
model.UID = uid;
db.SaveChanges();
}
}
public static void UpdatePOOBybillno(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
model.State = (int)PlanState.Confirm;
db.TF_PO.AddOrUpdate(p => p.UID, model);
db.SaveChanges();
}
}
public static List<V_POAll> GetlistByBillNum(V_POAll model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.Where(p => p.BillNum == model.BillNum).ToList();
}
}
public static TF_PO GetASNlist(string billnum, string vendid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.BillNum == billnum && p.VendId == vendid);
}
}
public static TF_PO GetPOModel(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.UID == id);
}
}
public static List<TF_PO> GetASNlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.ToList();
}
}
public static void DeletePO(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_PO.Remove(model);
db.SaveChanges();
}
}
}
}

68
北京北汽/SCP/CK.SCP.Controller/PODetailController.cs

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class PODetailController
{
public static V_POAllDetail GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAllDetail.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static TA_VENDER GetlistBySupplierCode(string VendId)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.SingleOrDefault(p => p.VendId == VendId);
}
}
public static List<TF_PO_DETAIL> GetDetaillistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO_DETAIL.Where(p => p.BillNum == billnum).ToList();
}
}
public static TF_PO_DETAIL GetDetaillistByuid(int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO_DETAIL.SingleOrDefault(p => p.UID == uid);
}
}
public static List<TF_PO_DETAIL> GetDetaillistBybillnos(string billno)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO_DETAIL.Where(p => p.BillNum == billno).ToList();
}
}
public static void Delete(TF_PO_DETAIL model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_PO_DETAIL.Remove(model);
}
}
public static TF_PO_DETAIL GetDetaillistBybillidandline(string bill, int linenum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO_DETAIL.SingleOrDefault(p => p.BillNum == bill && p.ErpLineNum == linenum);
}
}
}
}

29
北京北汽/SCP/CK.SCP.Controller/PartController.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class PartController
{
public static List<TA_PART> Getlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_PART.ToList();
}
}
public static List<TA_PART> GetlistByPartCode(TA_PART model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_PART.Where(p=>p.PartCode==model.PartCode).ToList();
}
}
}
}

60
北京北汽/SCP/CK.SCP.Controller/PlanMonthController.cs

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class PlanMonthController
{
public static TB_PlanMonth GetPlanMonthById(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TB_PlanMonth.SingleOrDefault(p => p.ID == id);
}
}
public static bool UpdatePlanMonthById(TB_PlanMonth model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
model.IsSend = "是";
model.SendTime = DateTime.Now;
db.TB_PlanMonth.AddOrUpdate(model);
db.SaveChanges();
}
return true;
}
public static TA_VENDER GetVend()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.OrderByDescending(p => p.Email).SingleOrDefault(p => p.Email != null);
}
}
public static List<TA_VENDER> GetVendList()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.ToList();
}
}
public static bool SaveTbPlanMonth(TB_PlanMonth model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TB_PlanMonth.AddOrUpdate(model);
db.SaveChanges();
}
return true;
}
}
}

36
北京北汽/SCP/CK.SCP.Controller/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("CK.SCP.CK.SCP.Controller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CK.SCP.CK.SCP.Controller")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("0c706e36-c79d-467c-91ca-ddf39bc43113")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

54
北京北汽/SCP/CK.SCP.Controller/PublicDataController.cs

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class PublicDataController
{
public static TB_PublicData GetlistByBillNo(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TB_PublicData.SingleOrDefault(p => p.ID == id);
}
}
public static bool SaveInfo(TB_PublicData model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TB_PublicData.AddOrUpdate(model);
db.SaveChanges();
}
return true;
}
public static bool UpdateInfo(TB_PublicData model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TB_PublicData.AddOrUpdate(p => p.ID, model);
db.SaveChanges();
}
return true;
}
public static void DeleteById(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var info = db.TB_PublicData.SingleOrDefault(p => p.ID == id);
if (info != null) db.TB_PublicData.Remove(info);
db.SaveChanges();
}
}
}
}

22
北京北汽/SCP/CK.SCP.Controller/ReceiveController.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class ReceiveController
{
public static V_Receive GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_Receive.SingleOrDefault(p => p.BillNum == billnum);
}
}
}
}

33
北京北汽/SCP/CK.SCP.Controller/ReceiveDetailController.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class ReceiveDetailController
{
public static V_ReceiveDetail GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_ReceiveDetail.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static bool UpdateReceive(V_ReceiveDetail model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.V_ReceiveDetail.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
}
}

42
北京北汽/SCP/CK.SCP.Controller/ResultObject.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Controller
{
/// <summary>
///返回结果类
/// </summary>
/// <typeparam name="T"></typeparam>
public class ResultObject<T>
{
public ResultObject()
{
ErrorList = new List<Exception>();
}
/// <summary>
/// 返回结果
/// </summary>
public T Result { set; get; }
/// <summary>
/// 错误列表
/// </summary>
public List<Exception> ErrorList { set; get; }
/// <summary>
/// 返回状态
/// </summary>
public ReturnStatus State
{private set; get; }
}
public enum ReturnStatus
{
[Description("失败")]
Failed,
[Description("成功")]
Succeed
}
}

23
北京北汽/SCP/CK.SCP.Controller/ShipController.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
namespace CK.SCP.Controller
{
public class ShipController
{
public static void DeleteById(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var asn = db.TF_ASN.SingleOrDefault(p => p.UID == id);
if (asn != null) db.TF_ASN.Remove(asn);
db.SaveChanges();
}
}
}
}

57
北京北汽/SCP/CK.SCP.Controller/ShipDetailController.cs

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class ShipDetailController
{
public static V_BillShipDetail GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillShipDetail.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static V_BillShip GetBillShiplistByBillNo(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_BillShip.SingleOrDefault(p => p.Bill == billnum);
}
}
public static TF_ASN GetlistByBillNo(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static TF_ASN_DETAIL GetDeatillistByBillNo(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_ASN_DETAIL.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static bool UpdateShip(TF_ASN model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_ASN.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
}
}

32
北京北汽/SCP/CK.SCP.Controller/SupplierController.cs

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class SupplierController
{
public static List<TA_VENDER> GetlistByName(TA_VENDER model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.Where(p => p.VendName == model.VendName).ToList();
}
}
public static List<TA_VENDER> Getlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.ToList();
}
}
}
}

29
北京北汽/SCP/CK.SCP.Controller/SupplierPartController.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class SupplierPartController
{
// public static List<V_VenderPart> Getlist()
// {
// using (ScpEntities db = EntitiesFactory.CreateScpInstance())
// {
// return db.V_VenderPart.ToList();
// }
// }
// public static List<V_VenderPart> GetlistByPartCode(V_VenderPart model)
// {
// using (ScpEntities db = EntitiesFactory.CreateScpInstance())
// {
// return db.V_VenderPart.Where(p => p.PartCode == model.PartCode).ToList();
// }
// }
}
}

253
北京北汽/SCP/CK.SCP.Controller/UniApiController.cs

@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CK.SCP.Models;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Models.UniApiEntity;
namespace CK.SCP.Controller
{
public static class UniApiController
{
public static void RemoveList(ScpEntities db, List<TS_UNI_API> uniApiList)
{
db.TS_UNI_API.RemoveRange(uniApiList);
}
public static void AddHisList(ScpEntities db, List<TS_UNI_API_HIS> uniApiHisList)
{
db.TS_UNI_API_HIS.AddRange(uniApiHisList);
}
public static void AddApiData(ScpEntities wdb, TS_UNI_API apiData)
{
wdb.TS_UNI_API.Add(apiData);
}
public static void AddApiDataList(ScpEntities wdb, List<TS_UNI_API> apiDataList)
{
wdb.TS_UNI_API.AddRange(apiDataList);
}
public static WmsTableName GetTableName(UniApiType uniApiType)
{
WmsTableName tableName;
switch (uniApiType)
{
case UniApiType.PO:
tableName = WmsTableName.TS_UNI_API;//中间表的名字
break;
case UniApiType.Receive:
tableName = WmsTableName.TS_UNI_API;
break;
case UniApiType.BarCode:
tableName = WmsTableName.TS_UNI_API;
break;
case UniApiType.Invoice:
tableName = WmsTableName.TS_UNI_API;
break;
default:
throw new ArgumentOutOfRangeException(nameof(uniApiType), uniApiType, null);
}
return tableName;
}
//创建采购订单
public static TS_UNI_API CreateBy(TF_PO bill, TF_PO_DETAIL detail, UniApiType uniApiType)
{
var tableName = GetTableName(uniApiType);
var apiData = new TS_UNI_API
{
InterfaceType = uniApiType.ToString(),
TableName = tableName.ToString(),
BillNum = bill.BillNum,
PartCode = detail.PartCode,
Batch = "",
Qty = detail.BillQty,
PoUnit = detail.PoUnit,
LocUnit = detail.LocUnit,
State = detail.State,
CreateOper = bill.OperName,
CreateTime = bill.BillTime,
PutTime = ScpCache.GetServerTime(),
VendId = bill.VendId,
BillType = (int)BillType.PuchaseOrder,
SubBillType = 0,
ValidDate = detail.DueDate,
ErpBillNum = bill.ErpBillNum,
ErpLineNum = detail.ErpLineNum,
VendBatch = "",
SourceBillNum = "",
Price = detail.Price,
PackQty = detail.PackQty,
Currency = detail.Currency,
Attn = "",//TODO
Buyer = bill.Buyer,
BuyerPhone = bill.BuyerPhone,
ModType = bill.ModType,
Receiver = "",//TODO
UmConv = (decimal)detail.UmConv,
};
return apiData;
}
private static ScpEntities db = EntitiesFactory.CreateScpInstance();
public static TS_UNI_API CreateBy(TF_PO bill, List<TF_PO_DETAIL> detail, UniApiType uniApiType)
{
var tableName = GetTableName(uniApiType);
TS_UNI_API asp = new TS_UNI_API();
foreach (var item in detail)
{
asp.InterfaceType = uniApiType.ToString();
asp.TableName = tableName.ToString();
asp.BillNum = bill.BillNum;
asp.Batch = string.Empty;
asp.CreateOper = bill.OperName;
asp.CreateTime = bill.BillTime;
asp.PutTime = ScpCache.GetServerTime();
asp.VendId = bill.VendId;
asp.BillType = (int)BillType.PO;
asp.SubBillType = 0;
asp.VendBatch = string.Empty;
asp.SourceBillNum = string.Empty;
asp.Attn = "";//TODO
asp.Buyer = bill.Buyer;
asp.BuyerPhone = bill.BuyerPhone;
asp.ModType = bill.ModType;
asp.Receiver = "";//TODO
asp.PartCode = item.PartCode;
asp.Qty = item.BillQty;
asp.PoUnit = item.PoUnit;
asp.LocUnit = item.LocUnit;
asp.State = item.State;
asp.ValidDate = item.DueDate;
asp.ErpBillNum = bill.BillNum;//暂时跟billnum 一样 后期可能会改 预留
asp.ErpLineNum = item.ErpLineNum;
asp.Price = item.Price;
asp.PackQty = item.PackQty;
asp.Currency = item.Currency;
asp.UmConv = (decimal)item.UmConv;
db.TS_UNI_API.Add(asp);
db.SaveChanges();
}
return asp;
}
//创建发货单
public static TS_UNI_API CreateBy(TF_ASN bill, TF_ASN_DETAIL detail, UniApiType uniApiType)
{
var tableName = GetTableName(uniApiType);
var apiData = new TS_UNI_API
{
InterfaceType = uniApiType.ToString(),
TableName = tableName.ToString(),
BillNum = bill.BillNum,
PartCode = detail.PartCode,
Batch = detail.Batch,
Qty = detail.BillQty,
PoUnit = detail.PoUnit,
LocUnit = detail.LocUnit,
State = detail.State,
CreateOper = bill.OperName,
CreateTime = bill.BillTime,
PutTime = ScpCache.GetServerTime(),
VendId = bill.VendId,
BillType = (int)BillType.PuchaseOrder,
SubBillType = 0,
ValidDate = detail.ProduceDate,
ErpBillNum = bill.PoBillNum,
ErpLineNum = detail.PoLineNum,
VendBatch = detail.VendBatch,
Price = detail.Price,
PackQty = detail.PackQty,
Currency = detail.Currency,
UmConv = (decimal) detail.UmConv,
};
return apiData;
}
//创建条码
public static TS_UNI_API CreateBy(TF_ASN bill, TS_BARCODE detail, UniApiType uniApiType)
{
var tableName = GetTableName(uniApiType);
var apiData = new TS_UNI_API
{
Barcode = detail.BarCode,
InterfaceType = uniApiType.ToString(),
TableName = tableName.ToString(),
BillNum = bill.BillNum,
PartCode = detail.PartCode,
Batch = detail.Batch,
Qty = detail.Qty,
PoUnit = detail.PoUnit,
LocUnit = detail.LocUnit,
State = detail.State,
CreateOper = bill.OperName,
CreateTime = bill.BillTime,
PutTime = ScpCache.GetServerTime(),
VendId = bill.VendId,
BillType = (int)BillType.PuchaseOrder,
SubBillType = 0,
ValidDate = detail.ProduceDate,
ErpBillNum = bill.PoBillNum,
ErpLineNum = detail.PoBillLine,
VendBatch = detail.VendBatch,
SourceBillNum = detail.FullBarCode,
PackQty = detail.PackQty,
};
return apiData;
}
//创建发票
public static TS_UNI_API CreateBy(TB_INVOICE bill, TB_INVOICE_DETAIL detail, UniApiType uniApiType)
{
var tableName = GetTableName(uniApiType);
var apiData = new TS_UNI_API
{
InterfaceType = uniApiType.ToString(),
TableName = tableName.ToString(),
BillNum = bill.BillNum,
PartCode = detail.PartCode,
Batch = "",
Qty = detail.Qty,
PoUnit = detail.PoUnit,
LocUnit = detail.LocUnit,
State = detail.State,
CreateOper = bill.OperName,
CreateTime = bill.BillTime,
PutTime = ScpCache.GetServerTime(),
VendId = bill.VendId,
BillType = (int)BillType.PuchaseOrder,
SubBillType = 0,
ValidDate = detail.ProduceDate,
ErpBillNum = detail.PoBillNum,
ErpLineNum = detail.PoLineNum,
VendBatch = "",
SourceBillNum = "",
Price = detail.Price,
PackQty = detail.PackQty,
Currency = detail.Currency,
Invoice = bill.InvoiceNum,
Tax = detail.Tax,
TaxAmt = detail.TaxAmt,
};
return apiData;
}
public static List<TS_UNI_API> GetNewInterfaceList(ScpEntities wdb)
{
return wdb.TS_UNI_API.Where(p => p.State == (int)BillState.New).OrderBy(p => p.UID).ToList();
}
}
}

14
北京北汽/SCP/CK.SCP.Controller/UserController.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Controller
{
public class UserController
{
}
}

21
北京北汽/SCP/CK.SCP.Controller/VEND_USERController.cs

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class VEND_USERController
{
public static TA_VEND_USER GetVendUserModel(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VEND_USER.SingleOrDefault(p => p.UID == id);
}
}
}
}

25
北京北汽/SCP/CK.SCP.Controller/app.config

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

5
北京北汽/SCP/CK.SCP.Controller/packages.config

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
</packages>

6
北京北汽/SCP/CK.SCP.DCUNI/App.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

87
北京北汽/SCP/CK.SCP.DCUNI/CK.SCP.DCUNI.csproj

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1EE718E2-C8BA-4DD5-80EC-A1DE0449A58D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CK.SCP.DCUNI</RootNamespace>
<AssemblyName>CK.SCP.DCUNI</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

39
北京北汽/SCP/CK.SCP.DCUNI/Form1.Designer.cs

@ -0,0 +1,39 @@
namespace CK.SCP.DCUNI
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
}
#endregion
}
}

20
北京北汽/SCP/CK.SCP.DCUNI/Form1.cs

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CK.SCP.DCUNI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

22
北京北汽/SCP/CK.SCP.DCUNI/Program.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CK.SCP.DCUNI
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

36
北京北汽/SCP/CK.SCP.DCUNI/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("CK.SCP.DCUNI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CK.SCP.DCUNI")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("1ee718e2-c8ba-4dd5-80ec-a1de0449a58d")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
北京北汽/SCP/CK.SCP.DCUNI/Properties/Resources.Designer.cs

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace CK.SCP.DCUNI.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CK.SCP.DCUNI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

117
北京北汽/SCP/CK.SCP.DCUNI/Properties/Resources.resx

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
北京北汽/SCP/CK.SCP.DCUNI/Properties/Settings.Designer.cs

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CK.SCP.DCUNI.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

7
北京北汽/SCP/CK.SCP.DCUNI/Properties/Settings.settings

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

20
北京北汽/SCP/CK.SCP.Models/App.config

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="ScpEntities" connectionString="data source=127.0.0.1;initial catalog=ChangKeTecSCP;persist security info=True;user id=sa;password=Microsoft2008;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

94
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/AppBoxContext.cs

@ -0,0 +1,94 @@
using System.Data.Entity;
namespace CK.SCP.Models.AppBoxEntity
{
public class AppBoxContext : DbContext
{
public AppBoxContext() : base(EntitiesFactory.GetEfConnectionString(GlobalConfig.AppBoxDatabase))
{
}
public AppBoxContext(string strConn) : base(strConn)
{
}
public DbSet<Config> Configs { get; set; }
public DbSet<Dept> Depts { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<Title> Titles { get; set; }
public DbSet<Online> Onlines { get; set; }
public DbSet<Log> Logs { get; set; }
public DbSet<Power> Powers { get; set; }
public DbSet<Menu> Menus { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Role>()
.HasMany(r => r.Users)
.WithMany(u => u.Roles)
.Map(x => x.ToTable("RoleUsers")
.MapLeftKey("RoleID")
.MapRightKey("UserID"));
modelBuilder.Entity<Title>()
.HasMany(t => t.Users)
.WithMany(u => u.Titles)
.Map(x => x.ToTable("TitleUsers")
.MapLeftKey("TitleID")
.MapRightKey("UserID"));
modelBuilder.Entity<Dept>()
.HasOptional(d => d.Parent)
.WithMany(d => d.Children)
.Map(x => x.MapKey("ParentID"));
modelBuilder.Entity<Dept>()
.HasMany(d => d.Users)
.WithOptional(u => u.Dept)
.Map(x => x.MapKey("DeptID"));
modelBuilder.Entity<Online>()
.HasRequired(o => o.User)
.WithMany()
.Map(x => x.MapKey("UserID"));
modelBuilder.Entity<Menu>()
.HasOptional(m => m.Parent)
.WithMany(m => m.Children)
.Map(x => x.MapKey("ParentID"));
//modelBuilder.Entity<Menu>()
// .HasOptional(m => m.Module)
// .WithMany()
// .Map(x => x.MapKey("ModuleID"));
//modelBuilder.Entity<Module>()
// .HasMany(m => m.ModulePowers)
// .WithRequired(mp => mp.Module);
//modelBuilder.Entity<Power>()
// .HasMany(p => p.ModulePowers)
// .WithRequired(mp => mp.Power);
modelBuilder.Entity<Menu>()
.HasOptional(m => m.ViewPower)
.WithMany()
.Map(x => x.MapKey("ViewPowerID"));
modelBuilder.Entity<Role>()
.HasMany(r => r.Powers)
.WithMany(p => p.Roles)
.Map(x => x.ToTable("RolePowers")
.MapLeftKey("RoleID")
.MapRightKey("PowerID"));
}
}
}

686
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/AppBoxDatabaseInitializer.cs

@ -0,0 +1,686 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
namespace CK.SCP.Models.AppBoxEntity
{
public class AppBoxDatabaseInitializer : DropCreateDatabaseIfModelChanges<AppBoxContext> // DropCreateDatabaseAlways<AppBoxContext> DropCreateDatabaseIfModelChanges<AppBoxContext>
{
protected override void Seed(AppBoxContext context)
{
GetConfigs().ForEach(c => context.Configs.Add(c));
GetDepts().ForEach(d => context.Depts.Add(d));
GetUsers().ForEach(u => context.Users.Add(u));
GetRoles().ForEach(r => context.Roles.Add(r));
GetPowers().ForEach(p => context.Powers.Add(p));
GetTitles().ForEach(t => context.Titles.Add(t));
context.SaveChanges();
// 添加菜单时需要指定ViewPower,所以上面需要先保存到数据库
GetMenus(context).ForEach(m => context.Menus.Add(m));
}
private static List<Menu> GetMenus(AppBoxContext context)
{
var menus = new List<Menu> {
new Menu
{
Name = "系统管理",
SortIndex = 1,
Remark = "顶级菜单",
Children = new List<Menu> {
new Menu
{
Name = "用户管理",
SortIndex = 10,
Remark = "二级菜单",
NavigateUrl = "~/admin/user.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreUserView").FirstOrDefault<Power>()
},
new Menu
{
Name = "职称管理",
SortIndex = 20,
Remark = "二级菜单",
NavigateUrl = "~/admin/title.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreTitleView").FirstOrDefault<Power>()
},
new Menu
{
Name = "职称用户管理",
SortIndex = 30,
Remark = "二级菜单",
NavigateUrl = "~/admin/title_user.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreTitleUserView").FirstOrDefault<Power>()
},
new Menu
{
Name = "部门管理",
SortIndex = 40,
Remark = "二级菜单",
NavigateUrl = "~/admin/dept.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreDeptView").FirstOrDefault<Power>()
},
new Menu
{
Name = "部门用户管理",
SortIndex = 50,
Remark = "二级菜单",
NavigateUrl = "~/admin/dept_user.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreDeptUserView").FirstOrDefault<Power>()
},
new Menu
{
Name = "角色管理",
SortIndex = 60,
Remark = "二级菜单",
NavigateUrl = "~/admin/role.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreRoleView").FirstOrDefault<Power>()
},
new Menu
{
Name = "角色用户管理",
SortIndex = 70,
Remark = "二级菜单",
NavigateUrl = "~/admin/role_user.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreRoleUserView").FirstOrDefault<Power>()
},
new Menu
{
Name = "权限管理",
SortIndex = 80,
Remark = "二级菜单",
NavigateUrl = "~/admin/power.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CorePowerView").FirstOrDefault<Power>()
},
new Menu
{
Name = "角色权限管理",
SortIndex = 90,
Remark = "二级菜单",
NavigateUrl = "~/admin/role_power.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreRolePowerView").FirstOrDefault<Power>()
},
new Menu
{
Name = "菜单管理",
SortIndex = 100,
Remark = "二级菜单",
NavigateUrl = "~/admin/menu.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreMenuView").FirstOrDefault<Power>()
},
new Menu
{
Name = "在线统计",
SortIndex = 110,
Remark = "二级菜单",
NavigateUrl = "~/admin/online.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreOnlineView").FirstOrDefault<Power>()
},
new Menu
{
Name = "系统配置",
SortIndex = 120,
Remark = "二级菜单",
NavigateUrl = "~/admin/config.aspx",
ImageUrl = "~/res/icon/tag_blue.png",
ViewPower = context.Powers.Where(p => p.Name == "CoreConfigView").FirstOrDefault<Power>()
},
new Menu
{
Name = "用户设置",
SortIndex = 130,
Remark = "二级菜单",
NavigateUrl = "~/admin/profile.aspx",
ImageUrl = "~/res/icon/tag_blue.png"
}
}
}
};
return menus;
}
private static List<Title> GetTitles()
{
var titles = new List<Title>()
{
new Title()
{
Name = "总经理"
},
new Title()
{
Name = "部门经理"
},
new Title()
{
Name = "高级工程师"
},
new Title()
{
Name = "工程师"
}
};
return titles;
}
private static List<Power> GetPowers()
{
var powers = new List<Power>
{
new Power
{
Name = "CoreUserView",
Title = "浏览用户列表",
GroupName = "CoreUser"
},
new Power
{
Name = "CoreUserNew",
Title = "新增用户",
GroupName = "CoreUser"
},
new Power
{
Name = "CoreUserEdit",
Title = "编辑用户",
GroupName = "CoreUser"
},
new Power
{
Name = "CoreUserDelete",
Title = "删除用户",
GroupName = "CoreUser"
},
new Power
{
Name = "CoreUserChangePassword",
Title = "修改用户登陆密码",
GroupName = "CoreUser"
},
new Power
{
Name = "CoreRoleView",
Title = "浏览角色列表",
GroupName = "CoreRole"
},
new Power
{
Name = "CoreRoleNew",
Title = "新增角色",
GroupName = "CoreRole"
},
new Power
{
Name = "CoreRoleEdit",
Title = "编辑角色",
GroupName = "CoreRole"
},
new Power
{
Name = "CoreRoleDelete",
Title = "删除角色",
GroupName = "CoreRole"
},
new Power
{
Name = "CoreRoleUserView",
Title = "浏览角色用户列表",
GroupName = "CoreRoleUser"
},
new Power
{
Name = "CoreRoleUserNew",
Title = "向角色添加用户",
GroupName = "CoreRoleUser"
},
new Power
{
Name = "CoreRoleUserDelete",
Title = "从角色中删除用户",
GroupName = "CoreRoleUser"
},
new Power
{
Name = "CoreOnlineView",
Title = "浏览在线用户列表",
GroupName = "CoreOnline"
},
new Power
{
Name = "CoreConfigView",
Title = "浏览全局配置参数",
GroupName = "CoreConfig"
},
new Power
{
Name = "CoreConfigEdit",
Title = "修改全局配置参数",
GroupName = "CoreConfig"
},
new Power
{
Name = "CoreMenuView",
Title = "浏览菜单列表",
GroupName = "CoreMenu"
},
new Power
{
Name = "CoreMenuNew",
Title = "新增菜单",
GroupName = "CoreMenu"
},
new Power
{
Name = "CoreMenuEdit",
Title = "编辑菜单",
GroupName = "CoreMenu"
},
new Power
{
Name = "CoreMenuDelete",
Title = "删除菜单",
GroupName = "CoreMenu"
},
new Power
{
Name = "CoreLogView",
Title = "浏览日志列表",
GroupName = "CoreLog"
},
new Power
{
Name = "CoreLogDelete",
Title = "删除日志",
GroupName = "CoreLog"
},
new Power
{
Name = "CoreTitleView",
Title = "浏览职务列表",
GroupName = "CoreTitle"
},
new Power
{
Name = "CoreTitleNew",
Title = "新增职务",
GroupName = "CoreTitle"
},
new Power
{
Name = "CoreTitleEdit",
Title = "编辑职务",
GroupName = "CoreTitle"
},
new Power
{
Name = "CoreTitleDelete",
Title = "删除职务",
GroupName = "CoreTitle"
},
new Power
{
Name = "CoreTitleUserView",
Title = "浏览职务用户列表",
GroupName = "CoreTitleUser"
},
new Power
{
Name = "CoreTitleUserNew",
Title = "向职务添加用户",
GroupName = "CoreTitleUser"
},
new Power
{
Name = "CoreTitleUserDelete",
Title = "从职务中删除用户",
GroupName = "CoreTitleUser"
},
new Power
{
Name = "CoreDeptView",
Title = "浏览部门列表",
GroupName = "CoreDept"
},
new Power
{
Name = "CoreDeptNew",
Title = "新增部门",
GroupName = "CoreDept"
},
new Power
{
Name = "CoreDeptEdit",
Title = "编辑部门",
GroupName = "CoreDept"
},
new Power
{
Name = "CoreDeptDelete",
Title = "删除部门",
GroupName = "CoreDept"
},
new Power
{
Name = "CoreDeptUserView",
Title = "浏览部门用户列表",
GroupName = "CoreDeptUser"
},
new Power
{
Name = "CoreDeptUserNew",
Title = "向部门添加用户",
GroupName = "CoreDeptUser"
},
new Power
{
Name = "CoreDeptUserDelete",
Title = "从部门中删除用户",
GroupName = "CoreDeptUser"
},
new Power
{
Name = "CorePowerView",
Title = "浏览权限列表",
GroupName = "CorePower"
},
new Power
{
Name = "CorePowerNew",
Title = "新增权限",
GroupName = "CorePower"
},
new Power
{
Name = "CorePowerEdit",
Title = "编辑权限",
GroupName = "CorePower"
},
new Power
{
Name = "CorePowerDelete",
Title = "删除权限",
GroupName = "CorePower"
},
new Power
{
Name = "CoreRolePowerView",
Title = "浏览角色权限列表",
GroupName = "CoreRolePower"
},
new Power
{
Name = "CoreRolePowerEdit",
Title = "编辑角色权限",
GroupName = "CoreRolePower"
}
};
return powers;
}
private static List<Role> GetRoles()
{
var roles = new List<Role>()
{
new Role()
{
Name = "系统管理员",
Remark = ""
},
new Role()
{
Name = "部门管理员",
Remark = ""
},
new Role()
{
Name = "项目经理",
Remark = ""
},
new Role()
{
Name = "开发经理",
Remark = ""
},
new Role()
{
Name = "开发人员",
Remark = ""
},
new Role()
{
Name = "后勤人员",
Remark = ""
},
new Role()
{
Name = "外包人员",
Remark = ""
}
};
return roles;
}
private static List<User> GetUsers()
{
string[] USER_NAMES = { "男", "童光喜", "男", "方原柏", "女", "祝春亚", "男", "涂辉", "男", "舒兆国", "男", "熊忠文", "男", "徐吉琳", "男", "方金海", "男", "包卫峰", "女", "靖小燕", "男", "杨习斌", "男", "徐长旺", "男", "聂建雄", "男", "周敦友", "男", "陈友庭", "女", "陆静芳", "男", "袁国柱", "女", "骆新桂", "男", "许治国", "男", "马先加", "男", "赵恢川", "男", "柯常胜", "男", "黄国鹏", "男", "柯尊北", "男", "刘海云", "男", "罗清波", "男", "张业权", "女", "丁溯鋆", "男", "吴俊", "男", "郑江", "男", "李亚华", "男", "石光富", "男", "谭志洪", "男", "胡中生", "男", "董龙剑", "男", "陈红", "男", "汪海平", "男", "彭道洲", "女", "尹莉君", "男", "占耀玲", "男", "付杰", "男", "王红艳", "男", "邝兴", "男", "饶玮", "男", "王方胜", "男", "陈劲松", "男", "邓庆华", "男", "王石林", "男", "胡俊明", "男", "索相龙", "男", "陈海军", "男", "吴文涛", "女", "熊望梅", "女", "段丽华", "女", "胡莎莎", "男", "徐友安", "男", "肖诗涛", "男", "王闯", "男", "余兴龙", "男", "芦荫杰", "男", "丁金富", "男", "谭军令", "女", "鄢旭燕", "男", "田坤", "男", "夏德胜", "男", "喻显发", "男", "马兴宝", "男", "孙学涛", "男", "陶云成", "男", "马远健", "男", "田华", "男", "聂子森", "男", "郑永军", "男", "余昌平", "男", "陶俊华", "男", "李小林", "男", "李荣宝", "男", "梅盈凯", "男", "张元群", "男", "郝新华", "男", "刘红涛", "男", "向志强", "男", "伍小峰", "男", "胡勇民", "男", "黄定祥", "女", "高红香", "男", "刘军", "男", "叶松", "男", "易俊林", "男", "张威", "男", "刘卫华", "男", "李浩", "男", "李寿庚", "男", "涂洋", "男", "曹晶", "男", "陈辉", "女", "彭博", "男", "严雪冰", "男", "刘青", "女", "印媛", "男", "吴道雄", "男", "邓旻", "男", "陈骏", "男", "崔波", "男", "韩静颐", "男", "严安勇", "男", "刘攀", "女", "刘艳", "女", "孙昕", "女", "郑新", "女", "徐睿", "女", "李月杰", "男", "吕焱鑫", "女", "刘沈", "男", "朱绍军", "女", "马茜", "女", "唐蕾", "女", "刘姣", "女", "于芳", "男", "吴健", "女", "张丹梅", "女", "王燕", "女", "贾兆梅", "男", "程柏漠", "男", "程辉", "女", "任明慧", "女", "焦莹", "女", "马淑娟", "男", "徐涛", "男", "孙庆国", "男", "刘胜", "女", "傅广凤", "男", "袁弘", "男", "高令旭", "男", "栾树权", "女", "申霞", "女", "韩文萍", "女", "隋艳", "男", "邢海洲", "女", "王宁", "女", "陈晶", "女", "吕翠", "女", "刘少敏", "女", "刘少君", "男", "孔鹏", "女", "张冰", "女", "王芳", "男", "万世忠", "女", "徐凡", "女", "张玉梅", "女", "何莉", "女", "时会云", "女", "王玉杰", "女", "谭素英", "女", "李艳红", "女", "刘素莉", "男", "王旭海", "女", "安丽梅", "女", "姚露", "女", "贾颖", "女", "曹微", "男", "黄经华", "女", "陈玉华", "女", "姜媛", "女", "魏立平", "女", "张萍", "男", "来辉", "女", "陈秀玫", "男", "石岩", "男", "王洪捍", "男", "张树军", "女", "李亚琴", "女", "王凤", "女", "王珊华", "女", "杨丹丹", "女", "教黎明", "女", "修晶", "女", "丁晓霞", "女", "张丽", "女", "郭素兰", "女", "徐艳丽", "女", "任子英", "女", "胡雁", "女", "彭洪亮", "女", "高玉珍", "女", "王玉姝", "男", "郑伟", "女", "姜春玲", "女", "张伟", "女", "王颖", "女", "金萍", "男", "孙望", "男", "闫宝东", "男", "周相永", "女", "杨美娜", "女", "欧立新", "女", "刘宝霞", "女", "刘艳杰", "女", "宋艳平", "男", "李克", "女", "梁翠", "女", "宗宏伟", "女", "刘国伟", "女", "敖志敏", "女", "尹玲" };
string[] EMAIL_NAMES = { "qq.com", "gmail.com", "163.com", "126.com", "outlook.com", "foxmail.com" };
var users = new List<User>();
var rdm = new Random();
for (int i = 0, count = USER_NAMES.Length; i < count; i += 2)
{
string gender = USER_NAMES[i];
string chineseName = USER_NAMES[i + 1];
string userName = "user" + i.ToString();
users.Add(new User
{
Name = userName,
Gender = gender,
Password = PasswordUtil.CreateDbPassword(userName),
ChineseName = chineseName,
Email = userName + "@" + EMAIL_NAMES[rdm.Next(0, EMAIL_NAMES.Length)],
Enabled = true,
CreateTime = DateTime.Now
});
}
// 添加超级管理员
users.Add(new User
{
Name = "admin",
Gender = "男",
Password = PasswordUtil.CreateDbPassword("admin"),
ChineseName = "超级管理员",
Email = "admin@examples.com",
Enabled = true,
CreateTime = DateTime.Now
});
return users;
}
private static List<Dept> GetDepts()
{
var depts = new List<Dept> {
new Dept
{
Name = "研发部",
SortIndex = 1,
Remark = "顶级部门",
Children = new List<Dept> {
new Dept
{
Name = "开发部",
SortIndex = 1,
Remark = "二级部门"
},
new Dept
{
Name = "测试部",
SortIndex = 2,
Remark = "二级部门"
}
}
},
new Dept
{
Name = "销售部",
SortIndex = 2,
Remark = "顶级部门",
Children = new List<Dept> {
new Dept
{
Name = "直销部",
SortIndex = 1,
Remark = "二级部门"
},
new Dept
{
Name = "渠道部",
SortIndex = 2,
Remark = "二级部门"
}
}
},
new Dept
{
Name = "客服部",
SortIndex = 3,
Remark = "顶级部门",
Children = new List<Dept> {
new Dept
{
Name = "实施部",
SortIndex = 1,
Remark = "二级部门"
},
new Dept
{
Name = "售后服务部",
SortIndex = 2,
Remark = "二级部门"
},
new Dept
{
Name = "大客户服务部",
SortIndex = 3,
Remark = "二级部门"
}
}
},
new Dept
{
Name = "财务部",
SortIndex = 4,
Remark = "顶级部门"
},
new Dept
{
Name = "行政部",
SortIndex = 5,
Remark = "顶级部门",
Children = new List<Dept> {
new Dept
{
Name = "人事部",
SortIndex = 1,
Remark = "二级部门"
},
new Dept
{
Name = "后勤部",
SortIndex = 2,
Remark = "二级部门"
},
new Dept
{
Name = "运输部",
SortIndex = 3,
Remark = "二级部门",
Children = new List<Dept>{
new Dept{
Name = "省内运输部",
SortIndex = 1,
Remark = "三级部门",
},
new Dept{
Name = "国内运输部",
SortIndex = 2,
Remark = "三级部门",
},
new Dept{
Name = "国际运输部",
SortIndex = 3,
Remark = "三级部门",
}
}
}
}
}
};
return depts;
}
private static List<Config> GetConfigs()
{
var configs = new List<Config> {
new Config
{
ConfigKey = "Title",
ConfigValue = "AppBox - 通用权限管理框架",
Remark = "网站的标题"
},
new Config
{
ConfigKey = "PageSize",
ConfigValue = "20",
Remark = "表格每页显示的个数"
},
new Config
{
ConfigKey = "MenuType",
ConfigValue = "tree",
Remark = "左侧菜单样式"
},
new Config
{
ConfigKey = "Theme",
ConfigValue = "Neptune",
Remark = "网站主题"
},
new Config
{
ConfigKey = "HelpList",
ConfigValue = "[{\"Text\":\"万年历\",\"Icon\":\"Calendar\",\"ID\":\"wannianli\",\"URL\":\"~/admin/help/wannianli.htm\"},{\"Text\":\"科学计算器\",\"Icon\":\"Calculator\",\"ID\":\"jisuanqi\",\"URL\":\"~/admin/help/jisuanqi.htm\"},{\"Text\":\"系统帮助\",\"Icon\":\"Help\",\"ID\":\"help\",\"URL\":\"~/admin/help/help.htm\"}]",
Remark = "帮助下拉列表的JSON字符串"
}
};
return configs;
}
}
}

19
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Config.cs

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Config : IKeyID
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string ConfigKey { get; set; }
[Required, StringLength(4000)]
public string ConfigValue { get; set; }
[StringLength(500)]
public string Remark { get; set; }
}
}

67
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Dept.cs

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CK.SCP.Models.AppBoxEntity
{
public class Dept : ICustomTree, IKeyID, ICloneable
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[Required]
public int SortIndex { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual Dept Parent { get; set; }
public virtual ICollection<Dept> Children { get; set; }
public virtual ICollection<User> Users { get; set; }
/// <summary>
/// 菜单在树形结构中的层级(从0开始)
/// </summary>
[NotMapped]
public int TreeLevel { get; set; }
/// <summary>
/// 是否可用(默认true),在模拟树的下拉列表中使用
/// </summary>
[NotMapped]
public bool Enabled { get; set; }
/// <summary>
/// 是否叶子节点(默认true)
/// </summary>
[NotMapped]
public bool IsTreeLeaf { get; set; }
public object Clone()
{
Dept dept = new Dept
{
ID = ID,
Name = Name,
Remark = Remark,
SortIndex = SortIndex,
TreeLevel = TreeLevel,
Enabled = Enabled,
IsTreeLeaf = IsTreeLeaf
};
return dept;
}
}
}

25
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/ICustomTree.cs

@ -0,0 +1,25 @@
namespace CK.SCP.Models.AppBoxEntity
{
public interface ICustomTree
{
/// <summary>
/// 名称
/// </summary>
string Name { get; set; }
/// <summary>
/// 菜单在树形结构中的层级(从0开始)
/// </summary>
int TreeLevel { get; set; }
/// <summary>
/// 是否可用(默认true),在模拟树的下拉列表中使用
/// </summary>
bool Enabled { get; set; }
/// <summary>
/// 是否叶子节点(默认true)
/// </summary>
bool IsTreeLeaf { get; set; }
}
}

8
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/IKeyID.cs

@ -0,0 +1,8 @@
namespace CK.SCP.Models.AppBoxEntity
{
public interface IKeyID
{
int ID { get; set; }
}
}

26
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Log.cs

@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Log : IKeyID
{
[Key]
public int ID { get; set; }
[StringLength(20)]
public string Level { get; set; }
[StringLength(200)]
public string Logger { get; set; }
[StringLength(4000)]
public string Message { get; set; }
[StringLength(4000)]
public string Exception { get; set; }
public DateTime LogTime { get; set; }
}
}

74
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Menu.cs

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CK.SCP.Models.AppBoxEntity
{
public class Menu : ICustomTree, IKeyID, ICloneable
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[StringLength(200)]
public string ImageUrl { get; set; }
[StringLength(200)]
public string NavigateUrl { get; set; }
[StringLength(500)]
public string Remark { get; set; }
[Required]
public int SortIndex { get; set; }
public virtual Menu Parent { get; set; }
public virtual ICollection<Menu> Children { get; set; }
public virtual Power ViewPower {get; set;}
/// <summary>
/// 菜单在树形结构中的层级(从0开始)
/// </summary>
[NotMapped]
public int TreeLevel { get; set; }
/// <summary>
/// 是否可用(默认true),在模拟树的下拉列表中使用
/// </summary>
[NotMapped]
public bool Enabled { get; set; }
/// <summary>
/// 是否叶子节点(默认true)
/// </summary>
[NotMapped]
public bool IsTreeLeaf { get; set; }
public object Clone()
{
Menu menu = new Menu {
ID = ID,
Name = Name,
ImageUrl = ImageUrl,
NavigateUrl = NavigateUrl,
Remark = Remark,
SortIndex = SortIndex,
TreeLevel = TreeLevel,
Enabled = Enabled,
IsTreeLeaf = IsTreeLeaf
};
return menu;
}
}
}

23
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Online.cs

@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Online : IKeyID
{
[Key]
public int ID { get; set; }
[StringLength(50)]
public string IPAdddress { get; set; }
public DateTime LoginTime { get; set; }
public DateTime? UpdateTime { get; set; }
public virtual User User { get; set; }
}
}

119
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/PasswordUtil.cs

@ -0,0 +1,119 @@
using System;
using System.Security.Cryptography;
namespace CK.SCP.Models.AppBoxEntity
{
/// <summary>
/// 单相混淆加密用户密码,并比较密码是否一致的类
/// </summary>
public class PasswordUtil
{
#region field & constructor
//private static readonly Log _log = new Log(typeof(PasswordUtil));
private const int saltLength = 4;
public PasswordUtil() { }
#endregion
/// <summary>
/// 对比用户明文密码是否和加密后密码一致
/// </summary>
/// <param name="dbPassword">数据库中单向加密后的密码</param>
/// <param name="userPassword">用户明文密码</param>
/// <returns></returns>
public static bool ComparePasswords(string dbPassword,string userPassword)
{
byte[] dbPwd = Convert.FromBase64String(dbPassword);
byte[] hashedPwd = HashString(userPassword);
if(dbPwd.Length ==0 || hashedPwd.Length ==0 || dbPwd.Length !=hashedPwd.Length + saltLength)
{
return false;
}
byte[] saltValue = new byte[saltLength];
// int saltOffset = dbPwd.Length - hashedPwd.Length;
int saltOffset = hashedPwd.Length;
for (int i = 0; i < saltLength; i++)
saltValue[i] = dbPwd[saltOffset + i];
byte[] saltedPassword = CreateSaltedPassword(saltValue, hashedPwd);
// compare the values
return CompareByteArray(dbPwd, saltedPassword);
}
/// <summary>
/// 创建用户的数据库密码
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string CreateDbPassword(string userPassword)
{
byte[] unsaltedPassword = HashString(userPassword);
//Create a salt value
byte[] saltValue = new byte[saltLength];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(saltValue);
byte[] saltedPassword = CreateSaltedPassword(saltValue, unsaltedPassword);
return Convert.ToBase64String(saltedPassword);
}
#region 私有函数
/// <summary>
/// 将一个字符串哈希化
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private static byte[] HashString(string str)
{
byte[] pwd = System.Text.Encoding.UTF8.GetBytes(str);
SHA1 sha1 = SHA1.Create();
byte[] saltedPassword = sha1.ComputeHash(pwd);
return saltedPassword;
}
private static bool CompareByteArray(byte[] array1, byte[] array2)
{
if (array1.Length != array2.Length)
return false;
for (int i = 0; i < array1.Length; i++)
{
if (array1[i] != array2[i])
return false;
}
return true;
}
// create a salted password given the salt value
private static byte[] CreateSaltedPassword(byte[] saltValue, byte[] unsaltedPassword)
{
// add the salt to the hash
byte[] rawSalted = new byte[unsaltedPassword.Length + saltValue.Length];
unsaltedPassword.CopyTo(rawSalted,0);
saltValue.CopyTo(rawSalted,unsaltedPassword.Length);
//Create the salted hash
SHA1 sha1 = SHA1.Create();
byte[] saltedPassword = sha1.ComputeHash(rawSalted);
// add the salt value to the salted hash
byte[] dbPassword = new byte[saltedPassword.Length + saltValue.Length];
saltedPassword.CopyTo(dbPassword,0);
saltValue.CopyTo(dbPassword,saltedPassword.Length);
return dbPassword;
}
#endregion
}
}

27
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Power.cs

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Power : IKeyID
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[StringLength(50)]
public string GroupName { get; set; }
[StringLength(200)]
public string Title { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
}

24
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Role.cs

@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Role : IKeyID
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual ICollection<User> Users { get; set; }
public virtual ICollection<Power> Powers { get; set; }
}
}

23
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/Title.cs

@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CK.SCP.Models.AppBoxEntity
{
public class Title : IKeyID
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual ICollection<User> Users { get; set; }
}
}

85
北京北汽/SCP/CK.SCP.Models/AppBoxEntity/User.cs

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CK.SCP.Models.AppBoxEntity
{
public class User : IKeyID
{
[Key]
public int ID { get; set; }
[Required, StringLength(50)]
public string Name { get; set; }
[Required, StringLength(100)]
public string Email { get; set; }
[Required, StringLength(50)]
public string Password { get; set; }
[Required]
public bool Enabled { get; set; }
[StringLength(10)]
public string Gender { get; set; }
[StringLength(100)]
public string ChineseName { get; set; }
[StringLength(100)]
public string EnglishName { get; set; }
[StringLength(200)]
public string Photo { get; set; }
[StringLength(50)]
public string QQ { get; set; }
[StringLength(100)]
public string CompanyEmail { get; set; }
[StringLength(50)]
public string OfficePhone { get; set; }
[StringLength(50)]
public string OfficePhoneExt { get; set; }
[StringLength(50)]
public string HomePhone { get; set; }
[StringLength(50)]
public string CellPhone { get; set; }
[StringLength(500)]
public string Address { get; set; }
[StringLength(500)]
public string Remark { get; set; }
[StringLength(500)]
public string SupplierCode { get; set; }
[NotMapped]
[StringLength(500)]
public string VendName { get; set; }
[StringLength(50)]
public string IdentityCard { get; set; }
public DateTime? Birthday { get; set; }
public DateTime? TakeOfficeTime { get; set; }
public DateTime? LastLoginTime { get; set; }
public DateTime? CreateTime { get; set; }
public virtual ICollection<Role> Roles { get; set; }
public virtual ICollection<Title> Titles { get; set; }
public virtual Dept Dept { get; set; }
}
}

252
北京北汽/SCP/CK.SCP.Models/CK.SCP.Models.csproj

@ -0,0 +1,252 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DD7C0DEF-71E7-443F-B0B7-DB2F5B12A506}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CK.SCP.Models</RootNamespace>
<AssemblyName>CK.SCP.Models</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\DLL\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppBoxEntity\AppBoxContext.cs" />
<Compile Include="AppBoxEntity\AppBoxDatabaseInitializer.cs" />
<Compile Include="AppBoxEntity\Config.cs" />
<Compile Include="AppBoxEntity\Dept.cs" />
<Compile Include="AppBoxEntity\ICustomTree.cs" />
<Compile Include="AppBoxEntity\IKeyID.cs" />
<Compile Include="AppBoxEntity\Log.cs" />
<Compile Include="AppBoxEntity\Menu.cs" />
<Compile Include="AppBoxEntity\Online.cs" />
<Compile Include="AppBoxEntity\PasswordUtil.cs" />
<Compile Include="AppBoxEntity\Power.cs" />
<Compile Include="AppBoxEntity\Role.cs" />
<Compile Include="AppBoxEntity\Title.cs" />
<Compile Include="AppBoxEntity\User.cs" />
<Compile Include="DbSetting.cs" />
<Compile Include="EntitiesFactory.cs" />
<Compile Include="EntitiesHelper.cs" />
<Compile Include="Enums\BillType.cs" />
<Compile Include="Enums\CollectionStepFinish.cs" />
<Compile Include="Enums\ControlType.cs" />
<Compile Include="Enums\DataBaseType.cs" />
<Compile Include="Enums\DataState.cs" />
<Compile Include="Enums\EquipmentState.cs" />
<Compile Include="Enums\ErpInterfaceType.cs" />
<Compile Include="Enums\GroupType.cs" />
<Compile Include="Enums\InspectionType.cs" />
<Compile Include="Enums\InspectType.cs" />
<Compile Include="Enums\InventoryState.cs" />
<Compile Include="Enums\InvoiceState.cs" />
<Compile Include="Enums\LocType.cs" />
<Compile Include="Enums\LoginState.cs" />
<Compile Include="Enums\LogType.cs" />
<Compile Include="Enums\ManageType.cs" />
<Compile Include="Enums\ManufactureProcedureType.cs" />
<Compile Include="Enums\NotifyType.cs" />
<Compile Include="Enums\OperateType.cs" />
<Compile Include="Enums\PartKind.cs" />
<Compile Include="Enums\PartState.cs" />
<Compile Include="Enums\PartType.cs" />
<Compile Include="Enums\PlanDayState.cs" />
<Compile Include="Enums\PlanState.cs" />
<Compile Include="Enums\PortalType.cs" />
<Compile Include="Enums\PrintType.cs" />
<Compile Include="Enums\Project.cs" />
<Compile Include="Enums\ProjectName.cs" />
<Compile Include="Enums\ReceiveBillType.cs" />
<Compile Include="Enums\ReceiveState.cs" />
<Compile Include="Enums\ResultCode.cs" />
<Compile Include="Enums\ServiceType.cs" />
<Compile Include="Enums\ShipState.cs" />
<Compile Include="Enums\StockState.cs" />
<Compile Include="Enums\StockWhereType.cs" />
<Compile Include="Enums\StopLineType.cs" />
<Compile Include="Enums\StoreArea.cs" />
<Compile Include="Enums\SubBillType.cs" />
<Compile Include="Enums\UniApiState.cs" />
<Compile Include="Enums\UniApiType.cs" />
<Compile Include="Enums\VinState.cs" />
<Compile Include="Enums\WhseType.cs" />
<Compile Include="Enums\WorkLineType.cs" />
<Compile Include="GlobalConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScpCache.cs" />
<Compile Include="ScpEntities.cs" />
<Compile Include="ScpEntity\ERP_ORDER.cs" />
<Compile Include="ScpEntity\ERP_ORDER_DETAIL.cs" />
<Compile Include="ScpEntity\QadOrder.cs" />
<Compile Include="ScpEntity\TA_BillNoType.cs" />
<Compile Include="ScpEntity\TA_BILLTYPE.cs" />
<Compile Include="ScpEntity\TA_CONFIG.cs" />
<Compile Include="ScpEntity\TA_FACTORY.cs" />
<Compile Include="ScpEntity\TA_Info.cs" />
<Compile Include="ScpEntity\TA_LANGUAGE.cs" />
<Compile Include="ScpEntity\TA_PART.cs" />
<Compile Include="ScpEntity\TA_Part_User.cs" />
<Compile Include="ScpEntity\TA_VENDER.cs" />
<Compile Include="ScpEntity\TA_VEND_PART.cs" />
<Compile Include="ScpEntity\TA_VEND_USER.cs" />
<Compile Include="ScpEntity\TB_ASK.cs" />
<Compile Include="ScpEntity\TB_ASK_DETAIL.cs" />
<Compile Include="ScpEntity\TB_ASN.cs" />
<Compile Include="ScpEntity\TB_ASN_DETAIL.cs" />
<Compile Include="ScpEntity\TB_INVOICE.cs" />
<Compile Include="ScpEntity\TB_INVOICE_DETAIL.cs" />
<Compile Include="ScpEntity\TB_PLAN.cs" />
<Compile Include="ScpEntity\TB_PlanMonth.cs" />
<Compile Include="ScpEntity\TB_PLAN_DETAIL.cs" />
<Compile Include="ScpEntity\TB_PO.cs" />
<Compile Include="ScpEntity\TB_PO_DETAIL.cs" />
<Compile Include="ScpEntity\TB_PublicData.cs" />
<Compile Include="ScpEntity\TB_QadOrder.cs" />
<Compile Include="ScpEntity\TB_QadOrderDetail.cs" />
<Compile Include="ScpEntity\TB_RECEIVE.cs" />
<Compile Include="ScpEntity\TB_RECEIVE_DETAIL.cs" />
<Compile Include="ScpEntity\TB_REJECT.cs" />
<Compile Include="ScpEntity\TB_REJECT_DETAIL.cs" />
<Compile Include="ScpEntity\TB_RETURN.cs" />
<Compile Include="ScpEntity\TB_RETURN_DETAIL.cs" />
<Compile Include="ScpEntity\TF_ASN.cs" />
<Compile Include="ScpEntity\TF_ASN_DETAIL.cs" />
<Compile Include="ScpEntity\TF_PO.cs" />
<Compile Include="ScpEntity\TF_PO_DETAIL.cs" />
<Compile Include="ScpEntity\TL_BASEDATA.cs" />
<Compile Include="ScpEntity\TL_BILL.cs" />
<Compile Include="ScpEntity\TL_OPER.cs" />
<Compile Include="ScpEntity\TL_USER.cs" />
<Compile Include="ScpEntity\TS_BARCODE.cs" />
<Compile Include="ScpEntity\TS_INFO.cs" />
<Compile Include="ScpEntity\TS_STOCK.cs" />
<Compile Include="ScpEntity\TS_UNI_API.cs" />
<Compile Include="ScpEntity\TS_UNI_API_HIS.cs" />
<Compile Include="ScpEntity\TT_CURRENCY.cs" />
<Compile Include="ScpEntity\TT_PROJECT.cs" />
<Compile Include="ScpEntity\TT_UNIT.cs" />
<Compile Include="ScpEntity\V_BillInvoice.cs" />
<Compile Include="ScpEntity\V_BillInvoiceDetail.cs" />
<Compile Include="ScpEntity\V_BillShip.cs" />
<Compile Include="ScpEntity\V_BillShipDetail.cs" />
<Compile Include="ScpEntity\V_Info.cs" />
<Compile Include="ScpEntity\V_PlanMonth.cs" />
<Compile Include="ScpEntity\V_POAll.cs" />
<Compile Include="ScpEntity\V_POAllDetail.cs" />
<Compile Include="ScpEntity\V_POReport.cs" />
<Compile Include="ScpEntity\V_QadOrder.cs" />
<Compile Include="ScpEntity\V_Receive.cs" />
<Compile Include="ScpEntity\V_ReceiveDetail.cs" />
<Compile Include="ScpEntity\V_ReportReceive.cs" />
<Compile Include="ScpEntity\V_Stock.cs" />
<Compile Include="SCPException.cs" />
<Compile Include="UniApiEntity\IControlTable.cs" />
<Compile Include="UniApiEntity\IDataTable.cs" />
<Compile Include="UniApiEntity\ITable.cs" />
<Compile Include="UniApiEntity\QadTableName.cs" />
<Compile Include="UniApiEntity\UniApiEntities.cs" />
<Compile Include="UniApiEntity\UniInterfaceExtention.cs" />
<Compile Include="UniApiEntity\xxbom_code_mstr.cs" />
<Compile Include="UniApiEntity\xxbom_ctrl.cs" />
<Compile Include="UniApiEntity\xxbom_ps_mstr.cs" />
<Compile Include="UniApiEntity\xxbom_pt_mstr.cs" />
<Compile Include="UniApiEntity\xxbom_ro_mstr.cs" />
<Compile Include="UniApiEntity\xxmes_ctrl.cs" />
<Compile Include="UniApiEntity\xxqad_cm_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_ctrl.cs" />
<Compile Include="UniApiEntity\xxqad_ld_det.cs" />
<Compile Include="UniApiEntity\xxqad_line_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_loc_det.cs" />
<Compile Include="UniApiEntity\xxqad_pod_det.cs" />
<Compile Include="UniApiEntity\xxqad_pprice_det.cs" />
<Compile Include="UniApiEntity\xxqad_prh_det.cs" />
<Compile Include="UniApiEntity\xxqad_ps_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_pt_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_repsch_det.cs" />
<Compile Include="UniApiEntity\xxqad_ro_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_sche_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_sct_det.cs" />
<Compile Include="UniApiEntity\xxqad_sod_det.cs" />
<Compile Include="UniApiEntity\xxqad_sprice_det.cs" />
<Compile Include="UniApiEntity\xxqad_vd_mstr.cs" />
<Compile Include="UniApiEntity\xxqad_vp_mstr.cs" />
<Compile Include="UniApiEntity\xxscm_ctrl.cs" />
<Compile Include="UniApiEntity\xxscm_inv_det.cs" />
<Compile Include="UniApiEntity\xxscm_pod_det.cs" />
<Compile Include="UniApiEntity\xxscm_tx_det.cs" />
<Compile Include="UniApiEntity\xxscm_tx_mstr.cs" />
<Compile Include="UniApiEntity\xxwms_bk_mstr.cs" />
<Compile Include="UniApiEntity\xxwms_ctrl.cs" />
<Compile Include="UniApiEntity\xxwms_iss_det.cs" />
<Compile Include="UniApiEntity\xxwms_ld_det.cs" />
<Compile Include="UniApiEntity\xxwms_rct_det.cs" />
<Compile Include="UniApiEntity\xxwms_rc_det.cs" />
<Compile Include="UniApiEntity\xxwms_rt_det.cs" />
<Compile Include="UniApiEntity\xxwms_soiss_det.cs" />
<Compile Include="UniApiEntity\xxwms_tag_det.cs" />
<Compile Include="UniApiEntity\xxwms_tr_det.cs" />
<Compile Include="ScpEntity\V_TB_ASK.cs" />
<Compile Include="ScpEntity\V_TB_ASK_DETAIL.cs" />
<Compile Include="ScpEntity\V_TB_ASN.cs" />
<Compile Include="ScpEntity\V_TB_ASN_DETAIL.cs" />
<Compile Include="ScpEntity\V_TB_PO.cs" />
<Compile Include="ScpEntity\V_TB_PO_DETAIL.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CK.SCP.Utils\CK.SCP.Utils.csproj">
<Project>{7118ac83-9dc0-41f5-94ea-e6f405ae0448}</Project>
<Name>CK.SCP.Utils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

28
北京北汽/SCP/CK.SCP.Models/DbSetting.cs

@ -0,0 +1,28 @@
using CK.SCP.Models.Enums;
namespace CK.SCP.Models
{
public class DbSetting
{
public override string ToString()
{
return EntitiesHelper.GetPropertiesString(this);
}
public DbSetting() { }
public DbSetting(DataBaseType type)
{
= type.ToString();
}
public string { get; set; } = Enums.DataBaseType.SQLServer.ToString();
public string { get; set; } = "127.0.0.1";
public string { get; set; } = "1433";
public string { get; set; } = "DB_NAME";
public string { get; set; } = "sa";
public string { get; set; } = "5E0AFEB85CA001A3371A9F19E7EC4DFF";
}
}

148
北京北汽/SCP/CK.SCP.Models/EntitiesFactory.cs

@ -0,0 +1,148 @@
using System;
using System.Data.Entity;
using System.Data.Entity.Core;
using System.Data.Entity.Core.EntityClient;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models.AppBoxEntity;
using CK.SCP.Models.Enums;
using CK.SCP.Models.UniApiEntity;
using CK.SCP.Utils;
namespace CK.SCP.Models
{
public static class EntitiesFactory
{
static EntitiesFactory()
{
Database.SetInitializer<ScpEntities>(null);
Database.SetInitializer<UniApiEntities>(null);
}
public static ScpEntities CreateScpInstance()
{
try
{
// var strConn = setting == null ? GetEfConnectionString("Wms") : GetEfConnectionString(setting);
var strConn = GetEfConnectionString(GlobalConfig.ScpDatabase);
var db = new ScpEntities(strConn);
return db;
}
catch (SqlException ex)
{
throw new Exception($"系统无法连接到数据库:{GlobalConfig.ScpDatabase},请检查配置的服务器,数据库,用户名和密码等信息是否正确。" + Environment.NewLine + ex);
}
}
public static UniApiEntities CreateUniApiInstance()
{
try
{
// var strConn = setting == null ? GetEfConnectionString("UniApi") : GetEfConnectionString(setting);
var strConn = GetEfConnectionString(GlobalConfig.UniApiDatabase);
var db = new UniApiEntities(strConn);
return db;
}
catch (SqlException ex)
{
throw new Exception($"系统无法连接到数据库:{GlobalConfig.UniApiDatabase},请检查配置的服务器,数据库,用户名和密码等信息是否正确。" + Environment.NewLine + ex);
}
}
public static AppBoxContext CreateAppBoxInstance()
{
try
{
// var strConn = setting == null ? GetEfConnectionString("UniApi") : GetEfConnectionString(setting);
var strConn = GetEfConnectionString(GlobalConfig.AppBoxDatabase);
var db = new AppBoxContext(strConn);
return db;
}
catch (SqlException ex)
{
throw new Exception($"系统无法连接到数据库:{GlobalConfig.AppBoxDatabase},请检查配置的服务器,数据库,用户名和密码等信息是否正确。" + Environment.NewLine + ex);
}
}
public static string GetEfConnectionString(DbSetting dbSetting)
{
var sbConn = new StringBuilder();
if (string.IsNullOrEmpty(dbSetting.))
{
throw new Exception("配置文件错误,请检查");
}
switch (dbSetting.)
{
case "SQLServer":
sbConn.Append($"Data source ={dbSetting.服务器地址}");
sbConn.Append(dbSetting. == "0" ? ";" : $",{dbSetting.端口};");
sbConn.Append($"Initial catalog = {dbSetting.数据库名称};");
sbConn.Append($"User id = {dbSetting.用户名};");
sbConn.Append($"Password = {EncryptHelper.Decrypt(dbSetting.密码)};");
sbConn.Append("MultipleActiveResultSets = True;");
sbConn.Append("persist security info = True;");
sbConn.Append("App = EntityFramework;");
break;
case "MySql":
sbConn.Append($"server ={dbSetting.服务器地址};");
sbConn.Append($"port ={dbSetting.端口};");
sbConn.Append($"database = {dbSetting.数据库名称};");
sbConn.Append($"user id = {dbSetting.用户名};");
sbConn.Append($"password = {EncryptHelper.Decrypt(dbSetting.密码)};");
sbConn.Append("persistsecurityinfo =True;");
break;
}
// LogHelper.Write(sbConn.ToString());
return sbConn.ToString();
}
public static void SaveDb(DbContext db)
{
try
{
db.SaveChanges();
}
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);
});
}
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
Console.WriteLine(ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
Console.WriteLine(ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
//Console.WriteLine(inner?.StateEntries[0].EntitySet.Name);
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
{
if (ex.InnerException != null) throw ex.InnerException;
}
}
}
}
}

162
北京北汽/SCP/CK.SCP.Models/EntitiesHelper.cs

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
namespace CK.SCP.Models
{
public static class EntitiesHelper
{
public static string GetPropertiesString<T>(T t,bool withName = true)
{
var peroperties = t.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
var sb = new StringBuilder();
foreach (var property in peroperties)
{
if (withName)
sb.Append($"{property.Name}:");
sb.Append($"{property.GetValue(t)},");
}
return sb.ToString();
}
public static List<T> GetData<T, TKey>(DbContext db, Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order)
where T : class
{
var list = db.Set<T>()
.Where(@where)
.OrderBy(order)
.Select(@select).ToList();
return list;
}
public static List<dynamic> GetData<T, TKey>(DbContext db, Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, out int count)
where T : class
{
count = db.Set<T>().Where(@where).Count();
var list = db.Set<T>()
.Where(@where)
.OrderBy(order)
.Select(@select).ToList();
return list;
}
public static List<dynamic> GetPagedDataAsc<T, TKey>(DbContext db, Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
total = db.Set<T>().Where(@where).Count();
var list = db.Set<T>()
.Where(@where)
.OrderBy(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
return list;
}
public static List<T> GetPagedDataAsc<T, TKey>(DbContext db, Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
total = db.Set<T>().Where(@where.Compile()).AsQueryable().Count();
var list = db.Set<T>()
.Where(@where.Compile()).AsQueryable()
.OrderBy(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
return list;
}
public static List<T> GetPagedDataAsc<T, TKey>(List<T> sourceList, Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
List<T> list = null;
total = 0;
try
{
total = sourceList.Where(where.Compile()).AsQueryable().Count();
}
catch (Exception e)
{
Console.WriteLine(e);
}
try
{
list = sourceList.Where(@where.Compile()).AsQueryable()
.OrderBy(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
}
catch (Exception e)
{
Console.WriteLine(e);
}
return list;
}
public static List<dynamic> GetPagedDataDesc<T, TKey>(DbContext db, Expression<Func<T, dynamic>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
total = db.Set<T>().Where(@where).Count();
var list = db.Set<T>()
.Where(@where)
.OrderByDescending(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
return list;
}
public static List<T> GetPagedDataDesc<T, TKey>(DbContext db, Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
total = db.Set<T>().Where(@where).Count();
var list = db.Set<T>()
.Where(@where)
.OrderByDescending(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
return list;
}
public static List<T> GetPagedDataDesc<T, TKey>(List<T> sourceList, Expression<Func<T, T>> select,
Expression<Func<T, bool>> where, Expression<Func<T, TKey>> order, int pageIndex, int pageSize, out int total)
where T : class
{
total = sourceList.Where(@where.Compile()).AsQueryable().Count();
var list = sourceList
.Where(@where.Compile()).AsQueryable()
.OrderByDescending(order)
.Select(@select)
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize).ToList();
return list;
}
}
}

158
北京北汽/SCP/CK.SCP.Models/Enums/BillType.cs

@ -0,0 +1,158 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum BillType
{
[Description("原料收货")]
MaterialReceive = 101,
[Description("原料入库")]
MaterialIn = 102,
[Description("原料出库")]
MaterialDeliver = 103,
[Description("生产叫料")]
MaterialAsk = 104,
[Description("原料退货")]
MatertialReturn = 105,
[Description("生产退库")]
MaterialBack = 106,
[Description("委外出库")]
OutsourceDeliver = 109,
// [Description("原料退货")]
// MaterialBack = 105,
// [Description("生产退库")]
// MaterialReturn = 106,
[Description("成品收货")]
ProductReceive = 201,
[Description("成品入库")]
ProductIn = 202,
[Description("成品发货")]
DeliverPlan = 204,
[Description("客户退货")]
ProductReturn = 205,
[Description("成品顺序发货")]
ProductSortedDeliver = 206,
[Description("成品销售")]
ProductSell = 207,
[Description("成品返修")]
ProductRepair = 208,
[Description("委外入库")]
OutsourceReceive = 209,
[Description("其它入库")]
OtherIn = 300,
[Description("其它出库")]
OtherOut = 301,
[Description("移库")]
StockMove = 302,
[Description("打包")]
StockPack = 303,
[Description("拆包")]
StockUnpack = 304,
[Description("盘点计划")]
InventoryPlan = 305,
[Description("结算比对")]
BalanceCompare = 307,
[Description("盘点库位")]
InventoryLoc = 306,
[Description("器具初始化")]
EqptRecover = 401,
[Description("器具保养")]
EqptMaintain = 402,
[Description("器具报废")]
EqptScrap = 403,
[Description("码托")]
EqptLoad = 404,
[Description("JIS收货")]
VinReceive = 501,
[Description("JIS发货")]
VinDeliver = 502,
[Description("JIS销售")]
VinSell = 503,
[Description("报检")]
Inspect = 601,
[Description("追溯")]
TraceBack = 602,
[Description("备货单")]
PickPlan = 603,
[Description("发料单")]
PickFact = 604,
[Description("生产计划")]
ProducePlan = 605,
[Description("生产订单")]
ManuOrder = 607,
[Description("不合格品单")]
UnqualifiedProd = 608,
[Description("设备点检模板")]
CheckModeEquipment = 609,
[Description("设备点检单")]
CheckBillEquipment = 610,
[Description("产品点检模板")]
CheckModeProduct = 611,
[Description("产品点检单")]
CheckBillProduct = 612,
[Description("首检模板")]
SpotInspectFirstMode = 613,
[Description("首检单")]
SpotInspectionFirst = 615,
[Description("巡检模板")]
SpotInspectMedMode = 616,
[Description("巡检单")]
SpotInspectionMed = 617,
[Description("末检模板")]
SpotInspectLastMode = 618,
[Description("末检单")]
SpotInspectionLast = 619,
[Description("停线单")]
LineStopBill = 620,
[Description("产线识别码")]
WorkLineDoc = 621,
[Description("工位识别码")]
WorkStationDoc = 622,
[Description("路由识别码")]
RouteDoc = 623,
[Description("工位拆解识别码")]
RouteBOMDoc = 624,
[Description("参数识别码")]
RoutePDoc = 625,
[Description("工位部件识别码")]
MachinePart = 626,
[Description("停线发通知编号")]
LineStopNoticeBill = 627,
[Description("停线预计处理编号")]
LineStopPrepareBill = 628,
[Description("措施编号")]
LineStopMeasureBill = 629,
[Description("点检表编号")]
CheckCode = 630,
ReHandleVin = 701,
[Description("采购订单")]
PuchaseOrder = 702,
[Description("发货单")]
AsnOrder = 703,
[Description("销售订单")]
SaleOrder = 704,
[Description("确认订单")]
PO = 704,
[Description("收货")]
Receive = 704,
[Description("条码")]
BarCode = 704,
[Description("发票")]
Invoice = 704,
}
}

11
北京北汽/SCP/CK.SCP.Models/Enums/CollectionStepFinish.cs

@ -0,0 +1,11 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum CollectionStepFinish
{
[Description("零件扫条码")] ScanPartBarCode = 1,
[Description("机器复位信号")] ScanMachineReset = 2,
[Description("专用计数设备")] counters = 3
}
}

16
北京北汽/SCP/CK.SCP.Models/Enums/ControlType.cs

@ -0,0 +1,16 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum ControlType
{
[Description("标签")]
Tab = 0,
[Description("群组")]
Grp = 1,
[Description("容器")]
Ctn = 2,
[Description("菜单项")]
Itm = 3,
}
}

10
北京北汽/SCP/CK.SCP.Models/Enums/DataBaseType.cs

@ -0,0 +1,10 @@
namespace CK.SCP.Models.Enums
{
public enum DataBaseType
{
SQLServer,
MySql,
Oracle,
PostgreSQL,
}
}

29
北京北汽/SCP/CK.SCP.Models/Enums/DataState.cs

@ -0,0 +1,29 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum DataState
{
[Description("无效")]
Disabled = 0,
[Description("有效")]
Enabled = 1,
}
public enum FormState
{
[Description("开放")]
= 1,
[Description("关闭")]
= 0,
}
public enum BillState
{
Cancel = -1,
New = 0,
Process = 1,
Finish = 2,
}
}

11
北京北汽/SCP/CK.SCP.Models/Enums/EquipmentState.cs

@ -0,0 +1,11 @@
namespace CK.SCP.Models.Enums
{
public enum EquipmentState
{
Idle,
InUsed,
Sent,
Maintaining,
Scraped
}
}

19
北京北汽/SCP/CK.SCP.Models/Enums/ErpInterfaceType.cs

@ -0,0 +1,19 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum ErpInterfaceType
{
[Description("移库")]
TR,
[Description("回冲")]
BK,
MaterialIn,
MaterialOut,
ProductIn,
ProductOut,
[Description("销售")]
SH,
RCT
}
}

15
北京北汽/SCP/CK.SCP.Models/Enums/GroupType.cs

@ -0,0 +1,15 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum GroupType
{
[Description("高位货架")]
Shelf = 0,
[Description("地面库位")]
Ground = 1,
[Description("线边货架")]
Wip = 2,
}
}

14
北京北汽/SCP/CK.SCP.Models/Enums/InspectType.cs

@ -0,0 +1,14 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum InspectType
{
[Description("免检")]
No = 0,
[Description("全检")]
All = 1,
[Description("抽检")]
Partial = 2
}
}

14
北京北汽/SCP/CK.SCP.Models/Enums/InspectionType.cs

@ -0,0 +1,14 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum InspectionType
{
//[Description("未知")] Unknow = 0,
[Description("首检")] InspectionFirst = 1,
[Description("巡检")] InspectionMed = 2,
[Description("末检")] InspectionLast = 3,
[Description("设备点检")] CheckEquipment = 4,
[Description("产品点检")] CheckProduction = 5,
}
}

19
北京北汽/SCP/CK.SCP.Models/Enums/InventoryState.cs

@ -0,0 +1,19 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum InventoryState
{
//状态 0:新建 1:已初盘 2:已重盘 3:已生成接口 -1:已取消
[Description("新建")]
New = 0,
[Description("已初盘")]
Checked = 1,
[Description("已重盘")]
ReChecked = 2,
[Description("已生成接口")]
ToErp = 3,
[Description("取消")]
Cancelled = -1
}
}

24
北京北汽/SCP/CK.SCP.Models/Enums/InvoiceState.cs

@ -0,0 +1,24 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum InvoiceState
{
[Description("新建")]
New = 0,
[Description("供应商申请")]
Apply = 1,
[Description("采购审核退回")]
CheckFail = 2,
[Description("采购审核通过")]
CheckSuccess = 3,
[Description("发票寄出")]
Mail = 4,
[Description("财务收票")]
FinanceReceive = 5,
[Description("财务退回")]
FinanceFail = 6,
[Description("发票作废")]
Reject = -1,
}
}

15
北京北汽/SCP/CK.SCP.Models/Enums/LocType.cs

@ -0,0 +1,15 @@
using System.ComponentModel;
namespace CK.SCP.Models.Enums
{
public enum LocType
{
[Description("存储库位")]
Store = 0,
[Description("线边库位")]
Wip = 1,
[Description("功能库位")]
Functional = 2,
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save