xinjiang/SGGL/FineUIPro.Web/CQMS/Check/RewardAndPunish.aspx.cs

287 lines
8.7 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Check
{
public partial class RewardAndPunish : PageBase
{/// <summary>
/// 项目id
/// </summary>
public string RewardAndPunishID
{
get
{
return (string)ViewState["RewardAndPunishID"];
}
set
{
ViewState["RewardAndPunishID"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();
btnNew.OnClientClick = Window1.GetShowReference("RewardAndPunishEdit.aspx") + "return false;";
// 绑定表格
BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
DataTable tb = ChecklistData();
// 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();
}
protected DataTable ChecklistData()
{
string strSql = @" SELECT RewardAndPunishID
,Type
,ResponseUnit
,Description
,Money
,Date
,CreateMan
,ProjectId
FROM dbo.Check_RewardAndPunish
where ProjectId=@ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
if (drpType.SelectedValue != Const._Null)
{
strSql += " AND Type=@Type";
listStr.Add(new SqlParameter("@Type", drpType.SelectedValue));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
return tb;
}
#region
/// <summary>
/// 过滤表头
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
//Grid1.SortDirection = e.SortDirection;
//Grid1.SortField = e.SortField;
BindGrid();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#endregion
//<summary>
//获取办理人姓名
//</summary>
//<param name="state"></param>
//<returns></returns>
protected string ConvertMan(object userid)
{
if (userid != null && !string.IsNullOrEmpty(userid.ToString()))
{
return BLL.UserService.GetUserByUserId(userid.ToString()).UserName;
}
return "";
}
protected string ConvertUnitName(object userid)
{
if (userid != null && !string.IsNullOrEmpty(userid.ToString()))
{
return BLL.UnitService.GetUnitByUnitId(userid.ToString()).UnitName;
}
return "";
}
protected string ConvertType(object type)
{
if (type != null)
{
if (type.ToString() == "0")
return "奖励通知单";
else
return "处罚通知单";
}
return "";
}
#region Grid双击事件
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
btnMenuModify_Click(null, null);
}
/// <summary>
/// 编辑按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuModify_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string codes = Grid1.SelectedRowID.Split(',')[0];
var checks = BLL.RewardAndPunishService.GetRewardAndPunishById(codes);
if (checks != null)
{
if (checks.CreateMan != this.CurrUser.UserId)
{
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
return;
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RewardAndPunishEdit.aspx?RewardAndPunishID={0}", codes, "编辑 - ")));
return;
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.RewardAndPunishMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDel.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuModify.Hidden = false;
}
}
}
#endregion
protected void drpType_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDel_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string codes = Grid1.SelectedRowID.Split(',')[0];
BLL.RewardAndPunishService.DeleteRewardAndPunishById(codes);
BLL.LogService.AddSys_Log(this.CurrUser, "", codes, BLL.Const.CheckListMenuId, "删除奖罚通知单(定稿)");
Grid1.DataBind();
BindGrid();
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
}
/// <summary>
/// 关闭弹出窗
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
}
}