1017 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1017 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | ||
| using System.Collections;
 | ||
| using System.Data;
 | ||
| using System.IO;
 | ||
| using System.Text;
 | ||
| using System.Web;
 | ||
| using System.Web.UI;
 | ||
| using System.Web.UI.HtmlControls;
 | ||
| using System.Web.UI.WebControls;
 | ||
| using DeiNiu.wms.Logical;
 | ||
| using DeiNiu.Utils;
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| public partial class ProjectCenter :  PageBase
 | ||
|     {
 | ||
|         private LProject _logic;
 | ||
|     
 | ||
|   
 | ||
|         protected void Page_Load(object sender, EventArgs e)
 | ||
|         { 
 | ||
|             if (!IsPostBack)
 | ||
|             {
 | ||
|                 if (lem == null) return ;
 | ||
|                 _logic = new LProject();
 | ||
|                 initializeControles();
 | ||
|                 Databound();
 | ||
| 
 | ||
|             }
 | ||
|             SessionSeting();
 | ||
| 
 | ||
|           
 | ||
| 
 | ||
|         }
 | ||
|  
 | ||
|         /*****************************************   private methods   ******************************************/
 | ||
| 
 | ||
| 
 | ||
|     
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// bound the query list.
 | ||
|         /// </summary>
 | ||
|         private void Databound()
 | ||
|         {
 | ||
|             GridView1.DataSource =  getProjects();
 | ||
|             GridView1.DataBind();
 | ||
|             UpdateSession();
 | ||
|            
 | ||
|            // ProjectDataBind();
 | ||
|          //   ProjectDetailDataBind();
 | ||
|             //    btnSubmit.Enabled = false;
 | ||
|            ClearProjDetailData();
 | ||
|            ClearProjData();
 | ||
|             intializeProjectMasterDept();
 | ||
|         }
 | ||
| 
 | ||
|     /// <summary>
 | ||
|     /// 根据条件取相应的项目信息
 | ||
|     /// </summary>
 | ||
|     /// <returns></returns>
 | ||
|      DataView  getProjects()
 | ||
|        {
 | ||
|            if (TreeDeptEmp.Nodes.Count == 0) return new DataView();
 | ||
|            DataView dv = _logic.GetProjectsByYearMonth( btnYear.Text, rdblstMonth.SelectedValue).DefaultView;
 | ||
|         string selectDept = string.Empty;
 | ||
|         string selectEmp = string.Empty;
 | ||
|         string inputProjectName = string.Empty;
 | ||
|         string rowFilter = string.Empty;
 | ||
| 
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|          if(rdlstAssignQry.SelectedValue=="0")  //all assigned and unassigned
 | ||
|          {
 | ||
|              
 | ||
|               //设定员工和部门条件
 | ||
|            if( TreeDeptEmp.SelectedNode != null)
 | ||
|              if(TreeDeptEmp.SelectedNode.Text.StartsWith(".")) //employee
 | ||
|              {
 | ||
|                  rowFilter = "pj_master = " + TreeDeptEmp.SelectedValue;
 | ||
|              }
 | ||
|              else
 | ||
|              {
 | ||
|                  rowFilter = "pj_dept =" + TreeDeptEmp.SelectedValue;
 | ||
|              }
 | ||
| 
 | ||
|         }
 | ||
|          else
 | ||
|          {
 | ||
|              if (rdlstAssignQry.SelectedValue == "1") //assigned 
 | ||
|                  rowFilter = "pj_status ='" + ProjectStatus.项目已分配 +"'";
 | ||
|              else
 | ||
|                  rowFilter = "pj_status ='" + ProjectStatus.项目未分配 +"'";
 | ||
|          }
 | ||
| 
 | ||
|              //设定项目名称过滤
 | ||
|              if(txtQryProjectName.Text.Trim().Length>0)
 | ||
|              {
 | ||
|                  if(rowFilter.Length>0)
 | ||
|                  {
 | ||
|                      rowFilter += " and ";
 | ||
| 
 | ||
|                  }
 | ||
|                  
 | ||
|              rowFilter += " pj_name like '%" + txtQryProjectName.Text.Trim() + "%'";
 | ||
|                   
 | ||
|              }
 | ||
| 
 | ||
| 
 | ||
|         dv.RowFilter = rowFilter;
 | ||
|            return dv;
 | ||
|        }
 | ||
| 
 | ||
|       
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 通过判断当前用户的身份,确定返回不同的项目列表
 | ||
|         /// </summary>
 | ||
|         /// <returns></returns>
 | ||
|          
 | ||
|         void initializeControles()
 | ||
|         {
 | ||
|             btnYear.Text = DateTime.Today.Year.ToString();
 | ||
|             rdblstMonth.SelectedItem.Selected = false;
 | ||
|             rdblstMonth.Items.FindByValue(DateTime.Today.Month.ToString()).Selected = true;
 | ||
|        
 | ||
|             drpdProjlisFromYear.Items.Clear();
 | ||
|             drplstProjectToYear.Items.Clear();
 | ||
|        
 | ||
|             for (int i = DateTime.Now.Year-10; i < DateTime.Now.Year + 10; i++)
 | ||
|             {
 | ||
|                 ListItem li = new ListItem(i.ToString(),i.ToString());
 | ||
|                 drpdProjlisFromYear.Items.Add(li);
 | ||
|                 drplstProjectToYear.Items.Add(li); 
 | ||
|             }
 | ||
|             SetDropDownlistSelection(drplstProjectToYear, DateTime.Now.Year.ToString());
 | ||
|             SetDropDownlistSelection(drpdProjlisFromYear, DateTime.Now.Year.ToString());
 | ||
| 
 | ||
|             intializeProjectMasterDept();
 | ||
|            bindDeptEmp();
 | ||
|            validDeptEmp();
 | ||
|         }
 | ||
| 
 | ||
|       void validDeptEmp()
 | ||
|       {
 | ||
|           if(lem.CanManageProjects) return;
 | ||
|          
 | ||
|       }
 | ||
| 
 | ||
|     
 | ||
| 
 | ||
|       void intializeProjectMasterDept()
 | ||
|       {
 | ||
|           txtProjMaster.Text = "";
 | ||
|           drplstProjDept.Items.Clear();
 | ||
|           if (TreeDeptEmp.SelectedValue == "0") return;
 | ||
|           if (TreeDeptEmp.SelectedNode != null)
 | ||
|               if (TreeDeptEmp.SelectedNode.Text.StartsWith(".")) //employee
 | ||
|               {
 | ||
|                   LEmployee tmp = new LEmployee();
 | ||
|                   tmp.Initialize(Convert.ToInt32(TreeDeptEmp.SelectedValue));
 | ||
|                   drplstProjDept.DataSource = tmp.GetEmployee.GetDepartments();
 | ||
|                   drplstProjDept.DataTextField = "DEP_NAME";
 | ||
|                   drplstProjDept.DataValueField = "ID";
 | ||
|                   drplstProjDept.DataBind();
 | ||
| 
 | ||
|                   txtProjMaster.Text = TreeDeptEmp.SelectedNode.Text.Substring(1).Replace("<strong>","").Replace("</strong>",string.Empty);  
 | ||
|               }
 | ||
|               else
 | ||
|               {
 | ||
|                   string dept = TreeDeptEmp.SelectedNode.Text.Substring(4);
 | ||
|                    dept = dept.Substring(0, dept.Length -5);
 | ||
|                   drplstProjDept.Items.Add(new ListItem(dept,TreeDeptEmp.SelectedNode.Value)); 
 | ||
|               }
 | ||
|       }
 | ||
| 
 | ||
|     /// <summary>
 | ||
|         /// 绑定部门及用户
 | ||
|         /// </summary>
 | ||
|         private void bindDeptEmp()
 | ||
|         {
 | ||
|             TreeDeptEmp.Nodes.Clear();
 | ||
|             if (lem.CanManageProjects) //拥有管理项目的角色则可以看到所有项目
 | ||
|                 BindEmpTree(TreeDeptEmp, "0", TreeDeptEmp.SelectedNode, lem.GetDepartments().DefaultView, lem.GetActivedEmpDept().DefaultView);
 | ||
|  
 | ||
|             else
 | ||
|                  BindEmpTree(TreeDeptEmp, Util.buildWhereIntIn(lem.GetCanApproveDeptList()), TreeDeptEmp.SelectedNode, lem.GetDepartments().DefaultView, lem.GetActivedEmpDept().DefaultView);
 | ||
| 
 | ||
|         if (TreeDeptEmp.Nodes.Count >0) TreeDeptEmp.Nodes[0].Selected = true;
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         public void BindEmpTree(TreeView tree, string id, TreeNode pNode, DataView deptdv, DataView empdv)
 | ||
|         {
 | ||
|             if (lem.CanManageProjects)
 | ||
|             {
 | ||
|                 deptdv.RowFilter = "dep_mastdept in (" + id + ")";
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 if (id == string.Empty) return;
 | ||
|                 deptdv.RowFilter = "dep_mastdept in (" + id + ")";
 | ||
| 
 | ||
|                 if (pNode == null)
 | ||
|                     deptdv.RowFilter = "ID in (" + id + ")";
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             foreach (DataRowView row in deptdv)
 | ||
|             {
 | ||
|                 TreeNode node = new TreeNode();
 | ||
|                 node.Text = "<em>" + row["dep_name"] + "</em>";
 | ||
|                 node.Value = row["ID"].ToString(); 
 | ||
|                 node.ShowCheckBox = false;
 | ||
|                 node.Expanded = false;
 | ||
|                 empdv.RowFilter = "de_dept=" + node.Value;
 | ||
|                 foreach (DataRowView emrow in empdv)
 | ||
|                 {
 | ||
|                     TreeNode tnEmp = new TreeNode(".<strong>" + emrow["em_name"].ToString() +"</strong>" , emrow["ID"].ToString());
 | ||
|                     node.ChildNodes.Add(tnEmp);
 | ||
|                 }
 | ||
|                 if (pNode == null)
 | ||
|                 //说明是根节点
 | ||
|                 { 
 | ||
|                     tree.Nodes.Add(node); 
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
| 
 | ||
|                     pNode.ChildNodes.Add(node);
 | ||
| 
 | ||
|                 }
 | ||
|                 
 | ||
|                 BindEmpTree(tree,  node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private void SessionSeting()
 | ||
|         {
 | ||
|             if (IsPostBack)
 | ||
|             {
 | ||
|                 //           _logic = (LEmployee)Session[appScope.PagelevelObj];
 | ||
|                 _logic = (LProject)Session[appScope.PagelevelObj];
 | ||
|             }
 | ||
|         }
 | ||
|     
 | ||
|         private void UpdateSession()
 | ||
|         {
 | ||
| //        Session[appScope.PagelevelObj] = _logic;
 | ||
|             Session[appScope.PagelevelObj] = _logic;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 绑定当前项目信息到页面的项目基本信息区
 | ||
|         /// </summary>
 | ||
|         void ProjectDataBind()
 | ||
|         {
 | ||
|             ProjectDetail.Visible = true;
 | ||
|             btnSaveNewProj.Enabled = true;
 | ||
|             txtProjectName.Text = _logic.GetProject.pj_name;
 | ||
|             SetDropDownlistSelection(drpdProjlisFromYear, Convert.ToDateTime(_logic.GetProject.pj_planStartDate) .Year.ToString());
 | ||
|             SetDropDownlistSelection(drplstProjFromMonth, Convert.ToDateTime(_logic.GetProject.pj_planStartDate).Month.ToString());
 | ||
|             SetDropDownlistSelection(drplstProjectToYear, Convert.ToDateTime(_logic.GetProject.pj_planEndDate).Year.ToString());
 | ||
|             SetDropDownlistSelection(drlstProjToMonth, Convert.ToDateTime(_logic.GetProject.pj_planEndDate).Month.ToString());
 | ||
|    
 | ||
|             txtPrjDesc.Text = _logic.GetProject.pj_mem;
 | ||
|             txtProjProgress.Text = _logic.GetProject.pj_progress.ToString();  //项目进度
 | ||
|             txtProjPercent.Text = _logic.GetProject.pj_percent.ToString();    //项目权重
 | ||
|             SetDropDownlistSelection(drplstProjType, _logic.GetProject.pj_type);
 | ||
|             txtProjMem4delete.Visible = _logic.GetProject.pj_status == DeiNiu.Utils.ProjectStatus.新增未提交;
 | ||
|             lbprjmem4Delete.Visible = _logic.GetProject.pj_status == DeiNiu.Utils.ProjectStatus.新增未提交;
 | ||
|             txtProjMem4delete.Text = _logic.GetProject.pj_mem4del;
 | ||
|           //  txtProjMaster.Text = lem.GetEmployee.em_name;
 | ||
|            txtProjPercent.Text = _logic.GetProject.pj_percent.ToString() ;
 | ||
|             SetDropDownlistSelection(drplstProjDept,   _logic.GetProject.pj_dept.ToString() );
 | ||
| 
 | ||
|             ApproveListBind(_logic.GetProject.ID);
 | ||
| 
 | ||
|             
 | ||
|            
 | ||
|         }
 | ||
|     void ApproveListBind(int id)
 | ||
|     {
 | ||
|         RepeaterApproveList.DataSource = _logic.PaObj.GetApproveListByTastkId(id);
 | ||
|         RepeaterApproveList.DataBind();
 | ||
|         panelApprovelist.Visible = true;
 | ||
|     }
 | ||
|         /// <summary>
 | ||
|         /// 页面的项目基本信息区的信息回传给项目实例
 | ||
|         ///  
 | ||
|         /// </summary>
 | ||
|         void SetProjectDataBack()
 | ||
|         {
 | ||
| 
 | ||
|             //if (_logic.GetProject.ID > 0)
 | ||
|             //{
 | ||
|             //    _logic.GetProject.lastmodified = DateTime.Now.ToString();
 | ||
| 
 | ||
|             //} 
 | ||
| 
 | ||
|             //    ProjectDetail.Visible = true;
 | ||
|             _logic.GetProject.pj_name  = txtProjectName.Text;
 | ||
|             _logic.GetProject.pj_planStartDate =  drpdProjlisFromYear.SelectedValue +"-" + drplstProjFromMonth.SelectedValue +"-01"; 
 | ||
|             _logic.GetProject.pj_planEndDate = drplstProjectToYear.SelectedValue +"-" + drlstProjToMonth.SelectedValue +"-01";
 | ||
|             _logic.GetProject.pj_master = lem.GetEmployee.ID;
 | ||
|             _logic.GetProject.pj_mem =txtPrjDesc.Text;
 | ||
|             //   _logic.GetProject.pj_progress  =   Convert.ToInt32(txtProjProgress.Text)  ;  //项目进度
 | ||
|             _logic.GetProject.pj_percent = Convert.ToInt32(txtProjPercent.Text) ;               //项目权重
 | ||
|             _logic.GetProject.pj_type = drplstProjType.SelectedValue;
 | ||
|             _logic.GetProject.pj_status =   ProjectStatus.新增未提交;
 | ||
|             _logic.GetProject.pj_mem4del = txtProjMem4delete.Text;
 | ||
|             _logic.GetProject.pj_dept = Convert.ToInt32(drplstProjDept.SelectedValue);
 | ||
|             _logic.GetProject.pj_nextDept = _logic.GetProject.pj_dept;
 | ||
|             //如果项目负责人是本部门的主管,则提交上级部门
 | ||
|             LDepartment dep = new LDepartment( _logic.GetProject.pj_dept);
 | ||
|             if (dep.GetDepartment.dep_manager == lem.GetEmployee.ID)
 | ||
|             {
 | ||
|                 _logic.GetProject.pj_nextDept = dep.GetDepartment.dep_mastdept;
 | ||
|                 if(dep.GetDepartment.dep_mastdept==0) //没有上级部门
 | ||
|                 {
 | ||
|                     _logic.GetProject.pj_status = ProjectStatus.新增考核通过;
 | ||
|                 }
 | ||
|             }
 | ||
|             _logic.GetProject.pj_percent = Convert.ToInt32(txtProjPercent.Text);
 | ||
|             lbuploadmessage.Text = "";
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// set data from shift object to page
 | ||
|         /// </summary>
 | ||
|         private void ProjectDetailDataBind()
 | ||
|         {
 | ||
|             ProjectMonthDetail.Visible = true;
 | ||
|             btnSubmit.Visible = true;
 | ||
|             txtPdName.Text = _logic.GetProject.pj_name;
 | ||
|             txtPdStartDate.Text = _logic.GetProject.pj_planStartDate;
 | ||
|             txtPdEndDate.Text = _logic.GetProject.pj_planEndDate;
 | ||
|             txtPrjProgress.Text = _logic.GetProject.pj_progress.ToString();
 | ||
|             txtPdActualEndDate.Text = _logic.GetProject.pj_finishDate;
 | ||
|             txtPdPlanTarget.Text = _logic.GetProjectDetail.pd_planTarget;
 | ||
|             txtPdFinishTarget.Text = _logic.GetProjectDetail.pd_finishedTarget;
 | ||
|             txtPdPercent.Text = _logic.GetProjectDetail.pd_percent.ToString();
 | ||
|             txtPdMem.Text = _logic.GetProjectDetail.pd_mem;
 | ||
| 
 | ||
|             //bind the files
 | ||
| 
 | ||
|             GVFiles.DataSource = _logic.GetProjectDetail.GetFiles();
 | ||
|             GVFiles.DataBind();
 | ||
|            
 | ||
|             ApproveListBind(_logic.GetProjectDetail.ID);
 | ||
|             
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// set data from shift object to page
 | ||
|         /// </summary>
 | ||
|         private void ClearProjDetailData()
 | ||
|         {
 | ||
|             ProjectMonthDetail.Visible = false;
 | ||
|             btnSubmit.Visible = false;
 | ||
|             txtPdName.Text = "";
 | ||
|             txtPdStartDate.Text = "";
 | ||
|             txtPdEndDate.Text = "";
 | ||
|             txtPrjProgress.Text = "";
 | ||
|             txtPdActualEndDate.Text = "";
 | ||
|             txtPdPlanTarget.Text ="";
 | ||
|             txtPdFinishTarget.Text = "";
 | ||
|             txtPdPercent.Text = "";
 | ||
|             txtPdMem.Text ="";
 | ||
| 
 | ||
|             //bind the files
 | ||
| 
 | ||
|             GVFiles.DataSource = _logic.GetProjectDetail.GetFiles();
 | ||
|             GVFiles.DataBind();
 | ||
|             panelApprovelist.Visible = false;
 | ||
|            
 | ||
|           
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void SetProjectDetailBack()
 | ||
|         {
 | ||
|             //if (_logic.GetProjectDetail.ID > 0)
 | ||
|             //{
 | ||
|             //    _logic.GetProjectDetail.lastmodified = DateTime.Now.ToString();
 | ||
| 
 | ||
|             //} 
 | ||
|  
 | ||
|             _logic.GetProject.pj_progress = Convert.ToInt32(txtPrjProgress.Text) ;
 | ||
|             _logic.GetProject.pj_finishDate =txtPdActualEndDate.Text  ;
 | ||
|             _logic.GetProjectDetail.pd_planTarget =txtPdPlanTarget.Text  ;
 | ||
|             _logic.GetProjectDetail.pd_finishedTarget = txtPdFinishTarget.Text  ;
 | ||
|             _logic.GetProjectDetail.pd_percent =Convert.ToInt32(txtPdPercent.Text)  ;
 | ||
|             _logic.GetProjectDetail.pd_mem =txtPdMem.Text ;
 | ||
|             //新增时status默认为”未提交‘
 | ||
|             lbuploadmessage.Text = "";
 | ||
|         }
 | ||
| 
 | ||
|         /************************************** protected methods (event listeners) ********************************/
 | ||
| 
 | ||
|         protected void btnAddnew_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             chgOperTxt(true);
 | ||
|             _logic.Initialize();
 | ||
|             ClearProjData();
 | ||
|             ProjectDetail.Visible = true;
 | ||
|             btnSaveNewProj.Enabled = true;
 | ||
|             validProjControles();
 | ||
|             intializeProjectMasterDept();
 | ||
|             lbuploadmessage.Text = "";
 | ||
|         }
 | ||
| 
 | ||
|         protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
 | ||
|         {
 | ||
|         }
 | ||
| 
 | ||
|   
 | ||
|         /// <summary>
 | ||
|         /// 保存项目基本信息
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void btnProjSubmit_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|           
 | ||
|             //检查项目状态有没有变化,变化则不允许保存。
 | ||
|            if(!_logic.GetProject.pj_status.Equals(ProjectStatus.项目未分配) )
 | ||
|            {  ScriptManager.RegisterStartupScript(Master.UpdatePanelMaster, typeof(UpdatePanel), "alert", "alert('项目  " + _logic.GetProject.pj_name + "已经被分配,不可以修改,保存失败。');", true);
 | ||
|               return;
 | ||
|            }
 | ||
|            
 | ||
|             
 | ||
|                 LProject lp = new LProject();
 | ||
|                 lp.GetProject.ID =_logic.GetProject.ID;
 | ||
|                 lp.GetProject.getModel();
 | ||
|                 if(!lp.GetProject.pj_status.Equals(_logic.GetProject.pj_status))
 | ||
|                 {
 | ||
|                     ScriptManager.RegisterStartupScript(Master.UpdatePanelMaster, typeof(UpdatePanel), "alert", "alert('并发操作,项目  " + _logic.GetProject.pj_name + "已经被他人修改,保存失败。');", true);
 | ||
|                     _logic.Initialize(_logic.GetProject.ID);
 | ||
|                     Databound();
 | ||
|                     ProjectDataBind();
 | ||
|                     return;
 | ||
|                 }
 | ||
|             
 | ||
|              SetProjectDataBack(); 
 | ||
|             if (_logic.GetProject.ID > 0) _logic.UpdateProject(); else _logic.AddProject();
 | ||
|             ClearProjData();
 | ||
|             Databound();
 | ||
|         
 | ||
|         }
 | ||
| 
 | ||
|     
 | ||
|         protected void GridView1_PageIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|         }
 | ||
| 
 | ||
|         protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
 | ||
|         {
 | ||
|             GridView1.PageIndex = e.NewPageIndex;
 | ||
|             Databound();
 | ||
| 
 | ||
|             //GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
 | ||
|             //     GridView1.DataBind();    
 | ||
|         }
 | ||
| 
 | ||
|         protected void GridView1_DataBinding(object sender, EventArgs e)
 | ||
|         {
 | ||
|         }
 | ||
| 
 | ||
|         protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 | ||
|         {
 | ||
|             /*
 | ||
|             CheckBox chk;
 | ||
|             if (e.Row.RowType == DataControlRowType.DataRow)
 | ||
|             {
 | ||
|                 chk = new CheckBox();
 | ||
|                 chk.ID = e.Row.Cells[0].Text.Trim();
 | ||
|                 string pdstatus = e.Row.Cells[13].Text.Trim();
 | ||
|                 chk.Enabled = (pdstatus == ProjectDetailStatus.月度未提交 || pdstatus == ProjectDetailStatus.考核未通过 ||
 | ||
|                                pdstatus == ProjectDetailStatus.审核未通过 || pdstatus == ProjectDetailStatus.预审未通过);
 | ||
|                 e.Row.Cells[1].Controls.Add(chk);
 | ||
|             }
 | ||
|             */
 | ||
|         }
 | ||
| 
 | ||
|         protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
 | ||
|         {
 | ||
|         }
 | ||
| 
 | ||
|         //reset the page
 | ||
|         protected void btnReset_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             _logic.Initialize();
 | ||
|             Page_Load(this, e);
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// delete the project and details
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void btnDelete_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             
 | ||
|             foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|             {
 | ||
|                 HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|                 if (!checkNews.Checked) continue;
 | ||
|                 _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|                 if (_logic.GetProject.pj_status.Equals(ProjectStatus.项目未分配))
 | ||
|                 {
 | ||
| 
 | ||
|                     _logic.GetProject.Delete();
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|             Databound();
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|         /***************************************** internal methods ********************************************/
 | ||
|  
 | ||
| 
 | ||
|         private void chgOperTxt(bool addNew)
 | ||
|         {
 | ||
|          
 | ||
|           
 | ||
|             btnSubmit.Enabled = true;
 | ||
|         }
 | ||
| 
 | ||
|         private void ClearProjData()  
 | ||
|         {
 | ||
|             ProjectDetail.Visible = false;
 | ||
|             btnSaveNewProj.Enabled = false;
 | ||
|             txtProjectName.Text = "";
 | ||
|             SetDropDownlistSelection(drpdProjlisFromYear, DateTime.Now.Year.ToString());
 | ||
|             SetDropDownlistSelection(drplstProjFromMonth, DateTime.Now.Month.ToString());
 | ||
|             SetDropDownlistSelection(drplstProjectToYear, DateTime.Now.Year.ToString());
 | ||
|             SetDropDownlistSelection(drlstProjToMonth, DateTime.Now.Month.ToString());
 | ||
| 
 | ||
|             txtProjMaster.Text = "";
 | ||
|             txtPrjDesc.Text ="";
 | ||
|             txtProjProgress.Text = "";  //项目进度
 | ||
|             txtProjPercent.Text = "";    //项目权重
 | ||
|             // SetDropDownlistSelection(drplstProjType, _logic.GetProject.pj_type);
 | ||
|             txtProjMem4delete.Visible =false;
 | ||
|             lbprjmem4Delete.Visible =false;
 | ||
|             txtProjMem4delete.Text = "";
 | ||
|             panelApprovelist.Visible = false;
 | ||
| 
 | ||
|             drplstProjDept.Items.Clear();
 | ||
|             lbuploadmessage.Text = "";
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|      
 | ||
|         protected void SetDropDownlistSelection(DropDownList drdlst,string value)
 | ||
|         {
 | ||
|            if(drdlst.SelectedIndex>=0) 
 | ||
|             drdlst.Items[drdlst.SelectedIndex].Selected = false;
 | ||
|             if (drdlst.Items.FindByValue(value)!=null)
 | ||
|                 drdlst.Items.FindByValue(value).Selected = true;
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// edit project detail
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
 | ||
|         {
 | ||
|             /*
 | ||
|         chgOperTxt(false);
 | ||
|         if (GridView1.DataKeys != null)
 | ||
|         {
 | ||
|             string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
 | ||
|             _logic.Initialize(int.Parse(id));
 | ||
|         }
 | ||
|         Databound();
 | ||
|         ProjectDetailDataBind();
 | ||
|     
 | ||
|          */
 | ||
|         }
 | ||
| 
 | ||
|   
 | ||
|         /// <summary>
 | ||
|         /// 显示项目基本信息
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void GridView1_EditProject(object sender, GridViewDeleteEventArgs e)
 | ||
|         {
 | ||
|         
 | ||
|             if (GridView1 != null)
 | ||
|             {
 | ||
|                 if (GridView1.DataKeys != null)
 | ||
|                 {
 | ||
|                     string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
 | ||
|                     _logic.Initialize(int.Parse(id));
 | ||
|                 }
 | ||
|             }
 | ||
|             GridView1.SelectedIndex = e.RowIndex;
 | ||
|             Databound();
 | ||
|             ProjectDataBind();
 | ||
|            // btnSaveNewProj.Enabled = _logic.GetProject.pj_status.Equals(ProjectStatus.新增未提交) || _logic.GetProject.pj_status.EndsWith("未通过");
 | ||
|            // btnDelete.Enabled = _logic.GetProject.pj_status.Equals(ProjectStatus.新增未提交) || _logic.GetProject.pj_status.EndsWith("未通过");
 | ||
|             validProjControles();
 | ||
|             btnSubmit.Visible = false;
 | ||
|       
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 进度编辑/计划
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             chgOperTxt(false);
 | ||
|             if (GridView1.DataKeys != null)
 | ||
|             {
 | ||
|                 string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
 | ||
|                 _logic.Initialize(int.Parse(id));
 | ||
|             }
 | ||
|             Databound();
 | ||
|             ProjectDetailDataBind();
 | ||
|             validPdControles();
 | ||
|         }
 | ||
|     void validProjControles()
 | ||
|     {
 | ||
|         divEditProject.Visible = _logic.GetProject.pj_status.Equals(ProjectStatus.项目未分配)  ; 
 | ||
|         txtProjectName.ReadOnly =!divEditProject.Visible;
 | ||
|         drpdProjlisFromYear.Enabled = divEditProject.Visible;
 | ||
|         drplstProjFromMonth.Enabled = divEditProject.Visible;
 | ||
|         drplstProjectToYear.Enabled = divEditProject.Visible;
 | ||
|         drlstProjToMonth.Enabled = divEditProject.Visible;
 | ||
|         drplstProjType.Enabled = divEditProject.Visible;
 | ||
|         txtPrjDesc.ReadOnly =!divEditProject.Visible;
 | ||
|         txtProjProgress.ReadOnly =!divEditProject.Visible; //项目进度
 | ||
|         txtProjPercent.ReadOnly =!divEditProject.Visible; //项目权重
 | ||
|         SetDropDownlistSelection(drplstProjType, _logic.GetProject.pj_type);
 | ||
|         txtProjMem4delete.ReadOnly =!divEditProject.Visible; //新增未提交;
 | ||
|         //  lbprjmem4Delete.Visible = divEditProject.Visible;
 | ||
|         drplstProjDept.Enabled = divEditProject.Visible;
 | ||
|         txtProjMaster.ReadOnly =!divEditProject.Visible;
 | ||
|     }
 | ||
|     void validPdControles()
 | ||
|     {
 | ||
|     //--monthly detail.
 | ||
|         projMonthDetailEdit.Visible =  false;
 | ||
|         txtPdName.ReadOnly =!projMonthDetailEdit.Visible;
 | ||
|         txtPdStartDate.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdEndDate.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPrjProgress.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdActualEndDate.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdPlanTarget.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdFinishTarget.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdPercent.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|         txtPdMem.ReadOnly =! projMonthDetailEdit.Visible ;
 | ||
|          
 | ||
|       
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// project detail 
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void btnSubmit_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             SetProjectDetailBack();
 | ||
|            
 | ||
|             _logic.GetProjectDetail.Update();
 | ||
|             ClearProjDetailData();
 | ||
|             Databound();
 | ||
|         }
 | ||
|         protected void rdblstMonth_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             GridView1.SelectedIndex = -1;
 | ||
|             Databound();
 | ||
|         }
 | ||
|         protected void btnYear_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             rdblstMonth.SelectedItem.Selected = false;
 | ||
|             rdblstMonth.Items[0].Selected = true;
 | ||
|             Databound();
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
| 
 | ||
|         protected void btnToApprove_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|        //       _logic.GetProject.ID = Convert.ToInt32(GridView1.Rows[1].Cells[0].Text.Trim());
 | ||
| 
 | ||
| 
 | ||
|             foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|             {
 | ||
|                 HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|                 if (!checkNews.Checked) continue;
 | ||
|                 _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|                 if(  _logic.GetProject.pj_status.EndsWith("未提交")||  _logic.GetProject.pj_status.EndsWith("未通过") )
 | ||
|                 {
 | ||
|                     _logic.GetProject.pj_nextDept = _logic.GetProject.pj_dept;
 | ||
|                     //如果项目负责人是本部门的主管,则提交上级部门
 | ||
|                     LDepartment dep = new LDepartment(_logic.GetProject.pj_dept);
 | ||
|                     if (dep.GetDepartment.dep_manager == lem.GetEmployee.ID)
 | ||
|                     {
 | ||
|                         _logic.GetProject.pj_nextDept = dep.GetDepartment.dep_mastdept;
 | ||
|                         if (dep.GetDepartment.dep_mastdept == 0) //没有上级部门
 | ||
|                         {
 | ||
|                             _logic.GetProject.pj_status = ProjectStatus.新增考核通过;
 | ||
|                             _logic.GetProject.Update();
 | ||
|                             continue; //超级领导自我审批
 | ||
|                         }
 | ||
|                     }
 | ||
|                     //正常情况下提交本部门领导批准
 | ||
|                     _logic.GetProject.pj_status = ProjectStatus.新增已提交;
 | ||
|                     _logic.GetProject.Update();
 | ||
|                 }
 | ||
|             }
 | ||
|              
 | ||
|             Databound();
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|     public string FormatShowContent(bool pass)
 | ||
|     {
 | ||
|         if (pass)
 | ||
|             return "通过" + "<img src=../Images/tick.png border=0 border=0 title= 审批通过>";
 | ||
|         return "未通过" + "<img src=../Images/cross.png border=0 border=0 title= 审批未通过>"; ;
 | ||
|     }
 | ||
| 
 | ||
|     protected void btnpdToApprove_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
| 
 | ||
|         foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|         {
 | ||
|             HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|             if (!checkNews.Checked) continue;
 | ||
|             _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|             if (_logic.GetProjectDetail.pd_status.EndsWith("未提交") || _logic.GetProjectDetail.pd_status.EndsWith("未通过"))
 | ||
|             {
 | ||
|                 _logic.GetProject.pj_nextDept = _logic.GetProject.pj_dept;
 | ||
|                 //如果项目负责人是本部门的主管,则提交上级部门
 | ||
|                 LDepartment dep = new LDepartment(_logic.GetProject.pj_dept);
 | ||
|                 if (dep.GetDepartment.dep_manager == lem.GetEmployee.ID)
 | ||
|                 {
 | ||
|                     _logic.GetProject.pj_nextDept = dep.GetDepartment.dep_mastdept;
 | ||
|                     if (dep.GetDepartment.dep_mastdept == 0) //没有上级部门
 | ||
|                     {
 | ||
|                         _logic.GetProjectDetail.pd_status = ProjectDetailStatus.审核通过; 
 | ||
|                         _logic.GetProject.Update();
 | ||
|                         _logic.GetProjectDetail.Update();
 | ||
|                         continue;  //超级领导自我审批
 | ||
|                     }
 | ||
|                 }
 | ||
|                 //正常情况下提交本部门领导批准
 | ||
|                 _logic.GetProject.Update();
 | ||
|                 _logic.GetProjectDetail.pd_status = ProjectDetailStatus.月度已提交;
 | ||
|                 _logic.GetProjectDetail.Update();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         Databound();
 | ||
| 
 | ||
|     }
 | ||
|     protected void btnpd2approve_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
| 
 | ||
|     }
 | ||
|     protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
 | ||
|     {
 | ||
|         GridView1.SelectedIndex = -1;
 | ||
|         intializeProjectMasterDept();
 | ||
|         Databound();
 | ||
|     }
 | ||
|     protected void btnQuery_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
|         Databound();
 | ||
|     }
 | ||
|     protected void btnAssign_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
| 
 | ||
|         if (TreeDeptEmp.SelectedNode == null || TreeDeptEmp.SelectedNode != null && TreeDeptEmp.SelectedValue == "0" || TreeDeptEmp.SelectedNode.Parent.Value=="0")
 | ||
|         {
 | ||
|             ScriptManager.RegisterStartupScript(Master.UpdatePanelMaster, typeof(UpdatePanel), "alert", "alert('请选择待分配项目的责任人。');", true);
 | ||
|             return;
 | ||
|         } 
 | ||
|         foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|         {
 | ||
|             HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|             if (!checkNews.Checked) continue;
 | ||
|             _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|             if (_logic.GetProject.pj_status.Equals(ProjectStatus.项目未分配) )
 | ||
|             {
 | ||
|                
 | ||
|                 _logic.GetProject.pj_status = ProjectStatus.项目已分配;
 | ||
|                 _logic.GetProject.pj_master = Convert.ToInt32(TreeDeptEmp.SelectedValue);
 | ||
|                 _logic.GetProject.pj_dept = Convert.ToInt32(TreeDeptEmp.SelectedNode.Parent.Value);
 | ||
|                 _logic.GetProject.Update();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         Databound();
 | ||
| 
 | ||
| 
 | ||
|     }
 | ||
|     protected void btnUnAssign_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
|         foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|         {
 | ||
|             HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|             if (!checkNews.Checked) continue;
 | ||
|             _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|             if (!_logic.GetProject.pj_status.Equals(ProjectStatus.项目冻结))
 | ||
|             {
 | ||
| 
 | ||
|                 _logic.GetProject.pj_status = ProjectStatus.项目冻结; 
 | ||
|                 _logic.GetProject.Update();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         Databound();
 | ||
|     }
 | ||
|   
 | ||
|     protected void btnFileUpload1_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
|         const string projectDest = "~/upload/projects/";
 | ||
|         if (fileUpload1.FileName.Length==0) return;
 | ||
|         lbuploadmessage.Text = "";
 | ||
|         DirectoryInfo dir = new DirectoryInfo(Server.MapPath(projectDest));
 | ||
|         if (!dir.Exists)
 | ||
|             dir.Create();
 | ||
|         string fileSavePath = Server.MapPath(projectDest + fileUpload1.FileName);
 | ||
|         fileUpload1.SaveAs(fileSavePath);
 | ||
|      //   Master.ScriptMgr.EnablePartialRendering = true;
 | ||
|        // pdUpload.Visible = false;
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         importProjects(fileSavePath);
 | ||
|         lbuploadmessage.Text = "上传成功!";
 | ||
|         Databound();
 | ||
|         
 | ||
|         System.IO.File.Delete(fileSavePath);
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
|     void importProjects(string fileName)
 | ||
|     {
 | ||
|             int Count = 1;
 | ||
|             string tableName = string.Empty;
 | ||
|         try
 | ||
|         { 
 | ||
|             
 | ||
|         DataSet ds = Util.Excel2DataSet(fileName);
 | ||
|         foreach (DataTable dt in ds.Tables)
 | ||
|         {
 | ||
| 
 | ||
|             Count = 1;
 | ||
|             tableName = dt.TableName;
 | ||
|             foreach (DataRow dr in dt.Rows)
 | ||
|             {
 | ||
|                 Count++; 
 | ||
|                 _logic.Initialize();
 | ||
|                 if (dr["部门代码"].ToString().Length>0)
 | ||
|                 _logic.GetProject.pj_dept = Convert.ToInt32(dr["部门代码"].ToString());
 | ||
|                  if (dr["人员编号"].ToString().Length > 0)
 | ||
|                 _logic.GetProject.pj_master = Convert.ToInt32(dr["人员编号"].ToString());
 | ||
|                   _logic.GetProject.pj_mem = dr["项目描述"].ToString().Substring(0,500);
 | ||
|                 _logic.GetProject.pj_name = dr["项目名称"].ToString().Substring(0,50);
 | ||
|                 if (dr["项目权重"].ToString().Length > 0)
 | ||
|                 _logic.GetProject.pj_percent = Convert.ToInt32(dr["项目权重"].ToString());
 | ||
|                 _logic.GetProject.pj_type = dr["项目性质"].ToString();
 | ||
|                 _logic.GetProject.pj_nextDept =-1; //不需审批
 | ||
|                 if (_logic.GetProject.pj_master >0) _logic.GetProject.pj_status = ProjectStatus.项目已分配;
 | ||
|                 else
 | ||
|                 {
 | ||
|                     _logic.GetProject.pj_status = ProjectStatus.项目未分配;
 | ||
|                 }
 | ||
| 
 | ||
|                 _logic.GetProject.pj_planStartDate = dr["项目开始年份"].ToString().Trim()  + "-" + dr["项目开始月份"].ToString().Trim()  + "-01";
 | ||
|                 _logic.GetProject.pj_planEndDate = _logic.GetProject.pj_planStartDate;
 | ||
|                
 | ||
|                 Convert.ToDateTime(_logic.GetProject.pj_planStartDate).AddMonths(Convert.ToInt32(dr["项目权重"].ToString()));
 | ||
|                 _logic.AddProject(); 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         }
 | ||
|         catch (Exception )
 | ||
|         {
 | ||
|             string errorMsg = "部门  " + tableName +"第 "+ Count  +" 行有错误,检查纠正后再试。";
 | ||
|             lbuploadmessage.Text = lbuploadmessage.Text + errorMsg;
 | ||
|             throw;
 | ||
|         //    ScriptManager.RegisterStartupScript(Master.UpdatePanelMaster, typeof(UpdatePanel), "alert", "alert('"+ errorMsg+"');", true);
 | ||
|           
 | ||
|              
 | ||
|         }
 | ||
|        
 | ||
| 
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
| 
 | ||
|    
 | ||
|     
 | ||
|     protected void btnActive_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
|      foreach (GridViewRow row in this.GridView1.Rows)
 | ||
|         {
 | ||
|             HtmlInputCheckBox checkNews = (HtmlInputCheckBox)row.FindControl("checkNews");
 | ||
|             if (!checkNews.Checked) continue;
 | ||
|             _logic.Initialize(Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value.ToString()));
 | ||
|             if (!_logic.GetProject.pj_status.Equals(ProjectStatus.项目解冻))
 | ||
|             {
 | ||
| 
 | ||
|                 _logic.GetProject.pj_status = ProjectStatus.项目解冻;
 | ||
|                 _logic.GetProject.Update();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         Databound();
 | ||
|     }
 | ||
| 
 | ||
|     protected void TxtBtnYear_TextChanged(object sender, EventArgs e)
 | ||
|     {
 | ||
|         //  btnYear.Text = TxtBtnYear.Text;
 | ||
|         rdblstMonth.SelectedItem.Selected = false;
 | ||
|         rdblstMonth.Items[0].Selected = true;
 | ||
|         Databound();
 | ||
| 
 | ||
|     }
 | ||
|     // 查看附件
 | ||
|     protected void GVFiles_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|     {
 | ||
|         LFile fileObj = new LFile();
 | ||
|         if (GVFiles.DataKeys != null)
 | ||
|         {
 | ||
|             string id = GVFiles.DataKeys[GVFiles.SelectedIndex].Value.ToString();
 | ||
| 
 | ||
|             fileObj.Initialize(int.Parse(id));
 | ||
|             string fileName = fileObj.GetFilesmgr.file_dest;
 | ||
|             fileName = Server.UrlEncode("../upload/" + fileObj.GetFilesmgr.File_type + "/" + fileObj.GetFilesmgr.file_dest);
 | ||
|             fileName = "../upload/" + fileObj.GetFilesmgr.File_type + "/" + fileObj.GetFilesmgr.file_dest;
 | ||
|             string openFile = "window.open('" + fileName + "');";
 | ||
|             ScriptManager.RegisterStartupScript(Master.UpdatePanelMaster, typeof(UpdatePanel), "alert", openFile, true);
 | ||
|         }
 | ||
|     }
 | ||
|     protected void Page_Init()
 | ||
|     {
 | ||
|     
 | ||
|      //   PostBackTrigger trigger = new PostBackTrigger();
 | ||
|     //   trigger.ControlID = Button1.UniqueID;
 | ||
|     //    ((UpdatePanel)Master.FindControl("UpdatePanel1")).Triggers.Add(trigger);
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
|     void page_init()
 | ||
|     {
 | ||
|         Master.ScriptMgr.EnablePartialRendering = false;
 | ||
|         PostBackTrigger trigger = new PostBackTrigger();
 | ||
|         trigger.ControlID = Button1.UniqueID;
 | ||
|         ((UpdatePanel)Master.FindControl("UpdatePanel1")).Triggers.Add(trigger);
 | ||
|     }
 | ||
| 
 | ||
| 
 | ||
|     public override void VerifyRenderingInServerForm(Control control)
 | ||
|     {
 | ||
|     }
 | ||
| 
 | ||
|     protected void Excel_Click(object sender, EventArgs e)
 | ||
|     {
 | ||
|         Master.ScriptMgr.RegisterPostBackControl(Button1);
 | ||
|         GridView1.AllowPaging = false;
 | ||
|         GridView1.Columns[GridView1.Columns.Count - 1].Visible = false;
 | ||
|         Databound();
 | ||
|         Export("application/ms-excel", "项目列表.xls");
 | ||
|         GridView1.AllowPaging = false;
 | ||
|         GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
 | ||
|         Databound();
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
|     private void Export(string FileType, string FileName)
 | ||
|     {
 | ||
| 
 | ||
|         Response.Charset = "GB2312";
 | ||
|         Response.ContentEncoding = Encoding.UTF7;
 | ||
|         Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
 | ||
|         Response.ContentType = FileType;
 | ||
|         EnableViewState = false;
 | ||
|         StringWriter tw = new StringWriter();
 | ||
|         HtmlTextWriter hw = new HtmlTextWriter(tw);
 | ||
|         GridView1.RenderControl(hw);
 | ||
|         Response.Write(tw.ToString());
 | ||
|         Response.End();
 | ||
| 
 | ||
|     }
 | ||
| }
 | ||
|   |