コード例 #1
0
ファイル: MainForm.cs プロジェクト: kgw100/reservation_system
        // 좌석 버튼 클릭시
        void newbtn_Click(object sender, EventArgs e)
        {
            Button  btn     = sender as Button;
            int     btn_num = int.Parse(btn.Text);
            SeatBtn seatBtn = new SeatBtn();

            seatBtn.btn_FocusRegister(btn);
            SeatInfo cur_seat = DataManager.seat_List[btn_num - 1];

            btn.BackColor = Color.FromArgb(230, 255, 204, 0); // 노란색으로 바꾸기

            if (cur_seat.isUsed)
            {
                tb_id.Text   = cur_seat.id.ToString();
                tb_name.Text = cur_seat.name;
                //readOnly로 설정
                tb_id.ReadOnly   = true;
                tb_name.ReadOnly = true;
            }
            else
            {
                tb_id.ReadOnly   = false;
                tb_name.ReadOnly = false;
                tb_id.Clear();
                tb_name.Clear();
            }
            tb_pos.Text = btn.Text;
        }
コード例 #2
0
 public static void Set()
 {
     // 생성된 xml이 없을 경우 생성
     //총 좌석 수가 설정되지 않았으므로, 정해주기
     Seat.total_SeatCnt = 120;
     SeatInfo[] make_Seat = new SeatInfo[Seat.total_SeatCnt];
     seat_List = new List <SeatInfo>(make_Seat);
     //모두 사용가능로 초기화
     for (int pos = 0; pos < Seat.total_SeatCnt; pos++)
     {
         seat_List[pos]        = new SeatInfo();
         seat_List[pos].isUsed = false;
     }
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: kgw100/reservation_system
        // 좌석현황 버튼 처리
        private void make_Btn()
        {
            SeatBtn seatBtn = new SeatBtn();

            for (int num = 0; num < Seat.total_SeatCnt; num++)
            {
                // 리스트안 각각 배열하나마다 객체를 또 생성해줘야 오류가 나지않는다.
                newButton[num]             = new Button();
                newButton[num].Text        = (num + 1).ToString();//num이 0부터 시작하기때문에
                newButton[num].Name        = "seat" + (num + 1).ToString();
                newButton[num].Click      += new EventHandler(newbtn_Click);
                newButton[num].GotFocus   += new EventHandler(seatBtn.newbtn_OnGotFocus);
                newButton[num].LostFocus  += new EventHandler(seatBtn.newbtn_OnLostFocus);
                newButton[num].MouseMove  += new System.Windows.Forms.MouseEventHandler(seatBtn.newbtn_MouseMove);
                newButton[num].MouseLeave += new EventHandler(seatBtn.newbtn_MouseLeave);
                newButton[num].Size        = new Size(37, 37);
                newButton[num].Font        = new Font("맑은 고딕", 9, FontStyle.Bold);
                newButton[num].ForeColor   = Color.White;
                //num+1에 해당하는 위치의 좌석 정보 불러오기
                SeatInfo seat = DataManager.seat_List[num];
                //사용 가능, 사용중 버튼 색을 다르게 세팅
                if (seat.isUsed == false)
                {
                    newButton[num].BackColor = Color.FromArgb(230, 0, 51, 255);
                }
                else
                {
                    newButton[num].BackColor = Color.FromArgb(250, 204, 204, 204);
                }
                // 버튼 동적 생성
                int btn_Row       = num; // 행 번호, 첫 줄은 세로로 이동시키지 않기 위해 1을 뺌
                int btn_ColumnCnt = 20;  // 한 줄당 버튼 개수
                int btn_distance  = 40;  // 버튼 간격
                if (num < btn_ColumnCnt)
                {
                    // 1로할경우는 num-1를 해줘야하지만  num이 0인 경우는 알아서 처리된다.
                    // num -1를 한 이유는 행에서 가장 첫번째 버튼은 고정으로 하기위해
                    // 7은 가장자리랑 떨어지기위해 더해준값,
                    newButton[num].Location = new Point(7 + btn_distance * (num), (btn_Row / btn_ColumnCnt) * btn_distance);
                }
                else
                {
                    newButton[num].Location = new Point(7 + btn_distance * (num - (btn_ColumnCnt * (btn_Row / btn_ColumnCnt))), (btn_Row / btn_ColumnCnt) * btn_distance);
                }

                seatList.Controls.Add(newButton[num]);
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: kgw100/reservation_system
        //사용 가능한 좌석버튼 클릭
        private void noUsedBtn_Click(int btn_num)
        {
            //학번 체크
            if (string.IsNullOrEmpty(tb_id.Text))
            {
                MessageBox.Show("학번이 입력되지않았습니다. 다시 입력하세요.");
                return;
            }
            int?   id   = int.Parse(tb_id.Text);
            string name = tb_name.Text;

            //이름체크
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("이름이 입력되지않았습니다. 다시 입력하세요.");
                return;
            }
            try
            {
                for (int i = 0; i < dgvResSts.Rows.Count; i++)
                {
                    if (Equals(dgvResSts.Rows[i].Cells[0].Value, id))
                    {
                        MessageBox.Show("이미 동일한 학번이 사용중입니다. 다시 입력하세요.");
                        return;
                    }
                    Thread.Sleep(5);
                }
                SeatInfo tempSeatUser = new SeatInfo()
                {
                    id = id, name = name, pos = btn_num, isUsed = true
                };
                dgvResSts.Rows.Add(tempSeatUser.id, tempSeatUser.name, tempSeatUser.pos);
                DataManager.seat_List[btn_num - 1] = tempSeatUser;
                newButton[btn_num - 1].BackColor   = Color.FromArgb(250, 204, 204, 204);
                Seat.used_SeatCnt += 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {   //입력했던것들 비우기
                tb_id.Clear();
                tb_name.Clear();
            }
        }