Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
OrderLineData.cs
Package: CSharpprogramming.rar [view]
Upload User: lxycoco
Upload Date: 2022-07-21
Package Size: 38457k
Code Size: 2k
Category:
CSharp
Development Platform:
Others
- using System;
- using System.EnterpriseServices;
- using System.Data;
- using System.Data.SqlClient;
- namespace Wrox.ProCSharp.EnterpriseServices
- {
- public interface IOrderLineUpdate
- {
- void Insert(int orderId, OrderLine orderDetail);
- void Update(OrderLine orderDetail);
- }
- [Transaction(TransactionOption.Required)]
- [EventTrackingEnabled(true)]
- [ConstructionEnabled(true, Default="server=localhost;database=northwind;trusted_connection=true")]
- public class OrderLineData : ServicedComponent, IOrderLineUpdate
- {
- public OrderLineData()
- {
- }
- private string connectionString = null;
- #region IOrderDetailUpdate Members
- public void Insert(int orderId, OrderLine orderDetail)
- {
- SqlConnection connection = new SqlConnection(connectionString);
- try
- {
- SqlCommand command = connection.CreateCommand();
- command.CommandText = "INSERT INTO [Order Details] (OrderId, ProductId, UnitPrice, Quantity)" +
- "VALUES(@OrderId, @ProductId, @UnitPrice, @Quantity)";
- command.Parameters.Add("@OrderId", orderId);
- command.Parameters.Add("@ProductId", orderDetail.ProductId);
- command.Parameters.Add("@UnitPrice", orderDetail.UnitPrice);
- command.Parameters.Add("@Quantity", orderDetail.Quantity);
- connection.Open();
- int rows = command.ExecuteNonQuery();
- if (rows != 1)
- throw new Exception("error");
- }
- catch (Exception ex)
- {
- System.Windows.Forms.MessageBox.Show(ex.Message);
- ContextUtil.SetAbort();
- throw;
- }
- finally
- {
- connection.Close();
- }
- ContextUtil.SetComplete();
- }
- protected override void Construct(string s)
- {
- connectionString = s;
- }
- public void Update(OrderLine orderDetail)
- {
- // TODO: Add UpdateOrderDetail.Update implementation
- }
- #endregion
- }
- }