using BLL; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using AspNet = System.Web.UI.WebControls; using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class DailyReportComplete : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); var teamGroup = BLL.Welder_TeamGroupService.GetAllTeamGroupList(CurrUser.LoginProjectId, ""); drpTeamGroup.DataValueField = "Value"; drpTeamGroup.DataTextField = "Text"; drpTeamGroup.DataSource = teamGroup; drpTeamGroup.DataBind(); Funs.FineUIPleaseSelect(drpTeamGroup, ""); this.BindGrid(); } } /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT daily.DailyReportCompleteId,unit.UnitCode,team.TeamGroupName, daily.DailyReportDate,daily.IsComplete,u.UserName AS ReportMan FROM dbo.Pipeline_DailyReportComplete daily LEFT JOIN dbo.Welder_TeamGroup team ON team.TeamGroupId = daily.TeamGroupId LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = daily.UnitId LEFT JOIN dbo.Sys_User u ON u.UserId=daily.ReportMan WHERE 1=1"; List parms = new List(); if (this.drpTeamGroup.SelectedValue != "" && this.drpTeamGroup.SelectedValue!=Const._Null) { strSql += " and daily.TeamGroupId = @TeamGroupId "; parms.Add(new SqlParameter("@TeamGroupId", this.drpTeamGroup.SelectedValue)); } strSql += " ORDER BY daily.DailyReportDate DESC "; SqlParameter[] parameter = parms.ToArray(); DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = dt.Rows.Count; var table = this.GetPagedDataTable(Grid1, dt); 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) { this.BindGrid(); } #endregion #region 统计按钮事件 /// /// 统计 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { BindGrid(); } #region 增加按钮事件 /// /// 增加按钮事件 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (GetButtonPower(Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DailyReportCompleteEdit.aspx", "新增 - "))); } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #region 编辑/查看/删除数据 /// /// 编辑 /// private void EditData() { if (GetButtonPower(BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent(Resources.Lan.SelectLeastOneRecord); return; } string Id = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DailyReportCompleteEdit.aspx?completeId={0}", Id, "编辑 - "))); } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } protected void btnMenuView_Click(object sender, EventArgs e) { if (GetButtonPower(BLL.Const.BtnSee)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DailyReportCompleteEdit.aspx?completeId={0}", Grid1.SelectedRowID, "查看 - "))); } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } /// /// 批量删除数据 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (GetButtonPower(BLL.Const.BtnDelete)) { string strShowNotify = string.Empty; if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); BLL.DailyReportCompleteService.DeleteDailyReportComplete(rowID); BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DailyReportCompleteMenuId, Const.BtnDelete, rowID); } } if (!string.IsNullOrEmpty(strShowNotify)) { Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning); } else { BindGrid(); ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); } } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } #endregion #region 关闭窗口 /// /// 关闭窗口 /// /// /// protected void Window1_Close(object sender, EventArgs e) { BindGrid(); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DailyReportCompleteMenuId, button); } #endregion #endregion } }