using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
namespace FineUIPro.Web.ZHGL.Plan
{
public partial class MainContractView : PageBase
{
#region 定义项
///
/// 主键
///
public string MainContractId
{
get
{
return (string)ViewState["MainContractId"];
}
set
{
ViewState["MainContractId"] = value;
}
}
///
/// 项目主键
///
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
///
/// 定义会签意见集合
///
public static List approves = new List();
#endregion
#region 加载
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.ProjectId = this.CurrUser.LoginProjectId;
this.MainContractId = Request.Params["MainContractId"];
var q = (from x in Funs.DB.Person_Persons where x.UnitId == Const.UnitId_SEDIN && x.DepartId == Const.Depart_constructionId && x.RoleIds != null && x.RoleIds != Const.NoOfficeRole && x.RoleIds != string.Empty && (!x.IsPost.HasValue || x.IsPost == true) orderby x.PersonName select x).ToList();
Model.ActionPlan_MainContract MainContract = BLL.MainContractService.GetMainContractById(this.MainContractId);
if (MainContract != null)
{
var compileMan = BLL.Person_PersonsService.GetPerson_PersonsById(MainContract.CompileMan);
if (compileMan != null)
{
q.Add(compileMan);
}
}
this.drpPerson.DataTextField = "PersonName";
this.drpPerson.DataValueField = "PersonId";
this.drpPerson.DataSource = q;
this.drpPerson.DataBind();
Funs.FineUIPleaseSelect(this.drpPerson);
if (!string.IsNullOrEmpty(this.MainContractId))
{
if (MainContract != null)
{
HFMainContractId.Text = this.MainContractId;
this.ProjectId = MainContract.ProjectId;
if (MainContract.Edition != null)
{
txtEdition.Text = MainContract.Edition.ToString();
}
///读取编号
this.txtMainContractCode.Text = MainContract.MainContractCode;
this.txtMainContractName.Text = MainContract.MainContractName;
this.txtProjectId.Text = MainContract.ProjectId;
this.txtVersionNo.Text = MainContract.VersionNo;
if (!string.IsNullOrEmpty(MainContract.ProjectType))
{
this.drpProjectType.SelectedValue = MainContract.ProjectType;
}
else
{
this.drpProjectType.Hidden = true;
}
this.txtCompileMan.Text = MainContract.CompileMan;
if (MainContract.CompileDate != null)
{
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", MainContract.CompileDate);
}
List list = BLL.MainContractApproveService.GetReviewingPersonIds(this.MainContractId);
if (list.Count > 0)
{
this.drpPerson.SelectedValueArray = list.ToArray();
}
bindApprove();
}
WindowAtt_Close(null, null);
}
else
{
this.txtCompileMan.Text = this.CurrUser.PersonName;
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.trAtt.Hidden = true;
txtEdition.Text = "0";
plApprove2.Hidden = true;
////自动生成编码
this.txtMainContractCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.OfficeMainContractMenuId, this.ProjectId, this.CurrUser.UnitId);
this.txtMainContractName.Text = this.SimpleForm1.Title;
this.txtVersionNo.Text = "V1.0";
}
}
}
///
/// 审批列表
///
private void bindApprove()
{
var list = MainContractOpinionService.getListData(MainContractId, null);
gvApprove.DataSource = list;
gvApprove.DataBind();
}
#endregion
#region 附件上传
///
/// 上传附件
///
///
///
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(HFMainContractId.Text)) //新增记录
{
HFMainContractId.Text = SQLHelper.GetNewID(typeof(Model.ActionPlan_MainContract));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/MainContractAttachUrl&menuId={1}&type=-1", HFMainContractId.Text, BLL.Const.OfficeMainContractMenuId)));
}
protected void btnapprove_Click(object sender, EventArgs e)
{
//HFConstructSolutionId.Text
var approve = MainContractApproveService.GetMainContractApproveByApproveMan(HFMainContractId.Text, CurrUser.PersonId);
if (approve != null)
{
var approveId = approve.MainContractApproveId;
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/MainContractAttachUrl&menuId={2}",
0, approveId, Const.OfficeMainContractMenuId)));
}
}
#endregion
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
{
this.divC.InnerHtml = string.Empty;
var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == HFMainContractId.Text);
if (getAtt != null)
{
this.divC.InnerHtml = UploadAttachmentService.ShowAttachment("../../", getAtt.AttachUrl);
}
else
{
this.trAtt.Hidden = true;
}
}
public string man(Object man)
{
string appman = string.Empty;
if (Person_PersonsService.GetPerson_PersonsById(man.ToString()) != null)
{
appman = Person_PersonsService.GetPerson_PersonsById(man.ToString()).PersonName;
}
return appman;
}
protected void gvApprove_RowCommand(object sender, GridCommandEventArgs e)
{
object[] keys = gvApprove.DataKeys[e.RowIndex];
string fileId = string.Empty;
if (keys == null)
{
return;
}
else
{
fileId = keys[0].ToString();
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/MainContractAttachUrl&menuId={2}",
-1, fileId, Const.OfficeMainContractMenuId)));
}
}
}