コード例 #1
0
    public static int Update(tip_tipoconta tip)
    {
        int retorno = 0;

        try
        {
            //Correto
            IDbConnection objConexao; //Abrir a conexão
            IDbCommand    objCommand; // Criar e executar os comandos
            string        sql = "update tip_tipoconta set tip_descricao = ?tip_descricao";

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

            objCommand.Parameters.Add(Mapped.Parameter("tip_descricao", tip.Tip_descricao));

            objCommand.ExecuteNonQuery();
            objConexao.Close();
            objConexao.Dispose();
            objCommand.Dispose();
        }
        catch (Exception)
        {
            //erro
            retorno = -2;
        }
        return(retorno);
    }
コード例 #2
0
ファイル: index.aspx.cs プロジェクト: nGuilhermeBarbosa/E-Van
    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);
            }
        }
    }
コード例 #3
0
    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);
            }
        }
    }