Esempio n. 1
0
        private void PrintButton_Click(object sender, EventArgs e)
        {
            FormMenu fm = (FormMenu)this.Owner;

            if (BarcodeTB.Text != "" && TabNoTB.Text != "")
            {
                Send_Receive("#PRINT" + GroupDefCB.Text + "|" + TypeDefCB.Text + "|" + TabNoTB.Text + "|" +
                             fm.SmenaCB.Text.Substring(0, 1) + "|" + LocCB.Text + "|" + fm.TypeCB.Text + "|" + fm.ControlTabNoTB.Text);
                BarcodeTB.Text = "";
            }
            else
            {
                AnswerTB.Text = "Заполнены не все поля!";
            }
        }
Esempio n. 2
0
        private void Send_Receive(string barcode)
        {
            FormMenu fm = (FormMenu)this.Owner;

            try
            {
                TcpClient    client = new TcpClient(Z_mXML.ServerIP, Convert.ToInt32(Z_mXML.ServerPort));
                Stream       s      = client.GetStream();
                StreamReader sr     = new StreamReader(s);
                StreamWriter sw     = new StreamWriter(s);
                sw.AutoFlush = true;
                Z_TSD_Message ztm = new Z_TSD_Message(Z_mXML.DeviceId, Z_mXML.ActionNumber, barcode);
                sw.WriteLine(ztm.ToString(Z_mXML.Separator));
                string server_answer = sr.ReadLine();
                if (server_answer.StartsWith("#QUERYGROUP"))
                {
                    server_answer = server_answer.Substring(11);
                    FillComboBox(GroupDefCB, server_answer, Z_mXML.Separator);
                    GroupDefCB.SelectedIndex = 0;
                }
                else
                if (server_answer.StartsWith("#QUERYLIST"))
                {
                    server_answer = server_answer.Substring(10);
                    FillComboBox(TypeDefCB, server_answer, Z_mXML.Separator);
                    TypeDefCB.SelectedIndex = 0;
                }
                else
                if (server_answer.StartsWith("#LOADLOC"))
                {
                    server_answer = server_answer.Substring(8);
                    FillComboBox(LocCB, server_answer, Z_mXML.Separator);
                    LocCB.SelectedIndex = Z_mXML.Location;
                }
                else
                {
                    AnswerTB.Text = server_answer;
                }

                s.Close();
                client.Close();
            }
            catch
            {
                MessageBox.Show("Потеряна связь с серверным приложением.", "Ошибка");
            }
        }
        private void FormSettings_KeyDown(object sender, KeyEventArgs e)
        {
            FormMenu fs       = (FormMenu)this.Owner;
            int      keyValue = e.KeyValue;

            if (keyValue == 125)
            {
                keyValue = 193;
            }
            if (keyValue == 126)
            {
                keyValue = 194;
            }
            switch (keyValue)
            {
            case (char)193:
                Z_mXML.DeviceId   = DeviceIdTB.Text;
                Z_mXML.ServerIP   = IPTB.Text;
                Z_mXML.ServerPort = PortTB.Text;
                Z_mXML.SaveXML();
                if (Z_mXML.IsOTK)
                {
                    fs.Text = "(" + Z_mXML.DeviceId + ") Выберите параметры:";
                }
                else
                {
                    fs.Text = "(" + DeviceIdTB.Text + ") Выбор действия";
                }
                this.Close();
                break;

            case (char)194:
                this.Close();
                break;
            }
        }