Exemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     cameraModel                  = new CameraModel();
     dateTimePicker1.Format       = DateTimePickerFormat.Custom;
     dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss";
 }
Exemplo n.º 2
0
        public void addTranscation(CameraModel transaction)
        {
            if ((data.Count + clients.Count) < countParkingPlace)
            {
                if (isExistClient(transaction.carNumber))
                {
                    showDecisionInfo(searchTransaction(transaction));
                }
                else
                {
                    switch (transaction.direction)
                    {
                    case "+":
                        showDecisionInfo(searchTransaction(transaction));
                        break;

                    case "-":
                        checkPayment(transaction);
                        break;

                    default:
                        MessageBox.Show("Направление не распознано.");
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("нет свободных парковочных мест");
            }
        }
Exemplo n.º 3
0
 public bool searchTransaction(CameraModel transaction)
 {
     foreach (CameraModel objectModel in data)
     {
         if (objectModel.carNumber == transaction.carNumber && objectModel.direction == transaction.direction)
         {
             return(false);
         }
     }
     this.data.Add(transaction);
     return(true);
 }
Exemplo n.º 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (gosNumberField.Text != "")
     {
         string[] args = new string[3];
         args[0] = gosNumberField.Text;
         args[1] = (directionList.SelectedIndex == 0) ? "+" : "-";
         args[2] = dateTimePicker1.Text;
         CameraModel model = new CameraModel(args);
         parking.addTranscation(model);
         updateDataGridView1();
     }
     else
     {
         MessageBox.Show("Заполните госномер");
     }
 }
Exemplo n.º 5
0
 private void checkPayment(CameraModel transaction)
 {
     foreach (CameraModel model in data)
     {
         if (model.carNumber == transaction.carNumber)
         {
             TimeSpan span        = Convert.ToDateTime(transaction.date) - Convert.ToDateTime(model.date);
             double   sum         = (span.Hours + ((span.Minutes > 0) ? 1 : 0)) * pricePerHour;
             double   fullDeposit = getFullDeposit(transaction.carNumber);
             if (sum <= fullDeposit)
             {
                 showDecisionInfo(searchTransaction(transaction));
             }
             else
             {
                 MessageBox.Show("Красный. Неоплачена парковка");
             }
             return;
         }
     }
     MessageBox.Show("Не найден въезд этой машины");
 }
Exemplo n.º 6
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         using (StreamReader reader = new StreamReader(textBox6.Text, Encoding.Default))
         {
             string[] array = reader.ReadLine().Split('|');
             if (array.Count() == 3)
             {
                 // Console.WriteLine((reader.ReadLine().Split('|')));
                 CameraModel model = new CameraModel(array);
                 parking.addTranscation(model);
                 updateDataGridView1();
             }
             else
             {
                 MessageBox.Show("Неправильная структура файла");
             }
         }
     } catch
     {
         MessageBox.Show("Файл не найден");
     }
 }