diff --git a/SGGL/FineUIPro.Web/File/Excel/Temp/202108211005342003.xls b/SGGL/FineUIPro.Web/File/Excel/Temp/202108211005342003.xls new file mode 100644 index 00000000..31c5530d Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/Temp/202108211005342003.xls differ diff --git a/SGGL/FineUIPro.Web/File/Excel/Temp/202108211050408504.xls b/SGGL/FineUIPro.Web/File/Excel/Temp/202108211050408504.xls new file mode 100644 index 00000000..08031425 Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/Temp/202108211050408504.xls differ diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx index c0313107..b4e90ec9 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx @@ -15,7 +15,7 @@ diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs index 46b82702..97144785 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs @@ -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(); } diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs index 5882e999..9995d333 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs @@ -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的数据导入数据库 /// /// 数据集 - /// 数据集行数 /// - 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 /// 数据集 /// 数据集列数 /// - 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)