Пример #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // validate user input
            if (ValidateLoginCode() == false)
            {
                return;
            }

            // request server
            string        GASSTATION_ID         = txtLoginCode.Text;
            string        GASSTATION_MACADDRESS = GetMacAddress();
            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () => {
                return(service.SGMSaleGas_ValidateGasStationLogin(GASSTATION_ID, GASSTATION_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;
                    }

                    new frmSGMSaleGas(dataResponse.ResponseDataSystemAdminDTO, dataResponse.ResponseDataGasStationDTO, dataResponse.ResponseCurrentPriceGas92, dataResponse.ResponseCurrentPriceGas95, dataResponse.ResponseCurrentPriceGasDO, dataResponse.ResponseGasStoreGas92Total, dataResponse.ResponseGasStoreGas95Total, dataResponse.ResponseGasStoreGasDOTotal).ShowDialog();
                    this.Close();
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }