public FrmCadProduto(FrmConsultaProduto consulta, Produto produto) { InitializeComponent(); init(consulta); this.produto=produto; this.fornecedor = produto.fornecedor; PreencherCampos(); //txtdescricao.Enabled = false; txtcodigo.Enabled = false; txtquantidade_inicial.Enabled = false; txtunidade.Enabled = false; }
public Produto getProduto() { Produto p = new Produto(); Fornecedor forn = new Fornecedor(); p.id_produto = Convert.ToInt32(tabela.CurrentRow.Cells[0].Value.ToString()); forn.id_fornecedor = Convert.ToInt32(tabela.CurrentRow.Cells[1].Value.ToString()); p.codigo = tabela.CurrentRow.Cells[2].Value.ToString(); p.descricao = tabela.CurrentRow.Cells[3].Value.ToString(); p.estoque= Convert.ToInt64( tabela.CurrentRow.Cells[4].Value.ToString()); p.unidade = tabela.CurrentRow.Cells[5].Value.ToString(); p.preco_compra = Convert.ToDecimal(tabela.CurrentRow.Cells[6].Value.ToString()); p.preco_venda = Convert.ToDecimal(tabela.CurrentRow.Cells[7].Value.ToString()); forn.razao_social = tabela.CurrentRow.Cells[8].Value.ToString(); p.data_cadastro = DateTime.Parse(tabela.CurrentRow.Cells[9].Value.ToString()); p.quantidade_minima = Convert.ToInt32(tabela.CurrentRow.Cells[10].Value.ToString()); p.fornecedor = forn; return p; }
public static bool verifica_estoque_minimo(FrmPrincipal principal) { string query = "select * from produto where quantidade_minima >=estoque and status=1"; MySqlConnection con = new MySqlConnection(Config.Conexao); MySqlCommand cmd = new MySqlCommand(query,con); con.Open(); MySqlDataReader reader = cmd.ExecuteReader(); if (!reader.HasRows) { con.Close(); return false; } else { List<Produto> lista = new List<Produto>(); while (reader.Read()) { Produto p = new Produto(); p.codigo = reader["codigo"].ToString(); p.descricao = reader["descricao"].ToString(); p.estoque = Convert.ToInt64(reader["estoque"].ToString()); lista.Add(p); } con.Close(); FrmEstoqueMinimo frm = new FrmEstoqueMinimo(lista); frm.MdiParent = principal; frm.Show(); return true; } }