Ejemplo n.º 1
0
        private void ResetRow(DataRow nRow, DataTable dtBasis, ArrayList arrItem, ArrayList arrInfo, ArrayList arrSubData, string _pParamItem, string _ColType, string _pOperation, StringBuilder sbSelect)
        {
            string        sCol       = string.Empty;
            string        sColName   = string.Empty;
            CommonSPCStat comSPCStat = new CommonSPCStat();

            for (int i = 0; i < arrItem.Count; i++)
            {
                string    sItem    = arrItem[i].ToString();
                DataRow[] drSelect = dtBasis.Select(string.Format("{0} AND {1} = '{2}'", sbSelect.ToString(), _pParamItem, sItem));

                foreach (DataRow subRow in drSelect)
                {
                    for (int j = 0; j < arrInfo.Count; j++)
                    {
                        sCol = arrInfo[j].ToString();
                        nRow[_pOperation + "_" + sCol + "_" + _ColType] = subRow[sCol];
                    }

                    for (int j = 0; j < arrSubData.Count; j++)
                    {
                        sCol     = arrSubData[j].ToString();
                        sColName = sItem + "_" + sCol + "_" + _ColType;

                        if (sCol.Equals(Definition.CHART_COLUMN.STDDEV))
                        {
                            double dSum2 = string.IsNullOrEmpty(subRow["SUM2"].ToString())? 0 : double.Parse(subRow["SUM2"].ToString());
                            double dSum  = string.IsNullOrEmpty(subRow["SUM"].ToString()) ? 0 : double.Parse(subRow["SUM"].ToString());
                            int    iQty  = string.IsNullOrEmpty(subRow["QTY"].ToString()) ? 0 : int.Parse(subRow["QTY"].ToString());
                            nRow[sColName] = Stat.std(dSum2, dSum, iQty);
                        }
                        else
                        {
                            nRow[sColName] = subRow[sCol].ToString();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void PROC_DataBinding()
        {
            ////초기화
            StringBuilder sb     = null;
            StringBuilder sbSort = null;

            CreateChartDataTable _chartData = null;
            DataTableGroupBy     dtGroupBy  = null;
            DataTable            dtGB       = null;
            DataTable            dtSearch   = null;
            DataSet       _ds         = null;
            CommonSPCStat comSPCStat  = null;
            List <double> listRawData = null;
            DataRow       nRow        = null;
            string        sField      = string.Empty;
            string        sGroupBy    = string.Empty;
            string        sRowFilter  = string.Empty;
            string        sWhere      = string.Empty;
            StringBuilder sbField     = new StringBuilder();
            StringBuilder sbGroup     = new StringBuilder();

            try
            {
                dtGB       = new DataTable();
                dtSearch   = new DataTable();
                dtGroupBy  = new DataTableGroupBy();
                _chartData = new CreateChartDataTable();
                sb         = new StringBuilder();
                sbSort     = new StringBuilder();
                comSPCStat = new CommonSPCStat();

                this.bsprData.ActiveSheet.ColumnCount = 0;
                this.bsprData.ActiveSheet.RowCount    = 0;
                SpreadHeader();
                this.bsprData.ActiveSheet.RowCount = 0;
                this.bsprData.DataSource           = null;
                this.MsgShow(COMMON_MSG.Query_Data);
                _llstSearchCondition.Add(Definition.CONDITION_KEY_CONTEXT_KEY_LIST, GetSelectString());
                _ds = _wsSPC.GetPpkReport(_llstSearchCondition.GetSerialData());
                if (!DataUtil.IsNullOrEmptyDataSet(_ds))
                {
                    dtSearch = CommonPageUtil.CLOBnBLOBParsing(_ds, _llstSearchCondition, false);
                    if (_ds != null)
                    {
                        _ds.Dispose();
                    }

                    if (DataUtil.IsNullOrEmptyDataTable(dtSearch))
                    {
                        this.MsgClose();
                        MSGHandler.DisplayMessage(MSGType.Warning, MSGHandler.GetMessage("INFORMATION_NODATA"));
                        return;
                    }

                    _chartData.COMPLEX_YN = "N";
                    if (dtSearch.Rows.Count > 0)
                    {
                        _chartData.COMPLEX_YN = dtSearch.Rows[0]["COMPLEX_YN"].ToString();
                    }

                    _dtResult     = _chartData.GetPpkMakeDataTable(dtSearch);
                    _lstRawColumn = _chartData.lstRawColumn;
                    if (_chartData != null)
                    {
                        _chartData = null;
                    }

                    sbField.AppendFormat("MODEL_CONFIG_RAWID,COMPLEX_YN,MAIN_YN,DEFAULT_CHART_LIST,AREA,{0} ,PARAM_ALIAS", _OperationColumnName);
                    sbGroup.AppendFormat("MODEL_CONFIG_RAWID,COMPLEX_YN,MAIN_YN,DEFAULT_CHART_LIST,AREA,{0},PARAM_ALIAS", _OperationColumnName);
                    sbSort.AppendFormat("{0},PARAM_ALIAS", _OperationColumnName);

                    for (int i = 0; i < this.arrSortingKey.Count; i++)
                    {
                        string sCol = this.arrSortingKey[i].ToString();
                        if (_dtResult.Columns.Contains(sCol))
                        {
                            sbField.AppendFormat(",{0}", sCol);
                            sbGroup.AppendFormat(",{0}", sCol);
                            sbSort.AppendFormat(",{0}", sCol);
                        }
                    }
                    sbSort.Append(",PERIOD,USL,LSL ASC");
                    sbField.Append(",PERIOD,MEAN_LSL LSL,MEAN_USL USL ");
                    sbGroup.Append(",PERIOD,MEAN_LSL,MEAN_USL ");
                    sRowFilter = string.Empty;
                    dtGB       = dtGroupBy.SelectGroupByInto("PPK", _dtResult, sbField.ToString(), sRowFilter, sbGroup.ToString());
                    dtGB       = DataUtil.DataTableImportRow(dtGB.Select(null, sbSort.ToString()));
                }
                else
                {
                    this.MsgClose();
                    MSGHandler.DisplayMessage(MSGType.Warning, MSGHandler.GetMessage("INFORMATION_NODATA"));
                    return;
                }

                _llstSearchCondition.Clear();
                _llstSearchCondition.Add(Definition.DynamicCondition_Condition_key.OPERATION_TYPE, this._sParamTypeCD == "MET" ? "METROLOGY" : "PROCESSING");
                DataSet dsOperation = _wsSPC.GetOperationID(_llstSearchCondition.GetSerialData());

                _dtMain = dtGB.Copy();
                _dtMain.Columns.Add(Definition.CHART_COLUMN.OPERATION_DESC, typeof(string));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.SPEC, typeof(string));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.MIN, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.MAX, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.SUM, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.SUM_SQUARED, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.STDDEV, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.AVG, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.PPK, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.PP, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.PPU, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.PPL, typeof(double));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.LOT_QTY, typeof(int));
                _dtMain.Columns.Add(Definition.CHART_COLUMN.SAMPLE_QTY, typeof(int));

                sField     = "count(LOT_ID) count ";
                sGroupBy   = "LOT_ID";
                sRowFilter = string.Empty;
                StringBuilder sbSelect = null;
                for (int i = 0; i < dtGB.Rows.Count; i++)
                {
                    string param_alias = dtGB.Rows[i][Definition.CHART_COLUMN.PARAM_ALIAS].ToString();
                    string operation   = dtGB.Rows[i][_OperationColumnName].ToString();
                    string sUsl        = dtGB.Rows[i][Definition.CHART_COLUMN.USL].ToString();
                    string sLsl        = dtGB.Rows[i][Definition.CHART_COLUMN.LSL].ToString();
                    double usl         = double.NaN;
                    double lsl         = double.NaN;

                    if (!string.IsNullOrEmpty(sUsl))
                    {
                        usl = double.Parse(sUsl);
                    }
                    if (!string.IsNullOrEmpty(sLsl))
                    {
                        lsl = double.Parse(sLsl);
                    }

                    sbSelect = new StringBuilder();
                    if (double.IsNaN(usl) && double.IsNaN(lsl))
                    {
                        sbSelect.AppendFormat("PARAM_ALIAS = '{0}' AND {1} = '{2}' AND MEAN_USL IS NULL AND MEAN_LSL IS NULL AND PERIOD = '{3}' "
                                              , param_alias
                                              , this._OperationColumnName
                                              , operation
                                              , dtGB.Rows[i]["PERIOD"].ToString()
                                              );
                    }
                    else if (double.IsNaN(usl) && !double.IsNaN(lsl))
                    {
                        sbSelect.AppendFormat("PARAM_ALIAS = '{0}' AND {1} = '{2}' AND MEAN_USL IS NULL AND MEAN_LSL = '{3}' AND PERIOD = '{4}' "
                                              , param_alias
                                              , this._OperationColumnName
                                              , operation
                                              , sLsl
                                              , dtGB.Rows[i]["PERIOD"].ToString()
                                              );
                    }
                    else if (!double.IsNaN(usl) && double.IsNaN(lsl))
                    {
                        sbSelect.AppendFormat("PARAM_ALIAS = '{0}' AND {1} = '{2}' AND MEAN_USL = '{3}' AND MEAN_LSL IS NULL AND PERIOD = '{4}' "
                                              , param_alias
                                              , this._OperationColumnName
                                              , operation
                                              , sUsl
                                              , dtGB.Rows[i]["PERIOD"].ToString()
                                              );
                    }
                    else
                    {
                        sbSelect.AppendFormat("PARAM_ALIAS = '{0}' AND {1} = '{2}' AND MEAN_USL = '{3}' AND MEAN_LSL = '{4}' AND PERIOD = '{5}' "
                                              , param_alias
                                              , this._OperationColumnName
                                              , operation
                                              , sUsl
                                              , sLsl
                                              , dtGB.Rows[i]["PERIOD"].ToString()
                                              );
                    }
                    for (int k = 0; k < this.arrSortingKey.Count; k++)
                    {
                        string sCol = this.arrSortingKey[k].ToString();
                        if (_dtResult.Columns.Contains(sCol))
                        {
                            sbSelect.AppendFormat(" AND {0} = '{1}'", sCol, dtGB.Rows[i][sCol].ToString());
                        }
                    }

                    DataTable dt = DataUtil.DataTableImportRow(_dtResult.Select(sbSelect.ToString()));
                    listRawData = comSPCStat.AddDataList(dt);
                    if (listRawData.Count == 0)
                    {
                        continue;
                    }

                    DataRow[] drSelectOperation = dsOperation.Tables[0].Select(string.Format("OPERATION_ID='{0}'", operation));
                    comSPCStat.CalcPpk(listRawData.ToArray(), usl, lsl);
                    nRow = _dtMain.Rows[i];
                    nRow[Definition.CHART_COLUMN.OPERATION_DESC] = drSelectOperation.Length > 0 ? drSelectOperation[0]["DESCRIPTION"].ToString() : null;
                    nRow[Definition.CHART_COLUMN.SPEC]           = sLsl + "~" + sUsl;
                    nRow[Definition.CHART_COLUMN.SAMPLE_QTY]     = listRawData.Count;
                    nRow[Definition.CHART_COLUMN.MIN]            = comSPCStat.min;
                    nRow[Definition.CHART_COLUMN.MAX]            = comSPCStat.max;
                    nRow[Definition.CHART_COLUMN.AVG]            = comSPCStat.mean;
                    nRow[Definition.CHART_COLUMN.SUM]            = comSPCStat.sum;
                    nRow[Definition.CHART_COLUMN.STDDEV]         = comSPCStat.stddev;
                    nRow[Definition.CHART_COLUMN.SUM_SQUARED]    = comSPCStat.sum2;
                    if (double.IsNaN(comSPCStat.ppk))
                    {
                        nRow[Definition.CHART_COLUMN.PPK] = DBNull.Value;
                    }
                    else
                    {
                        nRow[Definition.CHART_COLUMN.PPK] = comSPCStat.ppk;
                    }

                    if (double.IsNaN(comSPCStat.pp))
                    {
                        nRow[Definition.CHART_COLUMN.PP] = DBNull.Value;
                    }
                    else
                    {
                        nRow[Definition.CHART_COLUMN.PP] = comSPCStat.pp;
                    }

                    if (double.IsNaN(comSPCStat.ppu))
                    {
                        nRow[Definition.CHART_COLUMN.PPU] = DBNull.Value;
                    }
                    else
                    {
                        nRow[Definition.CHART_COLUMN.PPU] = comSPCStat.ppu;
                    }

                    if (double.IsNaN(comSPCStat.ppl))
                    {
                        nRow[Definition.CHART_COLUMN.PPL] = DBNull.Value;
                    }
                    else
                    {
                        nRow[Definition.CHART_COLUMN.PPL] = comSPCStat.ppl;
                    }
                    nRow[Definition.CHART_COLUMN.LOT_QTY] = dtGroupBy.SelectGroupByInto("LOT", dt, sField, sRowFilter, sGroupBy).Rows.Count;
                }
                _dtMain.AcceptChanges();

                this.bsprData.UseSpreadEdit       = false;
                this.bsprData.AutoGenerateColumns = false;
                this.bsprData.ActiveSheet.DefaultStyle.ResetLocked();
                this.bsprData.ClearHead();
                this.bsprData.UseEdit = true;
                this.bsprData.Locked  = true;

                //this.bsprData.ActiveSheet.FrozenColumnCount = 1;
                this.bsprData.ColFronzen = 1;

                this._Initialization.InitializePpkColumnHeader(ref this.bsprData, _sortHeader, this._sortHeaderLabel);
                this.bsprData.DataSource = _dtMain;
                if (dsOperation != null)
                {
                    dsOperation.Dispose();
                }
            }
            catch (Exception ex)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, ex);
            }
            finally
            {
                this.MsgClose();
                if (dtGB != null)
                {
                    dtGB.Dispose();
                }
                if (_dtMain != null)
                {
                    _dtMain.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        private void MeasResetRow(StringBuilder sbSelect, string _Item, DataTable dtBasis, DataRow nRow, DataRow dr, ArrayList _arrInfo, ArrayList _arrSubData, string _ColType, string _pOperation)
        {
            string        sCol       = string.Empty;
            string        sColName   = string.Empty;
            CommonSPCStat comSPCStat = new CommonSPCStat();

            DataTable     dt          = DataUtil.DataTableImportRow(dtBasis.Select(sbSelect.ToString()));
            List <double> listRawData = comSPCStat.AddDataList(dt);

            if (listRawData.Count == 0)
            {
                return;
            }
            comSPCStat.CalcMulti(listRawData.ToArray());

            if (this._arrSortingKey.Contains(Definition.CHART_COLUMN.SAMPLE))
            {
                nRow[Definition.CHART_COLUMN.SAMPLE] = listRawData.Count;
            }

            for (int j = 0; j < _arrInfo.Count; j++)
            {
                sCol     = _arrInfo[j].ToString();
                sColName = _pOperation + "_" + sCol + "_" + _ColType;

                if (sCol.Equals(Definition.CHART_COLUMN.SAMPLE))
                {
                    nRow[sColName] = listRawData.Count;
                }
                else
                {
                    nRow[sColName] = dt.Rows[0][sCol];
                }
            }

            for (int j = 0; j < _arrSubData.Count; j++)
            {
                sCol     = _arrSubData[j].ToString();
                sColName = _Item + "_" + sCol + "_" + _ColType;

                if (sCol.Equals(Definition.CHART_COLUMN.STDDEV))
                {
                    nRow[sColName] = comSPCStat.stddev;
                }
                else if (sCol.Equals(Definition.CHART_COLUMN.MEAN))
                {
                    nRow[sColName] = comSPCStat.mean;
                }
                else if (sCol.Equals(Definition.CHART_COLUMN.MIN))
                {
                    nRow[sColName] = comSPCStat.min;
                }
                else if (sCol.Equals(Definition.CHART_COLUMN.MAX))
                {
                    nRow[sColName] = comSPCStat.max;
                }
                else if (sCol.Equals(Definition.CHART_COLUMN.RANGE))
                {
                    nRow[sColName] = comSPCStat.range;
                }
                else
                {
                    nRow[sColName] = dt.Rows[0][sCol];
                }
            }
        }