Exemple #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;
                }
                GasStationDTO gas = new GasStationDTO();
                gas.GasStationID          = txtGSCode.Text.Trim();
                gas.GasStationName        = txtGSName.Text.Trim();
                gas.GasStationAddress     = txtGSAddress.Text.Trim();
                gas.GasStationDescription = txtGSDes.Text.Trim();
                gas.GasStoreID            = ((ComboboxItem)cboGasStore.SelectedItem).Value.ToString();

                DataTransfer request = new DataTransfer();
                request.ResponseDataGasStationDTO = gas;
                string        jsRequest = JSonHelper.ConvertObjectToJSon(request);
                Task <String> task      = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMManager_AddNewGasStaion(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";
                    LoadGasStationList();
                    SelectGSRow(gas.GasStationID);
                    UpdateStateControls(false);
                }, SynchronizationContext.Current);
            }
        }