示例#1
0
        /// <summary>
        /// 得到查询结果
        /// </summary>
        /// <param name="condition">条件字符串</param>
        /// <param name="ecweb"></param>
        /// <param name="srvtime"></param>
        /// <param name="plantid"></param>
        /// <param name="unitid"></param>
        /// <returns></returns>
        public static DataTable GetSearchList(string ecweb, string srvtime, string plantid = "", string unitid = "")
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(@"WITH KPIRealValueECT AS(
					SELECT a.ECID,  c.UnitID, c.UnitName, c.WorkID, a.ECName, d.EngunitName, b.ECOptimal, ECValue, 
					a.ECScore, ECQulity, ECTime, ECShift, ECOptExp,ECIndex,ECNote
					FROM KPI_ECSSSnapshot a   LEFT JOIN KPI_ECTag b on a.ECID = b.ECID 
						RIGHT JOIN KPI_Unit c on b.UnitID = c.UnitID 
						LEFT JOIN KPI_Engunit d on b.EngunitID = d.EngunitID 
					WHERE b.ECIsValid =1 AND b.ECIsDisplay=1 "                    );
            if (!String.IsNullOrEmpty(plantid))
            {
                sb.Append("AND c.PlantID ='" + plantid + "' ");
            }

            if (!String.IsNullOrEmpty(unitid))
            {
                sb.Append(" AND c.UnitID ='" + unitid + "' ");
            }
            if (!String.IsNullOrEmpty(ecweb))
            {
                sb.Append(" AND  b.ECWeb='" + ecweb + "' ");
            }
            sb.Append(")");
            List <KPI_UnitEntity> unitList = KPI_UnitDal.GetAllEntity();
            string   workid     = KPI_UnitDal.GetWorkIDByCode(unitList[0].UnitCode);
            string   ShiftName  = "";
            string   PeriodName = "";
            string   StartTime  = "";
            string   EndTime    = "";
            string   strTime    = KPI_SystemDal.GetKPISrvTime();
            bool     bGood      = KPI_WorkDal.GetShiftAndPeriod(workid, strTime, ref ShiftName, ref PeriodName, ref StartTime, ref EndTime);
            DateTime date       = DateTime.Parse(StartTime);

            date = new DateTime(date.Year, date.Month, 1);
            string strMonthStart = date.ToString("yyyy-MM-dd 01:00:00");

            date = date.AddMonths(1);
            string strMonthEnd = date.ToString("yyyy-MM-dd 01:00:00");

            sb.Append(" SELECT A.*,B.ECScoreDay,C.ECScoreMonth FROM KPIRealValueECT A ");
            sb.AppendFormat(" LEFT JOIN (SELECT SUM(Score)  ECScoreDay, ECID FROM KPI_ECHourData " +
                            "WHERE  Shift='{0}' AND CheckDate  BETWEEN '{1}' AND '{2}' " +
                            "GROUP BY ECID) B ON A.ECID=B.ECID", ShiftName, StartTime, EndTime);
            sb.AppendFormat(" LEFT JOIN (SELECT SUM(Score)  ECScoreMonth, ECID FROM KPI_ECHourData " +
                            "WHERE  Shift='{0}' AND CheckDate  BETWEEN '{1}' AND '{2}'  " +
                            "GROUP BY ECID) C ON A.ECID=C.ECID", ShiftName, strMonthStart, strMonthEnd);
            sb.Append(" ORDER BY ECIndex,UNitName");
            String    sqlText = sb.ToString();
            DataTable dt      = DBAccess.GetRelation().ExecuteDataset(sqlText).Tables[0];

            return(dt);
        }
 private List<SystemParameterEntity> GetDataSource()
 {
     KPI_SystemDal DataAccess = new KPI_SystemDal();
     List<SystemParameterEntity> List = new List<SystemParameterEntity>();
     SystemParameterEntity SystemParameter,Param;
     List<KPI_UnitEntity> UnitList = KPI_UnitDal.GetAllEntity();
     foreach (KPI_UnitEntity Unit in UnitList) {
         SystemParameter = DataAccess.GetSystemParameter(Unit.UnitID);
         if (SystemParameter == null) {
             SystemParameter = new SystemParameterEntity();
             SystemParameter.SysName = Unit.UnitID;
             SystemParameter.SysDesc = Unit.UnitName + "奖金金额";
         }
         SystemParameter.SysCode = Unit.UnitCode;
         Param = DataAccess.GetSystemParameter(Unit.UnitCode);
         if (Param != null) SystemParameter.SysValue2 = Param.SysValue;
         //SystemParameter.SysValue2 = DataAccess.GetSystemParameter(Unit.UnitCode).SysValue;
         List.Add(SystemParameter);
     }
     return List;
 }
        protected void btnSave_Click(Object sender, EventArgs e)
        {
            Literal lblSysName, lblSysDesc, lblSysCode;
            TextBox txtSysValue, txtSysNote, txtSysValue2;
            KPI_SystemDal DataAccess = new KPI_SystemDal();
            SystemParameterEntity SystemParameter;
            RepeaterItemCollection Items = Repeater1.Items;
            foreach (RepeaterItem Item in Items) {
                lblSysName = (Literal)Item.FindControl("lblSysName");
                lblSysDesc = (Literal)Item.FindControl("lblSysDesc");
                lblSysCode = (Literal)Item.FindControl("lblSysCode");
                txtSysValue = (TextBox)Item.FindControl("txtSysValue");
                txtSysValue2 = (TextBox)Item.FindControl("txtSysValue2");
                txtSysNote = (TextBox)Item.FindControl("txtSysNote");
                SystemParameter = new SystemParameterEntity();
                SystemParameter.SysEngunit = "元";
                SystemParameter.SysIsValid = 1;
                SystemParameter.SysID = DateTime.Now.Ticks + "";
                SystemParameter.SysName = lblSysName.Text;
                SystemParameter.SysDesc = lblSysDesc.Text;
                SystemParameter.SysValue = txtSysValue.Text;
                SystemParameter.SysNote = txtSysNote.Text;
                DataAccess.SaveSystemParameter(SystemParameter);

                SystemParameter = new SystemParameterEntity();
                SystemParameter.SysEngunit = "";
                SystemParameter.SysIsValid = 1;
                SystemParameter.SysID = lblSysName.Text;
                SystemParameter.SysName = lblSysCode.Text;
                SystemParameter.SysDesc = "奖励名次";
                SystemParameter.SysValue = txtSysValue2.Text;
                SystemParameter.SysNote = "奖励名次";
                DataAccess.SaveSystemParameter(SystemParameter);
            }
            ShowMessage("数据保存成功!");
        }