using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.PHTGL.Filing
{
public partial class BidDocumentsStandingBook : PageBase
{
#region 项目主键
///
/// 项目主键
///
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
///
/// 级别,1 为项目级
///
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
#region 加载
///
/// 加载页面
///
///
///
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();
}
}
///
/// 数据绑定
///
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 分页 排序
///
/// 改变索引事件
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
///
/// 分页下拉选择事件
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region 关闭弹出窗体
///
/// 关闭弹出窗体
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region 查询
///
/// 查询按钮
///
///
///
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 编辑
///
/// 双击事件
///
///
///
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
///
/// 右键编辑事件
///
///
///
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
///
/// 编辑数据方法
///
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 删除
///
/// 右键删除事件
///
///
///
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);
//}
}
///
/// 判断是否可以删除
///
///
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 获取按钮权限
///
/// 获取按钮权限
///
///
///
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 导出按钮
/// 导出按钮
///
///
///
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。
// ///
// /// 导出方法
// ///
// ///
// ///
// private string GetGridTableHtml(Grid grid)
//#pragma warning restore CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
// {
// StringBuilder sb = new StringBuilder();
// sb.Append("");
// sb.Append("
");
// sb.Append("");
// foreach (GridColumn column in grid.Columns)
// {
// sb.AppendFormat("| {0} | ", column.HeaderText);
// }
// sb.Append("
");
// foreach (GridRow row in grid.Rows)
// {
// sb.Append("");
// 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("| {0} | ", html);
// sb.AppendFormat("{0} | ", html);
// }
// sb.Append("
");
// }
// sb.Append("
");
// 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);
}
}
}
}