CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/PZHGL/GJSX/GJSXFind.aspx.cs

333 lines
12 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.PZHGL.GJSX
{
public partial class GJSXFind : PageBase
{
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
UnitService.InitUnitDropDownList(this.DropUnitId, this.CurrUser.LoginProjectId, true);
//专业
CNProfessionalService.InitCNProfessional(this.DropCNProfessional_ID, true);
//编号
string projectCode = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId);
//紧急程度
QuestionTypeService.InitQuestionTypeDropDownList(this.DropQuestionTypeID, true);
//事项类别
GJSXTypeService.InitGJSXTypeDropDownList(this.DropGJSXTypeID, true);
//验收人
UserService.InitUserDropDownList(DropUser_ReceiveID, CurrUser.LoginProjectId, true, string.Empty);
//接收人
UserService.InitUserDropDownList(DropUser_Acceptance, CurrUser.LoginProjectId, true, string.Empty);
//提出人
UserService.InitUserDropDownList(DropUserId, CurrUser.LoginProjectId, true, string.Empty);
Funs.DropDownPageSize(this.ddlPageSize);
////权限按钮方法
this.GetButtonPower();
this.btnNew.OnClientClick = Window1.GetShowReference("GJSXListEdit.aspx?EditType=add") + "return false;";
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
{
Grid1.PageSize = this.CurrUser.PageSize.Value;
}
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
this.BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = "";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值
{
listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
}
else
{
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
}
if (this.state.SelectedValue != "null")//状态
{
strSql += " AND state LIKE " + "'%" + this.state.SelectedText.Trim() + "%'";
}
if (this.DropUserId.SelectedValue != Const._Null)//提出人
{
strSql += " AND username LIKE " + "'%" + this.DropUserId.SelectedText.Trim() + "%'";
}
if (this.DropUser_ReceiveID.SelectedValue != Const._Null)//接受人
{
strSql += " AND User_ReceiveID LIKE " + "'%" + this.DropUser_ReceiveID.SelectedText.Trim() + "%'";
}
if (this.DropUnitId.SelectedValue != Const._Null)//责任单位
{
strSql += " AND unitname LIKE " + "'%" + this.DropUnitId.SelectedText.Trim() + "%'";
}
if (this.DropCNProfessional_ID.SelectedValue != Const._Null)//专业
{
strSql += " AND CNProfessionalId LIKE " + "'%" + this.DropCNProfessional_ID.SelectedText.Trim() + "%'";
}
if (this.DropQuestionTypeID.SelectedValue != Const._Null)//紧急程度
{
strSql += " AND QuestionTypeName LIKE " + "'%" + this.DropQuestionTypeID.SelectedText.Trim() + "%'";
}
if (this.DropGJSXTypeID.SelectedValue != Const._Null)//事项类别
{
strSql += " AND GJSXTypeName LIKE " + "'%" + this.DropGJSXTypeID.SelectedText.Trim() + "%'";
}
if (this.DropUser_Acceptance.SelectedValue != Const._Null)//验收人
{
strSql += " AND user_Acceptance LIKE " + "'%" + this.DropUser_Acceptance.SelectedText.Trim() + "%'";
}
if (!string.IsNullOrEmpty(this.txtStartTime.Text))//要求完成时间 start
{
strSql += " AND CompleteDate > convert(datetime," + "'" + this.txtStartTime.Text.Trim() + "')";
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))//要求完成时间 end
{
strSql += " AND CompleteDate <convert(datetime," + "'" + this.txtEndTime.Text.Trim() + "')";
}
listStr.Add(new SqlParameter("@sql_where", strSql));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("Sp_GJSX_getlist", parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.PersonSetMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
// this.btnImport.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
this.DeleteData();
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData()
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
string strShowNotify = string.Empty;
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var user = BLL.UserService.GetUserByUserId(rowID);
if (user != null)
{
string cont = judgementDelete(rowID);
if (string.IsNullOrEmpty(cont))
{
BLL.LogService.AddSys_Log(this.CurrUser, user.UserCode, user.UserId, BLL.Const.PersonSetMenuId, BLL.Const.BtnAdd);
BLL.UserService.DeleteUser(rowID);
}
else
{
strShowNotify += "人员:" + user.UserName + cont;
}
}
}
BindGrid();
if (!string.IsNullOrEmpty(strShowNotify))
{
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
}
else
{
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
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();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
/// <summary>
/// 编辑数据方法
/// </summary>
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string Id = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GJSXListEdit.aspx?EditType=Edit&Id={0}", Id, "编辑 - ")));
}
#region
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private string judgementDelete(string id)
{
string content = string.Empty;
if (Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.UserId == id) != null)
{
content += "已在【项目员工】中使用,不能删除!";
}
return content;
}
#endregion
/// <summary>
/// 参与项目情况
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtnPro_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ParticipateProject.aspx?userId={0}", Grid1.SelectedRowID, "参与项目情况 - "), "参与项目", 1000, 520));
}
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PersonIn.aspx", "导入 - ")));
}
#endregion
/// <summary>
/// 关闭导入弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window2_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
protected void ckbAll_CheckedChanged(object sender, CheckedEventArgs e)
{
BindGrid();
}
}
}