Ejemplo n.º 1
0
    public void VeiculoLoad()
    {
        hdf.Value = Session["value"].ToString();

        mot_motorista mot = new mot_motorista();

        DataSet codigo = new DataSet();

        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));
        // Label1.Text = par;
        int c = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        DataSet ds = tra_transporteDB.SelectDados(c);

        foreach (DataRow dados in ds.Tables[0].Rows)
        {
            Literal.Text += "<div class='list-item'><div class='serviceBox shadow'> "
                            + "<p class='destino title'>" + dados["tra_modelo"]
                            + "<span class='glyphicon glyphicon-remove text_right'>&nbsp Excluir</span></span>"
                            + "<span class='glyphicon glyphicon-edit'>&nbsp Editar</span></span></p>" + "</p>"
                            + "<div class='padding'>"
                            + "<p><b>Tipo de Veiculo</b>: " + dados["tve_descricao"] + "</p>"
                            + "<p><b>Lugares</b>:" + dados["tra_lugares"] + "</p>"
                            + "</p></div></div></div>";
        }
    }
Ejemplo n.º 2
0
    public void CarregarVisualizar()
    {
        hdf.Value = Session["value"].ToString();
        usu_usuario   usu = new usu_usuario();
        mot_motorista mot = new mot_motorista();
        pes_pessoa    pes = new pes_pessoa();
        mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato();
        tpc_tipo_contato           tpc = new tpc_tipo_contato();

        DataSet ds = mot_motoristaDB.SelectDados(Convert.ToInt32(hdf.Value));

        if (ds.Tables[0].Rows.Count == 1)
        {
            hdfID.Value                 = ds.Tables[0].Rows[0]["pes_id"].ToString();
            txtNome.Text                = ds.Tables[0].Rows[0]["pes_nome"].ToString();
            txtEmail.Text               = ds.Tables[0].Rows[0]["usu_email"].ToString();
            txtCNPJ.Text                = ds.Tables[0].Rows[0]["mot_cnpj"].ToString();
            ddlSexo.SelectedItem.Text   = ds.Tables[0].Rows[0]["pes_sexo"].ToString();
            ddlCidade.SelectedItem.Text = ds.Tables[0].Rows[0]["pes_cidade"].ToString();
            ddlEstado.SelectedItem.Text = ds.Tables[0].Rows[0]["pes_estado"].ToString();
            ddl.SelectedItem.Text       = ds.Tables[0].Rows[0]["tpc_descricao"].ToString();
            txtTelefone.Text            = ds.Tables[0].Rows[0]["mxc_descricao"].ToString();
            txtData.Text                = ds.Tables[0].Rows[0]["pes_nascimento"].ToString();
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["nome"] == null || Session["perfil"] == null)
        {
            Response.Redirect("error.aspx");
        }
        else
        {
            string perfil = Convert.ToString(Session["perfil"]);

            if (perfil == "Motorista")
            {
                Sessão usu = (Sessão)Session["nome"];
                lbl.Text = usu.nome;
                //Context.Items["value"] = usu.id.ToString();
                hdf.Value = usu.id.ToString();
                //lbl.Text = Session["nome"].ToString();
            }
            else
            {
                Response.Redirect("error.aspx");
            }
        }
        DateTime      data     = DateTime.Today;
        DateTime      firstDay = new DateTime(data.Year, data.Month, 1);
        mot_motorista mot      = new mot_motorista();

        if (data == firstDay)
        {
            int publicacoes = 0;
            mot.Mot_publicacoes = publicacoes;
            mot_motoristaDB.UpdatePublicacoes(mot);
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["nome"] != null)
            {
                hdf.Value = Session["value"].ToString();
                mot_motorista mot    = new mot_motorista();
                DataSet       codigo = new DataSet();
                codigo     = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));
                mot.Mot_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);
                int     a  = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);
                DataSet ds = mot_motoristaDB.SelectPETC(a);
                foreach (DataRow dados in ds.Tables[0].Rows)
                {
                    if (Convert.ToString(dados["tip_descricao"]) == "Free")
                    {
                        ExibirLimite();
                    }
                }

                DateTime data     = DateTime.Today;
                DateTime firstDay = new DateTime(data.Year, data.Month, 1);

                if (data == firstDay)
                {
                    int publicacoes = 0;
                    mot.Mot_publicacoes = publicacoes;
                    mot_motoristaDB.UpdatePublicacoes(mot);
                }
                CarregarLiteral();
                CadastroCompleto();
            }
        }
    }
