xinjiang/SGGL/FineUIPro.Web/SysManage/Schedule.aspx.cs

142 lines
4.5 KiB
C#
Raw Normal View History

2024-11-19 09:45:27 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using BLL;
namespace FineUIPro.Web.SysManage
{
public partial class Schedule : PageBase
{
public string Projectid
{
get
{
return (string)ViewState["Projectid"];
}
set
{
ViewState["Projectid"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Projectid = CurrUser.LoginProjectId;
////权限按钮方法
this.GetButtonPower();
// 绑定表格
this.BindGrid();
}
}
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var menuid = "F2601FA2-2C70-44A2-A2B0-2E3A5458AE00";
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, menuid);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
//查询user表里岗位项目角色是群安员的用户
string strSql = @"select ScheduleId,ScheduleName,ScheduleDate,S.ProjectId,J.ProjectName,SortId from Sys_Schedule S
left join Base_Project J on S.ProjectId= J.ProjectId
WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += " AND S.ProjectId=@ProjectId ";
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
strSql += " order by SortId ";
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();
}
#endregion
/// <summary>
/// 关闭弹出窗
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Projectid))
{
string id = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ScheduleEdit.aspx?ScheduleId={0}", id, "编辑 - ")));
}
else
{
Alert.ShowInTop("未获取到当前项目,请刷新页面或重新选择项目", MessageBoxIcon.Warning);
}
}
protected void btnMenuAdd_Click(object sender, EventArgs e)
{
//判断是否已经存在5个
if (!string.IsNullOrEmpty(Projectid))
{
var listSchedule = Funs.DB.Sys_Schedule.Where(x => x.ProjectId == Projectid).ToList();
if (listSchedule.Count >= 6)
{
Alert.ShowInTop("进度节点数据最多添加5条", MessageBoxIcon.Warning);
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ScheduleEdit.aspx", "添加 - ")));
}
}
else
{
Alert.ShowInTop("未获取到当前项目,请刷新页面或重新选择项目", MessageBoxIcon.Warning);
}
}
}
}