private void CarregarGridFerramentas() { FerramentaController frc = new FerramentaController(); List <Ferramenta> lista = frc.Listar(); gvFerramentas.DataSource = lista.OrderBy(c => c.Matricula); gvFerramentas.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { CarregarGridFerramentas(); if (!IsPostBack) { FerramentaController lc = new FerramentaController(); } }
protected void btnSalvar_Click(object sender, EventArgs e) { Ferramenta f = new Ferramenta(); f.Matricula = txtMatricula.Text; f.Diametro = txtDiametro.Text; f.LoteId = int.Parse(ddlLote.SelectedValue); FerramentaController fer = new FerramentaController(); fer.Adicionar(f); txtMatricula.Text = ""; txtDiametro.Text = ""; }
protected void btnExcluir_Click(object sender, EventArgs e) { FerramentaController fc = new FerramentaController(); Ferramenta fer = fc.BuscarPorMatricula(int.Parse(txtRMatricula.Text)); if (fer != null) { txtResultMatricula.Text = fer.Matricula; txtRDiametro.Text = fer.Diametro; //Convert.ToInt32(txtRlote.Text) = fer.LoteId; fc.Excluir(fer); } LimparCampo(); CarregarGridFerramentas(); }
protected void btnBuscar_Click(object sender, EventArgs e) { FerramentaController fc = new FerramentaController(); Ferramenta fer = fc.BuscarPorMatricula(int.Parse(txtRMatricula.Text)); if (fer != null) { //txtRMatricula.Text = fer.Matricula; txtResultMatricula.Text = fer.Matricula; txtRDiametro.Text = fer.Diametro; txtRlote.Text = fer.LoteId.ToString(); lblNExiste.Text = string.Empty; } else { lblNExiste.Text = "* Ferramenta procurada não existe!!!"; LimparCampo(); } }
protected void btnAlterar_Click(object sender, EventArgs e) { FerramentaController fc = new FerramentaController(); Ferramenta fer = fc.BuscarPorMatricula(int.Parse(txtRMatricula.Text)); if (fer != null) { fer.Matricula = txtResultMatricula.Text; fer.Diametro = txtRDiametro.Text; fer.LoteId = int.Parse(txtRlote.Text); fc.Editar(fer); lblNExiste.Text = "* Ferramenta Alterada!!!"; } else { lblNExiste.Text = "* Ferramenta procurada não existe!!!"; LimparCampo(); } CarregarGridFerramentas(); // LimparCampo(); }