315 lines
11 KiB
C#
315 lines
11 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.SubPackManage
|
|||
|
{
|
|||
|
public partial class SubPackTeamEvaluation : PageBase
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 项目id
|
|||
|
/// </summary>
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ProjectId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ProjectId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
// 表头过滤
|
|||
|
//FilterDataRowItem = FilterDataRowItemImplement;
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|||
|
|
|||
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
GetButtonPower();
|
|||
|
btnNew.OnClientClick = Window1.GetShowReference("SubPackTeamEvaluationEdit.aspx") + "return false;";
|
|||
|
|
|||
|
// 绑定表格
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <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)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
|
|||
|
public void BindGrid()
|
|||
|
{
|
|||
|
DataTable tb = SubPackTeamEvaluationData();
|
|||
|
|
|||
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
|
|||
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|||
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
|
|||
|
Grid1.DataSource = table;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Grid行双击事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|||
|
{
|
|||
|
btnMenuModify_Click(null, null);
|
|||
|
}
|
|||
|
|
|||
|
#region 编辑
|
|||
|
/// <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 id = Grid1.SelectedRowID.Split(',')[0];
|
|||
|
var item = Funs.DB.SubPack_TeamEvaluation.FirstOrDefault(p => p.SubPackTeamEvaluationID == id);
|
|||
|
if (item == null)
|
|||
|
{
|
|||
|
Alert.ShowInTop("你要修改的数据在数据库已经不存在了,请重新查询试试!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (item.State == Const.SubPackTeamEvaluation_AuditCompleted)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SubPackTeamEvaluationView.aspx?SubPackTeamEvaluationID={0}", id, "查看 - ")));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SubPackTeamEvaluationEdit.aspx?SubPackTeamEvaluationID={0}", id, "编辑 - ")));
|
|||
|
return;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <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
|
|||
|
|
|||
|
#region 删除
|
|||
|
/// <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 id = Grid1.SelectedRowID.Split(',')[0];
|
|||
|
var item = Funs.DB.SubPack_TeamEvaluation.FirstOrDefault(p => p.SubPackTeamEvaluationID == id);
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(item.State) && item.State != Const.SubPackTeamEvaluation_Write)
|
|||
|
{
|
|||
|
Alert.ShowInTop("此条数据已提交审核,不能删除!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
BLL.SubPackTeamEvaluationService.DeleteSubPackTeamEvaluation(id);
|
|||
|
|
|||
|
BLL.LogService.AddSys_Log(this.CurrUser, item.SubPackTeamEvaluationID, id, BLL.Const.SubPackTeamEvaluationMenuId, "删除劳务公司评价记录");
|
|||
|
Grid1.DataBind();
|
|||
|
BindGrid();
|
|||
|
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
string id = Grid1.SelectedRowID.Split(',')[0];
|
|||
|
var item = Funs.DB.SubPack_TeamEvaluation.FirstOrDefault(p => p.SubPackTeamEvaluationID == id);
|
|||
|
if (item == null)
|
|||
|
{
|
|||
|
Alert.ShowInTop("你要修改的数据在数据库已经不存在了,请重新查询试试!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SubPackTeamEvaluationView.aspx?SubPackTeamEvaluationID={0}", id, "查看 - ")));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查询按钮事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
protected void btnRset_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
txtStartTime.Text = "";
|
|||
|
txtEndTime.Text = "";
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
#region 获取按钮权限
|
|||
|
/// <summary>
|
|||
|
/// 获取按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="button"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
if (Request.Params["value"] == "0")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.SubPackTeamEvaluationMenuId);
|
|||
|
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
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 数据查询
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
protected DataTable SubPackTeamEvaluationData()
|
|||
|
{
|
|||
|
string strSql = @"select a.SubPackTeamEvaluationID,b.ProjectName,SubPackTeamEvaluationDate,a.State "
|
|||
|
+ @",(select top 1 Sys_User.UserName from Sys_User where Sys_User.UserId=a.SubPackTeamEvaluationMan) as SubPackTeamEvaluationManName "
|
|||
|
+ @",(select top 1 Sys_User.UserName from Sys_User where Sys_User.UserId=a.SubmitMan) as SubmitManName "
|
|||
|
+ @",(select top 1 Sys_User.UserName from Sys_User where Sys_User.UserId=a.SaveHandleMan) as SaveHandleManName "
|
|||
|
+ @"FROM SubPack_TeamEvaluation a "
|
|||
|
+ @" left join Base_Project b on a.ProjectId=b.ProjectId "
|
|||
|
+ @" WHERE a.ProjectId=@ProjectId ";
|
|||
|
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|||
|
strSql += " AND (a.SubPackTeamEvaluationDate>=@startTime or @startTime='') and (a.SubPackTeamEvaluationDate<=@endTime or @endTime='') ";
|
|||
|
listStr.Add(new SqlParameter("@startTime", !string.IsNullOrEmpty(txtStartTime.Text.Trim()) ? txtStartTime.Text.Trim() + " 00:00:00" : ""));
|
|||
|
listStr.Add(new SqlParameter("@endTime", !string.IsNullOrEmpty(txtEndTime.Text.Trim()) ? txtEndTime.Text.Trim() + " 23:59:59" : ""));
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
return tb;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 关闭弹出窗
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 把状态转换代号为文字形式
|
|||
|
/// </summary>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertState(object state, object subPackTeamEvaluationID)
|
|||
|
{
|
|||
|
var approves = BLL.Funs.DB.SubPack_TeamEvaluationApprove.Where(p => p.SubPackTeamEvaluationID == subPackTeamEvaluationID.ToString()).ToList();
|
|||
|
if (state != null)
|
|||
|
{
|
|||
|
if (state.ToString() == BLL.Const.SubPackTeamEvaluation_Write && approves.Count <= 0)
|
|||
|
{
|
|||
|
return "编制";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.SubPackTeamEvaluation_Write && approves.Count > 0)
|
|||
|
{
|
|||
|
return "重新编制";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.SubPackTeamEvaluation_Submit)
|
|||
|
{
|
|||
|
return "总包负责人审批";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.SubPackTeamEvaluation_AuditCompleted)
|
|||
|
{
|
|||
|
return "审核完成";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return "";
|
|||
|
}
|
|||
|
}
|
|||
|
return "";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|