protected void btnFiltro_Click(object sender, EventArgs e) { string sOpcao = DDLCliente.SelectedValue; switch (sOpcao) { case "1": if (!string.IsNullOrEmpty(txtPesquisa.Text)) { try { int Id = int.Parse(txtPesquisa.Text); GridView1.DataSource = CliDal.Detalhes(Id); GridView1.DataBind(); } catch (Exception ex) { string strTitulo = "Ocorreu erro ao tentar filtrar os dados. Certifique-se que você tenha informado numeral caso a busca seja por ID. Detalhes:"; ClientScript.RegisterStartupScript(GetType(), "alert", "ShowModal('" + strTitulo + "','" + ex.Message + "')", true); } } else { ClientScript.RegisterStartupScript(GetType(), "alert", "ShowModal('Campo em branco','Por favor, preencha um valor no Textbox para pesquisa.')", true); } break; case "2": if (!string.IsNullOrEmpty(txtPesquisa.Text)) { string strNome = txtPesquisa.Text; GridView1.DataSource = CliDal.Detalhes(strNome); GridView1.DataBind(); } else { ClientScript.RegisterStartupScript(GetType(), "alert", "ShowModal('Campo em branco','Por favor, preencha um valor no Textbox para pesquisa.')", true); } break; } }
protected void GVClientesOS_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Selecionar")) { int linhaGrid = Convert.ToInt32(e.CommandArgument); int idCliente = Convert.ToInt32(GVClientesOS.DataKeys[linhaGrid].Value.ToString()); DtClientes = CliOSDal.Detalhes(idCliente); txtIDCli.Text = idCliente.ToString(); txtNomeCli.Text = DtClientes.Rows[0]["Nome"].ToString(); txtDDDCli.Text = DtClientes.Rows[0]["DDD"].ToString(); txtTelCli.Text = DtClientes.Rows[0]["TelPrincipal"].ToString(); txtCelCli.Text = DtClientes.Rows[0]["CelPrincipal"].ToString(); txtEmailCli.Text = DtClientes.Rows[0]["EmailPrincipal"].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int Identificador = Convert.ToInt32(Session["IdentificadoId"]); DtClientes = CliDal.Detalhes(Identificador); tipo = Convert.ToInt32(DtClientes.Rows[0]["IdTipo"]); if (tipo == 0) { txtNomeFantasiaFormAlteracao.ReadOnly = true; txtCNPJFormAlteracao.ReadOnly = true; txtInscEstadualFormAlteracao.ReadOnly = true; if (DtClientes.Rows[0]["CPF"].ToString() == " ") { txtCPFFormAlteracao.Text = string.Empty; } else { txtCPFFormAlteracao.Text = string.Format(@"{0:000\.000\.000\-00}", long.Parse(DtClientes.Rows[0]["CPF"].ToString())); } if (DtClientes.Rows[0]["CEP"].ToString() == " ") { txtCEPFormAlteracao.Text = string.Empty; } else { txtCEPFormAlteracao.Text = string.Format(@"{0:00\.000\-000}", long.Parse(DtClientes.Rows[0]["CEP"].ToString())); } txtDataNascimentoFormAlteracao.Text = DtClientes.Rows[0]["DataNascimento"].ToString().Substring(0, 10); txtClienteDesdeFormAlteracao.Text = DtClientes.Rows[0]["ClienteDesde"].ToString().Substring(0, 10); txtIdClienteFormAlteracao.Text = DtClientes.Rows[0]["IdCliente"].ToString(); txtNomeFormAlteracao.Text = DtClientes.Rows[0]["Nome"].ToString(); txtIdentidadeFormAlteracao.Text = DtClientes.Rows[0]["Identidade"].ToString(); txtEnderecoFormAlteracao.Text = DtClientes.Rows[0]["Endereco"].ToString(); txtBairroFormAlteracao.Text = DtClientes.Rows[0]["Bairro"].ToString(); txtCidadeFormAlteracao.Text = DtClientes.Rows[0]["Cidade"].ToString(); txtEstadoFormAlteracao.Text = DtClientes.Rows[0]["Estado"].ToString(); txtDDDFormAlteracao.Text = DtClientes.Rows[0]["DDD"].ToString(); txtTelefoneFormAlteracao.Text = DtClientes.Rows[0]["TelPrincipal"].ToString(); txtTel2FormAlteracao.Text = DtClientes.Rows[0]["Tel2"].ToString(); txtCelularFormAlteracao.Text = DtClientes.Rows[0]["CelPrincipal"].ToString(); txtCel2FormAlteracao.Text = DtClientes.Rows[0]["Cel2"].ToString(); txtEmailFormAlteracao.Text = DtClientes.Rows[0]["EmailPrincipal"].ToString(); txtEmail2FormAlteracao.Text = DtClientes.Rows[0]["Email2"].ToString(); txtObservacoesFormAlteracao.Text = DtClientes.Rows[0]["Observacoes"].ToString(); } if (tipo == 1) { txtCPFFormAlteracao.ReadOnly = true; txtIdentidadeFormAlteracao.ReadOnly = true; if (DtClientes.Rows[0]["CNPJ"].ToString() == " ") { txtCNPJFormAlteracao.Text = string.Empty; } else { txtCNPJFormAlteracao.Text = string.Format(@"{0:00\.000\.000\/0000\-00}", long.Parse(DtClientes.Rows[0]["CNPJ"].ToString())); } if (DtClientes.Rows[0]["CEP"].ToString() == " ") { txtCEPFormAlteracao.Text = string.Empty; } else { txtCEPFormAlteracao.Text = string.Format(@"{0:00\.000\-000}", long.Parse(DtClientes.Rows[0]["CEP"].ToString())); } txtDataNascimentoFormAlteracao.Text = DtClientes.Rows[0]["DataNascimento"].ToString().Substring(0, 10); txtClienteDesdeFormAlteracao.Text = DtClientes.Rows[0]["ClienteDesde"].ToString().Substring(0, 10); txtIdClienteFormAlteracao.Text = DtClientes.Rows[0]["IdCliente"].ToString(); txtNomeFormAlteracao.Text = DtClientes.Rows[0]["Nome"].ToString(); txtNomeFantasiaFormAlteracao.Text = DtClientes.Rows[0]["NomeFantasia"].ToString(); txtInscEstadualFormAlteracao.Text = DtClientes.Rows[0]["InscEstadual"].ToString(); txtEnderecoFormAlteracao.Text = DtClientes.Rows[0]["Endereco"].ToString(); txtBairroFormAlteracao.Text = DtClientes.Rows[0]["Bairro"].ToString(); txtCidadeFormAlteracao.Text = DtClientes.Rows[0]["Cidade"].ToString(); txtEstadoFormAlteracao.Text = DtClientes.Rows[0]["Estado"].ToString(); txtDDDFormAlteracao.Text = DtClientes.Rows[0]["DDD"].ToString(); txtTelefoneFormAlteracao.Text = DtClientes.Rows[0]["TelPrincipal"].ToString(); txtTel2FormAlteracao.Text = DtClientes.Rows[0]["Tel2"].ToString(); txtCelularFormAlteracao.Text = DtClientes.Rows[0]["CelPrincipal"].ToString(); txtCel2FormAlteracao.Text = DtClientes.Rows[0]["Cel2"].ToString(); txtEmailFormAlteracao.Text = DtClientes.Rows[0]["EmailPrincipal"].ToString(); txtEmail2FormAlteracao.Text = DtClientes.Rows[0]["Email2"].ToString(); txtObservacoesFormAlteracao.Text = DtClientes.Rows[0]["Observacoes"].ToString(); } } }