Example #1
0
        public static KpiItem AddKpiItem(string empNo, int year, int month, string kpiName)
        {
            KpiItem kpi = GetKpiItem(empNo, year, month, kpiName);

            if (kpi == null)
            {
                kpi        = new KpiItem();
                kpi.标识     = Guid.NewGuid();
                kpi.员工编号   = empNo;
                kpi.年      = year;
                kpi.月      = month;
                kpi.考核项目名称 = kpiName;
                kpi.Save();
            }
            return(kpi);
        }
Example #2
0
        /// <summary>
        /// 通过 Id 获取
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static KpiItem GetKpiItem(Guid id)
        {
            KpiItem obj = (KpiItem)MyHelper.XpoSession.GetObjectByKey(typeof(KpiItem), id);

            return(obj);
        }
Example #3
0
        public static StringBuilder SychKpiItem(int year, int month)
        {
            //清除历史数据
            DeleteAll(year, month);

            StringBuilder sb = new StringBuilder();

            OleDbConnection conn = new OleDbConnection(MyHelper.GetPsConnectionString());

            using (conn)
            {
                OleDbDataReader rs = null;
                try
                {
                    conn.Open();
                    using (OleDbCommand cmd = conn.CreateCommand())
                    {
                        string sql = String.Format("SELECT * FROM C_INF_PER_KPI_DTL WHERE YEAR = '{0}' AND MONTH = '{1}' ORDER BY EMPLID", year, month);
                        cmd.CommandText = sql;
                        rs = cmd.ExecuteReader();

                        string         lastEmpLid = "";
                        List <KpiItem> items      = new List <KpiItem>();

                        while (rs.Read())
                        {
                            string empLid  = (string)rs["EMPLID"];
                            string kpiName = (string)rs["KPINAME"];

                            KpiItem item = KpiItem.AddKpiItem(empLid, year, month, kpiName);
                            if (item != null)
                            {
                                #region 读取数据

                                item.创建人    = "系统";
                                item.创建时间   = DateTime.Now;
                                item.原标识    = Convert.ToInt32(rs["ID"]);
                                item.岗位序号   = Convert.ToInt32(rs["EMPL_RCD"]);
                                item.职级代码   = (string)rs["SUPV_LVL_ID"];
                                item.职位编号   = (string)rs["POSITION_NBR"];
                                item.生效日期   = Convert.ToDateTime(rs["EFFDT"]);
                                item.考核基准工资 = Convert.ToDecimal(rs["BASESALARY"]);
                                item.个人挂钩比例 = Convert.ToDouble(rs["PERRATE"]);
                                item.公司奖励比例 = Convert.ToDouble(rs["COMRATE"]);
                                item.个人绩效标准 = Convert.ToDecimal(rs["STDPER"]);
                                item.公司奖励标准 = Convert.ToDecimal(rs["STDCOM"]);
                                item.个人绩效实得 = Convert.ToDecimal(rs["SLRPER"]);
                                item.公司奖励实得 = Convert.ToDecimal(rs["SLRCOM"]);

                                item.次同步时间 = DateTime.Now;

                                #endregion

                                item.Save();

                                items.Add(item);
                                //如果轮到下一个人,统计前一个人并保存
                                if (empLid != lastEmpLid && lastEmpLid == "")
                                {
                                    SumKpi(items, lastEmpLid, year, month);
                                }
                            }
                            lastEmpLid = empLid;
                        }
                        SumKpi(items, lastEmpLid, year, month);
                    }
                }
                catch (Exception err)
                {
                    Common.WriteLog(Environment.CurrentDirectory + "\\LogFiles\\Error.log", err.ToString());
                    DeleteAll(year, month);
                }
                finally
                {
                    if (rs != null)
                    {
                        rs.Close();
                    }
                    conn.Close();
                }
            }
            return(sb);
        }