|
@ -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(); |
|
|
for (int i = 0; i < Grid_Vender.Rows.Count; i++) |
|
|
//foreach (VenderUsers vu in _VenderUsers)
|
|
|
{ |
|
|
//{
|
|
|
if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString()) |
|
|
// for (int i = 0; i < Grid_Vender.Rows.Count; i++)
|
|
|
{ |
|
|
// {
|
|
|
lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString()); |
|
|
// if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
|
|
|
} |
|
|
// {
|
|
|
} |
|
|
// lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
|
|
|
} |
|
|
// }
|
|
|
|
|
|
// }
|
|
|
foreach (TA_VENDER vender in lsVenders) |
|
|
//}
|
|
|
{ |
|
|
|
|
|
if (lsCheckVenderID.Count == 0) |
|
|
if (lsCheckVenderID.Count == 0) |
|
|
{ |
|
|
{ |
|
|
uncheckedVenders.Add(vender); |
|
|
uncheckedVenders = lsVenders.OrderBy(p=>p.VendId).ToList(); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
foreach (string venderid in lsCheckVenderID) |
|
|
checkedVenders = lsVenders.Where(q => lsCheckVenderID.Contains(q.VendId)).ToList(); |
|
|
{ |
|
|
uncheckedVenders = lsVenders.Where(q => !lsCheckVenderID.Contains(q.VendId)).OrderBy(p => p.VendId).ToList(); |
|
|
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(); |
|
|
for (int i = 0; i < Grid_Vender.Rows.Count; i++) |
|
|
|
|
|
{ |
|
|
//foreach (VenderUsers vu in _VenderUsers)
|
|
|
if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString()) |
|
|
//{
|
|
|
{ |
|
|
// for (int i = 0; i < Grid_Vender.Rows.Count; i++)
|
|
|
lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString()); |
|
|
// {
|
|
|
} |
|
|
// if (vu.VenderId == Grid_Vender.Rows[i].DataKeys[1].ToString())
|
|
|
} |
|
|
// {
|
|
|
} |
|
|
// lsCheckVenderID.Add(Grid_Vender.Rows[i].DataKeys[1].ToString());
|
|
|
|
|
|
// }
|
|
|
foreach (TA_VENDER vender in lsVenders) |
|
|
// }
|
|
|
{ |
|
|
//}
|
|
|
if (lsCheckVenderID.Count == 0) |
|
|
if (lsCheckVenderID.Count == 0) |
|
|
{ |
|
|
{ |
|
|
uncheckedVenders.Add(vender); |
|
|
uncheckedVenders = lsVenders.OrderBy(p => p.VendId).ToList(); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
foreach (string venderid in lsCheckVenderID) |
|
|
checkedVenders = lsVenders.Where(q => lsCheckVenderID.Contains(q.VendId)).ToList(); |
|
|
{ |
|
|
uncheckedVenders = lsVenders.Where(q => !lsCheckVenderID.Contains(q.VendId)).OrderBy(p => p.VendId).ToList(); |
|
|
if (vender.VendId == venderid) |
|
|
} |
|
|
{ |
|
|
|
|
|
checkedVenders.Add(vender); |
|
|
//foreach (TA_VENDER vender in lsVenders)
|
|
|
} |
|
|
//{
|
|
|
else |
|
|
// if (lsCheckVenderID.Count == 0)
|
|
|
{ |
|
|
// {
|
|
|
uncheckedVenders.Add(vender); |
|
|
// 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(); |
|
|
|
|
|
|
|
@ -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()); |
|
|
} |
|
|
} |
|
|
|
|
|
DB.BulkSaveChanges(); |
|
|
int res = DB.SaveChanges(); |
|
|
|
|
|
if (res >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
Alert.Show("保存成功!"); |
|
|
Alert.Show("保存成功!"); |
|
|
BindVender(); |
|
|
BindVender(); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Alert.Show("保存失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
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("保存成功!"); |
|
|
Alert.Show("保存成功!"); |
|
|
BindVender(); |
|
|
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; |
|
|
|
|
|
int _count = _VenderUsers.Count(p => p.UserId == _vus.UserId && p.VenderId == _vus.VenderId); |
|
|
|
|
|
if (_count == 0) |
|
|
|
|
|
{ |
|
|
_vList.Add(_vus); |
|
|
_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("保存成功!"); |
|
|
Alert.Show("保存成功!"); |
|
|
BindVender(); |
|
|
BindVender(); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Alert.Show("保存失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|