Ejemplo n.º 5
0
    public void CondutorLoad()
    {
        hdf.Value = Session["value"].ToString();

        mot_motorista mot = new mot_motorista();

        DataSet codigo = new DataSet();

        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));
        // Label1.Text = par;
        int c = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        DataSet ds = con_condutorDB.SelectDados(c);

        foreach (DataRow dados in ds.Tables[0].Rows)
        {
            ltrCondutores.Text += "<div class='list-item'><div class='serviceBox shadow'> "
                                  + "<p class='destino title'>" + dados["con_nome"]
                                  + "<span class='glyphicon glyphicon-remove text_right'>&nbsp Excluir</span></span>"
                                  + "<span class='glyphicon glyphicon-edit'>&nbsp Editar</span></span></p>"
                                  + "<div class='padding'>"
                                  + "<p><b>Cpf</b>: " + dados["con_cpf"] + "</p>"
                                  + "<p><b>Tipo de Contato</b>:" + dados["tpc_descricao"] + "</p>"
                                  + "<p><b>Contato</b>: " + dados["ctp_descricao"] + " </p>"
                                  + "</p></div></div></div>";
        }
    }
Ejemplo n.º 6
0
    public void CarregarLiteral()
    {
        hdf.Value = Session["value"].ToString();

        mot_motorista mot = new mot_motorista();

        DataSet codigo = new DataSet();

        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));
        // Label1.Text = par;

        int     c         = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);
        int     esCounter = 0;
        DataSet ds        = ser_servicosDB.SelectServicos(c);

        foreach (DataRow dados in ds.Tables[0].Rows)
        {
            if (Convert.ToDateTime(dados["ser_datafim"]) < DateTime.Now)
            {
                ser_servicosDB.Delete(Convert.ToInt32(dados["ser_id"]));
                esCounter++;
            }
            else
            {
                Literal1.Text += "  <div class='list-item'><div class='serviceBox shadow'> "
                                 + "<div class='title'>" + dados["pes_nome"]
                                 //+ "<span class='text-right'>" + dados["ser_id"] + "</span>"
                                 + "<span class='text-right'><a href='#' onclick='excluir(" + dados["ser_id"] + ", \"" + dados["pes_nome"] + "\");'><span class='glyphicon glyphicon-remove'></span>&nbsp Excluir</a></span>"
                                 + "<span class='text-right'><a href = 'editService.aspx?ser=" + dados["ser_id"] + "'><span class='glyphicon glyphicon-edit'></span>&nbsp Editar</a></span></div>"
                                 + "<div class='padding'>"
                                 + "<p class='origem'><b>Origem</b>: " + dados["ser_origem"] + "</p>"
                                 + "<p class='destino'><b>Destino</b>: " + dados["ser_destino"] + "</p><hr>"
                                 + "<p><b>Data De Saida</b>:<e class='saida'>" + String.Format("{0:dd/MM/yyyy}", dados["ser_datainicio"]) + "</e></p>"
                                 + "<p><b>Hora de Saida</b>:<e class='horasaida'>" + String.Format("{0:HH:mm}", dados["ser_datainicio"]) + "</e></p><hr>"
                                 + "<p><b>Data De Volta</b>:<e class='chegada'>" + String.Format("{0:dd/MM/yyyy}", dados["ser_datafim"]) + "</e></p>"
                                 + "<p><b>Hora de Volta</b>:<e class='horachegada'>" + String.Format("{0:HH:mm}", dados["ser_datafim"]) + "</e></p><hr>"
                                 + "<p><b>Mensagem</b>:" + dados["ser_descricao"]
                                 + "</p></div></div></div>";
            }

            if (esCounter > 0)
            {
                fbse.Text    = "Serviços expirados: " + esCounter;
                fbse.Visible = true;
            }
            else
            {
                fbse.Visible = false;
            }
        }
    }
Ejemplo n.º 7
0
    public static void UpdatePremium(mot_motorista mot)
    {
        //Correto
        IDbConnection objConexao; //Abrir a conexão
        IDbCommand    objCommand; // Criar e executar os comandos
        string        sql = "update mot_motorista set tip_id = ?tip_id where mot_id = ?mot_id";

        objConexao = Mapped.Connection();
        objCommand = Mapped.Command(sql, objConexao);

        objCommand.Parameters.Add(Mapped.Parameter("?mot_id", mot.Mot_id));
        objCommand.Parameters.Add(Mapped.Parameter("?tip_id", mot.Tip_id.Tip_id));

        objCommand.ExecuteNonQuery();
        objConexao.Close();
        objConexao.Dispose();
        objCommand.Dispose();
    }
