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" <f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="现场人员考勤管理" EnableCollapse="true"
runat="server" BoxFlex="1" DataKeyNames="CheckingId" DataIDField="CheckingId" AllowSorting="true" SortField="IntoOutTime" runat="server" BoxFlex="1" DataKeyNames="CheckingId" DataIDField="CheckingId" AllowSorting="true" SortField="IntoOutTime"
SortDirection="DESC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true" ForceFit="true" 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"> OnRowDoubleClick="Grid1_RowDoubleClick" EnableRowDoubleClickEvent="True">
<Toolbars> <Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server"> <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.SelectedValue = this.CurrUser.UnitId;
this.drpUnit.Enabled = false; this.drpUnit.Enabled = false;
} }
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-1)); this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddMinutes(1)); this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(1));
// 绑定表格 // 绑定表格
BindGrid(); BindGrid();
} }

View File

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