Exemplo n.º 1
0
        public async Task <ContentResult> Post([FromBody] Driver driver)
        {
            try
            {
                string address       = $"{driver.Address.StreetName},{driver.Address.Number},{driver.Address.District},{driver.Address.City},{driver.Address.State},{driver.Address.Country}";
                var    configuration = new ConfigurationBuilder()
                                       .AddEnvironmentVariables()
                                       .Build();
                driver.Address.Location = await GeoLocator.GetLocation(configuration, address);

                await DriverDB.SaveDriver(driver);

                return(new ContentResult
                {
                    Content = "Created",
                    ContentType = "text/plain",
                    StatusCode = 201
                });
            }
            catch (Exception ex)
            {
                return(new ContentResult
                {
                    Content = $"Bad Request: { ex.Message }",
                    ContentType = "text/plain",
                    StatusCode = 400
                });
            }
        }
Exemplo n.º 2
0
        public async Task <ContentResult> Put([FromBody] Driver driver)
        {
            try
            {
                string address       = $"{driver.Address.StreetName},{driver.Address.Number},{driver.Address.District},{driver.Address.City},{driver.Address.State},{driver.Address.Country}";
                var    configuration = new ConfigurationBuilder()
                                       .AddJsonFile("appsettings.json")
                                       .Build();
                driver.Address.Location = await GeoLocator.GetLocation(configuration, address);

                await DriverDB.UpdateDriver(driver);

                return(new ContentResult
                {
                    Content = "OK",
                    ContentType = "text/plain",
                    StatusCode = 200
                });
            }
            catch (Exception ex)
            {
                return(new ContentResult
                {
                    Content = $"Bad Request: { ex.Message }",
                    ContentType = "text/plain",
                    StatusCode = 400
                });
            }
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        DataSet ds         = DriverDB.selectDriver(Convert.ToInt32(Session["id"]));
        string  ltl_status = "";

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            Literal top    = new Literal();
            Literal bottom = new Literal();

            ltl_status += "  <div class='container col-xl-3 col-lg-4 col-md-6 col-sm-12 mb-4'>";
            top.Text    = ltl_status;
            ltl_status  = "";
            LinkButton motorista = new LinkButton();;
            string     auxN      = dr["mot_nome"].ToString();
            var        names     = auxN.Split(' ');
            motorista.Text   = "<div class='container'><div class='card bg-light border-dark auxiliar'><div class='card-body'><img src = '../../img/Motorista.png' /> </div > <div class='card-footer text-center'> <p><h4>" + names[0] + "<h4> </p> </div>  </div> </div>";
            motorista.Click += new System.EventHandler(this.motoristaEsse_Click);
            motorista.ID     = "V" + dr["mot_id"].ToString();
            ltl_status      += "</div>";
            bottom.Text      = ltl_status;
            ltl_status       = "";

            phl_mot.Controls.Add(top);
            phl_mot.Controls.Add(motorista);
            phl_mot.Controls.Add(bottom);
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Caravan    car       = (Caravan)Session["cadastro"];
            endereco[] enderecos = (endereco[])Session["auxiliar"];
            Proposta   pro       = (Proposta)Session["cadastro2"];

            ltl_tituloCaravana.Text    = " " + car.Car_titulo;
            ltl_descricaoCaravana.Text = " " + car.Car_descricao;

            ltl_veiculo.Text   = VehicleDB.selectVeiculoPlaca(Convert.ToInt32(pro.Vei_id));
            ltl_motorista.Text = DriverDB.selectDriverNome(Convert.ToInt32(pro.Mot_id));
            ltl_frete.Text     = "R$ " + pro.Pro_valor.ToString() + ",00";

            int i = car.Car_privacidade;
            if (i == 0)
            {
                ltl_tipoCaravana.Text = " Caravana Publica";
            }
            else if (i == 1)
            {
                ltl_tipoCaravana.Text = " Caravana Privada";
            }

            ltl_datSaida.Text = " " + car.HoraDeSaída.ToShortDateString();
            ltl_datDest.Text  = " " + car.HoraDeChegada.ToShortDateString();


            ltl_endDest.Text  = " " + enderecos[0].End_cidade;
            ltl_endDest.Text += ", " + enderecos[0].End_uf + "<br/>";
            ltl_endDest.Text += " " + enderecos[0].End_rua;
            ltl_endDest.Text += ", " + enderecos[0].End_bairro;

            ltl_endSaida.Text  = " " + enderecos[1].End_cidade;
            ltl_endSaida.Text += ", " + enderecos[1].End_uf + "<br/>";
            ltl_endSaida.Text += " " + enderecos[1].End_rua;
            ltl_endSaida.Text += ", " + enderecos[1].End_bairro;

            string[] categoria = car.Car_categoria.Split(';');
            ltl_categoria.Text = " " + categoria[0];
            if (categoria.Length > 1)
            {
                ltl_categoria.Text += " e " + categoria[1];
            }
        }
    }
