using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; namespace FineUIPro.Web.HotProcessHard { public partial class HardReport : PageBase { #region 定义项 /// /// 主键 /// public string HardTrustItemID { get { return (string)ViewState["HardTrustItemID"]; } set { ViewState["HardTrustItemID"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HardTrustItemID = Request.Params["HardTrustItemID"]; this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 this.BindGrid(); } } /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT * from View_Hard_Report WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.HardTrustItemID)) { strSql += " AND HardTrustItemID = @HardTrustItemID"; listStr.Add(new SqlParameter("@HardTrustItemID", this.HardTrustItemID)); } if (!string.IsNullOrEmpty(this.txtHardReportNo.Text.Trim())) { strSql += " AND HardReportNo LIKE @HardReportNo"; listStr.Add(new SqlParameter("@HardReportNo", "%" + this.txtHardReportNo.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; // tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, EventArgs e) { BindGrid(); } #endregion #region 增加按钮事件 /// /// 增加按钮事件 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotHardManageEditMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HardReportEdit.aspx?HardTrustItemID={0}", this.HardTrustItemID, "新增 - "))); } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #region 编辑 /// /// 双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning); return; } ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面 if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotHardManageEditMenuId, Const.BtnEdit)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HardReportEdit.aspx?HardReportId={0}", Grid1.SelectedRowID, "编辑 - "))); } } #endregion #region 删除 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotHardManageEditMenuId, Const.BtnAdd)) { if (Grid1.SelectedRowIndexArray.Length > 0) { string strShowNotify = string.Empty; foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); var hardReport = BLL.Hard_ReportService.GetHardReportByHardReportId(rowID); if (hardReport != null) { string cont = judgementDelete(rowID); if (string.IsNullOrEmpty(cont)) { BLL.AttachFileService.DeleteAttachFile(Funs.RootPath, rowID, Const.HJGL_HotHardManageEditMenuId);//删除附件 BLL.Hard_ReportService.DeleteHard_ReportByHardReportId(rowID); //BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Resources.Lan.DeleteHardnessReport); } else { strShowNotify += Resources.Lan.HardnessReport+":" + hardReport.HardReportNo + cont; } } } BindGrid(); if (!string.IsNullOrEmpty(strShowNotify)) { Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning); } else { ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); } } } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private string judgementDelete(string id) { string content = string.Empty; //if (Funs.DB.Project_HJGL_HotHardReport.FirstOrDefault(x => x.HardReportId == id) != null) //{ // content += "已在【硬度报告】中使用,不能删除!"; //} return content; } #endregion #endregion /// /// 查询 /// /// /// protected void btnQuery_Click(object sender, EventArgs e) { this.BindGrid(); } #region 行点击事件 /// /// Grid行点击事件 /// /// /// protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string hardReportId = Grid1.DataKeys[e.RowIndex][0].ToString(); if (e.CommandName == "attchUrl") { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/HotProcessHard&menuId={1}&edit=0", hardReportId, BLL.Const.HJGL_HotHardManageEditMenuId))); } } #endregion } }