public bool Delete_VendaItens(Venda_Itens ent) { try { return(myRep.Delete <Venda_Itens>(ent)); } catch { throw; } }
public bool AddNew_VendaItens(Venda_Itens vend_it) { try { return(myRep.Add <Venda_Itens>(vend_it)); } catch { throw; } }
private void pb_pnlVendas_SubmitToDb_Click(object sender, EventArgs e) { if (alteraVenda == false && tb_pnlVendas_Desconto.Text != "" && tb_pnlVendas_TotalCompras.Text != "" && tb_pnlVendas_ValorFinal.Text != "" && comboBox_pnlVendas_AddCliente.Text != "" && comboBox_pnlVendas_AddFormaPagamento.Text != "" && //comboBox_pnlVendas_AddProduto.Text != "" && comboBox_pnlVendas_AddVendedor.Text != "") { /*Popula tabela dbo.Venda*/ venda = new Venda(); venda.codigo_Cliente = int.Parse(comboBox_pnlVendas_AddCliente.SelectedValue.ToString()); venda.codigo_Vendedor = int.Parse(comboBox_pnlVendas_AddVendedor.SelectedValue.ToString()); venda.data = dateTimePicker_pnlVendas_Add.Text.ToString(); venda.forma_pagamento = comboBox_pnlVendas_AddFormaPagamento.Text; venda.total_compra = float.Parse(tb_pnlVendas_TotalCompras.Text); venda.desconto = float.Parse(tb_pnlVendas_Desconto.Text); venda.valor_final = float.Parse(tb_pnlVendas_ValorFinal.Text); RemoteStatic.remoteObject.AddNew_Venda(venda); /*Popula tabela dbo.VendaItens*/ int codigoVenda = RemoteStatic.remoteObject.GetAll_Venda().Count(); foreach (DataGridViewRow drRowAux in dg_pnlVendas_AddProdutos.Rows) { vendaItens = new Venda_Itens(); vendaItens.codigo_Venda = codigoVenda; vendaItens.codigo_Produto = int.Parse(drRowAux.Cells[0].Value.ToString()); vendaItens.quantidade = int.Parse(drRowAux.Cells[3].Value.ToString()); RemoteStatic.remoteObject.AddNew_VendaItens(vendaItens); } MessageBox.Show("Venda cadastrada!", "Informação", MessageBoxButtons.OK); } else { MessageBox.Show(this, "Todos campos devem ser preenchidos.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } montaGrids(); pnlVenda_Add.Visible = false; limpaCamposVenda(); }