protected void btnSalvar_Click(object sender, EventArgs e) { Loja loja = new Loja(); loja.CnpjLOJ = txtCnpj.Text; loja.IdLOJ = txtID.Text; loja.EnderecoLOJ = txtEndereco.Text; LojaBD bd = new LojaBD(); if (bd.Insert(loja)) { lblMensagem.Text = "Loja cadastrada com sucesso"; txtCnpj.Text = ""; txtID.Text = ""; txtEndereco.Text = ""; txtID.Focus(); } else { lblMensagem.Text = "Ops, algo deu errado, tente novamente."; } }
private void Carrega() { LojaBD bd = new LojaBD(); DataSet ds = bd.SelectAll(); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); }
private void Carrega() { //Carrega Cliente ClienteBD clientebd = new ClienteBD(); DataSet clienteds = clientebd.SelectAll(); //vincula usuario ao dropdownlist dpdCliente.DataSource = clienteds.Tables[0].DefaultView; dpdCliente.DataTextField = "cli_cpf"; dpdCliente.DataValueField = "cli_codigo"; dpdCliente.DataBind(); dpdCliente.Items.Insert(0, new ListItem("Selecione", "")); //Carrega Taxa TaxaBD taxabd = new TaxaBD(); DataSet taxads = taxabd.SelectAll(); //Vincula taxas ao checkboxlist cblTaxa.DataSource = taxads.Tables[0].DefaultView; cblTaxa.DataTextField = "tax_taxaJuros"; cblTaxa.DataValueField = "tax_codigo"; cblTaxa.DataBind(); //Carrega Usuario UsuarioBD usuariobd = new UsuarioBD(); DataSet usuariods = usuariobd.SelectAll(); //vincula usuario ao dropdownlist dpdUsuario.DataSource = usuariods.Tables[0].DefaultView; dpdUsuario.DataTextField = "usu_nome"; dpdUsuario.DataValueField = "usu_codigo"; dpdUsuario.DataBind(); dpdUsuario.Items.Insert(0, new ListItem("Selecione", "")); //Carrega Loja LojaBD lojabd = new LojaBD(); DataSet lojads = lojabd.SelectAll(); //vincula loja ao dropdownlist dpdLoja.DataSource = lojads.Tables[0].DefaultView; dpdLoja.DataTextField = "loj_id"; dpdLoja.DataValueField = "loj_codigo"; dpdLoja.DataBind(); dpdLoja.Items.Insert(0, new ListItem("Selecione", "")); //Carrega Venda EmprestimoBD emprestimobd = new EmprestimoBD(); DataSet emprestimods = emprestimobd.SelectAll(); //vincula emprestimo ao dropdownlist dpdEmprestimo.DataSource = emprestimods.Tables[0].DefaultView; dpdEmprestimo.DataTextField = "emp_id"; dpdEmprestimo.DataValueField = "emp_codigo"; dpdEmprestimo.DataBind(); dpdEmprestimo.Items.Insert(0, new ListItem("Selecione", "")); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LojaBD bd = new LojaBD(); Loja loja = bd.Select(Convert.ToInt32(Session["ID"])); txtCnpj.Text = loja.CnpjLOJ; txtID.Text = loja.IdLOJ; txtEndereco.Text = loja.EnderecoLOJ; } }
protected void btnSalvar_Click(object sender, EventArgs e) { LojaBD bd = new LojaBD(); Loja loja = bd.Select(Convert.ToInt32(Session["ID"])); loja.CnpjLOJ = txtCnpj.Text; loja.IdLOJ = txtID.Text; loja.EnderecoLOJ = txtEndereco.Text; if (bd.Update(loja)) { lblMensagem.Text = "Loja alterada com sucesso"; txtID.Focus(); } else { lblMensagem.Text = "Erro ao salvar."; } }
private void Carrega() { //Carrega Loja LojaBD lojabd = new LojaBD(); DataSet lojads = lojabd.SelectAll(); //vincula produtos ao dropdownlist dpdLoja.DataSource = lojads.Tables[0].DefaultView; dpdLoja.DataTextField = "loj_id"; dpdLoja.DataValueField = "loj_codigo"; dpdLoja.DataBind(); dpdLoja.Items.Insert(0, "Selecione"); //Carrega Usuario UsuarioBD usuariobd = new UsuarioBD(); DataSet usuariods = usuariobd.SelectAll(); //Vincula fornecedores ao checkboxlist cblLogin.DataSource = usuariods.Tables[0].DefaultView; cblLogin.DataTextField = "usu_login"; cblLogin.DataValueField = "usu_codigo"; cblLogin.DataBind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int codigo = 0; switch (e.CommandName) { case "Alterar": codigo = Convert.ToInt32(e.CommandArgument); Session["ID"] = codigo; Response.Redirect("../Alterar/AlterarLoja.aspx"); break; case "Deletar": codigo = Convert.ToInt32(e.CommandArgument); LojaBD bd = new LojaBD(); bd.Delete(codigo); Carrega(); break; default: break; } }