Ejemplo n.º 8
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato();
        mot_motorista    mot           = new mot_motorista();
        tpc_tipo_contato tpc           = new tpc_tipo_contato();

        DataSet ds = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));


        mot.Mot_id   = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        mot.Mot_cnpj = txtCNPJ.Text;
        mot_motoristaDB.Update(mot);

        //tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue);
        //mxc.Tpc_id = tpc;

        //tpc_tipo_contatoDB.Update(tpc);

        mxc.Mxc_descricao = txtTelefone.Text;
        mxc_motorista_tipo_contatoDB.Update(mxc);

        pes_pessoa pes = new pes_pessoa();

        pes.Pes_id         = Convert.ToInt32(hdf.Value);
        pes.Pes_nome       = txtNome.Text;
        pes.Pes_sexo       = ddlSexo.SelectedValue;
        pes.Pes_cidade     = ddlCidade.SelectedValue;
        pes.Pes_estado     = ddlEstado.SelectedValue;
        pes.Pes_nascimento = Convert.ToDateTime(txtData.Text);

        switch (pes_pessoaDB.Update(pes))
        {
        case 0:
            //Response.Write("OK");
            Response.Write("<script>alert('Cadastrado com Sucesso');</script>");
            break;

        case -2:
            //Response.Write("ERRO");
            Response.Write("<script>alert('Ocorreu um Erro');</script>");
            break;
        }
    }
Ejemplo n.º 9
0
    public static int Insert(mot_motorista mot)
    {
        int retorno = 0;

        try
        {
            //Correto
            IDbConnection objConexao; //Abrir a conexão
            IDbCommand    objCommand; // Criar e executar os comandos
            string        sql = "insert into mot_motorista ";
            sql += "(mot_cnpj, mot_publicacoes, usu_id, tip_id)";
            sql += "values ";
            sql += "(?mot_cnpj, ?mot_publicacoes, ?usu_id, ?tip_id)";

            objConexao = Mapped.Connection();
            objCommand = Mapped.Command(sql, objConexao);



            objCommand.Parameters.Add(Mapped.Parameter("?mot_cnpj", mot.Mot_cnpj));
            objCommand.Parameters.Add(Mapped.Parameter("?mot_publicacoes", mot.Mot_publicacoes));

            // Chave estrangeira
            objCommand.Parameters.Add(Mapped.Parameter("?usu_id", mot.Usu_id.Usu_id));
            objCommand.Parameters.Add(Mapped.Parameter("?tip_id", mot.Tip_id.Tip_id));



            objCommand.ExecuteNonQuery();
            objConexao.Close();
            objConexao.Dispose();
            objCommand.Dispose();
        }
        catch (Exception)
        {
            //erro
            retorno = -2;
        }
        return(retorno);
    }
Ejemplo n.º 10
0
    public static DataSet Select(mot_motorista mot)
    {
        DataSet       ds = new DataSet();
        IDbConnection objConexao;
        IDbCommand    objCommand;

        IDataAdapter objDataAdapter;
        //string sql = "select emp_nome as NOME, emp_rua as RUA from emp_empresa order by emp_nome";
        //string sql = "select emp_nome, emp_rua from emp_empresa order by emp_nome";
        string sql = "select mot_nome, mot_cnpj, mot_sexo, mot_cidade, mot_estado, usu_email from mot_motorista inner join usu_usuario where mot_id = ?mot_id";

        objConexao = Mapped.Connection();
        objCommand = Mapped.Command(sql, objConexao);
        objCommand.Parameters.Add(Mapped.Parameter("?mot_id", mot.Mot_id));
        objDataAdapter = Mapped.Adapter(objCommand);
        objDataAdapter.Fill(ds);

        objConexao.Close();
        objConexao.Dispose();
        objCommand.Dispose();

        return(ds);
    }
Ejemplo n.º 11
0
    public void ExibirLimite()
    {
        hdf.Value = Session["value"].ToString();

        mot_motorista mot = new mot_motorista();

        DataSet codigo = new DataSet();

        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));

        mot.Mot_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        int a = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        DataSet ds = mot_motoristaDB.SelectPETC(a);

        foreach (DataRow dados in ds.Tables[0].Rows)
        {
            fbUnlimited.Visible = false;
            fbLimite.Text       = "Publicações: " + dados["mot_publicacoes"] + "/5";
            fbLimite.Visible    = true;
        }
    }
