440 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			440 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using BLL;
 | |
| using System.IO;
 | |
| using AspNet = System.Web.UI.WebControls;
 | |
| 
 | |
| namespace FineUIPro.Web.HJGL.MaterialManage
 | |
| {
 | |
|     public partial class ElectrodeRecovery : PageBase
 | |
|     {
 | |
|         #region 加载页面
 | |
|         /// <summary>
 | |
|         /// 加载页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             // 表头过滤
 | |
|             FilterDataRowItem = FilterDataRowItemImplement;
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 //删除人脸识别保存的附件图片
 | |
|                 string strFolderPath = Funs.RootPath + "FileUpload";
 | |
|                 var lstFiles = new List<string>();
 | |
|                 lstFiles = Directory.GetFiles(strFolderPath, "*.jpg").ToList();
 | |
|                 foreach (var lstFile in lstFiles)
 | |
|                 {
 | |
|                     if (File.Exists(lstFile))
 | |
|                     {
 | |
|                         File.Delete(lstFile);
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); 
 | |
|                 // 绑定表格
 | |
|                 this.BindGrid();
 | |
|             }
 | |
|             else if (GetRequestEventArgument() == "reloadGrid")
 | |
|             {
 | |
|                 this.BindGrid();
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 绑定数据
 | |
|         /// <summary>
 | |
|         /// 绑定数据
 | |
|         /// </summary>
 | |
|         private void BindGrid()
 | |
|         {
 | |
|             //string strSql = @"SELECT ElectrodeRecovery.ElectrodeRecoveryId,ElectrodeRecovery.ElectrodeRecoveryCode,ElectrodeRecovery.ElectrodeRecoveryDate,ElectrodeRecovery.CompileDate,CompileManUser.UserName AS CompileManName,Project.ProjectId,Project.ProjectName"
 | |
|             //    + @" ,ElectrodeRecovery.AuditDate,AuditManUser.UserName AS AuditManName"
 | |
|             //    + @" FROM HJGL_ElectrodeRecovery AS ElectrodeRecovery"
 | |
|             //    + @" LEFT JOIN Sys_User AS CompileManUser ON ElectrodeRecovery.CompileMan=CompileManUser.UserId"
 | |
|             //    + @" LEFT JOIN Sys_User AS AuditManUser ON ElectrodeRecovery.AuditMan=AuditManUser.UserId"
 | |
|             //    + @" LEFT JOIN Base_Project AS Project ON ElectrodeRecovery.ProjectId=Project.ProjectId"
 | |
|             //+ @" WHERE ElectrodeRecovery.ProjectId= @ProjectId";
 | |
|             string strSql = @"SELECT ElectrodeRecoveryId,ElectrodeRecoveryItemID,CompileDate,ElectrodeRecoveryCode,ElectrodeRecoveryDate,WelderCode,WED_Name,UnitName,ProjectName,WorkAreaName,CnProfession,Equipment"
 | |
|                           + @",WMT_MatName,STE_Name,WMT_MatType,Specifications,RecipientsCount,AuditDate,RoleAuditManName,AuditManName,ProjectId,AuditMan"
 | |
|                           + @" FROM dbo.HJGL_View_ElectrodeRecovery"
 | |
|                           + @" WHERE Type=1 and RecipientsCount is not null and ProjectId= @ProjectId";
 | |
| 
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
|             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | |
|             if (!string.IsNullOrEmpty(this.txtElectrodeRecoveryCode.Text.Trim()))
 | |
|             {
 | |
|                 strSql += " AND ElectrodeRecoveryCode LIKE @ElectrodeRecoveryCode";
 | |
|                 listStr.Add(new SqlParameter("@ElectrodeRecoveryCode", "%" + this.txtElectrodeRecoveryCode.Text.Trim() + "%"));
 | |
|             }
 | |
| 
 | |
|             if (!string.IsNullOrEmpty(this.txtStartTime.Text))
 | |
|             {
 | |
|                 strSql += " AND ElectrodeRecoveryDate >= @ElectrodeRecoveryStartDate";
 | |
|                 listStr.Add(new SqlParameter("@ElectrodeRecoveryStartDate", Funs.GetNewDateTime(this.txtStartTime.Text.Trim())));
 | |
|             }
 | |
| 
 | |
|             if (!string.IsNullOrEmpty(this.txtEndTime.Text))
 | |
|             {
 | |
|                 strSql += " AND ElectrodeRecoveryDate < @ElectrodeRecoveryEndDate";
 | |
|                 listStr.Add(new SqlParameter("@ElectrodeRecoveryEndDate", Funs.GetNewDateTime(this.txtEndTime.Text.Trim()).Value.AddDays(1)));
 | |
|             }
 | |
| 
 | |
|             //if ((this.cbIsAudit.Items[0].Selected && !this.cbIsAudit.Items[1].Selected))
 | |
|             //{
 | |
|             //    strSql += " AND (AuditDate IS NULL OR AuditMan IS NULL)";
 | |
|             //}
 | |
|             //if ((this.cbIsAudit.Items[1].Selected && !this.cbIsAudit.Items[0].Selected))
 | |
|             //{
 | |
|             //    strSql += " AND (AuditDate IS NOT NULL AND AuditMan IS NOT NULL)";
 | |
|             //}
 | |
| 
 | |
|             SqlParameter[] parameter = listStr.ToArray();
 | |
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | |
| 
 | |
|             // 2.获取当前分页数据
 | |
|             //var table = this.GetPagedDataTable(Grid1, tb1);
 | |
|             Grid1.RecordCount = tb.Rows.Count;
 | |
|             tb = GetFilteredTable(Grid1.FilteredData, tb);
 | |
|             var table = this.GetPagedDataTable(Grid1, tb);
 | |
| 
 | |
|             Grid1.DataSource = table;
 | |
|             Grid1.DataBind();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 增加焊条发放回收记录
 | |
|         /// <summary>
 | |
|         /// 增加焊条发放回收记录
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnNew_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ElectrodeRecoveryMenuId, Const.BtnAdd))
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ElectrodeRecoveryEdit.aspx?ElectrodeRecoveryId={0}", string.Empty, "新增 - ")));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 删除数据
 | |
|         /// <summary>
 | |
|         /// 右键删除事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuDelete_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.DeleteData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 删除方法
 | |
|         /// </summary>
 | |
|         private void DeleteData()
 | |
|         {
 | |
|             if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ElectrodeRecoveryMenuId, Const.BtnDelete))
 | |
|             {
 | |
|                 if (Grid1.SelectedRowIndexArray.Length > 0)
 | |
|                 {
 | |
|                     foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | |
|                     {
 | |
|                         string ElectrodeRecoveryId = Grid1.DataKeys[rowIndex][0].ToString();
 | |
|                         Model.HJGL_ElectrodeRecovery electrodeRecovery = Funs.DB.HJGL_ElectrodeRecovery.First(e => e.ElectrodeRecoveryId == ElectrodeRecoveryId);
 | |
|                       
 | |
|                         BLL.HJGL_ElectrodeRecoveryService.DeleteElectrodeRecoveryItem(this.CurrUser.LoginProjectId, electrodeRecovery.UnitId, ElectrodeRecoveryId);
 | |
|                         // BLL.HJGL_ElectrodeRecoveryService.DeleteElectrodeRecovery(ElectrodeRecoveryId); 
 | |
|                         Funs.DB.HJGL_ElectrodeRecovery.DeleteOnSubmit(electrodeRecovery);
 | |
|                         Funs.DB.SubmitChanges();
 | |
|                         //BLL.Sys_LogService.AddLog(BLL.Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊丝烘烤记录!");
 | |
|                     }
 | |
|                 }
 | |
|                 this.BindGrid();
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 数据编辑事件
 | |
|         /// <summary>
 | |
|         /// Grid行双击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 右键编辑事件通过
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuEdit_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 编辑方法
 | |
|         /// </summary>
 | |
|         private void EditData()
 | |
|         {
 | |
|             var electr = BLL.HJGL_ElectrodeRecoveryService.GetElectrodeRecoveryByItemID(Grid1.SelectedRowID);
 | |
|             if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ElectrodeRecoveryMenuId, Const.BtnSave))
 | |
|             {
 | |
|                 if (Grid1.SelectedRowIndexArray.Length == 0)
 | |
|                 {
 | |
|                     Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
 | |
|                     return;
 | |
|                 }
 | |
|  
 | |
|                 if (electr != null)
 | |
|                 {
 | |
|                     //if (electr.AuditDate.HasValue && !string.IsNullOrEmpty(electr.AuditMan))
 | |
|                     //{
 | |
|                     //    PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ElectrodeRecoveryView.aspx?ElectrodeRecoveryId={0}", Grid1.SelectedRowID, "查看 - ")));
 | |
| 
 | |
|                     //}
 | |
|                     //else
 | |
|                     {
 | |
|                         PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ElectrodeRecoveryEdit.aspx?ElectrodeRecoveryId={0}", electr.ElectrodeRecoveryId, "编辑 - ")));
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ElectrodeRecoveryView.aspx?ElectrodeRecoveryId={0}", electr.ElectrodeRecoveryId, "查看 - ")));
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 批量审核事件
 | |
|         /// <summary>
 | |
|         /// 右键编辑事件通过
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnBatch_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ElectrodeRecoveryMenuId, Const.BtnSave))
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ElectrodeRecoveryBatch.aspx", "查看 - ")));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 关闭弹出窗口
 | |
|         /// <summary>
 | |
|         /// 关闭弹出窗口
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Window2_Close(object sender, WindowCloseEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 分页 排序
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             this.BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
 | |
|             this.BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | |
|         {
 | |
|             this.BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 过滤表头
 | |
|         /// <summary>
 | |
|         /// 过滤表头
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_FilterChange(object sender, EventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据表头信息过滤列表数据
 | |
|         /// </summary>
 | |
|         /// <param name="sourceObj"></param>
 | |
|         /// <param name="fillteredOperator"></param>
 | |
|         /// <param name="fillteredObj"></param>
 | |
|         /// <param name="column"></param>
 | |
|         /// <returns></returns>
 | |
|         private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column)
 | |
|         {
 | |
|             bool valid = false;
 | |
|             if (column == "WelderCode")
 | |
|             {
 | |
|                 string sourceValue = sourceObj.ToString();
 | |
|                 string fillteredValue = fillteredObj.ToString();
 | |
|                 if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | |
|                 {
 | |
|                     valid = true;
 | |
|                 }
 | |
|                 else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | |
|                 {
 | |
|                     valid = true;
 | |
|                 }
 | |
|             }
 | |
|             return valid;
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region Grid行点击事件
 | |
|         /// <summary>
 | |
|         /// Grid行点击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
 | |
|         {
 | |
|             string electrodeRecoveryId = Grid1.DataKeys[e.RowIndex][0].ToString();
 | |
|             if (!string.IsNullOrEmpty(electrodeRecoveryId))
 | |
|             {
 | |
|                 if (e.CommandName == "print")
 | |
|                 {
 | |
|                     //ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>WelderRecordPrint('" + newElectrodeRecovery.ElectrodeRecoveryId + "','" + Request.Params["fileName"] + "','" + Request.Params["identityCard"] + "');</script>");
 | |
|                     Model.HJGL_ElectrodeRecoveryItem electrodeRecoveryItem = BLL.HJGL_ElectrodeRecoveryService.GetElectrodeRecoveryItemByRecoveryID(electrodeRecoveryId)[0];
 | |
|                     Model.BS_Welder welder = BLL.WelderService.GetWelderByCode(this.CurrUser.LoginProjectId,electrodeRecoveryItem.WelderCode);
 | |
|                     if (welder != null)
 | |
|                     {
 | |
|                         //var proccess = new RLSBProccess();
 | |
|                         //string fileName = proccess.GetImageByLabel(welder.IdentityCard);
 | |
|                         //if (fileName == "未找到匹配的图片")
 | |
|                         //{
 | |
|                         //    fileName = string.Empty;
 | |
|                         //}
 | |
|                         //PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("WelderRecordPrint.aspx?electrodeRecoveryId={0}&fileName={1}&identityCard={2}", electrodeRecoveryId, fileName, welder.IdentityCard, "打印 - ")));
 | |
|                         //PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("../../RLSB/WelderRecordPrint.aspx?electrodeRecoveryId={0}&fileName={1}&identityCard={2}&noAuto={3}", electrodeRecoveryId, fileName, welder.IdentityCard,"noAuto", "打印 - ")));
 | |
|                         //PageContext.RegisterStartupScript(String.Format("WelderRecordPrint('"+electrodeRecoveryId+"','"+fileName+"','"+welder.IdentityCard+"','noAuto');"));
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         ShowNotify("焊工不存在!", MessageBoxIcon.Warning);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 查询
 | |
|         /// <summary>
 | |
|         /// 查询
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void TextBox_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             this.BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 导出按钮
 | |
|         /// 导出按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnOut_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Response.ClearContent();
 | |
|             string filename = Funs.GetNewFileName();
 | |
|             Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊材发放记录" + filename, System.Text.Encoding.UTF8) + ".xls");
 | |
|             Response.ContentType = "application/excel";
 | |
|             Response.ContentEncoding = System.Text.Encoding.UTF8;
 | |
|             Response.Write(GetGridTableHtml(Grid1));
 | |
|             Response.End();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 导出方法
 | |
|         /// </summary>
 | |
|         /// <param name="grid"></param>
 | |
|         /// <returns></returns>
 | |
|         private string GetGridTableHtml(Grid grid)
 | |
|         {
 | |
|             this.Grid1.PageSize = 10000;
 | |
|             BindGrid();
 | |
|             StringBuilder sb = new StringBuilder();
 | |
|             sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/><html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
 | |
|             sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
 | |
|             sb.Append("<tr>");
 | |
|             foreach (GridColumn column in grid.Columns)
 | |
|             {
 | |
|                 if (column.ColumnID != "Print")
 | |
|                 {
 | |
|                     sb.AppendFormat("<td>{0}</td>", column.HeaderText);
 | |
|                 }
 | |
|             }
 | |
|             sb.Append("</tr>");
 | |
|             foreach (GridRow row in grid.Rows)
 | |
|             {
 | |
|                 sb.Append("<tr>");
 | |
|                 foreach (GridColumn column in grid.Columns)
 | |
|                 {
 | |
|                     if (column.ColumnID != "Print")
 | |
|                     {
 | |
|                         string html = row.Values[column.ColumnIndex].ToString();
 | |
|                         if (column.ColumnID == "tfNumber")
 | |
|                         {
 | |
|                             html = (row.FindControl("labNumber") as AspNet.Label).Text;
 | |
|                         }
 | |
|                         sb.AppendFormat("<td x:str>{0}</td>", html);
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 sb.Append("</tr>");
 | |
|             }
 | |
| 
 | |
|             sb.Append("</table>");
 | |
| 
 | |
|             return sb.ToString();
 | |
|         }
 | |
|         #endregion
 | |
|     }
 | |
| } |