This commit is contained in:
2023-06-27 23:06:59 +08:00
parent 225bc98fcd
commit da7bf97960
3 changed files with 25 additions and 31 deletions
@@ -638,7 +638,7 @@ namespace BLL
var getSitePerson = GetSitePersonByProjectIdPersonId(projectId, personId); var getSitePerson = GetSitePersonByProjectIdPersonId(projectId, personId);
if (getSitePerson != null && string.IsNullOrEmpty(getSitePerson.CardNo)) if (getSitePerson != null && string.IsNullOrEmpty(getSitePerson.CardNo))
{ {
cardNo= SendCarNobySiteperson(getSitePerson); cardNo= SendCarNobySiteperson(getSitePerson.SitePersonId);
} }
return cardNo; return cardNo;
@@ -649,36 +649,39 @@ namespace BLL
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
/// <returns></returns> /// <returns></returns>
public static string SendCarNobySiteperson(Model.SitePerson_Person item) public static string SendCarNobySiteperson(string sitePersonId)
{ {
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
string carNo = string.Empty; string carNo = string.Empty;
var isNull = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.PersonId && x.CheckResult == true); var item = db.SitePerson_Person.FirstOrDefault(x => x.SitePersonId == sitePersonId);
if (isNull != null) ////参加过培训的人员 if (item != null)
{ {
string prefix = UnitService.GetUnitCodeByUnitId(item.UnitId) + "-"; var isNull = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.PersonId && x.CheckResult == true);
var getCarPerson = db.SitePerson_Person.Where(x => x.ProjectId == item.ProjectId && x.CardNo.Contains(prefix) && x.CardNo.Length > 5); if (isNull != null) ////参加过培训的人员
if (getCarPerson.Count() > 0)
{ {
var getMaxCarNo = getCarPerson.Max(x => x.CardNo); string prefix = UnitService.GetUnitCodeByUnitId(item.UnitId) + "-";
if (!string.IsNullOrEmpty(getMaxCarNo) && getMaxCarNo.Length > 5) var getCarPerson = db.SitePerson_Person.Where(x => x.ProjectId == item.ProjectId && x.CardNo.Contains(prefix) && x.CardNo.Length > 5);
if (getCarPerson.Count() > 0)
{ {
var getInt = Funs.GetNewInt(getMaxCarNo.Substring(getMaxCarNo.Length - 5)); var getMaxCarNo = getCarPerson.Max(x => x.CardNo);
if (getInt.HasValue) if (!string.IsNullOrEmpty(getMaxCarNo) && getMaxCarNo.Length > 5)
{ {
carNo= item.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", item.ProjectId, prefix); var getInt = Funs.GetNewInt(getMaxCarNo.Substring(getMaxCarNo.Length - 5));
db.SubmitChanges(); if (getInt.HasValue)
{
carNo = item.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", item.ProjectId, prefix);
db.SubmitChanges();
}
} }
} }
} else
else {
{ carNo = item.CardNo = prefix + "00001";
carNo = item.CardNo = prefix + "00001"; db.SubmitChanges();
db.SubmitChanges(); }
} }
} }
return carNo; return carNo;
} }
} }
+1 -1
View File
@@ -522,7 +522,7 @@ namespace BLL
select x; select x;
foreach (var item in getPersons) foreach (var item in getPersons)
{ {
if (!string.IsNullOrEmpty(SitePerson_PersonService.SendCarNobySiteperson(item))) if (!string.IsNullOrEmpty(SitePerson_PersonService.SendCarNobySiteperson(item.SitePersonId)))
{ {
count++; count++;
} }
@@ -57,17 +57,8 @@ namespace FineUIPro.Web.HSSE.SitePerson
{ {
try try
{ {
var getSitePerson = SitePerson_PersonService.GetSitePersonById(this.StiePersonId); SitePerson_PersonService.SendCarNobySiteperson(this.StiePersonId);
if (getSitePerson != null) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
{
SitePerson_PersonService.SendCarNobySiteperson(getSitePerson);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("发卡未成功!", MessageBoxIcon.Warning);
return;
}
} }
catch catch
{ {