コード例 #1
0
    protected void carregaDados()
    {
        Empresas id = (Empresas)Session["emp_empresa"];

        Telefones tel   = new Telefones();
        DataSet   dsTel = TelefonesDB.SelectTel(id.Emp_id);

        tel.Tel_ddd = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_ddd"]);
        tel.Tel_num = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_num"]);

        tel.Emp_id        = new Empresas();
        tel.Emp_id.Emp_id = Convert.ToInt32(dsTel.Tables[0].Rows[0]["emp_id"]);


        DataSet ds = EmpresasDB.SelectID(id.Emp_id);

        tel.Emp_id.Emp_nome_fantasia   = Convert.ToString(ds.Tables[0].Rows[0]["emp_nome_fantasia"]);
        tel.Emp_id.Emp_senha           = Convert.ToString(ds.Tables[0].Rows[0]["emp_senha"]);
        tel.Emp_id.Emp_email           = Convert.ToString(ds.Tables[0].Rows[0]["emp_email"]);
        tel.Emp_id.Emp_razao_social    = Convert.ToString(ds.Tables[0].Rows[0]["emp_razao_social"]);
        tel.Emp_id.Emp_cnpj            = Convert.ToString(ds.Tables[0].Rows[0]["emp_cnpj"]);
        tel.Emp_id.Emp_foto_url        = Convert.ToString(ds.Tables[0].Rows[0]["emp_foto_url"]);
        tel.Emp_id.Emp_numero_endereco = Convert.ToString(ds.Tables[0].Rows[0]["emp_numero_endereco"]);


        textDDD.Text          = tel.Tel_ddd.ToString();
        textTelefone.Text     = tel.Tel_num.ToString();
        textNomeFantasia.Text = tel.Emp_id.Emp_nome_fantasia.ToString();
        textEmail2.Text       = tel.Emp_id.Emp_email.ToString();
        textSocial.Text       = tel.Emp_id.Emp_razao_social.ToString();
        textCNPJ.Text         = tel.Emp_id.Emp_cnpj.ToString();
    }
コード例 #2
0
    protected void btnAtualizar_Click(object sender, EventArgs e)
    {
        Empresas id = (Empresas)Session["emp_empresa"];

        Telefones tel   = new Telefones();
        DataSet   dsTel = TelefonesDB.SelectTel(id.Emp_id);

        tel.Tel_ddd = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_ddd"]);
        tel.Tel_num = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_num"]);

        tel.Emp_id        = new Empresas();
        tel.Emp_id.Emp_id = Convert.ToInt32(dsTel.Tables[0].Rows[0]["emp_id"]);


        DataSet ds = EmpresasDB.SelectID(id.Emp_id);

        tel.Emp_id.Emp_nome_fantasia   = Convert.ToString(ds.Tables[0].Rows[0]["emp_nome_fantasia"]);
        tel.Emp_id.Emp_senha           = Convert.ToString(ds.Tables[0].Rows[0]["emp_senha"]);
        tel.Emp_id.Emp_email           = Convert.ToString(ds.Tables[0].Rows[0]["emp_email"]);
        tel.Emp_id.Emp_razao_social    = Convert.ToString(ds.Tables[0].Rows[0]["emp_razao_social"]);
        tel.Emp_id.Emp_cnpj            = Convert.ToString(ds.Tables[0].Rows[0]["emp_cnpj"]);
        tel.Emp_id.Emp_foto_url        = Convert.ToString(ds.Tables[0].Rows[0]["emp_foto_url"]);
        tel.Emp_id.Emp_numero_endereco = Convert.ToString(ds.Tables[0].Rows[0]["emp_numero_endereco"]);


        tel.Tel_ddd = textDDD.Text;
        tel.Tel_num = textTelefone.Text;
        tel.Emp_id.Emp_nome_fantasia = textNomeFantasia.Text;
        tel.Emp_id.Emp_email         = textEmail2.Text;
        tel.Emp_id.Emp_razao_social  = textSocial.Text;
        tel.Emp_id.Emp_cnpj          = textCNPJ.Text;


        switch (EmpresasDB.Update(tel.Emp_id) & TelefonesDB.Update(tel))
        {
        case 0:
            ltl.Text = "<p class='text-success'>atualizado com sucesso </p>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);

            break;

        case -2:
            ltl.Text = "<p class='text-success'>Erro no cadastro</p>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);
            break;
        }
    }
