public async Task Submit() { try { if (Inputnumber != null) { var res = await HttpRequRes.GetMultitleNumResults(Convert.ToInt32(Inputnumber)); if (res != null && res.Error == false) { this.Results = res.Results; } else { this.Results = res.message; } } else { await App.Current.MainPage.DisplayAlert("Error", "Please Enter Number", "OK"); } } catch (Exception ex) { } }
private async void Button1_Click(object sender, System.EventArgs e) { try { if (!string.IsNullOrEmpty(this.textBox1.Text)) { ResponseModelDTO result = await HttpRequRes.GetMultitleNumResults(Convert.ToInt32(this.textBox1.Text)); if (result != null && result.Error == false) { this.label3.Text = result.Results; } else { this.label3.Text = result.message; } } else { MessageBox.Show("Error", "Please Enter Number", MessageBoxButtons.OK); } } catch (Exception ex) { } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(107, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(160, 20); this.label1.TabIndex = 0; this.label1.Text = "Please Enter Number"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(98, 78); this.textBox1.Name = "txtdata"; this.textBox1.Size = new System.Drawing.Size(212, 26); this.textBox1.TabIndex = 1; // // button1 // this.button1.Location = new System.Drawing.Point(111, 134); this.button1.Name = "btnSub"; this.button1.Size = new System.Drawing.Size(212, 66); this.button1.TabIndex = 2; this.button1.Text = "Submit"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += Button1_Click; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(83, 257); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(67, 20); this.label2.TabIndex = 3; this.label2.Text = "Results:"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(156, 257); this.label3.Name = "results"; this.label3.Size = new System.Drawing.Size(51, 20); this.label3.TabIndex = 4; this.label3.Text = ""; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(528, 350); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "MultipleTest"; this.ResumeLayout(false); this.PerformLayout(); HttpRequRes.RunAsync(); }
public MainViewModel() { HttpRequRes.RunAsync(); SubmitCommand = new Command(async() => await Submit()); }