示例#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");
         }
     }
 }
示例#2
0
 /*----------------------------------------*/
 private void btn_send_Click(object sender, EventArgs e)
 {
     if (Serial_port.IsOpen)
     {
         Serial_port.Write(txt_send.Text);
     }
     else
     {
         MessageBox.Show("Chưa mở cổng COM", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
示例#3
0
 private void btn_led_3_Click(object sender, EventArgs e)
 {
     if (Serial_port.IsOpen)
     {
         Serial_port.Write("3");
     }
     else
     {
         MessageBox.Show("Chưa mở cổng COM");
     }
 }
示例#4
0
 /*---Car OUT---*/
 void Car_out(string out_location) // lấy xe ra với vị trí với mã thẻ
 {
     try
     {
         if (IsNumber(out_location) && Convert.ToInt32(out_location) <= 6 && Convert.ToInt32(out_location) > 0 && done == true)
         {
             if (check_out_car(out_location) == true)
             {
                 if (Admin_test == false)
                 {
                     Serial_port.Write("E0");                      // OKE
                 }
                 else
                 {
                     Admin_test = false;
                 }
                 lb_error.Text  = "Complete";
                 done           = false;
                 txt_vitri.Text = out_location;
                 Set_status(false, out_location);
                 Set_ID_card_time("", "", "", out_location);
                 Timer_4.Start();
             }
             else
             {
                 MessageBox.Show("Chưa có xe tại vị trí đó", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             Serial_port.Write("E5"); // Thẻ chưa đc xử dụng
             lb_error.Text = "Card error";
         }
     }
     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");
         }
     }
 }