コード例 #3
0
    protected void btnConta_Click(object sender, EventArgs e)
    {
        if (EscolhePessoa.SelectedValue == "1")
        {
            Clientes cli = new Clientes();
            cli.Cli_nome            = textNome.Text;
            cli.Cli_email           = textEmail.Text;
            cli.Cli_senha           = ClientesDB.PWD(textSenha.Text);
            cli.Cli_sexo            = Convert.ToChar(rblSexo.SelectedValue);
            cli.Cli_data_nascimento = Convert.ToDateTime(textCalendario.Text);
            cli.Cli_celular         = textCelular.Text;
            cli.Cli_id = ClientesDB.Insert(cli);

            Cidades cid = new Cidades();

            Bairros bai = new Bairros();
            bai.Bai_nome = textBairro.Text;
            bai.Bai_rua  = textRua.Text;
            //FK
            cid.Cid_id = Convert.ToInt32(rblCidade.SelectedValue);
            bai.Cid_id = cid;
            bai.Bai_id = BairrosDB.Insert(bai);

            Enderecos end = new Enderecos();
            end.End_cep  = textCep.Text;
            end.End_tipo = textComplemento.Text;
            //FK
            end.Bai_id = bai;
            end.End_id = EnderecosDB.Insert(end);

            ClienteEndereco cle = new ClienteEndereco();
            cle.Cle_num       = textNumero.Text;
            cle.Cle_principal = true;
            //FK
            cle.Cli_id = cli;
            cle.End_id = end;


            switch (ClienteEnderecoDB.Insert(cle))
            {
            case 0:
                Session["cli_cliente"] = cli;
                Response.Redirect("../PaginaCliente/MeusDados.aspx");
                break;

            case -2:
                ltl.Text = "<p class='text-success'>Erro no cadastro</p>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);
                break;
            }
        }
        else
        {
            Cidades cid = new Cidades();

            Bairros bai = new Bairros();
            bai.Bai_nome = textBairro.Text;
            bai.Bai_rua  = textRua.Text;
            //FK
            cid.Cid_id = Convert.ToInt32(rblCidade.SelectedValue);
            bai.Cid_id = cid;
            bai.Bai_id = BairrosDB.Insert(bai);

            Enderecos end = new Enderecos();
            end.End_cep  = textCep.Text;
            end.End_tipo = textComplemento.Text;
            //FK
            end.Bai_id = bai;
            end.End_id = EnderecosDB.Insert(end);

            Empresas emp = new Empresas();
            emp.Emp_razao_social    = textSocial.Text;
            emp.Emp_email           = textEmail2.Text;
            emp.Emp_nome_fantasia   = textNomeFantasia.Text;
            emp.Emp_cnpj            = textCNPJ.Text;
            emp.Emp_senha           = EmpresasDB.PWD(textSenha2.Text);
            emp.Emp_numero_endereco = textNumero.Text;
            //FK
            emp.End_id = end;
            emp.Emp_id = EmpresasDB.Insert(emp);

            Telefones tel = new Telefones();
            tel.Tel_ddd = Convert.ToString(textDDD.Text);
            tel.Tel_num = Convert.ToString(textTelefone.Text);
            //FK
            tel.Emp_id = emp;

            switch (TelefonesDB.Insert(tel))
            {
            case -2:
                ltl.Text = "<p class='text-success'>Erro no cadastro</p>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#modalUpdate').modal('show');</script>", false);
                break;

            default:
                Session["emp_empresa"] = emp;
                Response.Redirect("../PaginaEmpresa/EmpDados.aspx");
                break;
            }
        }
    }