Пример #1
0
 private void ConnectToBD(bool isUser)
 {
     try
     {
         if (!_connectCan)
         {
             return;
         }
         //соединение с базой данных
         if (_sqlConnection == null)
         {
             _sqlConnectionString = "Data Source=" + tbConnectBD.Text +
                                    ";Initial Catalog=DatabasePeopleMain;User ID=sa;Password=operki1991";
             _sqlConnection = new SqlConnection(_sqlConnectionString);
             _sqlConnection.Open();
         }
         if (!isUser)
         {
             //_userName = "******";
             //_userRights = new[] {0, 0, 0, 0, 0};
             var terminalForm = new TerminalForm(_sqlConnectionString);
             Hide();
             terminalForm.Show(this);
         }
         else
         {
             var userIndex = lbUserNames.SelectedIndex;
             if (lbUserPasswords.Items[lbUserNames.SelectedIndex].ToString() != tbUserPass.Text)
             {
                 userIndex = -1;
             }
             if (userIndex < 0)
             {
                 bConnectBD.Text      = "        Неверный пароль";
                 bConnectBD.BackColor = Color.FromArgb(255, 13, 0);
                 tPass.Enabled        = true;
                 _connectCan          = false;
                 return;
             }
             _userName = lbUserNames.Text;
             SetUser();
             //экран добавления человека
             var startForm = new StartForm(_sqlConnectionString, _userName, _userRights);
             startForm.LoadFromConnect();
             Hide();
             startForm.Show(this);
         }
     }
     finally
     {
         _sqlReader?.Close();
     }
 }
Пример #2
0
 public AddAndUpdateForm(StartForm form)
 {
     InitializeComponent();
     if (isAdd)
     {
         this.Text = "添加";
     }
     else
     {
         this.Text = "修改";
     }
     this.orderService = form.orderService;
 }
Пример #3
0
 private void StartBtn_Click(object sender, EventArgs e)
 {
     // 맵과 경로가 있는경우에만 창 표시
     if (isMap && isPath)
     {
         StartForm startForm = new StartForm();
         Task.Run(() => startForm.start());
         startForm.ShowDialog();
     }
     else
     {
         MessageBox.Show("에러 : 맵과 경로를 먼저 입력하세요.");
     }
 }
Пример #4
0
        public bool keyPointSearch(StartForm startForm)
        {
            while (true)
            {
                Thread.Sleep(sleepTime);
                // 경로 == List<Tile> 형식 --> path[i].X  :  행  ,  path[i].Y   :  열  <-- 이렇게 접근 가능
                rotation(startForm);
                if (!avoidingHazard(startForm)) // 위험지역 나오면 다시 로테이션부터 시작
                {
                    if (MapManager.CreatePath() == 1)
                    {
                        return(false);
                    }
                    continue;
                }
                detectingColorBlob();
                // 오작동 했다면
                bool moveCorrect = simInterface.moveForward();
                set_cur();
                startForm.display();
                MapManager.getPath().RemoveAt(0); // 제대로 움직였으니 첫번째 패스 삭제
                if (!moveCorrect)
                {
                    if (!compensateMotion()) // 경로 재설정
                    {
                        return(false);
                    }
                }

                // 스팟에 도착했는지 검사
                if (MapManager.getCurrent().First == MapManager.getSpot()[0].First && MapManager.getCurrent().Second == MapManager.getSpot()[0].Second)
                {
                    // 스팟 지나가면 깃발 바꾸기
                    MapManager.getMap()[MapManager.getSpot()[0].First, MapManager.getSpot()[0].Second] = 5;
                    MapManager.getSpot().RemoveAt(0);
                    // 끝났으면
                    if (VerifyEnd())
                    {
                        Console.WriteLine("Successed!!!");
                        break;
                    }
                    else
                    {
                        MapManager.CreatePath();
                    }
                }
            }
            return(true);
        }
Пример #5
0
        public bool avoidingHazard(StartForm startForm)
        {
            bool ishazard = simInterface.getHazardSensor();

            if (ishazard)
            {
                // 위험지역이니 맵에게 알리는 코드
                MapManager.addHazard(ishazard);
                // StartForm에 위험지역 디스플레이 띄우기
                startForm.display();
                Thread.Sleep(sleepTime);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #6
0
        public void rotation(StartForm startForm)
        {
            if (MapManager.getPath().Count == 0)
            {
                Console.WriteLine("path 0 err");
                Application.ExitThread();
                Environment.Exit(0);
            }
            int x       = MapManager.getCurrent().First - MapManager.getPath()[0].X;
            int y       = MapManager.getPath()[0].Y - MapManager.getCurrent().Second;
            int forward = 0; // 진행할 방향

            if (x == 1 && y == 0)
            {
                forward = 0;
            }
            else if (x == 0 && y == 1)
            {
                forward = 1;
            }
            else if (x == -1 && y == 0)
            {
                forward = 2;
            }
            else if (x == 0 && y == -1)
            {
                forward = 3;
            }
            // 진행할 방향으로 헤드 돌리기
            while (head != forward)
            {
                head = (head + 1) % 4;
                simInterface.rotation();
                set_head();
                // StartForm에 회전 디스플레이 띄우기
                startForm.display();
                Thread.Sleep(sleepTime);
            }
        }
Пример #7
0
 public setting(StartForm s)
 {
     InitializeComponent();
     this.s = s;
 }