20220601 修改Global调用定时器、修改考勤导入列表及导入方法

This commit is contained in:
2022-06-01 14:27:42 +08:00
parent d33b007348
commit 31a7840cda
15 changed files with 365 additions and 210 deletions
@@ -324,8 +324,11 @@ namespace FineUIPro.Web.HSSE.SitePerson
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0]);
var isok = AddDatasetToSQL2(ds.Tables[0]);
if (isok)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
catch (Exception ex)
{
@@ -333,10 +336,10 @@ namespace FineUIPro.Web.HSSE.SitePerson
}
}
#endregion
/// <summary>
/// 人员考勤集合
/// </summary>
public static List<Model.View_SitePerson_Checking> viewCheckings = new List<Model.View_SitePerson_Checking>();
///// <summary>
///// 人员考勤集合
///// </summary>
//public static List<Model.View_SitePerson_Checking> viewCheckings = new List<Model.View_SitePerson_Checking>();
#region Dataset的数据导入数据库
/// <summary>
@@ -347,7 +350,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds)
{
viewCheckings.Clear();
List<Model.SitePerson_Checking> newCheckings = new List<Model.SitePerson_Checking>();
int ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
@@ -363,7 +366,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
string col4 = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrEmpty(col2) && !string.IsNullOrEmpty(col3) && !string.IsNullOrEmpty(col4))
{
Model.View_SitePerson_Checking checking = new Model.View_SitePerson_Checking
Model.SitePerson_Checking newChecking = new Model.SitePerson_Checking
{
UnitName = col0,
PersonName = col1,
@@ -371,27 +374,47 @@ namespace FineUIPro.Web.HSSE.SitePerson
IntoOut = col3 == "进" ? "1" : "0",
IntoOutTime = Convert.ToDateTime(col4)
};
var person = sitePersons.FirstOrDefault(x => x.IdentityCard == checking.IdentityCard);
var person = sitePersons.FirstOrDefault(x => x.IdentityCard == newChecking.IdentityCard);
if (person != null)
{
checking.PersonId = person.PersonId;
checking.ProjectId = person.ProjectId;
checking.CheckingId = SQLHelper.GetNewID();
viewCheckings.Add(checking);
newChecking.ProjectId = person.ProjectId;
newChecking.UnitId = person.UnitId;
newChecking.PersonId = person.PersonId;
newChecking.CardNo = person.CardNo;
newChecking.PersonName = person.PersonName;
newChecking.WorkAreaId = person.WorkAreaId;
if (!string.IsNullOrEmpty(person.WorkAreaId))
{
newChecking.WorkAreaName = UnitWorkService.GetUnitWorkName(person.WorkAreaId);
}
newChecking.CheckingId = SQLHelper.GetNewID();
newCheckings.Add(newChecking);
BLL.SitePerson_CheckingService.AddPersonInfo(newChecking);
}
}
}
if (viewCheckings.Count > 0)
if (newCheckings.Count > 0)
{
this.Grid1.Hidden = false;
this.Grid1.DataSource = viewCheckings;
this.Grid1.DataSource = newCheckings;
this.Grid1.DataBind();
ShowNotify("导入成功!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
string filePath = initFullPath + this.hdFileName.Text;
if (filePath != string.Empty && System.IO.File.Exists(filePath))
{
File.Delete(filePath);//删除上传的XLS文件
}
return true;
}
#endregion
@@ -405,53 +428,39 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(errorInfos))
{
foreach (var item in viewCheckings)
{
var getCheck = Funs.DB.SitePerson_Checking.FirstOrDefault(x => x.CheckingId == item.CheckingId);
if (getCheck == null)
{
Model.SitePerson_Checking newChecking = new Model.SitePerson_Checking
{
CheckingId = item.CheckingId,
ProjectId = item.ProjectId,
IdentityCard = item.IdentityCard,
IntoOutTime = item.IntoOutTime,
IntoOut = item.IntoOut,
PersonId = item.PersonId
};
BLL.SitePerson_CheckingService.AddPersonInfo(newChecking);
}
}
//int a = viewCheckings.Count();
//for (int i = 0; i < a; i++)
//{
// Model.SitePerson_Checking newChecking = new Model.SitePerson_Checking
// {
// CheckingId = viewCheckings[i].CheckingId,
// ProjectId = viewCheckings[i].ProjectId,
// IdentityCard = viewCheckings[i].IdentityCard,
// IntoOutTime = viewCheckings[i].IntoOutTime,
// IntoOut = viewCheckings[i].IntoOut,
// PersonId = viewCheckings[i].PersonId
// };
// BLL.SitePerson_CheckingService.AddPersonInfo(newChecking);
//}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
string filePath = initFullPath + this.hdFileName.Text;
if (filePath != string.Empty && System.IO.File.Exists(filePath))
{
File.Delete(filePath);//删除上传的XLS文件
}
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop("请先将错误数据修正,再重新导入保存!", MessageBoxIcon.Warning);
}
//if (string.IsNullOrEmpty(errorInfos))
//{
// foreach (var item in viewCheckings)
// {
// var getCheck = Funs.DB.SitePerson_Checking.FirstOrDefault(x => x.CheckingId == item.CheckingId);
// if (getCheck == null)
// {
// Model.SitePerson_Checking newChecking = new Model.SitePerson_Checking
// {
// CheckingId = item.CheckingId,
// ProjectId = item.ProjectId,
// IdentityCard = item.IdentityCard,
// IntoOutTime = item.IntoOutTime,
// IntoOut = item.IntoOut,
// PersonId = item.PersonId
// };
// BLL.SitePerson_CheckingService.AddPersonInfo(newChecking);
// }
// }
// string rootPath = Server.MapPath("~/");
// string initFullPath = rootPath + initPath;
// string filePath = initFullPath + this.hdFileName.Text;
// if (filePath != string.Empty && System.IO.File.Exists(filePath))
// {
// File.Delete(filePath);//删除上传的XLS文件
// }
// ShowNotify("导入成功!", MessageBoxIcon.Success);
// PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
//}
//else
//{
// Alert.ShowInTop("请先将错误数据修正,再重新导入保存!", MessageBoxIcon.Warning);
//}
}
#endregion