Exemplo n.º 1
0
        public void RderLine(int p_customerorder, System.Collections.Generic.IList <int> p_orderline)
        {
            try
            {
                SessionInitializeTransaction();
                P2GenNHibernate.EN.Default_.CustomerOrderEN customerOrderEN = null;
                customerOrderEN = (CustomerOrderEN)session.Load(typeof(CustomerOrderEN), p_customerorder);

                P2GenNHibernate.EN.Default_.OrderLineEN orderLineENAux = null;
                if (customerOrderEN.OrderLine != null)
                {
                    foreach (int item in p_orderline)
                    {
                        orderLineENAux = (P2GenNHibernate.EN.Default_.OrderLineEN)session.Load(typeof(P2GenNHibernate.EN.Default_.OrderLineEN), item);
                        if (customerOrderEN.OrderLine.Contains(orderLineENAux) == true)
                        {
                            customerOrderEN.OrderLine.Remove(orderLineENAux);
                            orderLineENAux.Order = null;
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_orderline you are trying to unrelationer, doesn't exist in CustomerOrderEN");
                        }
                    }
                }

                session.Update(customerOrderEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is P2GenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new P2GenNHibernate.Exceptions.DataLayerException("Error in CustomerOrderCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 2
0
        public void AddOrderLine(int p_customerorder, System.Collections.Generic.IList <int> p_orderline)
        {
            P2GenNHibernate.EN.Default_.CustomerOrderEN customerOrderEN = null;
            try
            {
                SessionInitializeTransaction();
                customerOrderEN = (CustomerOrderEN)session.Load(typeof(CustomerOrderEN), p_customerorder);
                P2GenNHibernate.EN.Default_.OrderLineEN orderLineENAux = null;
                if (customerOrderEN.OrderLine == null)
                {
                    customerOrderEN.OrderLine = new System.Collections.Generic.List <P2GenNHibernate.EN.Default_.OrderLineEN>();
                }

                foreach (int item in p_orderline)
                {
                    orderLineENAux       = new P2GenNHibernate.EN.Default_.OrderLineEN();
                    orderLineENAux       = (P2GenNHibernate.EN.Default_.OrderLineEN)session.Load(typeof(P2GenNHibernate.EN.Default_.OrderLineEN), item);
                    orderLineENAux.Order = customerOrderEN;

                    customerOrderEN.OrderLine.Add(orderLineENAux);
                }


                session.Update(customerOrderEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is P2GenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new P2GenNHibernate.Exceptions.DataLayerException("Error in CustomerOrderCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            OrderLineEN t = obj as OrderLineEN;

            if (t == null)
            {
                return(false);
            }
            if (Id.Equals(t.Id))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 public OrderLineEN(OrderLineEN orderLine)
 {
     this.init(Id, orderLine.Order, orderLine.Quantity, orderLine.Number, orderLine.Product);
 }