コード例 #1
0
 public double Calcular(Registro registro)
 {
     return(0);
 }
コード例 #2
0
        private void checkin_Click(object sender, EventArgs e)
        {
            Registro registro;

            List <Registro> reg = null;
            //dateTimeEntrada.Text = null;
            //dateTimeSaida.Text = null;
            int maxDigCpf = 11;

            if (radioButton2.Checked == true)
            {
                checkout_Click(sender, e);
            }
            else
            {
                try {
                    if (txbCPF.MaxLength == maxDigCpf)
                    {
                        Cliente novoCliente = new Cliente()
                        {
                            Nome        = txbNome.Text,
                            Cpf         = Int64.Parse(txbCPF.Text),
                            PlacaCarro  = txbPlaca.Text,
                            ModeloCarro = txbModelo.Text,
                            categoria   = tipoVeiculo.Text
                        };

                        registro = new Registro()
                        {
                            RegistroCliente = novoCliente,

                            Entrada       = Convert.ToDateTime(dateTimeEntrada.Value.GetDateTimeFormats()),
                            Saida         = Convert.ToDateTime(dateTimeSaida.Value.GetDateTimeFormats()),
                            vagasOcupadas = 1
                        };

                        if (FormasCobranca.SelectedIndex == 0)
                        {
                            registro.formaDeCobranca = "Horista";
                        }
                        else if (FormasCobranca.SelectedIndex == 1)
                        {
                            registro.formaDeCobranca = "Vip";
                        }
                        else
                        {
                            registro.formaDeCobranca = "Mensalista";
                        }
                        if (!File.Exists(Localizacao.Text + ".json"))
                        {
                            reg = new List <Registro> {
                                registro
                            };
                        }
                        else
                        {
                            reg = JsonConvert.DeserializeObject <List <Registro> >(File.ReadAllText(Localizacao.Text + ".json"));
                            var re = reg.FindLast(x => x.vagasOcupadas >= 0).vagasOcupadas;
                            registro.vagasOcupadas = re;
                            if (registro.vagasOcupadas < 100)
                            {
                                registro.vagasOcupadas++;
                                reg.Add(registro);
                            }
                            else
                            {
                                MessageBox.Show("Não há vagas!");
                            }
                        }

                        string novoJson = JsonConvert.SerializeObject(reg);
                        File.WriteAllText(Localizacao.Text + ".json", novoJson);
                        txbCPF.Clear();
                        txbModelo.Clear();
                        txbNome.Clear();
                        txbPlaca.Clear();
                        Localizacao.Text     = "";
                        tipoVeiculo.Text     = "";
                        FormasCobranca.Text  = "";
                        dateTimeEntrada.Text = null;
                        dateTimeSaida.Text   = null;
                    }
                }
                catch (Exception) {
                    MessageBox.Show("Erro Inesperado, tente novamente");
                }
            }
        }