コード例 #1
0
ファイル: InsertForm.cs プロジェクト: Pashkalab/satelite
 private void ClearTextBoxes()
 {
     Array.ForEach(Controls.OfType <TextBox>().ToArray(), box => box.Clear());
 }
コード例 #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var checkedButton = Controls.OfType <RadioButton>()
                                .FirstOrDefault(r => r.Checked);

            string command = checkedButton.Text;

            if (command.Equals("Add"))
            {
                SendMessageFromSocket("SAVE");

                Computer computer = new Computer();
                computer.Id    = textBox3.Text;
                computer.Price = textBox1.Text;
                computer.Brand = textBox2.Text;

                var serializedComp = computer.SerializeToString();
                SendAndGetMessageFromSocket(serializedComp);
            }

            if (command.Equals("Edit"))
            {
                SendMessageFromSocket("EDIT");

                Computer computer = new Computer();
                computer.Id    = textBox3.Text;
                computer.Price = textBox1.Text;
                computer.Brand = textBox2.Text;

                var serializedComp = computer.SerializeToString();
                SendAndGetMessageFromSocket(serializedComp);
            }

            if (command.Equals("Delete"))
            {
                SendMessageFromSocket("DELETE");

                Computer computer = new Computer();
                computer.Id    = textBox3.Text;
                computer.Price = textBox1.Text;
                computer.Brand = textBox2.Text;

                var serializedComp = computer.SerializeToString();
                SendAndGetMessageFromSocket(serializedComp);
            }

            if (command.Equals("Find by brand"))
            {
                if (textBox2.Text.Equals(""))
                {
                    SendAndGetMessageFromSocket("GET_ALL");
                }
                else
                {
                    SendMessageFromSocket("FIND");

                    Computer computer = new Computer();
                    computer.Id    = "";
                    computer.Price = "";
                    computer.Brand = textBox2.Text;

                    var serializedComp = computer.SerializeToString();
                    SendAndGetMessageFromSocket(serializedComp);
                }
            }

            textBox.Text += "\r\ndata has sent to the server";
        }