/// <summary> /// 双击采集的数据行。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gvResults_DoubleClick(object sender, EventArgs e) { int rowHandle = this.gvResults.FocusedRowHandle; if (rowHandle < 0) { return; } DataRow dr = this.gvResults.GetFocusedDataRow(); //获取当前班别名称。 Shift _shift = new Shift(); string defaultShift = _shift.GetCurrShiftName(); _edcData = new EdcGatherData(); _edcData.Operator = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); _edcData.LotNumber = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_LOT_NUMBER]); _edcData.EDCKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EDC_KEY]); _edcData.LineName = string.Empty; _edcData.OperationName = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_STEP_NAME]); _edcData.EquipmentKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EQUIPMENT_KEY]); _edcData.MaterialLot = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_MATERIAL_LOT]); _edcData.OrderNumber = Convert.ToString(dr[POR_WORK_ORDER_FIELDS.FIELD_ORDER_NUMBER]); _edcData.PartNumber = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_PART_NO]); _edcData.SupplierName = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_SUPPLIER]); _edcData.ShiftName = defaultShift; _edcData.EquipmentName = Convert.ToString(dr[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_NAME]); _edcData.EDCName = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EDC_NAME]); _edcData.FactoryRoomName = Convert.ToString(dr[FMM_LOCATION_FIELDS.FIELD_LOCATION_NAME]); _edcData.FactoryRoomKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_LOCATION_KEY]); _edcData.EDCActionName = Convert.ToString(dr[EDC_POINT_FIELDS.FIELD_ACTION_NAME]); _edcData.EDCPointKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EDC_POINT_KEY]); _edcData.EDCSPKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EDC_SP_KEY]); _edcData.PartType = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_PART_TYPE]); _edcData.EDCMainInsKey = Convert.ToString(dr[EDC_MAIN_INS_FIELDS.FIELD_EDC_INS_KEY]); //遍历工作台中的视图对象。 foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { if (viewContent.TitleName == "数据采集明细") { viewContent.WorkbenchWindow.CloseWindow(true); break; } } //创建新的视图对象并显示。 EDCData04WViewContent view = new EDCData04WViewContent(_edcData); WorkbenchSingleton.Workbench.ShowView(view); }
/// <summary> /// 数据采集按钮Click事件处理方法。 /// </summary> /// <param name="sender">触发事件的对象。</param> /// <param name="e">事件参数。</param> /// comment by peter 2012-2-23 private void btnMTData_Click(object sender, EventArgs e) { //车间是否输入? if (lueFactoryRoom.Text == string.Empty) { MessageService.ShowMessage("车间不能为空"); this.lueFactoryRoom.Focus(); return; } //工序是否输入? if (cbOperation.Text == string.Empty) { MessageService.ShowMessage("工序不能为空"); this.cbOperation.Focus(); return; } //采集项目不能为空 if (string.IsNullOrEmpty(this.lueEDCItem.Text)) { MessageService.ShowMessage("采集项目不能为空。"); this.lueEDCItem.Focus(); return; } string selectedEquipmentKey = Convert.ToString(this.lueEquipment.EditValue); //设备不能为空 if (string.IsNullOrEmpty(selectedEquipmentKey)) { MessageService.ShowMessage("设备不能为空。"); this.lueEquipment.Focus(); return; } string actionName = this.lueEDCItem.GetColumnValue("ACTION_NAME").ToString(); //数据采集项目触发时的动作。 string equipmentKey = this.lueEDCItem.GetColumnValue("EQUIPMENT_KEY").ToString(); //数据采集项目指定的设备主键。 string operationName = this.lueEDCItem.GetColumnValue("OPERATION_NAME").ToString(); //数据采集项目指定的工序名称。 string sField = Convert.ToString(this.lueEDCItem.GetColumnValue(EDC_POINT_FIELDS.FIELD_MUST_INPUT_FIELD)); //数据采集项目必须输入的栏位。 int field = 0; if (!int.TryParse(sField, out field)) { field = 0; } bool bMustInputLotNo = ((EDCPointMustInputField)field & EDCPointMustInputField.LotNo) == EDCPointMustInputField.LotNo; string edckey = this.lueEDCItem.GetColumnValue("EDC_KEY").ToString(); string spkey = this.lueEDCItem.GetColumnValue("SP_KEY").ToString(); if (!string.IsNullOrEmpty(equipmentKey) && equipmentKey != selectedEquipmentKey) { MessageService.ShowMessage("采集项目指定的设备和当前选中设备不一致。"); this.lueEquipment.Focus(); return; } if (operationName != cbOperation.Text) { MessageService.ShowMessage("采集项目指定的工序和当前选中工序不一致。"); this.lueEquipment.Focus(); return; } if (actionName != "NONE") { //批次号是否输入? if (this.txtLotNo.Text == string.Empty) { MessageService.ShowMessage("在线采集项目,批号必须输入。", "提示"); this.txtLotNo.Focus(); return; } //检查是否对该批次号具有权限。 if (!CheckLotNo(txtLotNo.Text.Trim(), ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT)) { return; } } else if (bMustInputLotNo)//离线采集项目且必须输入批次号。 { if (string.IsNullOrEmpty(this.txtLotNo.Text.Trim())) { MessageService.ShowMessage("指定的数据采集项目,批号必须输入。", "提示"); this.txtLotNo.Focus(); return; } //检查是否对该批次号具有权限。 if (!CheckLotNo(txtLotNo.Text.Trim(), ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_NONE)) { return; } } //如果有输入批次,则获取批次信息。 if (!string.IsNullOrEmpty(this.txtLotNo.Text)) { //如果没有成功获取到批次信息。 if (GetLotInfomation() == false) { return; } } //获取当前班别名称。 Shift _shift = new Shift(); string defaultShift = _shift.GetCurrShiftName(); _edcData = new EdcGatherData(); _edcData.Operator = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); _edcData.LotNumber = this.txtLotNo.Text.ToUpper(); _edcData.EDCKey = edckey; _edcData.LineName = this.lueLine.Text; _edcData.OperationName = operationName; _edcData.EquipmentKey = selectedEquipmentKey; _edcData.MaterialLot = this.txtMaterialLot.Text; _edcData.OrderNumber = this.txtWorkOrder.Text; _edcData.PartNumber = this.txtPartNumber.Text; _edcData.SupplierName = this.txtSupplier.Text; _edcData.ShiftName = defaultShift; _edcData.EquipmentName = this.lueEquipment.Text; _edcData.EDCName = this.lueEDCItem.Text; _edcData.FactoryRoomName = this.lueFactoryRoom.Text; _edcData.FactoryRoomKey = this.lueFactoryRoom.EditValue.ToString(); _edcData.EDCActionName = actionName; _edcData.EDCPointKey = this.lueEDCItem.EditValue.ToString(); _edcData.EDCSPKey = spkey; _edcData.PartType = Convert.ToString(this.luePartType.EditValue); //遍历工作台中的视图对象。 foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { if (viewContent is EDCData04WViewContent) { viewContent.WorkbenchWindow.CloseWindow(true); break; } } //创建新的视图对象并显示。 EDCData04WViewContent view = new EDCData04WViewContent(_edcData); WorkbenchSingleton.Workbench.ShowView(view); }