Ejemplo n.º 12
0
    protected void btnCadastrar_Click(object sender, EventArgs e)
    {
        hdf.Value = Session["value"].ToString();

        DataSet codigo = new DataSet();

        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));
        // Label1.Text = par;

        int c = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        sol_solicitacao sol = new sol_solicitacao();

        sol.Sol_id = Convert.ToInt32(Label1.Text);

        mot_motorista mot = new mot_motorista();

        mot.Mot_id = c;

        som_solicitacaomotorista som = new som_solicitacaomotorista();

        som.Sol_id       = sol;
        som.Mot_id       = mot;
        som.Som_proposta = Convert.ToDouble(txtProposta.Text);
        switch (som_solicitacaomotoristaDB.Insert(som))
        {
        case 0:
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true);
            txtProposta.Text = null;
            break;

        case -2:
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalE();", true);
            break;
        }
    }
    protected void btnCadastrar_Click(object sender, EventArgs e)
    {
        if (txtOrigem.Text == "" || txtDestino.Text == "" || txtDataInicio.Text == "" || txtLugares.Text == "")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalObrigatorio();", true);
        }
        else if (ddlTransporte.SelectedIndex == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalObrigatorioVeiculo();", true);
        }
        else
        {
            hdf.Value = Session["value"].ToString();
            mot_motorista mot1 = new mot_motorista();

            DataSet codigo1 = new DataSet();

            codigo1 = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));

            mot1.Mot_id = Convert.ToInt32(codigo1.Tables[0].Rows[0][0]);

            int     a1  = Convert.ToInt32(codigo1.Tables[0].Rows[0][0]);
            DataSet ds1 = mot_motoristaDB.SelectPETC(a1);
            foreach (DataRow dados1 in ds1.Tables[0].Rows)
            {
                if (Convert.ToInt32(dados1["mot_publicacoes"]) >= 5 && Convert.ToString(dados1["tip_descricao"]) == "Free")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalLimite();", true);
                }
                else
                {
                    if (Convert.ToDateTime(txtDataInicio.Text + " " + txtHoraPartida.Text) > Convert.ToDateTime(txtDataFim.Text + " " + txtHoraRetorno.Text))
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSET();", true);
                    }
                    else if (Convert.ToDateTime(txtDataFim.Text + " " + txtHoraRetorno.Text) < DateTime.Now)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSETN();", true);
                    }
                    else
                    {
                        DateTime data = DateTime.Now;

                        hdf.Value = Session["value"].ToString();

                        mot_motorista mot = new mot_motorista();

                        DataSet codigo = new DataSet();

                        codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));

                        mot.Mot_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

                        int a = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

                        DataSet ds  = mot_motoristaDB.SelectCon(a);
                        DataSet dsp = mot_motoristaDB.SelectPublicacoes(mot.Mot_id);

                        foreach (DataRow dados in dsp.Tables[0].Rows)
                        {
                            int publicacoes = Convert.ToInt32(dados["mot_publicacoes"]);
                            publicacoes++;
                            mot.Mot_publicacoes = publicacoes;
                            mot_motoristaDB.UpdatePublicacoes(mot);
                        }

                        int qtd = ds.Tables[0].Rows.Count;

                        ser_servicos   serv = new ser_servicos();
                        con_condutor   con  = new con_condutor();
                        tra_transporte tra  = new tra_transporte();
                        if (ddlTransporte.SelectedIndex != 0)
                        {
                            tra.Tra_id            = Convert.ToInt32(ddlTransporte.SelectedValue);
                            serv.Tra_id           = tra;
                            serv.Ser_datacadastro = data;
                            serv.Ser_origem       = txtOrigem.Text;
                            serv.Ser_destino      = txtDestino.Text;
                            serv.Ser_descricao    = txtDescricao.Text;
                            serv.Ser_datafim      = Convert.ToDateTime(txtDataFim.Text + " " + txtHoraRetorno.Text);
                            serv.Ser_datainicio   = Convert.ToDateTime(txtDataInicio.Text + " " + txtHoraPartida.Text);
                            serv.Ser_lugares      = Convert.ToInt32(txtLugares.Text);

                            serv.Mot_id = mot;
                            switch (ser_servicosDB.Insert(serv))
                            {
                            case 0:
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSS();", true);
                                //lblMsg.Text = "Cadastrado com sucesso";
                                break;

                            case -2:
                                //lblMsg.Text = "ERRO";
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSE();", true);
                                break;
                            }
                            string descricao = txtDescricao.Text;

                            DataSet id = new DataSet();

                            id = ser_servicosDB.SelectID(descricao);

                            serv.Ser_id = Convert.ToInt32(id.Tables[0].Rows[0][0]);

                            sco_servicoscondutor sco = new sco_servicoscondutor();
                            if (ddlCondutor.SelectedIndex != 0)
                            {
                                con.Con_id = Convert.ToInt32(ddlCondutor.SelectedValue);
                                sco.Con_id = con;
                                sco.Ser_id = serv;
                                sco_servicoscondutorDB.Insert(sco);
                            }



                            txtOrigem.Text      = "";
                            txtDestino.Text     = "";
                            txtDataFim.Text     = "";
                            txtDescricao.Text   = "";
                            txtDataInicio.Text  = "";
                            txtLugares.Text     = "";
                            txtHoraPartida.Text = "";
                            txtHoraRetorno.Text = "";
                        }
                        else
                        {
                            Label3.Visible = true;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 14
0
    protected void btnAdicionar_Click(object sender, EventArgs e)
    {
        hdf1.Value = Session["value"].ToString();

        DataSet codigo = new DataSet();

        codigo = con_condutorDB.SelectM(Convert.ToInt32(hdf1.Value));

        mot_motorista mot = new mot_motorista();

        mot.Mot_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

        con_condutor con = new con_condutor();

        con.Con_cpf  = txtCPF.Text;
        con.Con_nome = txtNome.Text;
        con.Mot_id   = mot;

        string name = txtNome.Text;

        con_condutorDB.Insert(con);

        DataSet id = new DataSet();

        id = con_condutorDB.SelectCon(name);

        con.Con_id = Convert.ToInt32(id.Tables[0].Rows[0][0]);

        tpc_tipo_contato          tpc = new tpc_tipo_contato();
        ctp_condutor_tipo_contato ctp = new ctp_condutor_tipo_contato();

        if (ddl.SelectedValue == 1.ToString())
        {
            ctp.Ctp_descricao = txtTelefone.Text;
        }
        else if (ddl.SelectedValue == 2.ToString())
        {
            ctp.Ctp_descricao = txtCelular.Text;
        }
        else if (ddl.SelectedValue == 3.ToString())
        {
            ctp.Ctp_descricao = txtWhatsapp.Text;
        }
        else if (ddl.SelectedValue == 4.ToString())
        {
            ctp.Ctp_descricao = txtEmail.Text;
        }

        tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue);


        ctp.Con_id = con;
        ctp.Tpc_id = tpc;


        switch (ctp_condutor_tipo_contatoDB.Insert(ctp))
        {
        case 0:

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSS();", true);
            txtNome.Text     = null;
            txtCPF.Text      = null;
            txtTelefone.Text = null;
            txtCelular.Text  = null;
            txtWhatsapp.Text = null;
            break;

        case -2:

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSE();", true);
            break;
        }
    }
