private void BindInitialData() { LotEDCEntity lotEntity = new LotEDCEntity(); dsCollectionData = lotEntity.GetEDCCollectionData(lotKey, edcInsKey); if (lotEntity.ErrorMsg == string.Empty) { try { if (dsCollectionData.Tables.Count > 0 && dsCollectionData.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsCollectionData.Tables[0].Rows.Count; i++) { for (int j = 1; j < tablePanel.RowCount; j++) { string strName = "lblParam" + j.ToString("00"); LabelControl lblCtrl = (LabelControl)tablePanel.Controls.Find(strName, true)[0]; if (lblCtrl.Tag.ToString() == dsCollectionData.Tables[0].Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_PARAM_KEY].ToString()) { //j为tablePanel的行号 int column = Convert.ToInt32(dsCollectionData.Tables[0].Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_SP_UNIT_SEQ]); TextEdit textEdit = (TextEdit)tablePanel.Controls.Find("txtBox" + j.ToString() + column.ToString(), true)[0]; textEdit.Text = dsCollectionData.Tables[0].Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_PARAM_VALUE].ToString(); if (textEdit.Tag.ToString().Substring(0, 1) == _edcData.DataType && (textEdit.Tag.ToString().Substring(1, 1) == "W" || textEdit.Tag.ToString().Substring(1, 1) == "N")) { textEdit.Properties.ReadOnly = true; } break; } } } if (CheckFinish()) { btSubmit.Enabled = false; btDeleteData.Enabled = false; } else { btSubmit.Enabled = true; btDeleteData.Enabled = true; } } } catch (Exception ex) { MessageService.ShowError(ex.Message); } } else { MessageService.ShowError(lotEntity.ErrorMsg); } }
private void btSubmit_Click(object sender, EventArgs e) { //if (THreadGet) //{ // MessageService.ShowMessage("数据接收中......"); // return; //} string isHold = "false"; DataTable saveTable = _edcData.BuildTable(EDC_COLLECTION_DATA_FIELDS.DATABASE_TABLE_NAME); int saveRowCount = 0; for (int i = 1; i < tablePanel.RowCount; i++) { LabelControl lblCtrl = (LabelControl)tablePanel.Controls.Find("lblParam" + i.ToString("00"), true)[0]; string paramKey = lblCtrl.Tag.ToString(); for (int j = 1; j <= Convert.ToInt32(dsParam.Tables[0].Rows[i - 1][EDC_POINT_PARAMS_FIELDS.FIELD_PARAM_COUNT]); j++) { TextEdit textEdit = tablePanel.Controls.Find("txtBox" + i.ToString() + j.ToString(), true)[0] as TextEdit; if (textEdit.Tag.ToString().Substring(0, 1) == _edcData.DataType) { if (textEdit.Tag.ToString().Substring(1, 1) != "R" && textEdit.Text != string.Empty) { string validFlag = string.Empty; if (textEdit.BackColor == Color.Red) { validFlag = "1"; isHold = "true"; } else { validFlag = "0"; } string result = CheckUpdateOrInsert(paramKey, j.ToString(), textEdit.Text); switch (result) { case "no": break; case "new": saveTable.Rows.Add(saveRowCount); saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_SP_SAMP_SEQ] = "1"; saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_SP_UNIT_SEQ] = j.ToString(); saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_PARAM_KEY] = paramKey; saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_PARAM_VALUE] = textEdit.Text; saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_EDC_INS_KEY] = edcInsKey; saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_COL_KEY] = string.Empty; saveTable.Rows[saveRowCount][EDC_COLLECTION_DATA_FIELDS.FIELD_VALID_FLAG] = validFlag; saveTable.Rows[saveRowCount][COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION] = "New"; saveRowCount++; break; case "update": break; default: break; } } } } } LotEDCEntity edcEntity = new LotEDCEntity(); DataSet dsSave = new DataSet(); if (saveTable.Rows.Count > 0) { dsSave.Tables.Add(saveTable); } string question = string.Empty; if (isHold == "false") { question = "确定要提交数据吗?"; } else { question = "数据超出范围,批次将被锁定。确定要保存数据吗?"; } if (MessageService.AskQuestionSpecifyNoButton(question)) { this.btSubmit.Enabled = false; int RCount = GetRecord(); edcEntity.Operator = _edcData.StaffNumber; edcEntity.SaveEDCPause(dsSave, RCount, lotKey, edcInsKey, isHold); if (edcEntity.ErrorMsg == "") { BindInitialData(); _edcData.UpdateSHRDataToSqlServer(shrTable_Q); MessageService.ShowMessage("保存成功。"); } else { MessageService.ShowError(edcEntity.ErrorMsg); } } }
/// <summary> /// 查询按钮Click事件方法。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { try { string factoryRoomKey = Convert.ToString(this.lueFactoryRoom.EditValue); if (string.IsNullOrEmpty(factoryRoomKey)) { MessageService.ShowMessage("请选择车间。", "提示"); this.lueFactoryRoom.Select(); return; } string stepName = this.cbOperation.Text.Trim(); string equipmentKey = Convert.ToString(this.lueEquipment.EditValue); string partType = Convert.ToString(this.luePartType.EditValue); string edcKey = Convert.ToString(this.lueEDCItem.EditValue); string lotNo = this.txtLotNo.Text.Trim(); string startTime = Convert.ToString(this.deStartTime.EditValue); string endTime = Convert.ToString(this.deEndTime.EditValue); if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) { if (this.deEndTime.DateTime < this.deStartTime.DateTime) { MessageService.ShowMessage("结束时间不能小于开始时间。", "提示"); this.deEndTime.Select(); return; } } LotEDCEntity entity = new LotEDCEntity(); Hashtable htParmas = new Hashtable(); //工厂车间 if (!string.IsNullOrEmpty(factoryRoomKey)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_LOCATION_KEY, factoryRoomKey); } //工序名称 if (!string.IsNullOrEmpty(stepName)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_STEP_NAME, stepName); } //设备主键 if (!string.IsNullOrEmpty(equipmentKey)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_EQUIPMENT_KEY, equipmentKey); } //产品类型 if (!string.IsNullOrEmpty(partType)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_PART_TYPE, partType); } //采集项目主键。 if (!string.IsNullOrEmpty(edcKey)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_EDC_KEY, edcKey); } //批次号 if (!string.IsNullOrEmpty(lotNo)) { htParmas.Add(EDC_MAIN_INS_FIELDS.FIELD_LOT_NUMBER, lotNo); } string startTime0 = EDC_MAIN_INS_FIELDS.FIELD_COL_START_TIME + "_START"; string startTime1 = EDC_MAIN_INS_FIELDS.FIELD_COL_START_TIME + "_END"; //开始时间 if (!string.IsNullOrEmpty(startTime)) { htParmas.Add(startTime0, this.deStartTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss")); } //结束时间 if (!string.IsNullOrEmpty(endTime)) { htParmas.Add(startTime1, this.deEndTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss")); } DataTable dtParams = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(htParmas); PagingQueryConfig config = new PagingQueryConfig() { PageNo = pgnQueryResult.PageNo, PageSize = pgnQueryResult.PageSize }; DataSet dsReturn = entity.QueryEDCData(dtParams, ref config); pgnQueryResult.Pages = config.Pages; pgnQueryResult.Records = config.Records; if (!string.IsNullOrEmpty(entity.ErrorMsg)) { MessageService.ShowMessage(entity.ErrorMsg); return; } gcResults.DataSource = dsReturn.Tables[0]; gcResults.MainView = gvResults; } catch (Exception ex) { MessageService.ShowMessage(ex.Message, "错误"); } }