protected void ddlRota_SelectedIndexChanged(object sender, EventArgs e) { ClientesRotasMod _ClienteRotaMod = new ClientesRotasMod(); ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); _ClienteRotaMod.iCodRota = Convert.ToInt32(ddlRota.SelectedValue); if (_ClienteRotaMod.iCodRota != 0) { try { foreach (ClientesRotasMod lista in _ClienteRotaNeg.listaClientesRotas(_ClienteRotaMod)) { lblDescricaoValor.Text = lista.sRota.Trim(); lblVendedorValor.Text = lista.sVendedor.Trim(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } CarregaGrid(_ClienteRotaMod); } }
protected void gdvClientesRotas_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); ClientesRotasMod _ClienteRotaMod = new ClientesRotasMod(); _ClienteRotaNeg.excluir(Convert.ToInt32(gdvClientesRotas.DataKeys[e.RowIndex].Value)); List <ClientesRotasMod> lista = new List <ClientesRotasMod>(); _ClienteRotaMod.iCodRota = Convert.ToInt32(lblCodigoRotaValor.Text); lista = _ClienteRotaNeg.listaClientesRotas(_ClienteRotaMod); for (int i = 1; i <= lista.Count; i++) { if (!(lista[i - 1].iSequencialRota == i)) { ClientesRotasMod cr = new ClientesRotasMod(); cr = lista[i - 1]; cr.iSequencialRota = lista[i - 1].iSequencialRota - 1; _ClienteRotaNeg.update(cr); } } CarregaGridClientesRotas(); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
protected void CarregaGrid(ClientesRotasMod _ClienteRotaMod) { ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); List <ClientesRotasMod> listaGrid = new List <ClientesRotasMod>(); listaGrid = _ClienteRotaNeg.listaClientesRotas(_ClienteRotaMod); Session.Add("ListaGrid", listaGrid); gdvRotas.DataSource = listaGrid; gdvRotas.DataBind(); }
protected void CarregaGridClientesRotas() { ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); ClientesRotasMod _ClienteRotaMod = new ClientesRotasMod(); List <ClientesRotasMod> listaGrid = new List <ClientesRotasMod>(); _ClienteRotaMod.iCodRota = Convert.ToInt32(lblCodigoRotaValor.Text); listaGrid = _ClienteRotaNeg.listaClientesRotas(_ClienteRotaMod); Session.Add("ListaGrid", listaGrid); gdvClientesRotas.DataSource = listaGrid; gdvClientesRotas.DataBind(); }
protected void btnInserirCliente_Click(object sender, EventArgs e) { ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); ClientesRotasMod _ClienteRotaMod = new ClientesRotasMod(); if (!(lblCodClienteRota.Text == string.Empty)) { _ClienteRotaMod.iCodigoClientesRotas = Convert.ToInt32(lblCodClienteRota.Text); } _ClienteRotaMod.iCodRota = Convert.ToInt32(lblCodigoRotaValor.Text); _ClienteRotaMod.iCodCliente = Convert.ToInt32(ddlClientes.SelectedValue); _ClienteRotaMod.iSequencialRota = gdvClientesRotas.Rows.Count + 1; _ClienteRotaNeg.salvar(_ClienteRotaMod); limpar(); CarregaGridClientesRotas(); }
protected void gdvClientesRotas_RowCommand(object sender, GridViewCommandEventArgs e) { ClientesRotasNeg _ClienteRotaNeg = new ClientesRotasNeg(); if (e.CommandName == "Up" || e.CommandName == "Down") { int iChave = Convert.ToInt32(e.CommandArgument); int iCodigo = Convert.ToInt32(gdvClientesRotas.DataKeys[iChave].Value); GridViewRow linha = gdvClientesRotas.Rows[Convert.ToInt32(e.CommandArgument)]; int iSequencia = Convert.ToInt32(linha.Cells[0].Text); if (e.CommandName == "Up") { if (iChave != 0) { int iChaveAnterior = Convert.ToInt32(e.CommandArgument) - 1; int iCodigoAnterior = Convert.ToInt32(gdvClientesRotas.DataKeys[iChaveAnterior].Value); GridViewRow linhaAnterior = gdvClientesRotas.Rows[Convert.ToInt32(e.CommandArgument) - 1]; int iSequenciaAnterior = Convert.ToInt32(linhaAnterior.Cells[0].Text); _ClienteRotaNeg.up(iCodigo, iCodigoAnterior, iSequencia, iSequenciaAnterior); } } if (e.CommandName == "Down") { if (iChave < gdvClientesRotas.Rows.Count - 1) { int iChavePosterior = Convert.ToInt32(e.CommandArgument) + 1; int iCodigoPosterior = Convert.ToInt32(gdvClientesRotas.DataKeys[iChavePosterior].Value); GridViewRow linhaPosterior = gdvClientesRotas.Rows[Convert.ToInt32(e.CommandArgument) + 1]; int iSequenciaPosteior = Convert.ToInt32(linhaPosterior.Cells[0].Text); _ClienteRotaNeg.up(iCodigo, iCodigoPosterior, iSequencia, iSequenciaPosteior); } } } CarregaGridClientesRotas(); }