Example #1
0
        public void ConectarePorturi()
        {
            DataTable dt1;

            dt1 = pordal.Select(con);
            if (dt1.Rows.Count > 0)
            {
                string port_1     = dt1.Rows[0].ItemArray[0].ToString();
                string baudrate_1 = dt1.Rows[0].ItemArray[1].ToString();
                string parity1    = dt1.Rows[0].ItemArray[2].ToString();
                string databits1  = dt1.Rows[0].ItemArray[3].ToString();
                string stopbits1  = dt1.Rows[0].ItemArray[4].ToString();
                //stabilire conexiune
                String   port     = port_1;
                int      baudrate = Convert.ToInt32(baudrate_1);
                Parity   parity   = (Parity)Enum.Parse(typeof(Parity), parity1);
                int      databits = Convert.ToInt32(databits1);
                StopBits stopbits = (StopBits)Enum.Parse(typeof(StopBits), stopbits1);

                serialport_connect(port, baudrate, parity, databits, stopbits);
            }
        }
Example #2
0
        private void cmdConnect_Click(object sender, EventArgs e)
        {
            String   port     = txtPort.Text;
            int      baudrate = Convert.ToInt32(cmbbaudrate.Text);
            Parity   parity   = (Parity)Enum.Parse(typeof(Parity), cmbparity.Text);
            int      databits = Convert.ToInt32(cmbdatabits.Text);
            StopBits stopbits = (StopBits)Enum.Parse(typeof(StopBits), cmbstopbits.Text);

            serialport_connect(port, baudrate, parity, databits, stopbits);

            DataTable dt;

            dt = pdal.Select(con);
            string port_existent = "";

            if (dt.Rows.Count > 0)
            {
                port_existent = dt.Rows[0].ItemArray[0].ToString();
            }
            p.Port     = txtPort.Text;
            p.Baudrate = cmbbaudrate.Text;
            p.Parity   = cmbparity.Text;
            p.Databits = cmbdatabits.Text;
            p.Stopbits = cmbstopbits.Text;

            bool success3 = pdal.Delete(p, con);
            bool success2 = pdal.Insert(p, con);

            if (success2 == true)
            {
                MessageBox.Show("Date salvate");
            }
            else
            {
                MessageBox.Show("Nu s a putut salva date comunicare");
            }
        }