Пример #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (m_iCurrentGSIndex >= 0)
            {
                if (btnEdit.Text.Equals("&Sửa"))
                {
                    m_stGSIDEdit = m_dsGasStation.Tables[0].Rows[m_iCurrentGSIndex]["GASSTATION_ID"].ToString();
                    btnEdit.Text = "&Lưu";
                    UpdateStateControls(true);
                    btnReset.Enabled = true;
                    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.GasStationMacAddress  = txtMacAddress.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_UpdateGasStation(jsRequest, m_stGSIDEdit));
                    });
                    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;
                        }
                        m_stGSIDEdit     = "";
                        btnEdit.Text     = "&Sửa";
                        btnReset.Enabled = false;
                        LoadGasStationList();
                        SelectGSRow(gas.GasStationID);
                        UpdateStateControls(false);
                    }, SynchronizationContext.Current);
                }
            }
        }