Beispiel #1
0
        public static void UpdateOrder(Order order)
        {
            if (order.OrderID == Guid.Empty)
                return;
            string sqlQuery = "UPDATE Order SET CustomerFacilityID=@CustomerFacilityID, TerritoryID=@TerritoryID, EmployeeID=@EmployeeID, OrderStatus=@OrderStatus, Identifier=@Identifier, OrderDate=@OrderDate, DateModified=@DateModified, SubTotal=@SubTotal, TaxAmount=@TaxAmount, Total=@Total, Comment=@Comment  WHERE OrderID='" + order.OrderID + "'";

            DbCommand dbCommand = DBHelper.GetDBCommand(sqlQuery);
            DBHelper.AddInParameter(dbCommand, "OrderID", DbType.Guid, order.OrderID);
            DBHelper.AddInParameter(dbCommand, "CustomerFacilityID", DbType.Guid, order.CustomerFacilityID);
            DBHelper.AddInParameter(dbCommand, "TerritoryID", DbType.Guid, order.TerritoryID);
            DBHelper.AddInParameter(dbCommand, "EmployeeID", DbType.Guid, order.EmployeeID);
            DBHelper.AddInParameter(dbCommand, "OrderStatus", DbType.Guid, order.OrderStatusID);
            DBHelper.AddInParameter(dbCommand, "Identifier", DbType.String, order.Identifier);
            DBHelper.AddInParameter(dbCommand, "OrderDate", DbType.DateTime, order.OrderDate);
            if (order.DateModified.HasValue)
                DBHelper.AddInParameter(dbCommand, "DateModified", DbType.DateTime, order.DateModified.Value);
            else
                DBHelper.AddInParameter(dbCommand, "DateModified", DbType.DateTime, DBNull.Value);

            DBHelper.AddInParameter(dbCommand, "SubTotal", DbType.Decimal, order.SubTotal);
            DBHelper.AddInParameter(dbCommand, "TaxAmount", DbType.Decimal, order.TaxAmount);
            DBHelper.AddInParameter(dbCommand, "Total", DbType.Decimal, order.Total);
            DBHelper.AddInParameter(dbCommand, "Comment", DbType.String, order.Comment);
            DBHelper.ExecuteNonQuery(dbCommand);
        }
Beispiel #2
0
        public static Order InsertOrder(Order order)
        {
            string sqlQuery = "INSERT INTO [Order] (OrderID, CustomerFacilityID, TerritoryID, EmployeeID, OrderStatus, Identifier, OrderDate, SubTotal, TaxAmount, Total, Comment) " +
                " VALUES(@OrderID,@CustomerFacilityID,@TerritoryID,@EmployeeID,@OrderStatus,@Identifier,@OrderDate,@SubTotal,@TaxAmount,@Total,@Comment)";
            if (order.OrderID == Guid.Empty)
                order.OrderID = Guid.NewGuid();
            else
                return null;

            DbCommand dbCommand = DBHelper.GetDBCommand(sqlQuery);
            DBHelper.AddInParameter(dbCommand, "OrderID", DbType.Guid, order.OrderID);
            DBHelper.AddInParameter(dbCommand, "CustomerFacilityID", DbType.Guid, order.CustomerFacilityID);
            DBHelper.AddInParameter(dbCommand, "TerritoryID", DbType.Guid, order.TerritoryID);
            DBHelper.AddInParameter(dbCommand, "EmployeeID", DbType.Guid, order.EmployeeID);
            DBHelper.AddInParameter(dbCommand, "OrderStatus", DbType.Guid, order.OrderStatusID);
            DBHelper.AddInParameter(dbCommand, "Identifier", DbType.String, order.Identifier);
            DBHelper.AddInParameter(dbCommand, "OrderDate", DbType.DateTime, order.OrderDate);
            DBHelper.AddInParameter(dbCommand, "SubTotal", DbType.Decimal, order.SubTotal);
            DBHelper.AddInParameter(dbCommand, "TaxAmount", DbType.Decimal, order.TaxAmount);
            DBHelper.AddInParameter(dbCommand, "Total", DbType.Decimal, order.Total);
            DBHelper.AddInParameter(dbCommand, "Comment", DbType.String, order.Comment);
            DBHelper.ExecuteNonQuery(dbCommand);

            return order;
        }
Beispiel #3
0
 public Invoice(Guid invoiceid, Order order, Dictionary invoicestatus, string number, DateTime date, bool ispaid)
 {
     this.invoiceid = invoiceid;
     this.order = order;
     this.invoicestatus = invoicestatus;
     this.number = number;
     this.date = date;
     this.ispaid = ispaid;
 }
Beispiel #4
0
 public OrderLine(OrderLineId id, int quantity, decimal itemprice, decimal itempricediscount, decimal total, Order order, Product product)
 {
     this.id= id;
     this.quantity= quantity;
     this.itemprice= itemprice;
     this.itempricediscount= itempricediscount;
     this.total= total;
     this.order= order;
     this.product= product;
 }
Beispiel #5
0
 public static Order InsertOrder(Order order)
 {
     order.OrderDate = DateTime.Now;
     order.Identifier = GenerateOrderIdentifier(order);
     OrderDB.InsertOrder(order);
     if(order.OrderID!=Guid.Empty)
     {
         foreach (OrderLine line in order.OrderLines)
         {
             line.OrderID = order.OrderID;
             OrderLineDB.InsertOrderLine(line);
         }
     }
     return order;
 }
Beispiel #6
0
        private static string GenerateOrderIdentifier(Order order)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(order.OrderDate.Day+"/"+order.OrderDate.Month+"/"+order.OrderDate.Year);
            builder.Append("_" + order.Territory.Name.Substring(0, 2));
            if (order.Employee.Contact != null)
            {
                builder.Append("_" + order.Employee.Contact.FirstName.Substring(0, 1) + order.Employee.Contact.LastName.Substring(0, 1));
            }
            Order newestOrder = OrderDB.GetOrders().Where(o => o.Identifier.Contains(builder.ToString())).OrderByDescending(o => o.Identifier).FirstOrDefault();
            int idx = 1;
            if (newestOrder != null)
            {
                idx = Int32.Parse(newestOrder.Identifier.Replace(builder.ToString() + "_", ""));
                idx++;
            }
            builder.Append("_" + idx);
            return builder.ToString();
        }
Beispiel #7
0
 public OrderLineId(Order order, Product product)
 {
     this.order= order;
     this.product= product;
 }
Beispiel #8
0
 private static Order GetOrderFromReader(IDataReader dataReader)
 {
     Order order = new Order();
     order.OrderID = DBHelper.GetGuid(dataReader, "OrderID");
     order.CustomerFacilityID = DBHelper.GetGuid(dataReader, "CustomerFacilityID");
     order.TerritoryID = DBHelper.GetGuid(dataReader, "TerritoryID");
     order.EmployeeID = DBHelper.GetGuid(dataReader, "EmployeeID");
     order.OrderStatusID = DBHelper.GetGuid(dataReader, "OrderStatus");
     order.Identifier = DBHelper.GetString(dataReader, "Identifier");
     order.OrderDate = DBHelper.GetDateTime(dataReader, "OrderDate");
     order.DateModified = DBHelper.GetNullableDateTime(dataReader, "DateModified");
     order.SubTotal = DBHelper.GetDecimal(dataReader, "SubTotal");
     order.TaxAmount = DBHelper.GetDecimal(dataReader, "TaxAmount");
     order.Total = DBHelper.GetDecimal(dataReader, "Total");
     order.Comment = DBHelper.GetString(dataReader, "Comment");
     return order;
 }