/// <summary> /// 构造函数。 /// </summary> public EdcPoint() { this.MustInputField = EDCPointMustInputField.None; }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolbarSave_Click(object sender, EventArgs e) { if (this.gvEDCPoint.State == GridState.Editing && this.gvEDCPoint.IsEditorFocused && this.gvEDCPoint.EditingValueModified) { this.gvEDCPoint.SetFocusedRowCellValue(this.gvEDCPoint.FocusedColumn, this.gvEDCPoint.EditingValue); } this.gvEDCPoint.UpdateCurrentRow(); if (string.IsNullOrEmpty(edcPoint.PointRowKey)) { return; } //Q.001 if (string.IsNullOrEmpty(meDesc.Text)) { MessageService.ShowMessage("原因不能为空", "提示"); return; } //Q.001 if (edcPoint.EDIT_DESC.Equals(meDesc.Text)) { MessageService.ShowMessage("没有修改原因栏位,还是原来的原因", "提示"); return; } if (MessageService.AskQuestion("确定要保存?", "提示")) { DataTable dt = new DataTable(); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_EDC_POINT_ROWKEY); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_NAME); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_BOUNDARY); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_SPEC); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_CONTROL); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_TARGET); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_CONTROL); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_SPEC); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_BOUNDARY); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_KEY); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_INDEX); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_TYPE); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_FORMULA); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_ALLOW_MIN_VALUE); dt.Columns.Add(EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_ALLOW_MAX_VALUE); for (int i = 0; i < gvEDCPoint.RowCount; i++) { //gridView1.GetRowCellValue(0, ""); string upperBoundary = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_BOUNDARY).ToString().Trim(); string lowerBoundary = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_BOUNDARY).ToString().Trim(); string paramCount = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT).ToString().Trim(); string paramType = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_TYPE).ToString().Trim(); string paramIndex = gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_INDEX).ToString().Trim(); string allowMinValue = Convert.ToString(gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_ALLOW_MIN_VALUE)); string allowMaxValue = Convert.ToString(gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_ALLOW_MAX_VALUE)); if (upperBoundary.Length == 0) { MessageService.ShowMessage("参数上线值不能为空", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_BOUNDARY]; return; } if (lowerBoundary.Length == 0) { MessageService.ShowMessage("参数下线值不能为空", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_BOUNDARY]; return; } if (paramCount.Length == 0) { MessageService.ShowMessage("抽检片数不能为空", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT]; return; } if (paramType.Length == 0) { MessageService.ShowMessage("参数类型不能为空", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_TYPE]; return; } if (paramIndex.Length == 0) { MessageService.ShowMessage("序号不能为空", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_INDEX]; return; } if (!string.IsNullOrEmpty(allowMinValue) && !string.IsNullOrEmpty(allowMaxValue)) { double nAllowMinValue = double.Parse(allowMinValue); double nAllowMaxValue = double.Parse(allowMaxValue); //最大值<最小值,则给出提示。 if (nAllowMaxValue < nAllowMinValue) { MessageService.ShowMessage("允许输入的最大值不能小于允许输入的最大值。", "提示"); this.gvEDCPoint.FocusedRowHandle = i; this.gvEDCPoint.FocusedColumn = this.gvEDCPoint.Columns[EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_ALLOW_MAX_VALUE]; return; } } dt.Rows.Add(edcPoint.PointRowKey, gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_NAME), upperBoundary, gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_SPEC), gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_UPPER_CONTROL), gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_TARGET), gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_CONTROL), gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_LOWER_SPEC), lowerBoundary, paramCount, gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_KEY), paramIndex, paramType, gvEDCPoint.GetRowCellValue(i, EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_FORMULA), allowMinValue, allowMaxValue ); } DataSet ds = new DataSet(); dt.TableName = TRANS_TABLES.TABLE_MAIN_DATA; ds.Tables.Add(dt); ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_GROUP_KEY, edcPoint.GroupKey); ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_EQUIPMENT_KEY, edcPoint.EquipmentKey); ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_EDITOR, PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_EDIT_DESC, meDesc.Text); ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_GROUP_NAME, txtGroupName.Text); string newEquipmentKey = Convert.ToString(this.teEquipmentKey.EditValue).Replace(" ", ""); ds.ExtendedProperties.Add("NEW_EQUIPMENT_KEY", newEquipmentKey); EDCPointMustInputField field = EDCPointMustInputField.None; if (this.chkIsMustInputLotNo.Checked) { field = EDCPointMustInputField.LotNo; } ds.ExtendedProperties.Add(EDC_POINT_FIELDS.FIELD_MUST_INPUT_FIELD, (int)field); if (edcPoint.UpdateEDCPointParams(ds)) { edcPoint.EquipmentKey = newEquipmentKey; MessageService.ShowMessage("保存成功", "提示"); } else { MessageService.ShowMessage("保存失败:" + edcPoint.ErrorMsg, "提示"); } } }