public void AtualizarProduto(Produto Item) { this.Codigo = Item.Codigo; this.Nome = Item.Nome; this.Descricao = Item.Descricao; this.Valor = Item.Valor; this.codFuncionario = Item.codFuncionario; this.Tipo = Item.Tipo; this.Ativo = Item.Ativo; }
public Produto(int codigo, string nome, string descricao, Produto_tipo tipo, double valor, int?funcionario, bool ativo = true) { Codigo = codigo; Nome = nome; Descricao = descricao; Valor = valor; codFuncionario = funcionario; Tipo = tipo; Ativo = ativo; }
private void add_produto_salvar_Click(object sender, EventArgs e) { if (nome_produto.Text == "") { MessageBox.Show("Insira um nome do produto."); } if (valor_text.Text == "") { MessageBox.Show("Insira um valor."); } if (codFornecedor == 0 && revendido.Checked == true) { MessageBox.Show("Insira um fornecedor"); } if (nome_produto.Text != "" && valor_text.Text != "" && !(codFornecedor == 0 && revendido.Checked == true)) { var produtos = Comercio.GerenciaEmpresa.Instance.Produtos; var query = "INSERT INTO ESTOQUE_PRODUTO VALUES(default" + "," + " '" + nome_produto.Text.FormatToDB() + "' " + "," + " '" + des_text.Text.FormatToDB() + "' " + "," + (fabricado.Checked ? 0 : 1) + ", " + Convert.ToDouble(valor_text.Text) + ", " + "'" + codFuncionario + "', default);"; Comercio.GerenciaEmpresa.Instance.Banco.Insert(query); Produto_tipo tipo = fabricado.Checked ? Produto_tipo.fabricado : Produto_tipo.revendido; var codProduto = Comercio.GerenciaEmpresa.Instance.CarregarProdutoBanco("SELECT * FROM laripaos.ESTOQUE_PRODUTO WHERE CODIGO = (SELECT MAX(CODIGO) FROM laripaos.ESTOQUE_PRODUTO);").FirstOrDefault(); int cod = codProduto == null ? 1 : codProduto.Codigo; var novoProduto = new Comercio.Produto(cod, nome_produto.Text, des_text.Text, tipo, Convert.ToDouble(valor_text.Text), codFornecedor); Comercio.GerenciaEmpresa.Instance.AdicionarProduto(novoProduto); Comercio.GerenciaEmpresa.Instance.SalvarProdutos(Comercio.GerenciaEmpresa.Instance.Produtos); if (revendido.Checked == true) { var queryProdRevendido = ("INSERT INTO ESTOQUE_PRODUTO_REVENDIDO VALUES( default, " + " '" + cod + "', " + " '" + codFornecedor + "', " + " '" + Convert.ToDouble(valor_text.Text) + "');"); Comercio.GerenciaEmpresa.Instance.Banco.Insert(queryProdRevendido); } else { foreach (var item in lista_ingredientes.Items) { string[] aux = item.ToString().Split('|'); int cod_ingrediente = Convert.ToInt32(aux[0].Trim()); double qtd_ingrediente = Convert.ToDouble(aux[2].Trim()); var queryItens = ("INSERT INTO UTILIZA VALUES( default," + " '" + cod + "', " + " '" + cod_ingrediente + "','" + +qtd_ingrediente + "');"); Comercio.GerenciaEmpresa.Instance.Banco.Insert(queryItens); } } this.Close(); } }