Exemplo n.º 1
0
        /// <summary>
        /// 绑定工序参数数据。
        /// </summary>
        private void BindParams()
        {
            RouteQueryEntity queryEntity     = new RouteQueryEntity();
            DataSet          dsOperationData = queryEntity.GetOperationBaseAndParamInfo(this._model.OperationName);

            if (!string.IsNullOrEmpty(queryEntity.ErrorMsg))
            {
                MessageService.ShowError(queryEntity.ErrorMsg);
                return;
            }
            //是否获取到工序参数数据。
            if (null == dsOperationData ||
                !dsOperationData.Tables.Contains(POR_ROUTE_OPERATION_VER_FIELDS.DATABASE_TABLE_NAME) ||
                !dsOperationData.Tables.Contains(POR_ROUTE_OPERATION_PARAM_FIELDS.DATABASE_TABLE_NAME)
                )
            {
                return;
            }
            this._dtOperationParamData = dsOperationData.Tables[POR_ROUTE_OPERATION_PARAM_FIELDS.DATABASE_TABLE_NAME];
            this._dtOperationBaseData  = dsOperationData.Tables[POR_ROUTE_OPERATION_VER_FIELDS.DATABASE_TABLE_NAME];
            //是否获取到工序参数数据。
            if (this._dtOperationBaseData.Rows.Count < 1 || this._dtOperationParamData.Rows.Count < 1)
            {
                return;
            }
            //根据工步主键获取绑定参数。
            int nOrderType = Convert.ToInt32(this._dtOperationBaseData.Rows[0][POR_ROUTE_OPERATION_VER_FIELDS.FIELD_PARAM_ORDER_TYPE]);

            this._paramOrderType   = (OperationParamOrderType)nOrderType;
            this._paramCountPerRow = Convert.ToInt32(this._dtOperationBaseData.Rows[0][POR_ROUTE_OPERATION_VER_FIELDS.FIELD_PARAM_COUNT_PER_ROW]);
            //初始化采集参数控件。
            InitParamsControl(this._dtOperationParamData, this._paramOrderType, this._paramCountPerRow);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化参数控件。
        /// </summary>
        /// <param name="paramCountPerRow">每行参数个数。</param>
        private void InitParamsControl(DataTable dtStepParamData, OperationParamOrderType orderType, int paramCountPerRow)
        {
            //初始化结构。
            DataTable dtParams = new DataTable();

            for (int i = 0; i < paramCountPerRow; i++)
            {
                GridColumn gcolRowNum = new GridColumn();
                gcolRowNum.Caption   = "序号";
                gcolRowNum.FieldName = string.Format("{0}_{1}", WIP_PARAM_FIELDS.FIELD_PARAM_INDEX, i);
                gcolRowNum.OptionsColumn.ReadOnly   = true;
                gcolRowNum.OptionsColumn.AllowEdit  = false;
                gcolRowNum.AppearanceCell.BackColor = System.Drawing.Color.LightGray;
                gcolRowNum.Name = string.Format("gcolRowNum{0}", i);
                gcolRowNum.OptionsColumn.FixedWidth = true;
                gcolRowNum.Width        = 50;
                gcolRowNum.Visible      = true;
                gcolRowNum.VisibleIndex = i * paramCountPerRow + 1;
                gcolRowNum.Tag          = i;
                this.gvParams.Columns.Add(gcolRowNum);

                GridColumn gcolName = new GridColumn();
                gcolName.Caption   = "参数名称";
                gcolName.FieldName = string.Format("{0}_{1}", WIP_PARAM_FIELDS.FIELD_PARAM_NAME, i);
                gcolName.OptionsColumn.ReadOnly   = true;
                gcolName.OptionsColumn.AllowEdit  = false;
                gcolName.AppearanceCell.BackColor = System.Drawing.Color.LightGray;
                gcolName.Name         = string.Format("gcolName{0}", i);
                gcolName.Visible      = true;
                gcolName.VisibleIndex = i * paramCountPerRow + 2;
                gcolName.Tag          = i;
                this.gvParams.Columns.Add(gcolName);

                GridColumn gcolValue = new GridColumn();
                gcolValue.Caption      = "参数值";
                gcolValue.FieldName    = string.Format("{0}_{1}", WIP_PARAM_FIELDS.FIELD_PARAM_VALUE, i);
                gcolValue.Name         = string.Format("gcolValue{0}", i);
                gcolValue.Visible      = true;
                gcolValue.Tag          = i;
                gcolValue.VisibleIndex = i * paramCountPerRow + 3;
                this.gvParams.Columns.Add(gcolValue);

                dtParams.Columns.Add(gcolRowNum.FieldName);
                dtParams.Columns.Add(string.Format("{0}_{1}", WIP_PARAM_FIELDS.FIELD_PARAM_KEY, i));
                dtParams.Columns.Add(gcolName.FieldName);
                dtParams.Columns.Add(gcolValue.FieldName);
            }
            //初始化数据。
            //计算行数。
            int nRowCount = dtStepParamData.Rows.Count / paramCountPerRow;

            if (dtStepParamData.Rows.Count % paramCountPerRow != 0)
            {
                nRowCount = nRowCount + 1;
            }
            for (int i = 0; i < nRowCount; i++)
            {
                DataRow drParam = dtParams.NewRow();
                dtParams.Rows.Add(drParam);
                int nCol = 0;
                for (int j = 0; j < paramCountPerRow; j++)
                {
                    int nRow = i * paramCountPerRow + j;  //先行后列时,抓取工步参数数据所在的行。
                    if (orderType == OperationParamOrderType.FirstColumn)
                    {
                        nRow = i + nRowCount * j;
                    }
                    if (nRow >= dtStepParamData.Rows.Count)
                    {
                        break;
                    }
                    drParam[nCol]     = dtStepParamData.Rows[nRow][POR_ROUTE_STEP_PARAM_FIELDS.FIELD_PARAM_INDEX];
                    drParam[nCol + 1] = dtStepParamData.Rows[nRow][POR_ROUTE_STEP_PARAM_FIELDS.FIELD_PARAM_KEY];
                    drParam[nCol + 2] = dtStepParamData.Rows[nRow][POR_ROUTE_STEP_PARAM_FIELDS.FIELD_PARAM_NAME];
                    nCol = nCol + 4;//跳过参数值。
                }
            }
            this.lciParams.SizeConstraintsType = SizeConstraintsType.Custom;
            int height = this.gvParams.RowHeight * (dtParams.Rows.Count + 1) + this.gvParams.ColumnPanelRowHeight + 10;

            this.lciParams.MinSize   = new Size(this.lciParams.MinSize.Width, height);
            this.lciParams.MaxSize   = new Size(this.lciParams.MaxSize.Width, height);
            this.lciParams.Size      = new Size(this.lciParams.Size.Width, height);
            this.gcParams.DataSource = dtParams;
            this.gcParams.MainView   = this.gvParams;
            this.gvParams.OptionsView.ColumnAutoWidth = true;
        }