Exemplo n.º 5
0
    protected void excluir_Click(object sender, EventArgs e)
    {
        Button button   = (Button)sender;
        string buttonId = button.ID;

        buttonId = Regex.Replace(buttonId, "[^0-9.]", "");

        if (DriverDB.deleteDriver(buttonId) == 0)
        {
            //Deu tudo certo!
            Response.Redirect(Request.RawUrl);
        }
        else
        {
            //Algo deu errado
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string aux = Session["auxiliar"].ToString();

        aux = Regex.Replace(aux, @"[\d-]", string.Empty);;
        ltl_auxiliar.Text = "<h2>Proposta para: " + aux + "</h2>";

        Proposta pro = (Proposta)Session["cadastro"];

        lblVeiculo.Text = VehicleDB.selectVeiculoPlaca(Convert.ToInt32(pro.Vei_id));

        string auxN  = DriverDB.selectDriverNome(pro.Mot_id);
        var    names = auxN.Split(' ');

        lbl_motorista.Text = names[0];

        lblValor.Text = "R$ " + pro.Pro_valor.ToString() + ",00";
    }
Exemplo n.º 7
0
    void editar_Click(object sender, EventArgs e)
    {
        Button button   = (Button)sender;
        string buttonId = button.ID;

        buttonId    = Regex.Replace(buttonId, "[^0-9.]", "");
        lbl_id.Text = buttonId;
        DataSet ds = DriverDB.selectDriver2(Convert.ToInt32(buttonId));

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            txt_nome.Text          = dr["mot_nome"].ToString();
            rbl_sexo.SelectedValue = dr["mot_genero"].ToString();
            var dob = Convert.ToDateTime(dr["mot_datanasciment"]);
            txt_nasc.Text  = dob.ToString("yyyy-MM-dd");
            txt_email.Text = dr["usu_email"].ToString();
        }
        Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#loginModal').modal('show');</script>", false);
    }
Exemplo n.º 8
0
        public Agents(DriverDB db)
        {
            InitializeComponent();

            if (db == null)
            {
                _db = new DriverDB();
            }
            else
            {
                _db = db;
            }

            var drivers = _db.GetDrivers();

            foreach (var d in drivers)
            {
                listBox.Items.Add(d.Name);
            }
        }
Exemplo n.º 9
0
    protected void btn_ConfirmarEdicao_Click(object sender, EventArgs e)
    {
        string    mot_id = lbl_id.Text;
        Motorista mot    = new Motorista();

        mot.Mot_nome             = txt_nome.Text;
        mot.Mot_genero           = Convert.ToChar(rbl_sexo.SelectedValue.ToString());
        mot.Mot_datadenascimento = Convert.ToDateTime(txt_nasc.Text);
        string email = txt_email.Text;

        if (DriverDB.updateDriver(mot, email, mot_id) == 0)
        {
            // Deu tudo certo!
            Response.Redirect(Request.RawUrl);
        }
        else
        {
            // Algo deu errado!
        }
    }
