Beispiel #1
0
 /*---Car IN---*/
 void Car_in(string in_location, string in_maso, string in_time, string in_date) // đưa xe vào với vị trí, mã thẻ, thời gian, ngày
 {
     try
     {
         if (IsNumber(in_location) && Convert.ToInt32(in_location) <= 6 && Convert.ToInt32(in_location) > 0 && done == true)
         {
             if (check_in_car(in_location) == true && check_ID_car_in(in_maso) == true)
             {
                 if (Admin_test == false)
                 {
                     Serial_port.Write("E0");                      // OKE
                 }
                 else
                 {
                     Admin_test = false;
                 }
                 lb_error.Text   = "Complete";
                 txt_vitri.Text  = in_location;
                 txt_maso.Text   = in_maso;
                 txt_time.Text   = in_time;
                 txt_date.Text   = in_date;
                 done            = false;
                 pic_car.Visible = true;
                 Set_status(true, in_location);
                 Set_ID_card_time(in_maso, in_time, in_date, in_location);
                 Timer_1.Start();
             }
             else
             {
                 if (check_in_car(in_location) == false)
                 {
                     Serial_port.Write("E3"); // Chưa đồng bộ dữ liệu
                     lb_error.Text = "Upload";
                 }
                 else if (check_ID_car_in(in_maso) == false)
                 {
                     Serial_port.Write("E2"); // Thẻ đã được xử dụng
                     lb_error.Text = "Used card";
                 }
             }
         }
         else
         {
             lb_error.Text = "Upload";
             Serial_port.Write("E3"); // Chưa đồng bộ dữ liệu
         }
     }
     catch
     {
         lb_error.Text = "Error";
         if (Serial_port.IsOpen)
         {
             Serial_port.Write("E4"); //Có lỗi xảy ra
         }
         else
         {
             MessageBox.Show("Chưa mở cổng COM");
         }
     }
 }
Beispiel #2
0
 private void Time_1_Tick(object sender, EventArgs e)
 {
     pictureBox1.Location = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y);
     if (pictureBox1.Location.X > panel3.Size.Width - pictureBox1.Size.Width)
     {
         led1.On = true;
         //pictureBox1.Image = new Bitmap(Application.StartupPath + "\\picture\\white.png");
         pictureBox1.Location = new Point(0, 0 + 470);
         Timer_1.Stop();
     }
 }
Beispiel #3
0
 /*-------------------simulation----------------------*/
 /*---------IN----------*/
 /*---Time 1---*/
 private void Timer_1_Tick(object sender, EventArgs e)
 {
     pic_car.Location = new Point(pic_car.Location.X + 10, pic_car.Location.Y);
     if (pic_car.Location.X > 300)
     {
         Timer_1.Stop();
         pic_car.Visible  = false;
         pic_car.Location = new Point(0, pic_car.Location.Y);
         pic_car_v2.Image = new Bitmap(Application.StartupPath + "\\picture\\er.png");
         Timer_2.Start();
     }
 }
 /*---Car IN---*/
 void Car_in(string in_location, string in_maso, string in_time, string in_date) // đưa xe vào với vị trí, mã thẻ, thời gian, ngày
 {
     try
     {
         if (IsNumber(in_location) && Convert.ToInt32(in_location) <= 6 && Convert.ToInt32(in_location) > 0 && done == true)
         {
             if (check_in_car(in_location) == true && check_ID_car_in(in_maso) == true)
             {
                 txt_vitri.Text  = in_location;
                 txt_maso.Text   = in_maso;
                 txt_time.Text   = in_time;
                 txt_date.Text   = in_date;
                 done            = false;
                 pic_car.Visible = true;
                 Set_status(true, in_location);
                 Set_ID_card_time(in_maso, in_time, in_date, in_location);
                 Timer_1.Start();
             }
             else
             {
                 if (check_in_car(in_location) == false)
                 {
                     MessageBox.Show("Đã có xe tại vị trí đó");
                 }
                 else if (check_ID_car_in(in_maso) == false)
                 {
                     MessageBox.Show("Thẻ đã được xử dụng");
                 }
             }
         }
         else
         {
             MessageBox.Show("Địa chỉ không hợp lệ");
         }
     }
     catch
     {
         MessageBox.Show("Có lỗi xảy ra");
     }
 }