private int SaveExistentFactura(Factura factura2Save) { string FacturasConnection = ConfigurationManager.ConnectionStrings["FacturasCS"].ConnectionString; SqlConnection cnn = new SqlConnection(FacturasConnection); SqlCommand dbCommand = new SqlCommand("Update dbo.Facturas set Emitida=@Emitida, FechaEmision=@FechaEmision where idFactura=@id", cnn); dbCommand.Parameters.AddWithValue("@Emitida", factura2Save.Emitida); dbCommand.Parameters.AddWithValue("@FechaEmision", factura2Save.FechaEmision); dbCommand.Parameters.AddWithValue("@id", factura2Save.Id); int count = dbCommand.ExecuteNonQuery(); return count; }
private Factura LoadFactura(int factura) { string FacturasConnection = ConfigurationManager.ConnectionStrings["FacturasCS"].ConnectionString; SqlDataAdapter custAdapter = new SqlDataAdapter("SELECT * FROM dbo.Facturas Where idFactura=" + factura + "", FacturasConnection); DataSet Facturas = new DataSet(); custAdapter.Fill(Facturas, "Facturas"); Factura miFactura = null; if (Facturas.Tables.Count>0 && Facturas.Tables["Facturas"].Rows.Count>0) foreach (DataRow pRow in Facturas.Tables["Facturas"].Rows) { miFactura = new Factura(); miFactura.Id = Int32.Parse(pRow["id"].ToString()); miFactura.Emitida = Boolean.Parse(pRow["Emitida"].ToString()); miFactura.FechaEmision = DateTime.Parse(pRow["FechaEmision"].ToString()); } return miFactura; }
private int SaveFactura(Factura factura2Save) { ///Codigo que se conecta a la Base de datos por adonet, por poner un ejemplo, en el peor de los casos será una stored string FacturasConnection = ConfigurationManager.ConnectionStrings["FacturasCS"].ConnectionString; }