Exemplo n.º 10
0
        public ContentResult GetDriversOrderedByFirstName()
        {
            try
            {
                var response = DriverDB.GetDriversOrderByFirstName();

                return(new ContentResult
                {
                    Content = JsonConvert.SerializeObject(response, Formatting.Indented),
                    ContentType = "application/json",
                    StatusCode = 200
                });
            }
            catch (Exception ex)
            {
                return(new ContentResult
                {
                    Content = $"Internal Server Error: { ex.Message }",
                    ContentType = "text/plain",
                    StatusCode = 500
                });
            }
        }
Exemplo n.º 11
0
        public async Task <ContentResult> Delete(string id)
        {
            try
            {
                await DriverDB.DeleteDriver(id);

                return(new ContentResult
                {
                    Content = "OK",
                    ContentType = "text/plain",
                    StatusCode = 200
                });
            }
            catch (Exception ex)
            {
                return(new ContentResult
                {
                    Content = $"Bad Request: { ex.Message }",
                    ContentType = "text/plain",
                    StatusCode = 400
                });
            }
        }
Exemplo n.º 12
0
    protected void btn_confirmar_Click(object sender, EventArgs e)
    {
        Motorista mot = (Motorista)Session["cadastro"];

        if (Session["auxiliar"] != null && Session["auxiliar"] is Usuario)
        {
            Usuario user = (Usuario)Session["auxiliar"];
            UserDB.insertUser(user);
            mot.Usu_id = UserDB.selectUser(user);
        }

        mot.Mot_tip_id = 1;
        mot.Mot_emp_id = (int)Session["id"];

        if (DriverDB.insertDriver(mot) == 0)
        {
            ltl_status.Text  = "<script type='text/javascript'> swal('Sucesso!', 'Você cadastrou um novo motorista!', 'success')";
            ltl_status.Text += ".then((value) => {window.location.replace('Drivers.aspx')}); </script> ";
        }
        else
        {
            //Não foi possível cadastrar motorista
        }
    }
Exemplo n.º 13
0
        public MainPage(DriverDB DB)
        {
            InitializeComponent();

            if (db == null)
            {
                db = new DriverDB();
            }
            else
            {
                db = DB;
            }

            calc = new Calculator();

            comboAgents.ItemsSource       = db.GetDrivers();
            comboAgents.SelectedValuePath = "AgentId";
            comboAgents.DisplayMemberPath = "Name";

            Submit.Click += (s, e) => Submit_Click(s, e);

            lbl_Result.Visibility = Visibility.Hidden;
            groupBox1.Visibility  = Visibility.Hidden;
        }
