diff --git a/DataBase/版本日志/SGGLDB_V2021-07-23-001.sql b/DataBase/版本日志/SGGLDB_V2021-07-23-001.sql new file mode 100644 index 00000000..1f3ce42f --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2021-07-23-001.sql @@ -0,0 +1,26 @@ +ALTER VIEW [dbo].[View_SitePerson_Checking] +AS +/*Աͼ*/ +SELECT ch.CheckingId +,person.CardNo +,ch.PersonId +,ch.ProjectId +,person.IdentityCard +,ch.WorkAreaId +,ch.IntoOutTime +,ch.IntoOut +,ch.[Address] +,ch.WorkAreaName +,person.PersonName +,person.UnitId +,unit.UnitName +,ch.States +from dbo.SitePerson_Checking ch + left join dbo.SitePerson_Person person on ch.PersonId=person.PersonId + left join dbo.Base_Unit unit on person.UnitId=unit.UnitId + + + +GO + + diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index feb51df1..154270da 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -2761,6 +2761,11 @@ namespace BLL /// 人工时月报模版文件原始的虚拟路径 /// public const string MonthReportTemplateUrl = "File\\Excel\\DataIn\\人工时月报模板.xls"; + + /// + /// 现场人员考勤导入模版 + /// + public const string PersonInfoTemplateUrl = "File\\Excel\\DataIn\\现场人员考勤导入模版.xls"; /// /// 百万工时安全统计月报表模板文件原始虚拟路径 /// diff --git a/SGGL/FineUIPro.Web/File/Excel/DataIn/现场人员考勤导入模版.xls b/SGGL/FineUIPro.Web/File/Excel/DataIn/现场人员考勤导入模版.xls new file mode 100644 index 00000000..a34dd0cf Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/DataIn/现场人员考勤导入模版.xls differ diff --git a/SGGL/FineUIPro.Web/FileUpload/PersonBaseInfo/2021-7/637625705542736742_微信图片_20210720095107.jpg b/SGGL/FineUIPro.Web/FileUpload/PersonBaseInfo/2021-7/637625705542736742_微信图片_20210720095107.jpg new file mode 100644 index 00000000..a7d32814 Binary files /dev/null and b/SGGL/FineUIPro.Web/FileUpload/PersonBaseInfo/2021-7/637625705542736742_微信图片_20210720095107.jpg differ diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index e495e632..4d9dd896 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -1013,6 +1013,7 @@ + @@ -11272,6 +11273,13 @@ PersonInfoEdit.aspx + + PersonInfoIn.aspx + ASPXCodeBehind + + + PersonInfoIn.aspx + PersonList.aspx ASPXCodeBehind diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx index a684125a..750e86be 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx @@ -8,111 +8,119 @@
- - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%-- + Width="300px" LabelAlign="Right" LabelWidth="50px"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs index babdcd05..edc2985a 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.cs @@ -336,6 +336,7 @@ namespace FineUIPro.Web.HSSE.SitePerson if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; + this.btnImport.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnModify)) { @@ -426,5 +427,15 @@ namespace FineUIPro.Web.HSSE.SitePerson { BindGrid(); } + + /// + /// 导入 + /// + /// + /// + protected void btnImport_Click(object sender, EventArgs e) + { + PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PersonInfoIn.aspx", "导入 - "))); + } } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.designer.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.designer.cs index 02531101..86e594f3 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfo.aspx.designer.cs @@ -120,6 +120,15 @@ namespace FineUIPro.Web.HSSE.SitePerson { /// protected global::FineUIPro.Button btnNew; + /// + /// btnImport 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnImport; + /// /// btnOut 控件。 /// @@ -201,6 +210,15 @@ namespace FineUIPro.Web.HSSE.SitePerson { /// protected global::FineUIPro.Window Window1; + /// + /// Window2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window Window2; + /// /// Menu1 控件。 /// diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx index f440675e..1589a912 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx @@ -5,36 +5,36 @@ 编辑现场考勤人员考勤信息 - +
- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + <%-- - - - - - - - - - - - - - - - - - - - - - - - <%-- - --%> - - - - - - - - - - - - - - - - - - - - - - - + --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx.cs index 84da0422..ea9a067e 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoEdit.aspx.cs @@ -70,6 +70,11 @@ namespace FineUIPro.Web.HSSE.SitePerson BindGrid(personInfo.PersonId); this.drpPersonId.Value = personInfo.PersonId; } + this.txtIdCard.Text = personInfo.IdentityCard; + if (!string.IsNullOrEmpty(personInfo.WorkAreaId)) + { + this.drpWorkArea.SelectedValueArray = personInfo.WorkAreaId.Split(','); + } this.txtWorkArea.Text = personInfo.WorkAreaName; this.txtAddress.Text = personInfo.Address; if (personInfo.IntoOutTime != null) @@ -99,16 +104,35 @@ namespace FineUIPro.Web.HSSE.SitePerson { if (!string.IsNullOrEmpty(this.drpPersonId.Value)) { - var person = BLL.PersonService.GetPersonById(this.drpPersonId.Value); - if (person != null) + string[] personIds = this.drpPersonId.Value.Split(','); + string idCards = string.Empty; + string workAreaIds = string.Empty; + string workAreaNames = string.Empty; + foreach (var item in personIds) { - this.txtIdCard.Text = person.IdentityCard; - if (!string.IsNullOrEmpty(person.WorkAreaId)) + var person = BLL.PersonService.GetPersonById(item.Trim()); + if (person != null) { - this.drpWorkArea.SelectedValue = person.WorkAreaId; - this.txtWorkArea.Text = this.drpWorkArea.SelectedItem.Text; + idCards += person.IdentityCard + ","; + workAreaIds += person.WorkAreaId; + if (!string.IsNullOrEmpty(person.WorkAreaId)) + { + workAreaNames += BLL.UnitWorkService.getUnitWorkByUnitWorkId(person.WorkAreaId).UnitWorkName + ","; + } } } + if (!string.IsNullOrEmpty(idCards)) + { + this.txtIdCard.Text = idCards.Substring(0, idCards.LastIndexOf(',')); + } + if (!string.IsNullOrEmpty(workAreaIds)) + { + this.drpWorkArea.SelectedValueArray = workAreaIds.Split(','); + } + if (!string.IsNullOrEmpty(workAreaNames)) + { + this.txtWorkArea.Text = workAreaNames.Substring(0, workAreaNames.LastIndexOf(',')); + } } } #endregion @@ -196,32 +220,67 @@ namespace FineUIPro.Web.HSSE.SitePerson ShowNotify("请选择人员!", MessageBoxIcon.Warning); return; } - Model.SitePerson_Checking personInfo = new Model.SitePerson_Checking + string[] personIds = this.drpPersonId.Value.Split(','); + foreach (var item in personIds) { - PersonId = this.drpPersonId.Value, - IdentityCard = this.txtIdCard.Text, - ProjectId = this.ProjectId, - WorkAreaName = this.txtWorkArea.Text.Trim(), - Address = this.txtAddress.Text.Trim() - }; - string date = string.IsNullOrEmpty(this.txtTime.Text) ? string.Format("{0:yyyy-MM-dd}", DateTime.Now) : this.txtTime.Text.Trim(); - string time = string.IsNullOrEmpty(this.txtTime2.Text) ? string.Format("{0:HH:mm:ss}", DateTime.Now) : this.txtTime2.Text.Trim(); - personInfo.IntoOutTime = Funs.GetNewDateTimeOrNow(date + " " + time); - personInfo.IntoOut = this.drpType.SelectedValue.Trim(); + Model.SitePerson_Checking personInfo = new Model.SitePerson_Checking(); + personInfo.ProjectId = this.ProjectId; + personInfo.PersonId = item.Trim(); + var person = BLL.PersonService.GetPersonById(personInfo.PersonId); + if (person != null) + { + personInfo.IdentityCard = person.IdentityCard; + if (!string.IsNullOrEmpty(person.WorkAreaId)) + { + personInfo.WorkAreaId = person.WorkAreaId; + personInfo.WorkAreaName = BLL.UnitWorkService.getUnitWorkByUnitWorkId(person.WorkAreaId).UnitWorkName; + } + } + personInfo.Address = this.txtAddress.Text.Trim(); + string date = string.IsNullOrEmpty(this.txtTime.Text) ? string.Format("{0:yyyy-MM-dd}", DateTime.Now) : this.txtTime.Text.Trim(); + string time = string.IsNullOrEmpty(this.txtTime2.Text) ? string.Format("{0:HH:mm:ss}", DateTime.Now) : this.txtTime2.Text.Trim(); + personInfo.IntoOutTime = Funs.GetNewDateTimeOrNow(date + " " + time); + personInfo.IntoOut = this.drpType.SelectedValue.Trim(); + if (!string.IsNullOrEmpty(CheckingId)) + { + personInfo.CheckingId = CheckingId; + BLL.SitePerson_CheckingService.UpdatePersonInfo(personInfo); + BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnModify); + } + else + { + //this.CheckingId = SQLHelper.GetNewID(); + personInfo.CheckingId = SQLHelper.GetNewID(); + BLL.SitePerson_CheckingService.AddPersonInfo(personInfo); + BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnDelete); + } + } + //Model.SitePerson_Checking personInfo = new Model.SitePerson_Checking + //{ + // PersonId = this.drpPersonId.Value, + // IdentityCard = this.txtIdCard.Text, + // ProjectId = this.ProjectId, + // WorkAreaName = this.txtWorkArea.Text.Trim(), + // Address = this.txtAddress.Text.Trim() + //}; + //string date = string.IsNullOrEmpty(this.txtTime.Text) ? string.Format("{0:yyyy-MM-dd}", DateTime.Now) : this.txtTime.Text.Trim(); + //string time = string.IsNullOrEmpty(this.txtTime2.Text) ? string.Format("{0:HH:mm:ss}", DateTime.Now) : this.txtTime2.Text.Trim(); + //personInfo.IntoOutTime = Funs.GetNewDateTimeOrNow(date + " " + time); + //personInfo.IntoOut = this.drpType.SelectedValue.Trim(); - if (!string.IsNullOrEmpty(CheckingId)) - { - personInfo.CheckingId = CheckingId; - BLL.SitePerson_CheckingService.UpdatePersonInfo(personInfo); - BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnModify); - } - else - { - this.CheckingId = SQLHelper.GetNewID(); - personInfo.CheckingId = this.CheckingId; - BLL.SitePerson_CheckingService.AddPersonInfo(personInfo); - BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnDelete); - } + //if (!string.IsNullOrEmpty(CheckingId)) + //{ + // personInfo.CheckingId = CheckingId; + // BLL.SitePerson_CheckingService.UpdatePersonInfo(personInfo); + // BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnModify); + //} + //else + //{ + // this.CheckingId = SQLHelper.GetNewID(); + // personInfo.CheckingId = this.CheckingId; + // BLL.SitePerson_CheckingService.AddPersonInfo(personInfo); + // BLL.LogService.AddSys_Log(this.CurrUser, personInfo.CardNo, personInfo.CheckingId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnDelete); + //} PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx new file mode 100644 index 00000000..51de4e7d --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx @@ -0,0 +1,94 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonInfoIn.aspx.cs" Inherits="FineUIPro.Web.HSSE.SitePerson.PersonInfoIn" %> + + + + + + + 现场人员考勤管理导入 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs new file mode 100644 index 00000000..b70942e2 --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.cs @@ -0,0 +1,494 @@ +using BLL; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.OleDb; +using System.IO; +using System.Linq; + +namespace FineUIPro.Web.HSSE.SitePerson +{ + public partial class PersonInfoIn : PageBase + { + #region 定义变量 + /// + /// 上传预设的虚拟路径 + /// + private string initPath = Const.ExcelUrl; + + /// + /// 人员考勤集合 + /// + public static List viewCheckings = new List(); + + /// + /// 错误集合 + /// + public static string errorInfos = string.Empty; + #endregion + + #region 加载页面 + /// + /// 加载页面 + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + this.hdFileName.Text = string.Empty; + this.hdCheckResult.Text = string.Empty; + if (viewCheckings != null) + { + viewCheckings.Clear(); + } + errorInfos = string.Empty; + } + } + #endregion + + #region 审核 + /// + /// 审核 + /// + /// + /// + protected void btnAudit_Click(object sender, EventArgs e) + { + try + { + if (this.fuAttachUrl.HasFile == false) + { + ShowNotify("请您选择Excel文件!", MessageBoxIcon.Warning); + return; + } + string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower(); + if (IsXls != ".xls") + { + ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning); + return; + } + if (viewCheckings!=null) + { + viewCheckings.Clear(); + } + if (!string.IsNullOrEmpty(errorInfos)) + { + errorInfos = string.Empty; + } + string rootPath = Server.MapPath("~/"); + string initFullPath = rootPath + initPath; + if (!Directory.Exists(initFullPath)) + { + Directory.CreateDirectory(initFullPath); + } + + this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls; + string filePath = initFullPath + this.hdFileName.Text; + this.fuAttachUrl.PostedFile.SaveAs(filePath); + ImportXlsToData(rootPath + initPath + this.hdFileName.Text); + } + catch (Exception ex) + { + ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning); + } + } + + #region 读Excel提取数据 + /// + /// 从Excel提取数据--》Dataset + /// + /// Excel文件路径名 + private void ImportXlsToData(string fileName) + { + try + { + string oleDBConnString = String.Empty; + oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"; + oleDBConnString += "Data Source="; + oleDBConnString += fileName; + oleDBConnString += ";Extended Properties=Excel 8.0;"; + OleDbConnection oleDBConn = null; + OleDbDataAdapter oleAdMaster = null; + DataTable m_tableName = new DataTable(); + DataSet ds = new DataSet(); + + oleDBConn = new OleDbConnection(oleDBConnString); + oleDBConn.Open(); + m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); + + if (m_tableName != null && m_tableName.Rows.Count > 0) + { + + m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim(); + + } + string sqlMaster; + sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]"; + oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn); + oleAdMaster.Fill(ds, "m_tableName"); + oleAdMaster.Dispose(); + oleDBConn.Close(); + oleDBConn.Dispose(); + + AddDatasetToSQL(ds.Tables[0], 5); + } + catch (Exception ex) + { + throw ex; + } + } + #endregion + + #region 将Dataset的数据导入数据库 + /// + /// 将Dataset的数据导入数据库 + /// + /// 数据集 + /// 数据集行数 + /// + private bool AddDatasetToSQL(DataTable pds, int Cols) + { + 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; + if (pds != null && ir > 0) + { + var units = from x in Funs.DB.Base_Unit select x; + var sitePersons = from x in Funs.DB.SitePerson_Person where x.ProjectId == this.CurrUser.LoginProjectId select x; + + for (int i = 0; i < ir; i++) + { + string col0 = pds.Rows[i][0].ToString().Trim(); + if (!string.IsNullOrEmpty(col0)) + { + var unit = units.FirstOrDefault(e => e.UnitName == col0); + if (unit != null) + { + 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 + "]不在单位表中!" + "|"; + } + } + string col1 = pds.Rows[i][1].ToString().Trim(); + if (!string.IsNullOrEmpty(col1)) + { + var person = sitePersons.FirstOrDefault(e => e.PersonName == col1); + if (person == null) + { + result += "第" + (i + 2).ToString() + "行," + "姓名" + "," + "[" + col1 + "]不在人员信息表中!" + "|"; + } + } + string col2 = pds.Rows[i][2].ToString().Trim(); + 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() + "行," + "身份证号码" + "," + "此项为必填项!" + "|"; + } + 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 + "]错误!" + "|"; + } + } + } + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.LastIndexOf("|")); + errorInfos = result; + Alert alert = new Alert + { + Message = result, + Target = Target.Self + }; + alert.Show(); + } + else + { + errorInfos = string.Empty; + ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success); + } + } + else + { + ShowNotify("导入数据为空!", MessageBoxIcon.Warning); + } + return true; + } + #endregion + #endregion + + #region 导入 + /// + /// 导入 + /// + /// + /// + protected void btnImport_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(errorInfos)) + { + if (!string.IsNullOrEmpty(this.hdFileName.Text)) + { + string rootPath = Server.MapPath("~/"); + ImportXlsToData2(rootPath + initPath + this.hdFileName.Text); + } + else + { + ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning); + } + } + else + { + Alert.ShowInTop("请先将错误数据修正,再重新导入保存!", MessageBoxIcon.Warning); + } + } + + #region Excel提取数据 + /// + /// 从Excel提取数据--》Dataset + /// + /// Excel文件路径名 + private void ImportXlsToData2(string fileName) + { + try + { + string oleDBConnString = String.Empty; + oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"; + oleDBConnString += "Data Source="; + oleDBConnString += fileName; + oleDBConnString += ";Extended Properties=Excel 8.0;"; + OleDbConnection oleDBConn = null; + OleDbDataAdapter oleAdMaster = null; + DataTable m_tableName = new DataTable(); + DataSet ds = new DataSet(); + + oleDBConn = new OleDbConnection(oleDBConnString); + oleDBConn.Open(); + m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); + + if (m_tableName != null && m_tableName.Rows.Count > 0) + { + + m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim(); + + } + string sqlMaster; + sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]"; + oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn); + oleAdMaster.Fill(ds, "m_tableName"); + oleAdMaster.Dispose(); + oleDBConn.Close(); + oleDBConn.Dispose(); + + AddDatasetToSQL2(ds.Tables[0], 5); + } + catch (Exception ex) + { + throw ex; + } + } + #endregion + + #region 将Dataset的数据导入数据库 + /// + /// 将Dataset的数据导入数据库 + /// + /// 数据集 + /// 数据集列数 + /// + private bool AddDatasetToSQL2(DataTable pds, int Cols) + { + 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; + if (pds != null && ir > 0) + { + var units = from x in Funs.DB.Base_Unit select x; + var sitePersons = from x in Funs.DB.SitePerson_Person where x.ProjectId == this.CurrUser.LoginProjectId select x; + + 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 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)) + { + 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); + } + } + } + if (viewCheckings.Count > 0) + { + this.Grid1.Hidden = false; + this.Grid1.DataSource = viewCheckings; + this.Grid1.DataBind(); + } + } + else + { + ShowNotify("导入数据为空!", MessageBoxIcon.Warning); + } + return true; + } + #endregion + #endregion + + #region 保存 + /// + /// 保存 + /// + /// + /// + protected void btnSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(errorInfos)) + { + int a = viewCheckings.Count(); + for (int i = 0; i < a; i++) + { + Model.SitePerson_Checking newChecking = new Model.SitePerson_Checking + { + CheckingId = viewCheckings[i].CheckingId, + ProjectId = this.CurrUser.LoginProjectId, + 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)) + { + System.IO.File.Delete(filePath);//删除上传的XLS文件 + } + ShowNotify("导入成功!", MessageBoxIcon.Success); + PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); + } + else + { + Alert.ShowInTop("请先将错误数据修正,再重新导入保存!", MessageBoxIcon.Warning); + } + } + #endregion + + #region 下载模板 + /// + /// 下载模板按钮 + /// + /// + /// + protected void btnDownLoad_Click(object sender, EventArgs e) + { + PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载导入模板吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel"))); + } + + /// + /// 下载导入模板 + /// + /// + /// + protected void PageManager1_CustomEvent(object sender, CustomEventArgs e) + { + if (e.EventArgument == "Confirm_OK") + { + string rootPath = Server.MapPath("~/"); + string uploadfilepath = rootPath + Const.PersonInfoTemplateUrl; + string filePath = Const.PersonInfoTemplateUrl; + string fileName = Path.GetFileName(filePath); + FileInfo info = new FileInfo(uploadfilepath); + long fileSize = info.Length; + Response.ClearContent(); + Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.ContentType = "excel/plain"; + Response.ContentEncoding = System.Text.Encoding.UTF8; + Response.AddHeader("Content-Length", fileSize.ToString().Trim()); + Response.TransmitFile(uploadfilepath, 0, fileSize); + Response.End(); + } + } + #endregion + + #region 转换字符串 + /// + /// 把进出转换为字符串类型 + /// + /// + /// + protected string ConvertIntoOut(object intoOut) + { + if (intoOut != null) + { + if (Convert.ToBoolean(intoOut) == true) + { + return "进场"; + } + else + { + return "出场"; + } + } + return ""; + } + #endregion + } +} \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.designer.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.designer.cs new file mode 100644 index 00000000..878fcdba --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonInfoIn.aspx.designer.cs @@ -0,0 +1,159 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.HSSE.SitePerson { + + + public partial class PersonInfoIn { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// SimpleForm1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Form SimpleForm1; + + /// + /// Toolbar2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar2; + + /// + /// ToolbarFill1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarFill ToolbarFill1; + + /// + /// btnAudit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnAudit; + + /// + /// btnImport 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnImport; + + /// + /// btnSave 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnSave; + + /// + /// btnDownLoad 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnDownLoad; + + /// + /// fuAttachUrl 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.FileUpload fuAttachUrl; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// Label2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label Label2; + + /// + /// lblIntoOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblIntoOut; + + /// + /// hdFileName 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.HiddenField hdFileName; + + /// + /// hdCheckResult 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.HiddenField hdCheckResult; + + /// + /// lblBottom 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Label lblBottom; + } +} diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx index c9fcac18..04e4e3b2 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx @@ -123,9 +123,9 @@ - - + <%-- + --%> diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs index c6273111..b006b4c8 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs @@ -184,10 +184,17 @@ namespace FineUIPro.Web.HSSE.SitePerson { new SqlParameter("@ProjectId", this.ProjectId) }; - if (!string.IsNullOrEmpty(unitId) && unitId != "0") + if (!string.IsNullOrEmpty(unitId)) { - strSql += " AND UnitId =@UnitId "; - listStr.Add(new SqlParameter("@UnitId", unitId)); + if (unitId == "0") + { + strSql += " AND UnitId IS NULL "; + } + else + { + strSql += " AND UnitId =@UnitId "; + listStr.Add(new SqlParameter("@UnitId", unitId)); + } } if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim())) { diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx index 0e352dc9..30f1cbd5 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx @@ -12,6 +12,7 @@ .userphoto img { width: 100%; + height:auto; } .uploadbutton .f-btn { @@ -158,6 +159,7 @@ + diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx.cs index 64b8b3a8..513a7750 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListEdit.aspx.cs @@ -1,6 +1,7 @@ using BLL; using Newtonsoft.Json.Linq; using System; +using System.IO; using System.Linq; namespace FineUIPro.Web.HSSE.SitePerson @@ -618,7 +619,18 @@ namespace FineUIPro.Web.HSSE.SitePerson fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = DateTime.Now.Ticks.ToString() + "_" + fileName; string url = "~/FileUpload/PersonBaseInfo/" + DateTime.Now.Year + "-" + DateTime.Now.Month + "/"; - filePhoto.SaveAs(Server.MapPath(url + fileName)); + string fileMapPath = Server.MapPath(url + fileName); + filePhoto.SaveAs(fileMapPath); + if (File.Exists(fileMapPath)) + { + FileInfo fileInfo = new FileInfo(fileMapPath); + double size = Math.Ceiling(fileInfo.Length * 1.0 / 1024.0); + if (size > 300) + { + Alert.ShowInTop("照片大小超过300KB,请重新上传!", MessageBoxIcon.Warning); + return; + } + } imgPhoto.ImageUrl = url + fileName; // 清空文件上传组件 filePhoto.Reset(); diff --git a/SGGL/Model/Model.cs b/SGGL/Model/Model.cs index dfd305ba..bebef70f 100644 --- a/SGGL/Model/Model.cs +++ b/SGGL/Model/Model.cs @@ -325791,6 +325791,8 @@ namespace Model private string _CardNo; + private string _PersonId; + private string _ProjectId; private string _IdentityCard; @@ -325799,7 +325801,7 @@ namespace Model private System.Nullable _IntoOutTime; - private System.Nullable _IntoOut; + private string _IntoOut; private string _Address; @@ -325849,6 +325851,22 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PersonId", DbType="NVarChar(50)")] + public string PersonId + { + get + { + return this._PersonId; + } + set + { + if ((this._PersonId != value)) + { + this._PersonId = value; + } + } + } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")] public string ProjectId { @@ -325881,7 +325899,7 @@ namespace Model } } - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaId", DbType="NVarChar(MAX)", UpdateCheck=UpdateCheck.Never)] + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaId", DbType="NVarChar(50)")] public string WorkAreaId { get @@ -325913,8 +325931,8 @@ namespace Model } } - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IntoOut", DbType="Bit")] - public System.Nullable IntoOut + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IntoOut", DbType="Char(1)")] + public string IntoOut { get { @@ -325945,7 +325963,7 @@ namespace Model } } - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaName", DbType="NVarChar(500)")] + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaName", DbType="NVarChar(100)")] public string WorkAreaName { get @@ -326009,7 +326027,7 @@ namespace Model } } - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_States", DbType="VarChar(1)")] + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_States", DbType="Char(1)")] public string States { get