/// <summary> /// 窗体载入事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LotFutureHoldDetailDialog_Load(object sender, EventArgs e) { FutureHoldEntity entity = new FutureHoldEntity(); _dsParams = entity.Get(this._futureHoldKey); if (!string.IsNullOrEmpty(entity.ErrorMsg)) { MessageService.ShowMessage(entity.ErrorMsg); _dsParams = null; } if (_dsParams != null && _dsParams.Tables.Count > 0 && _dsParams.Tables[0].Rows.Count > 0) { DataTable dt = _dsParams.Tables[0]; this._enterpriseKey = Convert.ToString(dt.Rows[0][WIP_FUTUREHOLD_FIELDS.FIELDS_ENTERPRISE_KEY]); this._routeKey = Convert.ToString(dt.Rows[0][WIP_FUTUREHOLD_FIELDS.FIELDS_ROUTE_KEY]); BindLotBaseInfoToControl(); BindReasonCodeGroupDataToControl(); BindActionToControl(); BindStepToControl(); InitControlValue(); } }
/// <summary> /// 删除按钮Click事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { if (this.gvLot.RowCount == 0) { return; } if (this.gvLot.SelectedRowsCount != 1) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotFutureHold.Msg001}"), MESSAGEBOX_CAPTION);//请必须选择一行 //MessageService.ShowMessage("请必须选择一行。", "提示"); return; } int[] rows = this.gvLot.GetSelectedRows(); int row = rows[0]; string rowKey = Convert.ToString(this.gvLot.GetRowCellValue(row, "ROW_KEY")); string deletor = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); //if (MessageService.AskQuestion("确定要删除选中的记录?", "提示") == true) //确定要删除选中的记录? if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotFutureHold.Msg002}"), MESSAGEBOX_CAPTION) == true) //确定要删除选中的记录? { FutureHoldEntity entity = new FutureHoldEntity(); entity.Delete(rowKey, deletor); if (!string.IsNullOrEmpty(entity.ErrorMsg)) { MessageService.ShowMessage(entity.ErrorMsg, MESSAGEBOX_CAPTION); } else { BindFutureHoldLotToControl(); } } }
/// <summary> /// 绑定预设暂停的批次数据到控件中。 /// </summary> private void BindFutureHoldLotToControl() { FutureHoldEntity entity = new FutureHoldEntity(); DataSet dsParams = new DataSet(); Hashtable htParams = new Hashtable(); if (!string.IsNullOrEmpty(this._factoryRoomKey)) { htParams.Add(POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY, this._factoryRoomKey); } if (!string.IsNullOrEmpty(this._lotNo)) { htParams.Add(WIP_FUTUREHOLD_FIELDS.FIELDS_LOT_NUMBER, this._lotNo); } if (!string.IsNullOrEmpty(this._operationName)) { htParams.Add(WIP_FUTUREHOLD_FIELDS.FIELDS_OPERATION_NAME, this._operationName); } if (!string.IsNullOrEmpty(this._workOrderNo)) { htParams.Add(WIP_FUTUREHOLD_FIELDS.FIELDS_WORKORDER_NUMBER, this._workOrderNo); } if (!string.IsNullOrEmpty(this._action)) { htParams.Add(WIP_FUTUREHOLD_FIELDS.FIELDS_ACTION_NAME, this._action); } DataTable dtParams = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(htParams); dsParams.Tables.Add(dtParams); PagingQueryConfig config = new PagingQueryConfig() { PageNo = pgnQueryResult.PageNo, PageSize = pgnQueryResult.PageSize }; DataSet ds = entity.Query(dsParams, ref config); pgnQueryResult.Pages = config.Pages; pgnQueryResult.Records = config.Records; if (string.IsNullOrEmpty(entity.ErrorMsg)) { this.gcLot.DataSource = ds.Tables[0]; gvLot.BestFitColumns(); } else { MessageService.ShowMessage(entity.ErrorMsg, MESSAGEBOX_CAPTION); } }
/// <summary> /// 确定按钮Click事件函数。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { if (_dsLot == null) { return; } if (_dsParams == null) { return; } DataTable dtLots = _dsLot.Tables[0]; if (dtLots == null || dtLots.Rows.Count == 0) { MessageService.ShowMessage("记录为空,不能进行修改。", "提示"); return; } string enterpriseKey = this._enterpriseKey; string routeKey = this._routeKey; string stepKey = Convert.ToString(this.lueStep.EditValue); string stepName = Convert.ToString(this.lueStep.Text); string action = Convert.ToString(this.lueAction.EditValue); string holdGroupName = Convert.ToString(this.lueHoldGroup.Text); string holdGroupKey = Convert.ToString(this.lueHoldGroup.EditValue); string holdCode = Convert.ToString(this.lueHoldCode.Text); string holdCodeKey = Convert.ToString(this.lueHoldCode.EditValue); string remark = this.meRemark.Text.Trim(); string editor = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); string holdPassword = this.teHoldPassword.Text; string confirmPassword = this.teConfirmPassword.Text; if (string.IsNullOrEmpty(stepKey)) { MessageService.ShowMessage("请先选择暂停工序。", "提示"); this.lueStep.Select(); return; } if (string.IsNullOrEmpty(action)) { MessageService.ShowMessage("请先选择暂停动作。", "提示"); this.lueAction.Select(); return; } if (string.IsNullOrEmpty(holdGroupKey)) { MessageService.ShowMessage("请先选择暂停组别。", "提示"); this.lueHoldGroup.Select(); return; } if (string.IsNullOrEmpty(holdCodeKey)) { MessageService.ShowMessage("请先选择暂停原因。", "提示"); this.lueHoldCode.Select(); return; } //if (string.IsNullOrEmpty(holdPassword)) //{ // MessageService.ShowMessage("请先输入暂停密码。", "提示"); // this.teHoldPassword.Select(); // return; //} if (holdPassword != confirmPassword) { MessageService.ShowMessage("输入的密码不一致,请重新输入。", "提示"); this.teConfirmPassword.Select(); return; } if (string.IsNullOrEmpty(remark)) { MessageService.ShowMessage("请必须输入备注。", "提示"); this.meRemark.Select(); return; } DataSet dsParams = new DataSet(); DataTable dtParams = new DataTable(); dtParams.TableName = WIP_FUTUREHOLD_FIELDS.DATABASE_TABLE_NAME; WIP_FUTUREHOLD_FIELDS field = new WIP_FUTUREHOLD_FIELDS(); foreach (string key in field.FIELDS.Keys) { dtParams.Columns.Add(key); } foreach (DataRow dr in dtLots.Rows) { DataRow drNew = dtParams.NewRow(); string rowkey = this._futureHoldKey; string lotNo = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]); string lotKey = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_KEY]); string setEnterpriseKey = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); string setRouteKey = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string setStepKey = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); string orderNumber = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_WORK_ORDER_NO]); string editTime = Convert.ToString(_dsParams.Tables[0].Rows[0][WIP_FUTUREHOLD_FIELDS.FIELDS_EDIT_TIME]); drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_ACTION_NAME] = action; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_EDITOR] = editor; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_ENTERPRISE_KEY] = enterpriseKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_LOT_KEY] = lotKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_LOT_NUMBER] = lotNo; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_OPERATION_NAME] = stepName; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_REASON_CODE] = holdCode; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_REASON_CODE_CATEGORY_KEY] = holdGroupKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_REASON_CODE_CATEGORY_NAME] = holdGroupName; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_REASON_CODE_KEY] = holdCodeKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_REMARK] = remark; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_ROUTE_KEY] = routeKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_SET_ENTERPRISE_KEY] = setEnterpriseKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_SET_ROUTE_KEY] = setRouteKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_SET_STEP_KEY] = setStepKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_STEP_KEY] = stepKey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_WORKORDER_NUMBER] = orderNumber; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_ROW_KEY] = rowkey; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_HOLD_PASSWORD] = holdPassword; drNew[WIP_FUTUREHOLD_FIELDS.FIELDS_EDIT_TIME] = editTime; dtParams.Rows.Add(drNew); } dsParams.Tables.Add(dtParams); FutureHoldEntity entity = new FutureHoldEntity(); entity.Update(dsParams); if (string.IsNullOrEmpty(entity.ErrorMsg)) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageService.ShowMessage(entity.ErrorMsg, "错误"); } }