private void btn_Submit_Click(object sender, EventArgs e) { // Check to see if both validation checks return true if (ValidShareSize() && ValidSharePrice()) { selectedCompany.addSellOrder(Convert.ToDouble(textBox2.Text), Convert.ToInt32(textBox1.Text)); foreach (Control control in this.Controls) { if (control is TextBox) { TextBox textBox = (TextBox)control; textBox.Text = null; } if (control is ComboBox) { ComboBox comboBox = (ComboBox)control; if (comboBox.Items.Count > 0) { comboBox.SelectedIndex = 0; } } } } }
private void btn_Submit_Click(object sender, EventArgs e) { // Check to see if both validation checks return true if (ValidShareSize() && ValidSharePrice()) { selectedCompany.addSellOrder(Convert.ToDouble(textBox2.Text), Convert.ToInt32(textBox1.Text)); tempObj tO; NetworkStream nwstream = client.GetStream(); string companymsg = "sellOrder SME/TCP-1.0\nCSeq: " + CSeq++ + " Session: " + sessionNum + " Data: "; tO = new tempObj(Convert.ToDouble(textBox2.Text), Convert.ToInt32(textBox1.Text)); string orders; if (selectedCompany.Symbol == "MSFT") { orders = JsonConvert.SerializeObject(new { MSFT = tO }); } else if (selectedCompany.Symbol == "AAPL") { orders = JsonConvert.SerializeObject(new { AAPL = tO }); } else { orders = JsonConvert.SerializeObject(new { FB = tO }); } companymsg += orders; //send to server byte[] tosend = ASCIIEncoding.ASCII.GetBytes(companymsg); nwstream.Write(tosend, 0, tosend.Length); //wait for response //byte[] read = new byte[client.ReceiveBufferSize]; //int bytesread = nwstream.Read(read, 0, client.ReceiveBufferSize); //string decode = Encoding.ASCII.GetString(read, 0, bytesread); foreach (Control control in this.Controls) { if (control is TextBox) { TextBox textBox = (TextBox)control; textBox.Text = null; } if (control is ComboBox) { ComboBox comboBox = (ComboBox)control; if (comboBox.Items.Count > 0) { comboBox.SelectedIndex = 0; } } } } }