public void GetCValueFromDB()
        {
            string source = ConfigurationManager.ConnectionStrings["EPInfoSys"].ConnectionString.ToString();

            if (this._RuleType == "TotalNumLess" || this._RuleType == "TotalNumGreater")              //表示只需要获得返回的行数
            {
                DataTable retDT;
                string    DBcommand = @"SELECT
									[合格]
								FROM [EPInfoSystem].[dbo].[CheckInfo]
									WHERE [统计时间] LIKE'"                                     + this._Time + "%'AND [车间]='" + this._Factory + "' AND [检查类型]='" + this._Type + "'";
                DBOper    dbcom     = new DBOper(source, DBcommand);
                retDT = dbcom.ReturnDataSet();
                this.CollectionValue = retDT.Rows.Count;
            }
            else if (this._RuleType == "PerGreater" || this._RuleType == "PerLess")
            {
                DataTable retDT1;
                DataTable retDT2;
                float     ret1, ret2;
                string    DBcommand1 = @"SELECT
									[合格]
								FROM [EPInfoSystem].[dbo].[CheckInfo]
									WHERE [统计时间] LIKE'"                                     + this._Time + "%'AND [车间]='" + this._Factory + "' AND [检查类型]='" + this._Type + "'";
                DBOper    dbcom1     = new DBOper(source, DBcommand1);
                retDT1 = dbcom1.ReturnDataSet();
                string DBcommand2 = @"SELECT
									[合格]
								FROM [EPInfoSystem].[dbo].[CheckInfo]
									WHERE [统计时间] LIKE'"                                     + this._Time + "%'AND [车间]='" + this._Factory + "' AND [检查类型]='" + this._Type + "' AND [合格]= 1";
                DBOper dbcom2     = new DBOper(source, DBcommand2);
                retDT2 = dbcom2.ReturnDataSet();
                ret1   = (float)retDT1.Rows.Count;
                ret2   = (float)retDT2.Rows.Count;
                if (ret1 == 0)
                {
                    this.CollectionValue = -1;
                }
                else
                {
                    this.CollectionValue = ret2 / ret1;
                }
            }
        }
示例#2
0
    public string ReadFromDBbyDay()
    {
        string    ret;
        DataTable retDT;
        string    source    = ConfigurationManager.ConnectionStrings["EPInfoSys"].ConnectionString.ToString();
        string    DBcommand =
            @"SELECT 
				[data]
			FROM [EPInfoSystem].[dbo].[DustSourceRecord]
			WHERE [time] LIKE'"             + this._Time + "%' AND [workshop]='" + this._Workshop + "'";
        DBOper dbcom = new DBOper(source, DBcommand);

        retDT = dbcom.ReturnDataSet();
        if (retDT.Rows.Count == 0)        //没有数据
        {
            ret = ReadListByWS();
        }
        else          //有一个数据
        {
            ret = retDT.Rows[0][0].ToString();
        }
        return(ret);
    }