Exemplo n.º 14
0
    protected void Page_Init(object sender, EventArgs e)
    {
        DataSet ds         = DriverDB.selectDriver(Convert.ToInt32(Session["id"]));
        string  ltl_status = "";

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            Literal top    = new Literal();
            Literal bottom = new Literal();


            ltl_status  = "<div class='col-md-4 col-12 mt-3'>";
            ltl_status += "<div class='card'>";
            ltl_status += "<div class='card-header  text-center  pt-2 pb-1 '>";
            ltl_status += "<h5 class ='text-center'>";
            string auxN  = dr["mot_nome"].ToString();
            var    names = auxN.Split(' ');
            ltl_status += names[0];
            ltl_status += "</h5>";
            ltl_status += "</div>";
            ltl_status += "<div class='row'>";
            ltl_status += "<div class='col-12 rx-2'>";
            ltl_status += "<img src='" + dr["foto"].ToString() + "' Class='w-100 border border-light rounded'>";
            ltl_status += "</div>";
            ltl_status += "<div class='col-md-12  pt-2'>";
            ltl_status += "<div class='card-block btn-more'>";
            ltl_status += "<div class='ml-1 text-center'>";
            ltl_status += "<div class='mb-2'>";
            ltl_status += "<div>";
            ltl_status += "<strong>Nome Completo:</strong>";
            ltl_status += "<asp:Literal runat='server'>" + dr["mot_nome"].ToString() + "</asp:Literal>";
            ltl_status += "</div>";
            ltl_status += "<div>";
            ltl_status += "<strong>Gênero: </strong>";
            string aux = dr["mot_genero"].ToString();
            if (aux == "M")
            {
                aux = "Masculino";
            }
            else if (aux == "F")
            {
                aux = "Feminino";
            }
            else if (aux == "O")
            {
                aux = "Outro";
            }
            ltl_status += "<asp:Literal runat='server'>" + aux + "</asp:Literal>";
            ltl_status += "</div>";
            ltl_status += "</div>";
            ltl_status += "<div>";
            ltl_status += "<strong>Idade:</strong>";
            var data  = DateTime.Today;
            var nasc  = Convert.ToDateTime(dr["mot_datanasciment"]);
            var idade = data.Year - nasc.Year;
            if (nasc.Date > data.AddYears(-idade))
            {
                idade--;
            }
            ltl_status += "<asp:Literal runat='server'>" + idade.ToString() + " Anos</asp:Literal>";
            ltl_status += "</div>";
            ltl_status += "<div>";
            ltl_status += "<strong>Data de nascimento: </strong>";
            ltl_status += "<asp:Literal runat='server'>" + nasc.ToShortDateString() + "</asp:Literal>";
            ltl_status += "</div>";
            ltl_status += "<div class='mt-2'>";
            ltl_status += "<strong>E - mail:: </strong>";
            ltl_status += "<asp:Literal runat='server'>" + dr["usu_email"].ToString() + "</asp:Literal>";
            ltl_status += "</div>";
            ltl_status += "</div>";
            ltl_status += "<div class='col-12 mb-1 mt-5 mt-auto'>";
            ltl_status += "<div class='row'>";
            ltl_status += "<div class='col-2'>";
            ltl_status += "<div class='btn-group dropright'>";
            ltl_status += "<button class='btn btn-secondary dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false' style='padding-bottom:10px;background-color:#ffcc00;border: 1px solid transparent;'>";
            ltl_status += "<i class='fa fa-cog fa-lg pt-2'></i>";
            ltl_status += "</button>";
            ltl_status += "<div class='dropdown-menu' style='background-color:#ffcc00;'>";
            top.Text    = ltl_status;
            ltl_status  = " ";
            Button btn_editar = new Button();
            btn_editar.Text     = "Editar Motorista";
            btn_editar.ID       = "E" + dr["mot_id"].ToString();
            btn_editar.CssClass = "dropdown-item m";
            btn_editar.Click   += new System.EventHandler(this.editar_Click);
            Button btn_excluir = new Button();
            btn_excluir.Text     = "Excluir Motorista";
            btn_excluir.ID       = "D" + dr["mot_id"].ToString();
            btn_excluir.CssClass = "dropdown-item m";
            btn_excluir.Click   += new System.EventHandler(this.excluir_Click);
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "<div class='col-md-9 col-10  '>";
            ltl_status          += "<label  class='genric-btn info w-100 btn-more mt-1'> Livre</label>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            ltl_status          += "</div>";
            bottom.Text          = ltl_status;
            plh_status.Controls.Add(top);
            plh_status.Controls.Add(btn_editar);
            plh_status.Controls.Add(btn_excluir);
            plh_status.Controls.Add(bottom);
        }
        if (ltl_status == "")
        {
            Literal none = new Literal();
            ltl_status  = "";
            ltl_status += "    <div class='col - 12'>";
            ltl_status += "  <h5 class='text-center'>Não há motoristas cadastrados</h5>";
            ltl_status += "</div>";
            none.Text   = ltl_status;
            plh_status.Controls.Add(none);
        }
    }