2022-09-05 16:36:31 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
namespace FineUIPro.Web.PHTGL.ContractCompile
{
public partial class ContractReview_Countersign : PageBase
{
public string ContractId
{
get
{
return ( string ) ViewState [ "ContractId" ] ;
}
set
{
ViewState [ "ContractId" ] = 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 ( ) ;
btnNew . OnClientClick = Window1 . GetShowReference ( "ContractReviewEdit.aspx" , "创建审批流" ) + "return false;" ;
GetButtonPower ( ) ;
BindGrid ( ) ;
}
}
/// <summary>
/// 数据绑定
/// </summary>
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 @ContractCreat_Complete THEN ' 编 制 完 成 '
WHEN @Contract_countersign THEN ' 会 签 中 '
WHEN @Contract_countersign_Complete THEN ' 会 签 完 成 '
WHEN @Contract_countersign_Refuse THEN ' 会 签 被 拒 '
WHEN @ContractReviewing THEN ' 审 批 中 '
WHEN @ContractReview_Complete THEN ' 审 批 成 功 '
WHEN @ContractReview_Refuse THEN ' 审 批 被 拒 ' END ) AS State ,
ApproveType = stuff ( ( select ',' + ApproveType from PHTGL_Approve app2 where app2 . ContractId = Rev . ContractReviewId and app2 . state = 0 for xml path ( ' ' ) ) , 1 , 1 , ' ' ) ,
Con . Remarks ,
Con . EPCCode ,
Con . ProjectShortName ,
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 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 State in (@ContractCreat_Complete,@Contract_countersign,@Contract_countersign_Refuse)" ;
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 ( "@Contract_countersign_Complete" , Const . Contract_countersign_Complete ) ) ;
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 ( "@Contract_countersign_Refuse" , Const . Contract_countersign_Refuse ) ) ;
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 ( ) + "%" ) ) ;
}
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 )
{
OAWebSevice . Pushoa ( ) ;
BindGrid ( ) ;
}
#endregion
#region 双 击 单 机 事 件
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
this . ApproveData ( ) ;
}
/// <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_ContractReviewService . GetPHTGL_ContractReviewById ( id ) ;
if ( actReview . State = = Const . Contract_countersign_Refuse )
{
btnEditContract . Hidden = false ;
}
else
{
btnEditContract . Hidden = true ;
}
}
#endregion
/// <summary>
/// 修改合同
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEditContract_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string id = Grid1 . SelectedRowID ;
var Model_ContractView = BLL . PHTGL_ContractReviewService . GetPHTGL_ContractReviewById ( id ) ;
var Model_Contract = BLL . ContractService . GetContractById ( Model_ContractView . ContractId ) ;
if ( Model_Contract ! = null )
{
if ( Model_Contract . Agent = = this . CurrUser . PersonId | | Model_Contract . CreatUser = = this . CurrUser . PersonId )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "ContractFormationEdit.aspx?ContractId={0}" , Model_Contract . ContractId , "编辑 - " ) ) ) ;
}
else
{
ShowNotify ( "当前用户非合同编制人无法修改" , MessageBoxIcon . Warning ) ;
}
}
}
/// <summary>
/// 编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click ( object sender , EventArgs e )
{
EditData ( ) ;
}
//private void SubmitAgain()
//{
// if (Grid1.SelectedRowIndexArray.Length == 0)
// {
// Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
// return;
// }
// string id = Grid1.SelectedRowID;
// Model.PHTGL_ContractReview _ContractReview = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(id);
// Model.PHTGL_Contract _Contract = BLL.ContractService.GetContractById(_ContractReview.ContractId);
// if (_Contract.CreatUser != this.CurrUser.PersonId)
// {
// Alert.ShowInTop("您不是编制人无法重新提交!", MessageBoxIcon.Warning);
// return;
// }
// _ContractReview.State = Const.Contract_countersign;
// BLL.PHTGL_ContractReviewService.UpdatePHTGL_ContractReview(_ContractReview);
// _Contract.ApproveState = Const.Contract_countersign;
// ContractService.UpdateContract(_Contract);
// var tbRefuseMan = PHTGL_ApproveService.GetRefuseEndMan(id);//获取审批拒绝的人员
// var Countersignermodel = PHTGL_ContractReviewService.GetApproveManModels__Countersigner(id);
// var ApproveMan = Countersignermodel.Find(x => x.Rolename == tbRefuseMan.Rows[0]["ApproveType"].ToString());
// if (ApproveMan!=null) //判断拒绝的人员是否属于会签
// {
// for (int i = 0; i < Countersignermodel.Count; i++)
// {
// Model.PHTGL_Approve _Approve = new Model.PHTGL_Approve();
// _Approve.ApproveId = SQLHelper.GetNewID(typeof(Model.PHTGL_Approve));
// _Approve.ContractId = id;
// _Approve.ApproveMan = Countersignermodel[i].userid;
// _Approve.ApproveDate = "";
// _Approve.State = 0;
// _Approve.IsAgree = 0;
// _Approve.ApproveIdea = "";
// _Approve.ApproveType = Countersignermodel[i].Rolename;
// _Approve.IsPushOa = 0;
// _Approve.ApproveForm = PHTGL_ApproveService.ContractReview_Countersign;
// BLL.PHTGL_ApproveService.AddPHTGL_Approve(_Approve);
// }
// }
// else
// {
// Model.PHTGL_Approve _Approve = new Model.PHTGL_Approve();
// _Approve.ApproveId = SQLHelper.GetNewID(typeof(Model.PHTGL_Approve));
// _Approve.ContractId = id;
// _Approve.ApproveMan = tbRefuseMan.Rows[0]["ApproveMan"].ToString();
// _Approve.ApproveDate = "";
// _Approve.State = 0;
// _Approve.IsAgree = 0;
// _Approve.ApproveIdea = "";
// _Approve.ApproveType = tbRefuseMan.Rows[0]["ApproveType"].ToString();
// _Approve.IsPushOa = 0;
// _Approve.ApproveForm = PHTGL_ApproveService.ContractReview_Countersign;
// BLL.PHTGL_ApproveService.AddPHTGL_Approve(_Approve);
// }
// OAWebSevice.Pushoa();
// ShowNotify("重新提交成功!", MessageBoxIcon.Success);
// BindGrid();
//}
/// <summary>
/// 审批
/// </summary>
private void ApproveData ( )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string id = Grid1 . SelectedRowID ;
var contract = BLL . PHTGL_ContractReviewService . GetPHTGL_ContractReviewById ( id ) ;
if ( contract ! = null )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "ContractReviewDetail.aspx?ContractReviewId={0}" , id , "编辑 - " ) ) ) ;
}
}
protected void btnQueryApprove_Click ( object sender , EventArgs e )
{
this . ApproveData ( ) ;
}
private void EditData ( )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string id = Grid1 . SelectedRowID ;
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "ContractReviewEdit.aspx?ContractReviewId={0}" , id , "编辑 - " ) ) ) ;
}
#region 删 除
/// <summary>
/// 删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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 . PHTGL_ContractReviewService . GetPHTGL_ContractReviewById ( rowID ) ;
if ( p ! = null )
{
BLL . LogService . AddSys_Log ( this . CurrUser , p . ContractId , p . ContractId , BLL . Const . ContractMenuId , BLL . Const . BtnDelete ) ;
BLL . PHTGL_ApproveService . DeletePHTGL_ApproveBycontractId ( rowID ) ;
var ContractModel = BLL . ContractService . GetContractById ( p . ContractId ) ;
ContractModel . ApproveState = Const . ContractCreating ;
ContractService . UpdateContract ( ContractModel ) ;
BLL . PHTGL_ContractReviewService . DeletePHTGL_ContractReviewById ( 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 . ContractReview ) ;
if ( buttonList . Count ( ) > 0 )
{
if ( buttonList . Contains ( Const . BtnAdd ) )
{
// btnNew.Hidden = false;
}
if ( buttonList . Contains ( Const . BtnModify ) )
{
btnMenuEdit . Hidden = false ;
}
if ( buttonList . Contains ( Const . BtnDelete ) )
{
btnDelete . Hidden = false ;
}
}
}
#endregion
protected void btnPrinter_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string Id = Grid1 . SelectedRowID ;
//ContractReview contractReview = new ContractReview();
//contractReview.Print(Id);
2023-03-03 10:46:14 +08:00
BLL . PHTGL_ContractReviewService . PrintFile ( Id ) ;
2022-09-05 16:36:31 +08:00
}
protected void btnPrinterWord_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string Id = Grid1 . SelectedRowID ;
btnPrinterWord . EnablePress = false ;
ContractId = BLL . PHTGL_ContractReviewService . GetPHTGL_ContractReviewById ( Id ) . ContractId ;
var Con = BLL . ContractService . GetContractById ( ContractId ) ;
if ( Con . IsUseStandardtxt = = 2 | | Con . ContractAttribute = = 1 )
{
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ContractAttachUrl&menuId={1}" , ContractId , BLL . Const . ContractFormation ) ) ) ;
}
else
{
//ContractReview contractReview = new ContractReview();
//contractReview.printContractAgreement(ContractId);
BLL . PHTGL_ContractReviewService . printContractAgreement ( ContractId ) ;
}
}
}
}