Esempio n. 1
0
        private void btn_match_Click(object sender, EventArgs e)
        {
            Label label = sender as Label;

            if (label.Text != "" || date_confirm() == -1)
            {
                return;
            }

            string name     = label.Name;
            string pic_name = "p" + name;

            Control[]  con     = this.Controls.Find(pic_name, true);
            PictureBox picture = (PictureBox)con[0];

            int time_num = 0;

            if (name.Length > 3)
            {
                time_num = int.Parse(name.Substring(0, name.Length - 2).Substring(1));
            }
            else
            {
                time_num = int.Parse(name.Substring(1));
            }

            string date = picker.Value.ToShortDateString();

            try
            {
                match m = new match(this, 1);
                m.ShowDialog();
            }
            catch
            {
                return;
            }
            if (sel_num != -1)
            {
                Reserve reservation = new Reserve();
                reservation.Type      = (int)PacketType.매칭;
                reservation.send_name = ID_txtBox.Text;
                reservation.time      = time_num;
                reservation.match_num = 2;
                reservation.tnum      = match_num;
                reservation.date      = date;
                Packet.Serialize(reservation).CopyTo(this.sendBuffer, 0);
                this.stream = clientSocket.GetStream();
                this.Send();

                this.Recv();
                Packet packet = (Packet)Packet.Deserialize(this.readBuffer);
                if ((int)packet.Type == (int)PacketType.매칭)
                {
                    reservation = (Reserve)Packet.Deserialize(this.readBuffer);
                    int num = reservation.used; // 0 : 성공 & 매칭 대기, 1 : 전체 사용중, 6 : 성공 & 꽉참 나머지 : 팀 인원수 불일치 (상대팀 인원수)

                    if (num == 0 || num == 6)
                    {
                        string img = match_num + ".png";
                        MessageBox.Show("Success Reservation !!!");
                        picture.Image    = Image.FromFile(img);
                        picture.SizeMode = PictureBoxSizeMode.StretchImage;

                        label.Text = ID_txtBox.Text;
                    }
                    else if (num == 1)
                    {
                        MessageBox.Show("Already reserved !!!");
                    }
                    else
                    {
                        MessageBox.Show("Number of Oposite Team : " + num.ToString() + "\nMatch Not Available !!!");
                    }
                }
            }

            unVisible();
            res_inform();
            update_msg_panel();
            btn_team.BackgroundImage = Image.FromFile("onTeamMatch.png");
            pn_team.Visible          = true;
        }
Esempio n. 2
0
        private void res_button_click(object sender, EventArgs e)
        {
            PictureBox picture = (PictureBox)sender;

            string pic_name = picture.Name + "_1";
            string date     = picker.Value.ToShortDateString();

            if (date_confirm() == -1)
            {
                return;
            }

            int time_num = int.Parse(picture.Name.Substring(7, 1));

            sel_num = -1;

            try
            {
                match m = new match(this);
                m.ShowDialog();
            }
            catch
            {
                return;
            }

            if (sel_num != -1)
            {
                if (sel_num == 1) // 혼자
                {
                    Reserve reservation = new Reserve();
                    reservation.Type      = (int)PacketType.혼자;
                    reservation.send_name = ID_txtBox.Text;
                    reservation.time      = time_num;
                    reservation.match_num = 1;
                    reservation.date      = date;
                    Packet.Serialize(reservation).CopyTo(this.sendBuffer, 0);
                    this.stream = clientSocket.GetStream();
                    this.Send();

                    this.Recv();
                    Packet packet = (Packet)Packet.Deserialize(this.readBuffer);
                    if ((int)packet.Type == (int)PacketType.혼자)
                    {
                        reservation = (Reserve)Packet.Deserialize(this.readBuffer);
                        int num = reservation.used; // 0 : 성공, 1 : 전체다 사용중, 2 : 매칭만 가능

                        if (num == 0)
                        {
                            MessageBox.Show("Success Reservation !!!");
                            picture.Image = Image.FromFile("btn_red.png");
                            Control[]  con = this.Controls.Find(pic_name, true);
                            PictureBox pic = (PictureBox)con[0];
                            pic.Image    = Image.FromFile("goal.png");
                            pic.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                        else if (num == 1)
                        {
                            MessageBox.Show("Already reserved !!!");
                        }
                        else
                        {
                            MessageBox.Show("Only Match Available !!!");
                        }
                    }
                }
                else // 매칭
                {
                    Reserve reservation = new Reserve();
                    reservation.Type      = (int)PacketType.매칭;
                    reservation.send_name = ID_txtBox.Text;
                    reservation.time      = time_num;
                    reservation.match_num = 2;
                    reservation.tnum      = match_num;
                    reservation.date      = date;
                    Packet.Serialize(reservation).CopyTo(this.sendBuffer, 0);
                    this.stream = clientSocket.GetStream();
                    this.Send();

                    this.Recv();
                    Packet packet = (Packet)Packet.Deserialize(this.readBuffer);
                    if ((int)packet.Type == (int)PacketType.매칭)
                    {
                        reservation = (Reserve)Packet.Deserialize(this.readBuffer);
                        int num = reservation.used; // 0 : 성공 & 매칭 대기, 1 : 전체 사용중, 6 : 성공 & 꽉참 나머지 : 팀 인원수 불일치 (상대팀 인원수)

                        if (num == 0)
                        {
                            MessageBox.Show("Success Reservation !!!");
                            //picture.Image = Image.FromFile("btn_red.png");
                            Control[]  con = this.Controls.Find(pic_name, true);
                            PictureBox pic = (PictureBox)con[0];
                            pic.Image    = Image.FromFile("football.png");
                            pic.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                        else if (num == 6)
                        {
                            MessageBox.Show("Success Reservation !!!");
                            picture.Image = Image.FromFile("btn_red.png");
                            Control[]  con = this.Controls.Find(pic_name, true);
                            PictureBox pic = (PictureBox)con[0];
                            pic.Image    = Image.FromFile("football.png");
                            pic.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                        else if (num == 1)
                        {
                            MessageBox.Show("Already reserved !!!");
                        }
                        else
                        {
                            MessageBox.Show("Number of Oposite Team : " + num.ToString() + "\nMatch Not Available !!!");
                        }
                    }
                }
            }
        }