SGGL_SHJ/SGGL/FineUIPro.Web/PHTGL/Filing/ContractStandingBook.aspx.cs

384 lines
14 KiB
C#

using BLL;
using FineUIPro.Web.PHTGL.ContractCompile;
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.PHTGL.Filing
{
public partial class ContractStandingBook : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
BLL.DepartService.InitDepartDropDownList(this.drpDepartId, true);
btnNew.OnClientClick = Window1.GetShowReference("ContractStandingBookEdit.aspx", "基本信息") + "return false;";
BindGrid();
}
}
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
var model = new Model.PHTGL_ContractStandingBook();
var RoleIds = this.CurrUser.RoleIds;
if (RoleIds.Contains(Const.SedinHTGLManager))
{
//model.UnitId=this.CurrUser.UnitId;
}
else if (RoleIds.Contains(Const.OtherHTGLManager))
{
model.UnitId = this.CurrUser.UnitId;
}
else if (RoleIds.Contains(Const.SedinHTGLDepartManager))
{
model.UnitId = this.CurrUser.UnitId;
model.DepartId= this.CurrUser.DepartId;
}
else
{
model.UnitId = "normal";
}
if (!string.IsNullOrEmpty(txtContractName.Text.Trim()))
{
model.ContractName = txtContractName.Text.Trim();
}
if (dropState.SelectedValue != Const._Null)
{
model.States = Funs.GetNewInt(dropState.SelectedValue);
}
var list= BLL.ContractStandingBookService.GetPHTGL_ContractStandingBookByModle( model);
//var list= BLL.ContractStandingBookService.getListData( model, Grid1);
if (drpDepartId.SelectedValue != Const._Null)
{
list=list.Where(d => d.DepartId==drpDepartId.SelectedValue). ToList();
}
Grid1.RecordCount = list.Count;
var table = this.GetPagedDataTable(Grid1, list);
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="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ContractStandingBookMenuId);
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;
}
if (buttonList.Contains(Const.BtnIn))
{
btnImport.Hidden = false;
}
}
}
#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)
{
txtContractName.Text = string.Empty;
drpDepartId.SelectedValue = Const._Null;
dropState.SelectedValue = Const._Null;
//txtSubConstruction.Text = string.Empty;
}
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;
}
#region
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ContractStandingBookIn.aspx?", "导入 - ")));
}
/// <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.ContractStandingBookService.GetContractById(id);
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ContractStandingBookEdit.aspx?ContractId={0}", id, "编辑 - ")));
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
EditData();
}
#endregion
#region
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.ContractStandingBookService.GetContractById(rowID);
if (p != null)
{
if (p.States == 1)
{
ShowNotify(message: "已提交,删除失败!", MessageBoxIcon.Error);
return;
}
// BLL.LogService.AddSys_Log(this.CurrUser, p.ContractName, p.ContractId, BLL.Const.ContractMenuId, BLL.Const.BtnDelete);
BLL.ContractStandingBookService.DeleteContractById(rowID);
AttachFileService.DeleteAttachFile(Funs.RootPath, rowID , Const.ContractStandingBookMenuId);
// 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);
}
}
/// <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>
/// <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
}
}