daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Xml.Linq;
  12. using FirebirdSql.Data.FirebirdClient;
  13. using System.Collections.Generic;
  14.  
  15. namespace carregar
  16. {
  17.     [Serializable]
  18.     public class ESTOQUE
  19.     {
  20.         public Int64 Codigo { get; set; }
  21.         public String Nome { get; set; }
  22.         public String Und_V { get; set; }
  23.         public Double Qtd { get; set; }
  24.         public Double Preco_Cons { get; set; }
  25.         public Double Preco_Rev { get; set; }
  26.  
  27.         public static List<ESTOQUE> RecuperarTodos()
  28.         {
  29.  
  30.             //string de conex√£o
  31.             string conex = @"User=SYSDBA; " +
  32.                                   "Password=masterkey; " +
  33.                                   "Database=C:\\base\\PEDIDO.FDB; " +
  34.                                   "DataSource=localhost;Port=3050;Dialect=3;Pooling=false";
  35.  
  36.             string strCmd = "SELECT CODIGO, NOME, UND_V, QTD, PRECO_CONS, PRECO_REV FROM ESTOQUE ORDER BY NOME";
  37.             FbConnection objFbConnection;
  38.             DataSet ds = new DataSet();
  39.  
  40.             using (objFbConnection = new FbConnection(conex))
  41.             {
  42.                 FbCommand strFbCommand = new FbCommand(strCmd, objFbConnection);
  43.                 FbDataAdapter objDa = new FbDataAdapter(strFbCommand);
  44.                 objFbConnection.Open();
  45.  
  46.                 objDa.Fill(ds, "ESTOQUE");
  47.  
  48.                 objFbConnection.Close();
  49.             }
  50.  
  51.             DataTable dtEstoque = ds.Tables["ESTOQUE"];
  52.  
  53.             List<ESTOQUE> objEstoques = new List<ESTOQUE>();
  54.  
  55.             ESTOQUE objEstoqueTemp = new ESTOQUE { Codigo = 0, Nome = "", Preco_Cons = 0, Preco_Rev = 0, Qtd = 0, Und_V = "" };
  56.  
  57.             objEstoques.Add(objEstoqueTemp);
  58.  
  59.             foreach (DataRow row in dtEstoque.Rows)
  60.             {
  61.                 ESTOQUE objEstoque = new ESTOQUE
  62.                 {
  63.                     Codigo = row["CODIGO"] == DBNull.Value ? 0 : Convert.ToInt32(row["CODIGO"]),
  64.                     Nome = row["NOME"] == DBNull.Value ? "" : Convert.ToString(row["NOME"]),
  65.                     Preco_Cons = row["PRECO_CONS"] == DBNull.Value ? 0 : Convert.ToDouble(row["PRECO_CONS"]),
  66.                     Preco_Rev = row["PRECO_REV"] == DBNull.Value ? 0 : Convert.ToDouble(row["PRECO_REV"]),
  67.                     Qtd = row["QTD"] == DBNull.Value ? 0 : Convert.ToDouble(row["QTD"]),
  68.                     Und_V = row["UND_V"] == DBNull.Value ? "" : Convert.ToString(row["UND_V"])
  69.                 };
  70.  
  71.                 objEstoques.Add(objEstoque);
  72.  
  73.             }
  74.             return objEstoques;
  75.         }
  76.     }
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top