Ejemplo n.º 15
0
    protected void btnCadastrar_Click(object sender, EventArgs e)
    {
        hdf.Value = Session["value"].ToString();
        tra_transporte tra = new tra_transporte();
        string         arq;
        string         placa;
        string         dir = Request.PhysicalApplicationPath + "pg\\uploads\\";

        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }

        foreach (HttpPostedFile flp in fup.PostedFiles)
        {
            double mp = 2000;

            if (fup.HasFile)
            {
                arq = Path.GetFileName(flp.FileName);
                string ext = Path.GetExtension(flp.FileName);
                ext = ext.ToLower();
                double ta = flp.ContentLength / 1024;

                if (ext == ".jpg" || ext == ".png" || ext == ".gif")
                {
                    if (ta <= mp)
                    {
                        arq = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ext;
                        if (!File.Exists(dir + arq))
                        {
                            flp.SaveAs(dir + arq);

                            System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(Server.MapPath("~/pg/uploads/" + arq), true);

                            System.Drawing.Image.GetThumbnailImageAbort miniatura = new System.Drawing.Image.GetThumbnailImageAbort(erro);

                            System.Drawing.Image imgRedimensionada;

                            int width, height;

                            if (imgOriginal.Width > 200)
                            {
                                width = 200; height = (int)(width * imgOriginal.Height) / imgOriginal.Width;
                            }
                            else
                            {
                                width = imgOriginal.Width; height = imgOriginal.Height;
                            }

                            imgRedimensionada = imgOriginal.GetThumbnailImage(width, height, miniatura, IntPtr.Zero);


                            imgRedimensionada.Dispose();

                            imgOriginal.Dispose();


                            tve_tipoveiculo tve = new tve_tipoveiculo();
                            tve.Tve_id = Convert.ToInt32(ddlVeiculo.SelectedValue);


                            tra.Tra_lugares = Convert.ToInt32(txtLugar.Text);
                            tra.Tra_modelo  = txtModelo.Text;
                            tra.Tra_ano     = Convert.ToInt32(txtAno.Text);
                            tra.Tra_placa   = txtPlaca.Text;
                            tra.Tve_id      = tve;
                            placa           = txtPlaca.Text;
                            tra_transporteDB.Insert(tra);

                            DataSet codigo = new DataSet();
                            codigo     = tra_transporteDB.SelectLugar(placa);
                            tra.Tra_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);

                            img_imagemveiculo img = new img_imagemveiculo();
                            img.Img_foto = arq;
                            img.Tra_id   = tra;
                            img_imagemveiculoDB.Insert(img);



                            if (cb1.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 1;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }
                            if (cb2.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 2;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }
                            if (cb3.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 3;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }
                            if (cb4.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 4;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }
                            if (cb5.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 5;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }
                            if (cb6.Checked)
                            {
                                rec_recursos rec = new rec_recursos();
                                rec.Rec_id = 6;

                                txr_transporte_recursos txr = new txr_transporte_recursos();
                                txr.Tra_id = tra;
                                txr.Rec_id = rec;

                                txr_transporte_recursosDB.Insert(txr);
                            }

                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true);
                        }
                        else
                        {
                            //Response.Write("<script>alert('Arquivo ja existe');</script>");
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalF();", true);
                        }
                    }
                    else
                    {
                        //Response.Write("<script>alert('Tamanho maximo excedido - 500KB');</script>");
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalMS();", true);
                    }
                }
                else
                {
                    //Response.Write("<script>alert('Extensão invalida');</script>");
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalEI();", true);
                }
            }
            else
            {
                //Response.Write("<script>alert('Selecione um arquivo');</script>");
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSl();", true);
            }
        }

        DataSet idMot = new DataSet();

        idMot = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));

        mot_motorista mot = new mot_motorista();

        mot.Mot_id = Convert.ToInt32(idMot.Tables[0].Rows[0][0]);

        txm_transporte_motorista txm = new txm_transporte_motorista();

        txm.Mot_id = mot;
        txm.Tra_id = tra;
        txm_transporte_motoristaDB.Insert(txm);
    }
