Browse Source

北汽优化

master
qian 9 months ago
parent
commit
49c374e307
  1. 14
      北京北汽/Controller/SCP_ASN_CONTROLLER.cs
  2. 4
      北京北汽/SCP/SCP.csproj
  3. 233
      北京北汽/SCP/Views/BasicData/SCP_VenderUser.aspx.cs

14
北京北汽/Controller/SCP_ASN_CONTROLLER.cs

@ -780,13 +780,19 @@ namespace CK.SCP.Controller
_ls.ForEach(p => _ls.ForEach(p =>
{ {
V_ASN_PRINT_DETAIL _detail = new V_ASN_PRINT_DETAIL(); V_ASN_PRINT_DETAIL _detail = new V_ASN_PRINT_DETAIL();
string qty = "";
string std = "";
string boxes = "";
_detail.PartNo = p.PartCode; _detail.PartNo = p.PartCode;
_detail.PartDesc = p.PartDesc1; _detail.PartDesc = p.PartDesc1;
_detail.Unit = p.PoUnit; _detail.Unit = p.PoUnit;
_detail.STD = p.PackQty.ToString(); std = p.PackQty.ToString();
_detail.Boxes = (Math.Truncate((p.Qty / p.PackQty)) + (((p.Qty % p.PackQty) > 0) ? 1 : 0)).ToString(); _detail.STD = std.Contains(".")? std.TrimEnd('0').TrimEnd('.'): std;
_detail.DeliverQty = p.Qty.ToString(); boxes = (Math.Truncate((p.Qty / p.PackQty)) + (((p.Qty % p.PackQty) > 0) ? 1 : 0)).ToString();
_detail.ReceiveQty = p.Qty.ToString(); _detail.Boxes = boxes.Contains(".")? boxes.TrimEnd('0').TrimEnd('.'):boxes;
qty = p.Qty.ToString();
_detail.DeliverQty = p.Qty.ToString().Contains(".") ? qty.TrimEnd('0').TrimEnd('.') : qty;
_detail.ReceiveQty = p.Qty.ToString().Contains(".") ?qty.TrimEnd('0').TrimEnd('.') :qty;
_detail.PoNo = p.PoBillNum+"."+p.AskBillNum; _detail.PoNo = p.PoBillNum+"."+p.AskBillNum;
_detail.LineNO = p.PoLine.ToString(); _detail.LineNO = p.PoLine.ToString();
_detail.Memo = p.Remark; _detail.Memo = p.Remark;

4
北京北汽/SCP/SCP.csproj

@ -159,6 +159,10 @@
<Reference Include="Microsoft.AspNet.FriendlyUrls"> <Reference Include="Microsoft.AspNet.FriendlyUrls">
<HintPath>..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.2\lib\net45\Microsoft.AspNet.FriendlyUrls.dll</HintPath> <HintPath>..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.2\lib\net45\Microsoft.AspNet.FriendlyUrls.dll</HintPath>
</Reference> </Reference>
<Reference Include="Z.EntityFramework.Extensions, Version=6.13.5.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Z.EntityFramework.Extensions.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.ApplicationInsights"> <Reference Include="Microsoft.ApplicationInsights">

233
北京北汽/SCP/Views/BasicData/SCP_VenderUser.aspx.cs

@ -52,15 +52,16 @@ namespace SCP.Views.BasicData
_list = _list.Where(p => lsFacID.Contains(p.Site)).ToList(); _list = _list.Where(p => lsFacID.Contains(p.Site)).ToList();
if (_list.Count() > 0) if (_list.Count() > 0)
{ {
var factorylist = DB.TA_FACTORY.ToList();
foreach (var item in _list) foreach (var item in _list)
{ {
if ((item.Site == "BJBMPT") && (!string.IsNullOrEmpty(item.SubSite))) if ((item.Site == "BJBMPT") && (!string.IsNullOrEmpty(item.SubSite)))
{ {
item.FactoryNameForView = DB.TA_FACTORY.FirstOrDefault(a => a.ErpDomain == item.Site && a.ErpSite == item.SubSite).FactoryName; item.FactoryNameForView = factorylist.FirstOrDefault(a => a.ErpDomain == item.Site && a.ErpSite == item.SubSite).FactoryName;
} }
else else
{ {
item.FactoryNameForView = DB.TA_FACTORY.FirstOrDefault(a => a.ErpDomain == item.Site).FactoryName; item.FactoryNameForView = factorylist.FirstOrDefault(a => a.ErpDomain == item.Site).FactoryName;
} }
} }
} }
@ -68,11 +69,11 @@ namespace SCP.Views.BasicData
lsVenders = _list; lsVenders = _list;
var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid_Vender); //var list = Sort<TA_VENDER>(_list.AsQueryable(), Grid_Vender);
Grid_Vender.DataSource = list; //Grid_Vender.DataSource = list;
Grid_Vender.RecordCount = list.Count(); //Grid_Vender.RecordCount = list.Count();
Grid_Vender.DataBind(); //Grid_Vender.DataBind();
} }
@ -168,39 +169,29 @@ namespace SCP.Views.BasicData
string tempVender = ""; string tempVender = "";
string[] szVenders = new string[] { }; string[] szVenders = new string[] { };
List<string> lsCheckVenderID = new List<string>(); List<string> lsCheckVenderID = new List<string>();
foreach (VenderUsers vu in _VenderUsers) var venlist = _VenderUsers.Select(q => q.VenderId).ToList();
lsCheckVenderID = lsVenders.Where(q => venlist.Contains(q.VendId)).Select(q => q.VendId).Distinct().ToList();
//foreach (VenderUsers vu in _VenderUsers)
//{
// for (int i = 0; i < Grid_Vender.Rows.Count; i++)
// {
// if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
// {
// lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
// }
// }
//}
if (lsCheckVenderID.Count == 0)
{ {
for (int i = 0; i < Grid_Vender.Rows.Count; i++) uncheckedVenders = lsVenders.OrderBy(p=>p.VendId).ToList();
{
if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
{
lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
}
}
} }
else
foreach (TA_VENDER vender in lsVenders)
{ {
if (lsCheckVenderID.Count == 0) checkedVenders = lsVenders.Where(q => lsCheckVenderID.Contains(q.VendId)).ToList();
{ uncheckedVenders = lsVenders.Where(q => !lsCheckVenderID.Contains(q.VendId)).OrderBy(p => p.VendId).ToList();
uncheckedVenders.Add(vender);
}
else
{
foreach (string venderid in lsCheckVenderID)
{
if (vender.VendId == venderid)
{
checkedVenders.Add(vender);
}
else
{
uncheckedVenders.Add(vender);
}
}
}
} }
uncheckedVenders = uncheckedVenders.OrderBy(p => p.VendId).ToList();
//uncheckedVenders = uncheckedVenders.OrderBy(p => p.VendId).ToList();
finalVenders = checkedVenders.Union(uncheckedVenders).ToList(); finalVenders = checkedVenders.Union(uncheckedVenders).ToList();
Grid_Vender.DataSource = finalVenders; Grid_Vender.DataSource = finalVenders;
Grid_Vender.RecordCount = finalVenders.Count(); Grid_Vender.RecordCount = finalVenders.Count();
@ -262,42 +253,53 @@ namespace SCP.Views.BasicData
string tempVender = ""; string tempVender = "";
string[] szVenders = new string[] { }; string[] szVenders = new string[] { };
List<string> lsCheckVenderID = new List<string>(); List<string> lsCheckVenderID = new List<string>();
foreach (VenderUsers vu in _VenderUsers) var venlist = _VenderUsers.Select(q => q.VenderId).ToList();
lsCheckVenderID = lsVenders.Where(q => venlist.Contains(q.VendId)).Select(q => q.VendId).Distinct().ToList();
//foreach (VenderUsers vu in _VenderUsers)
//{
// for (int i = 0; i < Grid_Vender.Rows.Count; i++)
// {
// if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
// {
// lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
// }
// }
//}
if (lsCheckVenderID.Count == 0)
{ {
for (int i = 0; i < Grid_Vender.Rows.Count; i++) uncheckedVenders = lsVenders.OrderBy(p => p.VendId).ToList();
{
if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
{
lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
}
}
} }
else
foreach (TA_VENDER vender in lsVenders)
{ {
if (lsCheckVenderID.Count == 0) checkedVenders = lsVenders.Where(q => lsCheckVenderID.Contains(q.VendId)).ToList();
{ uncheckedVenders = lsVenders.Where(q => !lsCheckVenderID.Contains(q.VendId)).OrderBy(p => p.VendId).ToList();
uncheckedVenders.Add(vender);
}
else
{
foreach (string venderid in lsCheckVenderID)
{
if (vender.VendId == venderid)
{
checkedVenders.Add(vender);
}
else
{
uncheckedVenders.Add(vender);
}
}
}
} }
uncheckedVenders = uncheckedVenders.OrderBy(p => p.VendId).ToList(); //foreach (TA_VENDER vender in lsVenders)
//{
// if (lsCheckVenderID.Count == 0)
// {
// uncheckedVenders.Add(vender);
// }
// else
// {
// foreach (string venderid in lsCheckVenderID)
// {
// if (vender.VendId == venderid)
// {
// checkedVenders.Add(vender);
// }
// else
// {
// uncheckedVenders.Add(vender);
// }
// }
// }
//}
//uncheckedVenders = uncheckedVenders.OrderBy(p => p.VendId).ToList();
finalVenders = checkedVenders.Union(uncheckedVenders).ToList(); finalVenders = checkedVenders.Union(uncheckedVenders).ToList();
@ -392,16 +394,13 @@ namespace SCP.Views.BasicData
} }
List<VenderUsers> _vList = new List<VenderUsers>(); List<VenderUsers> _vList = new List<VenderUsers>();
int[] selections = Grid_Vender.SelectedRowIndexArray;
int selectedCount = Grid_Vender.SelectedRowIndexArray.Length; if (selections != null)
if (selectedCount > 0)
{ {
for (int i = 0; i < selectedCount; i++) foreach (int rowIndex in selections)
{ {
int rowIndex = Grid_Vender.SelectedRowIndexArray[i];
string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString(); string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString();
string site= Grid_Vender.Rows[rowIndex].DataKeys[3].ToString(); string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString();
VenderUsers _vus = new VenderUsers(); VenderUsers _vus = new VenderUsers();
_vus.UserId = iUserId; _vus.UserId = iUserId;
_vus.VenderId = venderid; _vus.VenderId = venderid;
@ -409,22 +408,16 @@ namespace SCP.Views.BasicData
} }
} }
if (_vList.Count > 0) if (_vList.Count > 0)
{ {
var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId)); var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId));
DB.VenderUsers.AddRange(list.ToArray()); DB.VenderUsers.BulkInsert(list.ToArray());
}
int res = DB.SaveChanges();
if (res >= 0)
{
Alert.Show("保存成功!");
BindVender();
}
else
{
Alert.Show("保存失败!");
} }
DB.BulkSaveChanges();
Alert.Show("保存成功!");
BindVender();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -598,12 +591,12 @@ namespace SCP.Views.BasicData
if (_VenderUsers != null && _VenderUsers.Count > 0) if (_VenderUsers != null && _VenderUsers.Count > 0)
{ {
List<VenderUsers> _vList = new List<VenderUsers>(); List<VenderUsers> _vList = new List<VenderUsers>();
int selectedCount = Grid_Vender.SelectedRowIndexArray.Length; //int selectedCount = Grid_Vender.SelectedRowIndexArray.Length;
if (selectedCount > 0) int[] selections = Grid_Vender.SelectedRowIndexArray;
if (selections != null)
{ {
for (int i = 0; i < selectedCount; i++) foreach (int rowIndex in selections)
{ {
int rowIndex = Grid_Vender.SelectedRowIndexArray[i];
string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString(); string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString();
string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString(); string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString();
VenderUsers _vus = new VenderUsers(); VenderUsers _vus = new VenderUsers();
@ -616,59 +609,67 @@ namespace SCP.Views.BasicData
} }
} }
} }
//if (selectedCount > 0)
//{
// for (int i = 0; i < selectedCount; i++)
// {
// int rowIndex = Grid_Vender.SelectedRowIndexArray[i];
// string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString();
// string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString();
// VenderUsers _vus = new VenderUsers();
// _vus.UserId = iUserId;
// _vus.VenderId = venderid;
// int _count = _VenderUsers.Count(p => p.UserId == _vus.UserId && p.VenderId == _vus.VenderId);
// if (_count == 0)
// {
// _vList.Add(_vus);
// }
// }
//}
if (_vList.Count > 0) if (_vList.Count > 0)
{ {
var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId)); var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId));
DB.VenderUsers.AddRange(list.ToArray()); DB.VenderUsers.BulkInsert(list.ToArray());
} }
int res = DB.SaveChanges(); DB.BulkSaveChanges();
if (res >= 0) Alert.Show("保存成功!");
{ BindVender();
Alert.Show("保存成功!");
BindVender();
}
else
{
Alert.Show("保存失败!");
}
} }
else else
{ {
if (_VenderUsers != null && _VenderUsers.Count == 0) if (_VenderUsers != null && _VenderUsers.Count == 0)
{ {
List<VenderUsers> _vList = new List<VenderUsers>(); List<VenderUsers> _vList = new List<VenderUsers>();
int selectedCount = Grid_Vender.SelectedRowIndexArray.Length; //int selectedCount = Grid_Vender.SelectedRowIndexArray.Length;
if (selectedCount > 0) int[] selections = Grid_Vender.SelectedRowIndexArray;
if (selections != null)
{ {
for (int i = 0; i < selectedCount; i++) foreach (int rowIndex in selections)
{ {
int rowIndex = Grid_Vender.SelectedRowIndexArray[i];
string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString(); string venderid = Grid_Vender.Rows[rowIndex].DataKeys[1].ToString();
string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString(); string site = Grid_Vender.Rows[rowIndex].DataKeys[3].ToString();
VenderUsers _vus = new VenderUsers(); VenderUsers _vus = new VenderUsers();
_vus.UserId = iUserId; _vus.UserId = iUserId;
_vus.VenderId = venderid; _vus.VenderId = venderid;
_vList.Add(_vus); int _count = _VenderUsers.Count(p => p.UserId == _vus.UserId && p.VenderId == _vus.VenderId);
if (_count == 0)
{
_vList.Add(_vus);
}
} }
} }
if (_vList.Count > 0) if (_vList.Count > 0)
{ {
var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId)); var list = _vList.Where(itm => itm.UserId > 0 && !string.IsNullOrEmpty(itm.VenderId));
DB.VenderUsers.AddRange(list.ToArray()); DB.VenderUsers.BulkInsert(list.ToArray());
} }
int res = DB.SaveChanges(); DB.BulkSaveChanges();
if (res >= 0) Alert.Show("保存成功!");
{ BindVender();
Alert.Show("保存成功!");
BindVender();
}
else
{
Alert.Show("保存失败!");
}
} }
} }

Loading…
Cancel
Save