using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Threading.Tasks; namespace FineUIPro.Web.CQMS.RewardAndPunish { public partial class RewardAndPunish : PageBase { /// /// 项目id /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { // 表头过滤 //FilterDataRowItem = FilterDataRowItemImplement; if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; //权限按钮方法 GetButtonPower(); BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.ProjectId, Const.ProjectUnitType_2, true); btnNew.OnClientClick = Window1.GetShowReference("RewardAndPunishEdit.aspx") + "return false;"; ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 BindGrid(); } } #endregion protected DataTable insklistData() { string strSql = @"SELECT ins.*,un.UnitName,u.PersonName as CompileManName,case ins.Type when '1' then '奖励' else '处罚' end as TypeStr,case ins.Type when '1' then rt.RewardCause else pt.PunishCause end as Cause,case ins.Type when '1' then rt.RewardDecision else pt.PunishDecision end as Decision" + @" FROM RewardAndPunish_RewardAndPunish ins" + @" left join Base_Unit un on un.UnitId = ins.UnitId" + @" left join Base_RewardType rt on rt.RewardTypeId = ins.RewardAndPunishTypeId" + @" left join Base_PunishType pt on pt.PunishTypeId = ins.RewardAndPunishTypeId" + @" left join Person_Persons u on u.PersonId = ins.CompileMan" + @" where ins.ProjectId=@ProjectId "; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); if (drpUnit.SelectedValue != BLL.Const._Null) { strSql += " AND ins.UnitId=@UnitId"; listStr.Add(new SqlParameter("@UnitId", drpUnit.SelectedValue)); } if (this.rblType.SelectedValue != "0") { strSql += " AND ins.Type=@Type"; listStr.Add(new SqlParameter("@Type", rblType.SelectedValue)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); return tb; } /// /// 绑定数据 /// public void BindGrid() { DataTable tb = insklistData(); // 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(); } #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 过滤表头、排序、分页、关闭窗口 /// /// 过滤表头 /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { //Grid1.SortDirection = e.SortDirection; //Grid1.SortField = e.SortField; BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 关闭弹出窗 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); string str = this.hdID.Text; if (!string.IsNullOrEmpty(str)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RewardAndPunishEdit.aspx?RewardAndPunishId={0}", str, "查看 - "))); } this.hdID.Text = string.Empty; } #endregion #region Grid双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnMenuModify_Click(null, null); } #endregion #region 编辑 /// /// 编辑按钮 /// /// /// protected void btnMenuModify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var ins = BLL.RewardAndPunishService.GetRewardAndPunishById(id); if (ins != null) { if (ins.State.Equals(Const.RewardAndPunish_Complete)) { Alert.ShowInTop("流程已闭环,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } Model.RewardAndPunish_RewardAndPunishApprove approve = BLL.RewardAndPunishApproveService.GetRewardAndPunishApproveByRewardAndPunishId(id); if (approve != null) { if (!string.IsNullOrEmpty(approve.ApproveMan)) { if (this.CurrUser.PersonId == approve.ApproveMan || CurrUser.PersonId == Const.sysglyId) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RewardAndPunishEdit.aspx?RewardAndPunishId={0}", id, "编辑 - "))); return; } else { Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } } } else { Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 删除 /// /// 批量删除 /// /// /// protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var ins = BLL.RewardAndPunishService.GetRewardAndPunishById(id); ////删除附件表 BLL.CommonService.DeleteAttachFileById(id); BLL.RewardAndPunishApproveService.DeleteRewardAndPunishApprovesByRewardAndPunishId(id); BLL.RewardAndPunishService.DeleteRewardAndPunishById(id); BLL.LogService.AddSys_Log(this.CurrUser, ins.RewardAndPunishCode, id, BLL.Const.RewardAndPunishMenuId, "删除质量奖罚"); Grid1.DataBind(); BindGrid(); Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.PersonId, BLL.Const.RewardAndPunishMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnMenuModify.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDel.Hidden = false; } } } #endregion // //获取主持人 // // // protected string ConvertHostMan(object HostMan) { string names = string.Empty; if (HostMan != null) { string[] strs = HostMan.ToString().Split(','); foreach (var item in strs) { names += BLL.Person_PersonsService.GetPersonsNameById(item) + ","; } if (!string.IsNullOrEmpty(names)) { names = names.Substring(0, names.Length - 1); } } return names; } /// /// 把状态转换代号为文字形式 /// /// /// protected string ConvertState(object state) { if (state != null) { if (state.ToString() == BLL.Const.RewardAndPunish_ReCompile) { return "重新编制"; } else if (state.ToString() == BLL.Const.RewardAndPunish_Compile) { return "编制"; } else if (state.ToString() == BLL.Const.RewardAndPunish_Audit1) { return "质量经理审核"; } else if (state.ToString() == BLL.Const.RewardAndPunish_Audit2) { return "项目经理批准"; } else if (state.ToString() == BLL.Const.RewardAndPunish_Complete) { return "审批完成"; } else { return ""; } } return ""; } // //获取办理人姓名 // // // protected string ConvertMan(object RewardAndPunishId) { if (RewardAndPunishId != null) { Model.RewardAndPunish_RewardAndPunishApprove a = BLL.RewardAndPunishApproveService.GetRewardAndPunishApproveByRewardAndPunishId(RewardAndPunishId.ToString()); if (a != null) { if (a.ApproveMan != null) { return BLL.Person_PersonsService.GetPersonsNameById(a.ApproveMan); } } else { return ""; } } return ""; } protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { } protected void btnMenuView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var ins = BLL.RewardAndPunishService.GetRewardAndPunishById(id); if (ins != null) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RewardAndPunishView.aspx?RewardAndPunishId={0}", id, "查看 - "))); } } /// /// 搜索 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } /// /// 重置 /// /// /// protected void btnRset_Click(object sender, EventArgs e) { drpUnit.SelectedIndex = 0; this.rblType.SelectedValue = "0"; BindGrid(); } } }