Ejemplo n.º 16
0
    protected void btnCadastrar_Click(object sender, EventArgs e)
    {
        //DataSet d = usu_usuarioDB.SelectEmail();
        //int qtd = d.Tables[0].Rows.Count;
        //for (int i = 0; i<=qtd;i++)
        //{
        //    if (txtEmailM.Text == Convert.ToString(d.Tables[0].Rows[0][0]) || txtEmail.Text == Convert.ToString(d.Tables[0].Rows[0][0])) {
        //        Response.Write("ERRO");
        //    }
        //}

        if (Convert.ToInt32(ddlPM.SelectedItem.Value) == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalAt();", true);
            Label2.Visible = false;
        }
        else if (ddlPM.SelectedIndex == 1)
        {
            if (txtSenha.Text == txtSenha2.Text)
            {
                if (CheckBox1.Checked == false)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalCb();", true);
                }
                else if (Convert.ToInt32(ddlPM.SelectedItem.Value) == 0)
                {
                    Label2.Text    = "Por favor selecione uma opção para proseguir com o cadastro";
                    Label2.Visible = true;
                    Label1.Visible = false;
                }
                else
                {
                    pes_pessoa pessoa = new pes_pessoa();
                    pessoa.Pes_nome       = txtNome.Text;
                    pessoa.Pes_sexo       = ddlSexo.SelectedValue;
                    pessoa.Pes_cidade     = ddlCidade.SelectedValue;
                    pessoa.Pes_estado     = ddlEstado.SelectedValue;
                    pessoa.Pes_sexo       = ddlSexo.SelectedValue;
                    pessoa.Pes_nascimento = Convert.ToDateTime(txtData.Text);
                    string name = txtNome.Text;

                    pes_pessoaDB.Insert(pessoa);

                    DataSet codigo = new DataSet();

                    codigo = pes_pessoaDB.SelectByEmail(name);

                    pessoa.Pes_id = Convert.ToInt32(codigo.Tables[0].Rows[0][0]);



                    usu_usuario us = new usu_usuario();
                    us.Usu_email = txtEmail.Text;
                    us.Usu_senha = Funções.Hash(txtSenha.Text, "SHA512");
                    us.Usu_tipo  = ddlPM.SelectedValue;
                    us.Pes_id    = pessoa;

                    usu_usuarioDB.Insert(us);

                    pas_passageiro passageiro = new pas_passageiro();
                    passageiro.Pas_cpf = txtCpf.Text;

                    ////joga o email pra uma variavel
                    string email = txtEmail.Text;

                    ////cria um dataset, pois o SelectByEmail retorna um dataset
                    DataSet id = new DataSet();

                    id = usu_usuarioDB.SelectByEmail(email);

                    us.Usu_id = Convert.ToInt32(id.Tables[0].Rows[0][0]);

                    passageiro.Usu_id = us;


                    switch (pas_passageiroDB.Insert(passageiro))
                    {
                    case 0:

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true);
                        txtEmail.Text     = "";
                        txtNome.Text      = "";
                        txtCpf.Text       = "";
                        txtData.Text      = "";
                        Label1.Visible    = false;
                        CheckBox1.Checked = false;
                        break;

                    case -2:

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalE();", true);
                        break;
                    }
                }
            }


            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalP();", true);
            }
        }
        else
        {
            if (txtSenhaCM.Text == txtSenhaM.Text)
            {
                if (CheckBox1.Checked == false)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalCb();", true);
                }
                else
                {
                    pes_pessoa pes = new pes_pessoa();
                    pes.Pes_nome       = txtNomeM.Text;
                    pes.Pes_sexo       = ddlSexoM.SelectedValue;
                    pes.Pes_cidade     = ddlCidadeM.SelectedValue;
                    pes.Pes_estado     = ddlEstadoM.SelectedValue;
                    pes.Pes_nascimento = Convert.ToDateTime(txtDataM.Text);

                    pes_pessoaDB.Insert(pes);

                    string nome = txtNomeM.Text;

                    DataSet cod = new DataSet();

                    cod = pes_pessoaDB.SelectByEmail(nome);

                    pes.Pes_id = Convert.ToInt32(cod.Tables[0].Rows[0][0]);


                    usu_usuario us = new usu_usuario();
                    us.Usu_email = txtEmailM.Text;
                    us.Usu_senha = Funções.Hash(txtSenhaM.Text, "SHA512");
                    us.Usu_tipo  = ddlPM.SelectedValue;
                    us.Pes_id    = pes;

                    usu_usuarioDB.Insert(us);

                    mot_motorista mot = new mot_motorista();
                    mot.Mot_cnpj        = txtCnpj.Text;
                    mot.Mot_publicacoes = 0;
                    ////joga o email pra uma variavel
                    string emai = txtEmailM.Text;

                    ////cria um dataset, pois o SelectByEmail retorna um dataset
                    DataSet ds = new DataSet();


                    ds = usu_usuarioDB.SelectByEmail(emai);


                    us.Usu_id = Convert.ToInt32(ds.Tables[0].Rows[0][0]);

                    mot.Usu_id = us;

                    DataSet dss          = new DataSet();
                    string  TCTemporario = "Free";

                    tip_tipoconta tip = new tip_tipoconta();

                    dss        = tip_tipocontaDB.SelectID(TCTemporario);
                    tip.Tip_id = Convert.ToInt32(dss.Tables[0].Rows[0][0]);
                    mot.Tip_id = tip;

                    switch (mot_motoristaDB.Insert(mot))
                    {
                    case 0:

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true);
                        txtEmailM.Text    = "";
                        txtNomeM.Text     = "";
                        txtCnpj.Text      = "";
                        txtDataM.Text     = "";
                        Label1.Visible    = false;
                        CheckBox1.Checked = false;
                        break;

                    case -2:

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalE();", true);
                        break;
                    }
                }

                Label1.Visible = false;
            }


            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalP();", true);
            }
        }
    }
    protected void btnEnviar_Click(object sender, EventArgs e)
    {
        hdf.Value = Session["value"].ToString();

        DataSet ds = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value));

        mot_motorista mot = new mot_motorista();

        mot.Mot_id = Convert.ToInt32(ds.Tables[0].Rows[0]["mot_id"]);

        tpc_tipo_contato tpc = new tpc_tipo_contato();

        tpc.Tpc_id = Convert.ToInt32(ddl.SelectedValue);


        mxc_motorista_tipo_contato mxc = new mxc_motorista_tipo_contato();

        if (ddl.SelectedIndex == 1)
        {
            mxc.Mxc_descricao = txtTelefone.Text;
        }
        else if (ddl.SelectedIndex == 2)
        {
            mxc.Mxc_descricao = txtCelular.Text;
        }
        else if (ddl.SelectedIndex == 3)
        {
            mxc.Mxc_descricao = txtWhatsapp.Text;
        }
        else if (ddl.SelectedIndex == 4)
        {
            mxc.Mxc_descricao = txtEmailAlt.Text;
        }

        mxc.Mot_id = mot;
        mxc.Tpc_id = tpc;
        mxc_motorista_tipo_contatoDB.Insert(mxc);

        string dir = Request.PhysicalApplicationPath + "pg\\uploads\\";

        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }

        foreach (HttpPostedFile flp in fup.PostedFiles)
        {
            double mp = 2000;

            if (fup.HasFile)
            {
                string arq = Path.GetFileName(flp.FileName);
                string ext = Path.GetExtension(flp.FileName);
                ext = ext.ToLower();
                double ta = flp.ContentLength / 1024;

                if (ext == ".jpg" || ext == ".png" || ext == ".gif")
                {
                    if (ta <= mp)
                    {
                        arq = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ext;
                        if (!File.Exists(dir + arq))
                        {
                            flp.SaveAs(dir + arq);

                            System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(Server.MapPath("~/pg/uploads/" + arq), true);

                            System.Drawing.Image.GetThumbnailImageAbort miniatura = new System.Drawing.Image.GetThumbnailImageAbort(erro);

                            System.Drawing.Image imgRedimensionada;

                            int width, height;

                            if (imgOriginal.Width > 200)
                            {
                                width = 200; height = (int)(width * imgOriginal.Height) / imgOriginal.Width;
                            }
                            else
                            {
                                width = imgOriginal.Width; height = imgOriginal.Height;
                            }

                            imgRedimensionada = imgOriginal.GetThumbnailImage(width, height, miniatura, IntPtr.Zero);


                            imgRedimensionada.Dispose();

                            imgOriginal.Dispose();

                            //Atualizar tipo de conta
                            if (rbMensal.Checked)
                            {
                                string        kindOfPremium = "Premium M";
                                DataSet       dsp           = new DataSet();
                                tip_tipoconta tip           = new tip_tipoconta();

                                dsp        = tip_tipocontaDB.SelectID(kindOfPremium);
                                tip.Tip_id = Convert.ToInt32(dsp.Tables[0].Rows[0][0]);
                                mot.Tip_id = tip;
                                mot_motoristaDB.UpdatePremium(mot);
                            }
                            else if (rbAnual.Checked)
                            {
                                string        kindOfPremium = "Premium A";
                                DataSet       dsp           = new DataSet();
                                tip_tipoconta tip           = new tip_tipoconta();

                                dsp        = tip_tipocontaDB.SelectID(kindOfPremium);
                                tip.Tip_id = Convert.ToInt32(dsp.Tables[0].Rows[0][0]);
                                mot.Tip_id = tip;
                                mot_motoristaDB.UpdatePremium(mot);
                            }

                            //Response.Write("<script>alert('Cadastrado com sucesso');</script>");
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true);
                            tdo_tipodocumento tdo = new tdo_tipodocumento();
                            tdo.Tdo_image = arq;
                            tdo_tipodocumentoDB.Insert(tdo);

                            string  img = arq;
                            DataSet id  = new DataSet();
                            id         = tdo_tipodocumentoDB.SelectImage(img);
                            tdo.Tdo_id = Convert.ToInt32(id.Tables[0].Rows[0][0]);

                            doc_documento doc = new doc_documento();
                            doc.Mot_id = mot;
                            doc.Tdo_id = tdo;
                            doc_documentoDB.Insert(doc);

                            pBefore.Visible = false;
                            pAfter.Visible  = true;
                        }
                        else
                        {
                            //Response.Write("<script>alert('Arquivo ja existe');</script>");
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalF();", true);
                        }
                    }
                    else
                    {
                        //Response.Write("<script>alert('Tamanho maximo excedido - 500KB');</script>");
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalMS();", true);
                    }
                }
                else
                {
                    //Response.Write("<script>alert('Extensão invalida');</script>");
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalEI();", true);
                }
            }
            else
            {
                //Response.Write("<script>alert('Selecione um arquivo');</script>");
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalSl();", true);
            }
        }
    }