310 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			310 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			C#
		
	
	
	
|  |  | |||
|  | /// <summary> | |||
|  | ///INTERFACE CLASS FOR TABLE t_Project | |||
|  | ///By wm with codesmith.  | |||
|  | ///on 04/18/2017 | |||
|  | /// </summary> | |||
|  | 
 | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Text; | |||
|  | using System.Data; | |||
|  | using System.Collections; | |||
|  |   | |||
|  | using DeiNiu.Utils; | |||
|  | 
 | |||
|  | namespace DeiNiu.wms.Data.Model | |||
|  | { | |||
|  |     [Serializable] | |||
|  |     public class Project : Project_base | |||
|  |     { | |||
|  |         public Project() | |||
|  |         { | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         public Project(int id): base(id) | |||
|  |         { | |||
|  | 
 | |||
|  |         } | |||
|  |         protected override void getImp() | |||
|  |         { | |||
|  |             model_imp = new Project_Imp(); | |||
|  | 
 | |||
|  |         } | |||
|  |         private Employee _prjMaster; | |||
|  | 
 | |||
|  |         protected internal string _prjMasterName = string.Empty; | |||
|  |         /// <summary> | |||
|  |         /// 返回某员工的特定年月的所有项目 | |||
|  |         /// </summary> | |||
|  |         /// <param name="emId"></param> | |||
|  |         /// <param name="year"></param> | |||
|  |         /// <param name="month"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public DataTable GetProjects(int emId, string year, string month) | |||
|  |         { | |||
|  |             cmdParameters[0] = emId; | |||
|  |             cmdParameters[1] = year; | |||
|  |             cmdParameters[2] = month; | |||
|  | 
 | |||
|  |             return CustQuery(100).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 返回某员工的特定年的所有项目 | |||
|  |         /// </summary> | |||
|  |         /// <param name="emId"></param> | |||
|  |         /// <param name="year"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public DataTable GetProjects(int emId, string year) | |||
|  |         { | |||
|  |             cmdParameters[0] = emId; | |||
|  |             cmdParameters[1] = year; | |||
|  | 
 | |||
|  |             return CustQuery(300).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 返回某部门员工的特定年的所有项目 | |||
|  |         /// </summary> | |||
|  |         /// <param name="emId"></param> | |||
|  |         /// <param name="year"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public DataTable GetProjectsByDept(int deptID, string year) | |||
|  |         { | |||
|  |             cmdParameters[0] = deptID; | |||
|  |             cmdParameters[1] = year; | |||
|  | 
 | |||
|  |             return CustQuery(400).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         public string PrjMasterName | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return _prjMasterName; | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         public Employee PrjMaster | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return _prjMaster; | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  |         public new int Add() | |||
|  |         { | |||
|  |             base.Add(); | |||
|  |             // _id = Convert.ToInt32(CustQuery(200).Tables[0].Rows[0][0].ToString()); | |||
|  | 
 | |||
|  | 
 | |||
|  |             return _id; | |||
|  |         } | |||
|  |         public void balanceThePercent() | |||
|  |         { | |||
|  |             DateTime dt1 = Convert.ToDateTime(_pj_planStartDate); | |||
|  |             balanceThePercent(pj_master, dt1.Year.ToString(), dt1.Month.ToString()); | |||
|  | 
 | |||
|  |         } | |||
|  |         /// <summary> | |||
|  |         /// 平衡月度的项目权重 | |||
|  |         /// </summary> | |||
|  |         public void balanceThePercent(int emId, string year, string month) | |||
|  |         { | |||
|  | 
 | |||
|  |             DataView dv = GetProjects(emId, year, month).DefaultView; | |||
|  |             //     string rowfilter = "pj_status in('" + ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.项目已分配 + "','"+ ProjectStatus.项目解冻 + "','"+ | |||
|  |             //                        ProjectStatus.删减审核通过 + "')"  ; | |||
|  |             string rowfilter = "pj_status in('" + ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.项目已分配 + "','" + ProjectStatus.项目解冻 + "')"; | |||
|  |             dv.RowFilter = rowfilter; | |||
|  |             decimal totalPercent = 0; | |||
|  | 
 | |||
|  |             //总分数 | |||
|  |             for (int i = 0; i < dv.Count; i++) | |||
|  |             { | |||
|  |                 try | |||
|  |                 { | |||
|  |                     //  totalPercent += Convert.ToDecimal(dv.Table.Rows[i]["pj_percent"].ToString()); | |||
|  | 
 | |||
|  |                     totalPercent += Convert.ToDecimal(dv[i]["pj_percent"].ToString()); | |||
|  |                 } | |||
|  |                 catch (Exception) | |||
|  |                 { | |||
|  |                     continue; | |||
|  |                 } | |||
|  | 
 | |||
|  |             } | |||
|  | 
 | |||
|  | 
 | |||
|  |             Project tmpPrj; | |||
|  |             // | |||
|  |             for (int i = 0; i < dv.Count; i++) | |||
|  |             { | |||
|  |                 decimal oldPercent; | |||
|  |                 decimal newPercent; | |||
|  |                 try | |||
|  |                 { | |||
|  |                     if (totalPercent.Equals(new decimal(0)))  //总计0 | |||
|  |                     { | |||
|  |                         newPercent = 100 / dv.Count; | |||
|  |                     } | |||
|  |                     else | |||
|  |                     { | |||
|  |                         oldPercent = Convert.ToDecimal(dv[i]["pj_percent"].ToString()); | |||
|  | 
 | |||
|  |                         newPercent = oldPercent / totalPercent * 100; | |||
|  | 
 | |||
|  |                     } | |||
|  |                     tmpPrj = new Project(Convert.ToInt32(dv[i]["pk_t_project"].ToString())); | |||
|  |                     tmpPrj.pj_percent = Convert.ToInt32(newPercent); | |||
|  |                     if (tmpPrj.pj_score > 0) tmpPrj.pj_score = tmpPrj.pj_percent * tmpPrj.pj_progress / 100; | |||
|  |                     tmpPrj.Update(); | |||
|  | 
 | |||
|  |                 } | |||
|  |                 catch (Exception) | |||
|  |                 { | |||
|  | 
 | |||
|  |                     continue; | |||
|  |                 } | |||
|  | 
 | |||
|  |             } | |||
|  | 
 | |||
|  |             refineThePercent(emId, year, month); | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  |         public void refineThePercent(int emId, string year, string month) | |||
|  |         { | |||
|  |             DataView dv = GetProjects(emId, year, month).DefaultView; | |||
|  |             string rowfilter = "pj_status in('" + ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.项目已分配 + "','" + ProjectStatus.项目解冻 + "','" + | |||
|  |                               ProjectStatus.删减审核通过 + "')"; | |||
|  |             dv.RowFilter = rowfilter; | |||
|  |             decimal totalPercent = 0; | |||
|  |             decimal refinePercent; | |||
|  | 
 | |||
|  |             //总分数 | |||
|  |             for (int i = 0; i < dv.Count; i++) | |||
|  |             { | |||
|  |                 try | |||
|  |                 { | |||
|  |                     totalPercent += Convert.ToDecimal(dv[i]["pj_percent"].ToString()); | |||
|  |                 } | |||
|  |                 catch (Exception er) | |||
|  |                 { | |||
|  |                     continue; | |||
|  |                 } | |||
|  | 
 | |||
|  |             } | |||
|  | 
 | |||
|  |             if (totalPercent == 100) | |||
|  |                 return; | |||
|  | 
 | |||
|  |             refinePercent = totalPercent - 100; | |||
|  |             Project tmpPrj; | |||
|  |             // | |||
|  |             for (int i = 0; i < dv.Count; i++) | |||
|  |             { | |||
|  |                 decimal oldPercent; | |||
|  |                 decimal newPercent = 0; | |||
|  |                 try | |||
|  |                 { | |||
|  |                     oldPercent = Convert.ToDecimal(dv[i]["pj_percent"].ToString()); | |||
|  | 
 | |||
|  |                     newPercent = oldPercent - refinePercent; | |||
|  |                     if (newPercent <= 0) | |||
|  |                         continue; | |||
|  | 
 | |||
|  |                     tmpPrj = new Project(Convert.ToInt32(dv[i]["pk_t_project"].ToString())); | |||
|  |                     tmpPrj.pj_percent = Convert.ToInt32(newPercent); | |||
|  |                     if (tmpPrj.pj_score > 0) tmpPrj.pj_score = tmpPrj.pj_percent * tmpPrj.pj_progress / 100; | |||
|  |                     tmpPrj.Update(); | |||
|  |                     break; | |||
|  |                 } | |||
|  |                 catch (Exception) | |||
|  |                 { | |||
|  |                     continue; | |||
|  |                 } | |||
|  | 
 | |||
|  |             } | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         public DataTable GetProjectsByYearMonth(string year, string month) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             cmdParameters[1] = month; | |||
|  | 
 | |||
|  |             return CustQuery(500).Tables[0]; | |||
|  |         } | |||
|  |         public DataTable GetKaoHeHistoryProjectsByYearMonth(string year, string month) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             cmdParameters[1] = month; | |||
|  | 
 | |||
|  |             return CustQuery(501).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         public DataTable GetKaoHeHistoryProjectsByYear(string year) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             return CustQuery(502).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         public DataTable GetProjectsByYear(string year) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             return CustQuery(600).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         ///按 部门 获得需要其来 审批的项目列表 | |||
|  |         /// </summary> | |||
|  |         /// <param name="deptList"> 部门列表</param> | |||
|  |         /// <returns></returns> | |||
|  |         public DataTable Get4ApproveListYear(ArrayList deptList, string year) | |||
|  |         { | |||
|  |             if (deptList.Count == 0) return new DataTable(); | |||
|  |             cmdParameters[0] = Utils.Util.buildWhereIntIn(deptList); | |||
|  |             cmdParameters[1] = year; | |||
|  | 
 | |||
|  |             return CustQuery(700).Tables[0]; | |||
|  |         } | |||
|  |         /// <summary> | |||
|  |         ///按 部门 获得需要其来 审批的项目列表 | |||
|  |         /// </summary> | |||
|  |         /// <param name="deptList"> 部门列表</param> | |||
|  |         /// <returns></returns> | |||
|  |         public DataTable Get4ApproveListYearMonth(ArrayList deptList, string year, string month) | |||
|  |         { | |||
|  |             if (deptList.Count == 0) return new DataTable(); | |||
|  |             cmdParameters[0] = Utils.Util.buildWhereIntIn(deptList); | |||
|  |             cmdParameters[1] = year; | |||
|  |             cmdParameters[2] = month; | |||
|  |             return CustQuery(800).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |         public DataTable GetSumProjectsByYearMonth(string year, string month) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             cmdParameters[1] = month; | |||
|  | 
 | |||
|  |             return CustQuery(900).Tables[0]; | |||
|  |         } | |||
|  |         public DataTable GetSumProjectsByYear(string year) | |||
|  |         { | |||
|  |             cmdParameters[0] = year; | |||
|  |             return CustQuery(1000).Tables[0]; | |||
|  |         } | |||
|  | 
 | |||
|  |     } | |||
|  | } |