SGGL_SHJ/SGGL/FineUIPro.Web/PHTGL/BiddingManagement/ActionPlanFormation.aspx.cs

404 lines
14 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.PHTGL.BiddingManagement
{
public partial class ActionPlanFormation : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
this.DropState.DataValueField = "Value";
DropState.DataTextField = "Text";
DropState.DataSource = BLL.DropListService.GetState();
DropState.DataBind();
Funs.FineUIPleaseSelect(DropState);
DropState.SelectedValue = Const.ContractCreating.ToString();
btnNew.OnClientClick = Window1.GetShowReference("ActionPlanFormationEdit.aspx", "实施计划编制") + "return false;";
GetButtonPower();
BindGrid();
}
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT Act.ActionPlanID
,Act.ActionPlanCode
,Act.ProjectShortName as Name
,Act.EPCCode
,(CASE Act.State
WHEN @ContractCreating THEN '编制中'
WHEN @ContractCreat_Complete THEN '编制完成'
WHEN @Contract_countersign THEN '会签中'
WHEN @ContractReviewing THEN '审批中'
WHEN @ContractReview_Complete THEN '审批成功'
WHEN @ContractReview_Refuse THEN '审批被拒' END) AS State
,U.PersonName as CreatUser
,Act.CreateTime
,Act.ProjectID
,Act.ProjectName
,Act.Unit
,Act.BidProject
,Act.BidType
,Act.PriceType
,Act.BidPrice
,Act.ConstructionSite
FROM PHTGL_ActionPlanFormation AS Act
LEFT JOIN Person_Persons AS U ON U.PersonId = Act.CreatUser
LEFT JOIN Base_Project AS Pro ON Pro.ProjectId = Act.ProjectID WHERE 1=1";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ContractCreating", Const.ContractCreating.ToString()));
listStr.Add(new SqlParameter("@ContractCreat_Complete", Const.ContractCreat_Complete.ToString()));
listStr.Add(new SqlParameter("@Contract_countersign", Const.Contract_countersign));
listStr.Add(new SqlParameter("@ContractReviewing", Const.ContractReviewing));
listStr.Add(new SqlParameter("@ContractReview_Complete", Const.ContractReview_Complete));
listStr.Add(new SqlParameter("@ContractReview_Refuse", Const.ContractReview_Refuse));
if (!(this.CurrUser.PersonId == Const.sysglyId))
{
strSql += " and Act.ProjectID =@ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
}
if (!string.IsNullOrEmpty(txtActionPlanCode.Text))
{
strSql += " and Act.ActionPlanCode like @ActionPlanCode ";
listStr.Add(new SqlParameter("@ActionPlanCode", "%" + txtActionPlanCode.Text + "%"));
}
if (DropState.SelectedItemArray.Length > 0)
{
strSql += string.Format(" and Act.State in ({0}) ", string.Join(",", DropState.SelectedValueArray));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#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
#region
/// <summary>
/// 关闭弹出窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 查询按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
protected void btnRset_Click(object sender, EventArgs e)
{
txtActionPlanCode.Text = "";
DropState.SelectedValue = Const.ContractCreating.ToString();
BindGrid();
}
#endregion
#region
/// <summary>
/// 双击事件
/// </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 Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
object[] keys = Grid1.DataKeys[e.RowIndex];
string fileId = string.Empty;
if (keys == null)
{
return;
}
else
{
fileId = keys[0].ToString();
}
if (e.CommandName == "LooK")
{
string id = fileId;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - ")));
return;
}
if (e.CommandName == "export")
{
btnPrinter_Click(null, null);
}
}
/// <summary>
/// 表格单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
{
string id = Grid1.SelectedRowID;
var actReview = PHTGL_ActionPlanReviewService.GetPHTGL_ActionPlanReviewByActionPlanID(id);
if (actReview != null)
{
if (actReview.State == Const.ContractReview_Refuse)
{
btnEditAgain.Hidden = false;
}
else
{
btnEditAgain.Hidden = true;
}
if (actReview.State >= Const.ContractCreat_Complete)
{
btnDelete.Hidden = true;
}
else
{
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ActionPlanFormation);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(Const.BtnDelete))
{
btnDelete.Hidden = false;
}
}
}
}
}
/// <summary>
/// 编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
/// <summary>
/// 重新编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEditAgain_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
var model = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(id);
model.State = Const.ContractCreating;
PHTGL_ActionPlanFormationService.UpdatePHTGL_ActionPlanFormation(model);
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - ")));
}
/// <summary>
/// 编辑数据方法
/// </summary>
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - ")));
}
#endregion
#region
/// <summary>
/// 删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
bool isShow = false;
if (Grid1.SelectedRowIndexArray.Length == 1)
{
isShow = true;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (this.judgementDelete(rowID, isShow))
{
var p = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(rowID);
if (p != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, p.ProjectName, p.ActionPlanID, BLL.Const.ActionPlanFormation, BLL.Const.BtnDelete);
BLL.PHTGL_ActionPlanFormationService.DeletePHTGL_ActionPlanFormationById(rowID);
BLL.PHTGL_ActionPlanFormation_Sch1Service.DeletePHTGL_ActionPlanFormation_Sch1ById(rowID);
}
}
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete(string id, bool isShow)
{
string content = string.Empty;
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content);
}
return false;
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ActionPlanFormation);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(Const.BtnAdd))
{
btnNew.Hidden = false;
}
if (buttonList.Contains(Const.BtnModify))
{
btnEdit.Hidden = false;
}
if (buttonList.Contains(Const.BtnDelete))
{
btnDelete.Hidden = false;
}
}
}
#endregion
#region
protected void btnPrinter_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string Id = Grid1.SelectedRowID;
BLL.PHTGL_ActionPlanFormationService.PrintFile(Id);
}
#endregion
}
}