private void frmSGMConfig_Load(object sender, EventArgs e) { if (SGMConfig.Flag_DisableReader) { openLoginFrm(); } m_stSettingFile = Application.StartupPath + m_stSettingFile; m_stCurrentPortName = RFIDReader.LoadConfig(m_stSettingFile); loadPortsName(); if (!m_stCurrentPortName.Equals("")) { for (int i = 0; i < cboPorts.Items.Count; i++) { if (cboPorts.Items[i].ToString().Equals(m_stCurrentPortName)) { if (InitComPort()) { openLoginFrm(); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, SGMText.FRM_CONFIG_CANT_CONNECT_READER, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } } } } m_stCurrentPortName = cboPorts.Text; }
private void btnLogin_Click(object sender, EventArgs e) { // validate user input if (ValidateLoginCode() == false) { return; } // request server string GASSTORE_ID = txtLoginCode.Text; string GASSTORE_MACADDRESS = GetMacAddress(); Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return(service.SGMSaleGas_ValidateGasStoreLogin(GASSTORE_ID, GASSTORE_MACADDRESS)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { String stResponse = task.Result as String; DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse); if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { this.Hide(); if (Program.ReaderPort != null) { Program.ReaderPort.DataReceived -= serialDatahandler; } frmSGMUpdateStore frm = new frmSGMUpdateStore(dataResponse.ResponseDataGasStoreDTO); frm.ShowDialog(); this.Close(); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); }
private void btnUpdate_Click(object sender, EventArgs e) { if (_storeDTO == null) { //frmMsg.ShowMsg(SGMText.SGM_ERROR, "DTO NULL", SGMMessageType.SGM_MESSAGE_TYPE_ERROR); return; } if (!ValidateDataInput()) { return; } float gas92Add = float.Parse(txtGas92New.Text); float gas95Add = float.Parse(txtGas95New.Text); float gasDOAdd = float.Parse(txtGasDONew.Text); DataTransfer request = new DataTransfer(); GasStoreDTO cloneStoreDTO = new GasStoreDTO(_storeDTO); cloneStoreDTO.GasStoreGas92Total = _storeDTO.GasStoreGas92Total + gas92Add; cloneStoreDTO.GasStoreGas95Total = _storeDTO.GasStoreGas95Total + gas95Add; cloneStoreDTO.GasStoreGasDOTotal = _storeDTO.GasStoreGasDOTotal + gasDOAdd; request.ResponseDataGasStoreDTO = cloneStoreDTO; string jsRequest = JSonHelper.ConvertObjectToJSon(request); Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return(m_service.SGMManager_UpdateGasStore(jsRequest, cloneStoreDTO.GasStoreID)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { String stResponse = task.Result as String; DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse); if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { DataTransfer request2 = new DataTransfer(); GasStoreUpdateDTO dto = new GasStoreUpdateDTO(); dto.GasStoreID = _storeDTO.GasStoreID; dto.GSUpdateDate = DateTime.Now; dto.GSUpdateDescription = txtNote.Text; dto.GSUpdateGas92Add = gas92Add; dto.GSUpdateGas95Add = gas95Add; dto.GSUpdateGasDOAdd = gasDOAdd; dto.GSUpdateGas92Total = _storeDTO.GasStoreGas92Total; dto.GSUpdateGas95Total = _storeDTO.GasStoreGas95Total; dto.GSUpdateGasDOTotal = _storeDTO.GasStoreGasDOTotal; request2.ResponseDataGasStoreUpdateDTO = dto; string jsRequest2 = JSonHelper.ConvertObjectToJSon(request2); Task <String> task2 = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return(m_service.SGMManager_AddNewGasStoreUpdate(jsRequest2)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task2, () => { String stResponse2 = task2.Result as String; DataTransfer dataResponse2 = JSonHelper.ConvertJSonToObject(stResponse); if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.GASSTORE_UPDATE_TOTAL_SUCCESS, SGMMessageType.SGM_MESSAGE_TYPE_INFO); _storeDTO.GasStoreGas92Total += gas92Add; _storeDTO.GasStoreGas95Total += gas95Add; _storeDTO.GasStoreGasDOTotal += gasDOAdd; DataToUIView(); RefreshUpdateHistory(); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); }