Exemplo n.º 1
0
        /// <summary>
        /// Only for test, for future the request has to be approved. But for now simple generation is also good.
        /// </summary>
        public List <byte> CreateRequest(BussinesTripInfo info)
        {
            List <byte> bytes = new List <byte>();

            bytes.Add((byte)Operations.CreateRequest);
            bytes.AddRange(info.serialise());
            SendToClient(bytes.ToArray());
            List <byte> file = ReceiveForClient().ToList();

            return(file);
        }
Exemplo n.º 2
0
        public List <BussinesTripInfo> GetDocuments()
        {
            List <byte> bytes = new List <byte>();

            bytes.Add((byte)Operations.GetDocuments);
            SendToClient(bytes.ToArray());
            List <byte> answer         = ReceiveForClient().ToList();
            Int32       documentsCount = BitConverter.ToInt32(answer.ToArray(), 0);

            answer.RemoveRange(0, sizeof(Int32));

            List <BussinesTripInfo> documents = new List <BussinesTripInfo>();

            for (int i = 0; i < documentsCount; i++)
            {
                documents.Add(BussinesTripInfo.deserialise(answer));
            }

            return(documents);
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (!CheckUserInput())
            {
                return;
            }

            string[] fullname = comboBox1.Text.Split(' ');

            BussinesTripInfo info = new BussinesTripInfo(fullname[0], fullname[1], fullname[2], textBox1.Text,
                                                         currentDestinationPlace.name + " " + currentDestinationPlace.address, richTextBox1.Text, textBox2.Text, dateTimePicker1.Value, dateTimePicker2.Value, 0);

            var file = client.CreateRequest(info);

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Word document|*.docx";
            saveFileDialog.Title  = "Сохранить командировочное удостоверение";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                File.WriteAllBytes(saveFileDialog.FileName, file.ToArray());
            }
        }