Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text.Equals("&Thêm"))
            {
                btnAdd.Text = "&Lưu";
                UpdateStateControls(true);
                clearInput();
                txtGSCode.Focus();
            }
            else
            {
                if (!ValidateDataInput())
                {
                    return;
                }
                GasStoreDTO gas = new GasStoreDTO();
                gas.GasStoreID          = txtGSCode.Text.Trim();
                gas.GasStoreName        = txtGSName.Text.Trim();
                gas.GasStoreAddress     = txtGSAddress.Text.Trim();
                gas.GasStoreDescription = txtGSDes.Text.Trim();
                gas.GasStoreGas92Total  = 0;
                gas.GasStoreGas95Total  = 0;
                gas.GasStoreGasDOTotal  = 0;

                DataTransfer request = new DataTransfer();
                request.ResponseDataGasStoreDTO = gas;
                string        jsRequest = JSonHelper.ConvertObjectToJSon(request);
                Task <String> task      = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMManager_AddNewGasStore(jsRequest));
                });
                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)
                    {
                        frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg + "\n" + dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                        return;
                    }
                    btnAdd.Text = "&Thêm";
                    LoadGasStoreList();
                    SelectGSRow(gas.GasStoreID);
                    UpdateStateControls(false);
                }, SynchronizationContext.Current);
            }
        }