Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using System.Configuration;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
- using FirebirdSql.Data.FirebirdClient;
- using System.Collections.Generic;
- namespace carregar
- {
- [Serializable]
- public class ESTOQUE
- {
- public Int64 Codigo { get; set; }
- public String Nome { get; set; }
- public String Und_V { get; set; }
- public Double Qtd { get; set; }
- public Double Preco_Cons { get; set; }
- public Double Preco_Rev { get; set; }
- public static List<ESTOQUE> RecuperarTodos()
- {
- //string de conexão
- string conex = @"User=SYSDBA; " +
- "Password=masterkey; " +
- "Database=C:\\base\\PEDIDO.FDB; " +
- "DataSource=localhost;Port=3050;Dialect=3;Pooling=false";
- string strCmd = "SELECT CODIGO, NOME, UND_V, QTD, PRECO_CONS, PRECO_REV FROM ESTOQUE ORDER BY NOME";
- FbConnection objFbConnection;
- DataSet ds = new DataSet();
- using (objFbConnection = new FbConnection(conex))
- {
- FbCommand strFbCommand = new FbCommand(strCmd, objFbConnection);
- FbDataAdapter objDa = new FbDataAdapter(strFbCommand);
- objFbConnection.Open();
- objDa.Fill(ds, "ESTOQUE");
- objFbConnection.Close();
- }
- DataTable dtEstoque = ds.Tables["ESTOQUE"];
- List<ESTOQUE> objEstoques = new List<ESTOQUE>();
- ESTOQUE objEstoqueTemp = new ESTOQUE { Codigo = 0, Nome = "", Preco_Cons = 0, Preco_Rev = 0, Qtd = 0, Und_V = "" };
- objEstoques.Add(objEstoqueTemp);
- foreach (DataRow row in dtEstoque.Rows)
- {
- ESTOQUE objEstoque = new ESTOQUE
- {
- Codigo = row["CODIGO"] == DBNull.Value ? 0 : Convert.ToInt32(row["CODIGO"]),
- Nome = row["NOME"] == DBNull.Value ? "" : Convert.ToString(row["NOME"]),
- Preco_Cons = row["PRECO_CONS"] == DBNull.Value ? 0 : Convert.ToDouble(row["PRECO_CONS"]),
- Preco_Rev = row["PRECO_REV"] == DBNull.Value ? 0 : Convert.ToDouble(row["PRECO_REV"]),
- Qtd = row["QTD"] == DBNull.Value ? 0 : Convert.ToDouble(row["QTD"]),
- Und_V = row["UND_V"] == DBNull.Value ? "" : Convert.ToString(row["UND_V"])
- };
- objEstoques.Add(objEstoque);
- }
- return objEstoques;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement