using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.PHTGL.Filing
{
public partial class Files : PageBase
{
#region 加载
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.DepartService.InitDepartDropDownList(this.drpDepartId, false);
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
GetButtonPower();
BindGrid();
}
}
#endregion
#region 数据绑定
///
/// 数据绑定
///
private void BindGrid()
{
string strSql = @"SELECT Rev.ContractReviewId,
Con.ContractId,
Con.ProjectId,
Con.ContractName,
Con.ContractNum,
Con.Parties,
Con.Currency,
Con.ContractAmount,
Con.DepartId,
Con.Agent,
(CASE Con.ContractType WHEN '1' THEN '施工总承包分包合同'
WHEN '2' THEN '施工专业分包合同'
WHEN '3' THEN '施工劳务分包合同'
WHEN '4' THEN '试车服务合同'
WHEN '5' THEN 'ds' END) AS ContractType,
( CASE Rev.State
WHEN @ContractCreating THEN '编制中'
WHEN @Contract_countersign THEN '会签中'
WHEN @ContractReviewing THEN '审批中'
WHEN @ContractReview_Complete THEN '审批成功'
WHEN @ContractReview_Refuse THEN '审批被拒' END) AS State ,
Con.Remarks,
Con.EPCCode,
Con.ProjectShortName,
Con.[OpeningBank-TT] as OpeningBank_TT ,
Con.[OpeningBank-electrophore] as OpeningBank_electrophore,
Con.[BankAccount-TT] as BankAccount_TT,
Con.[BankAccount-electrophore] as BankAccount_electrophore,
Con.[LineNumber-electrophore] as LineNumber_electrophore,
Con.Retentionmoney,
(CASE Con.Status WHEN '0' THEN '已签订'
WHEN '1' THEN '已完毕' END) as Status,
Con.ContactUnitOfPartyA,
Con.ContactPersonOfPartyA,
Con.ContactPersonOfPartyB,
Con.ContactPersonPhoneOfPartyB,
Con.ContactPersonEmailOfPartyB,
Con.ContractAmountExcludingTax,
Con.PriceMethod,
CONVERT(varchar(100), SignedOnDate, 111) as SignedOnDate,
CONVERT(varchar(100), ContractStartDate, 111) as ContractStartDate,
CONVERT(varchar(100), ContractEndDate, 111) as ContractEndDate,
Con.PricingBasis,
(CASE Con.SubcontractingMethod WHEN '1' then '内部分包'
WHEN '2' THEN '外部分包' END ) as SubcontractingMethod,
(CASE Con.IsItACentralizedPurchaseSupplier WHEN '0' then '否'
WHEN '1' THEN '是' END ) as IsItACentralizedPurchaseSupplier,
Pro.ProjectCode,
Pro.ProjectName,
Dep.DepartName,
U.PersonName AS AgentName "
+ @" from PHTGL_ContractReview AS Rev"
+ @" LEFT JOIN PHTGL_Contract AS Con ON Con.ContractId=Rev.ContractId"
//+ @" left join PHTGL_ActionPlanFormation as Act on Act.EPCCode=Con.EPCCode"
+ @" LEFT JOIN Base_Project AS Pro ON Pro.ProjectId = Con.ProjectId"
+ @" LEFT JOIN Base_Depart AS Dep ON Dep.DepartId = Con.DepartId"
+ @" LEFT JOIN Person_Persons AS U ON U.PersonId = Con.Agent WHERE 1=1 and Rev.State=@State";
List listStr = new List();
listStr.Add(new SqlParameter("@ContractCreating", Const.ContractCreating.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));
listStr.Add(new SqlParameter("@State", Const.ContractReview_Complete));
if (!(this.CurrUser.PersonId == Const.sysglyId))
{
strSql += " and Con.ProjectId =@ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
}
if (!string.IsNullOrEmpty(this.txtContractName.Text.Trim()))
{
strSql += " AND Con.ContractName LIKE @ContractName";
listStr.Add(new SqlParameter("@ContractName", "%" + this.txtContractName.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(drpDepartId.SelectedValue))
{
strSql += " AND Con.DepartId = @DepartId";
listStr.Add(new SqlParameter("@DepartId", drpDepartId.SelectedValue));
}
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 分页 排序
///
/// 改变索引事件
///
///
///
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();
}
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 == "export")
//{
// ActionPlanFormation actionPlanFormation = new ActionPlanFormation();
// var Act = BLL.PHTGL_ActionPlanReviewService.GetPHTGL_ActionPlanReviewById(fileId);
// actionPlanFormation.Print(Act.ActionPlanID);
// return;
//}
//if (e.CommandName == "download")
//{
// PageContext.RegisterStartupScript(Windowtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ActionPlanAttachUrl&menuId={1}", fileId, BLL.Const.ActionPlanReview)));
// return;
//}
}
#endregion
#region 查询 重置
///
/// 查询按钮
///
///
///
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
protected void btnRset_Click(object sender, EventArgs e)
{
txtContractName.Text = "";
BindGrid();
}
#endregion
#region 获取按钮权限
///
/// 获取按钮权限
///
///
///
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ActionPlanReview);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(Const.BtnAdd))
{
}
if (buttonList.Contains(Const.BtnDelete))
{
}
}
}
#endregion
#region 打印
protected void btnPrinter_Click1(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string Id = Grid1.SelectedRowID;
PHTGL_ContractReviewService.PrintApprovalForm(Id);
}
#endregion
}
}