This commit is contained in:
杨红卫 2021-08-21 10:53:31 +08:00
parent 64655b051c
commit 21b3fd1b44
5 changed files with 76 additions and 89 deletions

View File

@ -15,7 +15,7 @@
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="现场人员考勤管理" EnableCollapse="true"
runat="server" BoxFlex="1" DataKeyNames="CheckingId" DataIDField="CheckingId" AllowSorting="true" SortField="IntoOutTime"
SortDirection="DESC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true" ForceFit="true"
PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" EnableColumnLines="true" EnableTextSelection="True"
OnPageIndexChange="Grid1_PageIndexChange" EnableColumnLines="true" EnableTextSelection="True"
OnRowDoubleClick="Grid1_RowDoubleClick" EnableRowDoubleClickEvent="True">
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server">

View File

@ -63,8 +63,8 @@ namespace FineUIPro.Web.HSSE.SitePerson
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
this.drpUnit.Enabled = false;
}
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-1));
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddMinutes(1));
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(1));
// 绑定表格
BindGrid();
}

View File

@ -132,7 +132,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 5);
AddDatasetToSQL(ds.Tables[0]);
}
catch (Exception ex)
{
@ -146,18 +146,11 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
private bool AddDatasetToSQL(DataTable pds)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
Alert.ShowInTop("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
}
ir = pds.Rows.Count;
int ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var units = from x in Funs.DB.Base_Unit select x;
@ -166,62 +159,65 @@ namespace FineUIPro.Web.HSSE.SitePerson
for (int i = 0; i < ir; i++)
{
string col0 = pds.Rows[i][0].ToString().Trim();
if (!string.IsNullOrEmpty(col0))
string col1 = pds.Rows[i][1].ToString().Trim();
string col2 = pds.Rows[i][2].ToString().Trim();
string col3 = pds.Rows[i][3].ToString().Trim();
string col4 = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrEmpty(col2) && !string.IsNullOrEmpty(col3) && !string.IsNullOrEmpty(col4))
{
var unit = units.FirstOrDefault(e => e.UnitName == col0);
if (unit != null)
if (!string.IsNullOrEmpty(col0))
{
var projectUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == unit.UnitId);
if (projectUnit == null)
var unit = units.FirstOrDefault(e => e.UnitName == col0);
if (unit != null)
{
result += "第" + (i + 2).ToString() + "行," + "单位" + "," + "[" + col0 + "]不在本项目中!" + "|";
var projectUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == unit.UnitId);
if (projectUnit == null)
{
result += "第" + (i + 2).ToString() + "行," + "单位" + "," + "[" + col0 + "]不在本项目中!" + "|";
}
}
else
{
result += "第" + (i + 2).ToString() + "行," + "单位" + "," + "[" + col0 + "]不在单位表中!" + "|";
}
}
if (!string.IsNullOrEmpty(col1))
{
var person = sitePersons.FirstOrDefault(e => e.PersonName == col1);
if (person == null)
{
result += "第" + (i + 2).ToString() + "行," + "姓名" + "," + "[" + col1 + "]不在人员信息表中!" + "|";
}
}
if (!string.IsNullOrEmpty(col2))
{
var person = sitePersons.FirstOrDefault(e => e.IdentityCard == col2);
if (person == null)
{
result += "第" + (i + 2).ToString() + "行," + "身份证号码" + "," + "[" + col2 + "]错误!" + "|";
}
}
else
{
result += "第" + (i + 2).ToString() + "行," + "单位" + "," + "[" + col0 + "]不在单位表中!" + "|";
result += "第" + (i + 2).ToString() + "行," + "身份证号码" + "," + "此项为必填项" + "|";
}
}
string col1 = pds.Rows[i][1].ToString().Trim();
if (!string.IsNullOrEmpty(col1))
{
var person = sitePersons.FirstOrDefault(e => e.PersonName == col1);
if (person == null)
if (!string.IsNullOrEmpty(col3))
{
result += "第" + (i + 2).ToString() + "行," + "姓名" + "," + "[" + col1 + "]不在人员信息表中!" + "|";
if (col3 != "进" && col3 != "出")
{
result += "第" + (i + 2).ToString() + "行," + "进/出" + "," + "[" + col3 + "]错误!" + "|";
}
}
}
string col2 = pds.Rows[i][2].ToString().Trim();
if (!string.IsNullOrEmpty(col2))
{
var person = sitePersons.FirstOrDefault(e => e.IdentityCard == col2);
if (person == null)
if (!string.IsNullOrEmpty(col4))
{
result += "第" + (i + 2).ToString() + "行," + "身份证号码" + "," + "[" + col2 + "]错误!" + "|";
}
}
else
{
result += "第" + (i + 2).ToString() + "行," + "身份证号码" + "," + "此项为必填项!" + "|";
}
string col3 = pds.Rows[i][3].ToString().Trim();
if (!string.IsNullOrEmpty(col3))
{
if (col3 != "进" && col3 != "出")
{
result += "第" + (i + 2).ToString() + "行," + "进/出" + "," + "[" + col3 + "]错误!" + "|";
}
}
string col4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(col4))
{
try
{
DateTime inToOutTime = Convert.ToDateTime(col4);
}
catch (Exception)
{
result += "第" + (i + 2).ToString() + "行," + "时间" + "," + "[" + col4 + "]错误!" + "|";
try
{
DateTime inToOutTime = Convert.ToDateTime(col4);
}
catch (Exception)
{
result += "第" + (i + 2).ToString() + "行," + "时间" + "," + "[" + col4 + "]错误!" + "|";
}
}
}
}
@ -314,7 +310,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 5);
AddDatasetToSQL2(ds.Tables[0]);
}
catch (Exception ex)
{
@ -330,17 +326,10 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
private bool AddDatasetToSQL2(DataTable pds)
{
int ic, ir;
viewCheckings.Clear();
ic = pds.Columns.Count;
if (ic < Cols)
{
Alert.ShowInTop("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
ir = pds.Rows.Count;
viewCheckings.Clear();
int ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var units = from x in Funs.DB.Base_Unit select x;
@ -348,30 +337,28 @@ namespace FineUIPro.Web.HSSE.SitePerson
for (int i = 0; i < ir; i++)
{
string col0 = pds.Rows[i][0].ToString().Trim();
string col1 = pds.Rows[i][1].ToString().Trim();
string col2 = pds.Rows[i][2].ToString().Trim();
if (!string.IsNullOrEmpty(col2))
string col3 = pds.Rows[i][3].ToString().Trim();
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();
string col0 = pds.Rows[i][0].ToString().Trim();
string col1 = pds.Rows[i][1].ToString().Trim();
string col3 = pds.Rows[i][3].ToString().Trim();
string col4 = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrEmpty(col2))
Model.View_SitePerson_Checking checking = new Model.View_SitePerson_Checking
{
checking.UnitName = col0;
checking.PersonName = col1;
checking.IdentityCard = col2;
checking.IntoOut = col3 == "进" ? "1" : "0";
checking.IntoOutTime = Convert.ToDateTime(col4);
var person = BLL.PersonService.GetPersonByIdentityCard(this.CurrUser.LoginProjectId, checking.IdentityCard);
if (person != null)
{
checking.PersonId = person.PersonId;
}
checking.CheckingId = SQLHelper.GetNewID(typeof(Model.SitePerson_Checking));
viewCheckings.Add(checking);
UnitName = col0,
PersonName = col1,
IdentityCard = col2,
IntoOut = col3 == "进" ? "1" : "0",
IntoOutTime = Convert.ToDateTime(col4)
};
var person = BLL.PersonService.GetPersonByIdentityCard(this.CurrUser.LoginProjectId, checking.IdentityCard);
if (person != null)
{
checking.PersonId = person.PersonId;
}
checking.CheckingId = SQLHelper.GetNewID(typeof(Model.SitePerson_Checking));
viewCheckings.Add(checking);
}
}
if (viewCheckings.Count > 0)