496 lines
18 KiB
C#
496 lines
18 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using System.Web.UI.DataVisualization.Charting;
|
||
|
||
namespace FineUIPro.Web.PHTGL.Filing
|
||
{
|
||
public partial class BidDocumentsStandingBook : PageBase
|
||
{
|
||
#region 项目主键
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
/// <summary>
|
||
/// 级别,1 为项目级
|
||
/// </summary>
|
||
public string Type
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["Type"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["Type"] = value;
|
||
}
|
||
}
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
BLL.DepartService.InitDepartDropDownList(this.drpDepartId, false);
|
||
Type = Request.Params["Type"];
|
||
GetButtonPower();
|
||
if (Type=="1")
|
||
{
|
||
btnNew.OnClientClick = Window1.GetShowReference("BidDocumentsStandingBookEditProject.aspx", "基本信息") + "return false;";
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||
{
|
||
this.ProjectId = Request.Params["projectId"];
|
||
}
|
||
}
|
||
else
|
||
{
|
||
btnNew.OnClientClick = Window1.GetShowReference("BidDocumentsStandingBookEdit.aspx", "基本信息") + "return false;";
|
||
|
||
}
|
||
|
||
BindGrid();
|
||
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 数据绑定
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
Model.PHTGL_BidDocumentsStandingBook _BidDocumentsStandingBook = new Model.PHTGL_BidDocumentsStandingBook();
|
||
|
||
if (Type=="1")
|
||
{
|
||
if (!(this.CurrUser.PersonId == Const.sysglyId || this.CurrUser.PersonId == Const.hfnbdId))
|
||
{
|
||
_BidDocumentsStandingBook.ProjectId = this.CurrUser.LoginProjectId;
|
||
}
|
||
}
|
||
|
||
var RoleIds = this.CurrUser.RoleIds;
|
||
_BidDocumentsStandingBook.UnitId = "normal";
|
||
if (!string.IsNullOrEmpty(RoleIds))
|
||
{
|
||
if (RoleIds.Contains(Const.SedinHTGLManager))
|
||
{
|
||
//model.UnitId=this.CurrUser.UnitId;
|
||
}
|
||
else if (RoleIds.Contains(Const.OtherHTGLManager))
|
||
{
|
||
_BidDocumentsStandingBook.UnitId = this.CurrUser.UnitId;
|
||
}
|
||
else if (RoleIds.Contains(Const.SedinHTGLDepartManager))
|
||
{
|
||
_BidDocumentsStandingBook.UnitId = this.CurrUser.UnitId;
|
||
_BidDocumentsStandingBook.DepartId = this.CurrUser.DepartId;
|
||
|
||
}
|
||
}
|
||
if (dropState.SelectedValue!=Const._Null)
|
||
{
|
||
_BidDocumentsStandingBook.State = Funs.GetNewInt(dropState.SelectedValue) ;
|
||
}
|
||
if (!string.IsNullOrEmpty(txtEPCCode.Text))
|
||
{
|
||
_BidDocumentsStandingBook.EPCCode= txtEPCCode.Text;
|
||
}
|
||
if (!string.IsNullOrEmpty(txtShortName.Text))
|
||
{
|
||
_BidDocumentsStandingBook.ProjectShortName= txtShortName.Text;
|
||
}
|
||
if (!string.IsNullOrEmpty(txtProjectCode.Text))
|
||
{
|
||
_BidDocumentsStandingBook.ProjectCode= txtProjectCode.Text;
|
||
}
|
||
|
||
var q= BLL.BidDocStandingBookService.GetPHTGL_BidDocumentsStandingBookByModle(_BidDocumentsStandingBook);
|
||
Grid1.RecordCount = q.Count;
|
||
Grid1.DataSource=q;
|
||
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();
|
||
}
|
||
#endregion
|
||
protected void btnReset_Click(object sender, EventArgs e)
|
||
{
|
||
txtProjectCode.Text = string.Empty;
|
||
txtShortName.Text = string.Empty;
|
||
txtEPCCode.Text = string.Empty;
|
||
//txtSubConstruction.Text = string.Empty;
|
||
}
|
||
|
||
#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 btnMenuEdit_Click(object sender, EventArgs e)
|
||
{
|
||
this.EditData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 编辑数据方法
|
||
/// </summary>
|
||
private void EditData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string id = Grid1.SelectedRowID;
|
||
var model=BLL.BidDocStandingBookService.GetPHTGL_BidDocumentsStandingBookById(id);
|
||
if (model != null)
|
||
{
|
||
if (Type=="1")
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("BidDocumentsStandingBookEditProject.aspx?BidDocumentsStandingBookId={0}", id, "编辑 - ")));
|
||
|
||
}
|
||
else
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("BidDocumentsStandingBookEdit.aspx?BidDocumentsStandingBookId={0}", id, "编辑 - ")));
|
||
|
||
}
|
||
}
|
||
}
|
||
protected void btnEdit_Click(object sender, EventArgs e)
|
||
{
|
||
EditData();
|
||
}
|
||
#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.ContractService.GetContractById(rowID);
|
||
// var Sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(rowID);
|
||
// var Spe = PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsByContractId(rowID);
|
||
// if (Sub != null)
|
||
// {
|
||
// SubcontractAgreementService.DeleteSubcontractAgreementBycontractId(rowID);
|
||
// }
|
||
// if (Spe != null)
|
||
// {
|
||
// PHTGL_SpecialTermsConditionsService.DeleteSpecialTermsConditionsBycontractId(rowID);
|
||
// }
|
||
// if (p != null)
|
||
// {
|
||
// BLL.LogService.AddSys_Log(this.CurrUser, p.ContractName, p.ContractId, BLL.Const.ContractMenuId, BLL.Const.BtnDelete);
|
||
// BLL.ContractService.DeleteContractById(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.ProjectBidDocumentsStandingBookMenuId);
|
||
if (buttonList.Count() > 0)
|
||
{
|
||
if (buttonList.Contains(Const.BtnAdd))
|
||
{
|
||
btnNew.Hidden = false;
|
||
}
|
||
if (buttonList.Contains(Const.BtnModify))
|
||
{
|
||
// btnMenuEdit.Hidden = false;
|
||
btnEdit.Hidden = false;
|
||
}
|
||
if (buttonList.Contains(Const.BtnDelete))
|
||
{
|
||
// btnMenuDelete.Hidden = false;
|
||
btnDelete.Hidden = false;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
#region 导出按钮
|
||
/// 导出按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnOut_Click(object sender, EventArgs e)
|
||
{
|
||
Response.ClearContent();
|
||
string filename = Funs.GetNewFileName();
|
||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("施工分包合同管理台账" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||
Response.ContentType = "application/excel";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
//this.Grid1.PageSize = this.;
|
||
BindGrid();
|
||
Response.Write(GetGridTableHtml(Grid1));
|
||
Response.End();
|
||
}
|
||
|
||
//#pragma warning disable CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||
// /// <summary>
|
||
// /// 导出方法
|
||
// /// </summary>
|
||
// /// <param name="grid"></param>
|
||
// /// <returns></returns>
|
||
// private string GetGridTableHtml(Grid grid)
|
||
//#pragma warning restore CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||
// {
|
||
// StringBuilder sb = new StringBuilder();
|
||
// sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||
// sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||
// sb.Append("<tr>");
|
||
// foreach (GridColumn column in grid.Columns)
|
||
// {
|
||
// sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||
// }
|
||
// sb.Append("</tr>");
|
||
// foreach (GridRow row in grid.Rows)
|
||
// {
|
||
// sb.Append("<tr>");
|
||
// foreach (GridColumn column in grid.Columns)
|
||
// {
|
||
// string html = row.Values[column.ColumnIndex].ToString();
|
||
// if (column.ColumnID == "tfNumber")
|
||
// {
|
||
// html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
||
// }
|
||
// if (column.ColumnID == "tfI")
|
||
// {
|
||
// html = (row.FindControl("lbI") as AspNet.Label).Text;
|
||
// }
|
||
// //sb.AppendFormat("<td>{0}</td>", html);
|
||
// sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||
// }
|
||
|
||
// sb.Append("</tr>");
|
||
// }
|
||
|
||
// sb.Append("</table>");
|
||
|
||
// return sb.ToString();
|
||
// }
|
||
#endregion
|
||
|
||
protected void btnImport_Click(object sender, EventArgs e)
|
||
{
|
||
if (Type=="1")
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("BidDocumentsStandingBookIn.aspx?Type=1", "导入 - ")));
|
||
|
||
}
|
||
else
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("BidDocumentsStandingBookIn.aspx", "导入 - ")));
|
||
|
||
}
|
||
|
||
}
|
||
public string ConvertState(object State)
|
||
{
|
||
string StateName = string.Empty;
|
||
if (State!=null&&!string.IsNullOrEmpty(State.ToString()))
|
||
{
|
||
switch (State.ToString())
|
||
{
|
||
case "0":
|
||
StateName = "未提交";
|
||
break;
|
||
case "1":
|
||
StateName = "已提交";
|
||
break;
|
||
default:
|
||
StateName = "未提交";
|
||
break;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
StateName = "未提交";
|
||
}
|
||
return StateName;
|
||
}
|
||
|
||
protected void btnDelete_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.BidDocStandingBookService.GetPHTGL_BidDocumentsStandingBookById(rowID);
|
||
if (p != null)
|
||
{
|
||
if (p.State==1)
|
||
{
|
||
ShowNotify(message: "已提交,删除失败!", MessageBoxIcon.Error);
|
||
return;
|
||
|
||
}
|
||
// BLL.LogService.AddSys_Log(this.CurrUser, p.ContractName, p.ContractId, BLL.Const.ContractMenuId, BLL.Const.BtnDelete);
|
||
BLL.BidDocStandingBookService.DeletePHTGL_BidDocumentsStandingBookById(rowID);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-BidUnit", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-BidNotice", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-ActionPlan", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-BidDocuments", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-ApprovePersonForm", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID + "-SetSubReview", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID +"-ShortListApproval", Const.ProjectBidDocumentsStandingBookMenuId);
|
||
}
|
||
}
|
||
}
|
||
BindGrid();
|
||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
} |