//CARREGA TODOS OS ITENS DO ORCAMENTO NO DDLITEMS private void CarryItems(int id) { BudgetItemBD db = new BudgetItemBD(); DataSet ds = db.SelectAllById(id); ddlItem.DataSource = ds.Tables[0].DefaultView; ddlItem.DataTextField = "ori_descricao"; ddlItem.DataValueField = "ori_id"; ddlItem.DataBind(); ddlItem.Items.Insert(0, "Selecione"); }
//CARREGA DADOS DO ITEM SELECIONADO private void CarryItemData(int id) { if (!hasItem()) { return; } BudgetItemBD db = new BudgetItemBD(); BudgetItem budgetitem = db.Select(id); txtTotal.Text = budgetitem.Amount.ToString(); txtUnitValue.Text = budgetitem.Price.ToString(); lblType.Text = budgetitem.Type.ToString(); // Oculto para usuário txtNeedBuy.Text = budgetitem.Amount.ToString(); }
protected void btnSalvar_Click(object sender, EventArgs e) { int id = 0; BudgetBD orcamentobd = new BudgetBD(); if (Session["ID"] != null) { id = Convert.ToInt32(Session["ID"]); } bool sucesso = true; if (orcamentobd.Insert(DateTime.Now, GridView1.Rows[0].Cells[0].Text, GridView1.Rows[0].Cells[1].Text, id)) { BudgetItemBD orcamentoItem = new BudgetItemBD(); BudgetBD budget = new BudgetBD(); int lastId = budget.SelectLastBudget(); for (int j = 0; j < GridView1.Rows.Count; j++) { if (orcamentoItem.Insert(GridView1.Rows[j].Cells[2].Text, GridView1.Rows[j].Cells[3].Text, GridView1.Rows[j].Cells[4].Text, GridView1.Rows[j].Cells[5].Text, 1, lastId)) { sucesso = true; } else { sucesso = false; } } } //for (int i = 0; i < GridView1.Rows.Count; i++) //{ //} }