Advertisement
bogdanhu

StockElement

Feb 12th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using DevExpress.ExpressApp;
  9. using DevExpress.Persistent.Base;
  10. using DevExpress.Persistent.BaseImpl;
  11. using DevExpress.Xpo;
  12. using DevExpress.ExpressApp.Model;
  13. using DevExpress.ExpressApp.DC;
  14. using DevExpress.Persistent.Validation;
  15. using DevExpress.Utils.MVVM.Services;
  16.  
  17. using System.Collections.Generic;  
  18.  
  19.  
  20.  
  21.  
  22. namespace SituatieIsis.Module.BusinessObjects
  23. {
  24.     [NavigationItem(false)]
  25.     [XafDisplayName("StockItems")]
  26.  
  27.     public class StockElement : BaseObject
  28.     {
  29.         public StockElement(Session session) : base(session) { }
  30.  
  31.         private bool isLoaded = false;
  32.             private bool isCreated = false;
  33.             private Produse product;
  34.             private int quantity;
  35.             private decimal discount;
  36.    
  37.    
  38.     //    
  39.             [ImmediatePostData]
  40.             public virtual Produse Produs
  41.             {
  42.                 get { return product; }
  43.                 set { product = value;// UpdateAmount();
  44.                 }
  45.             }
  46.  
  47.         private int _Iesiri;
  48.         private int _StocInitial;
  49.         private int _Stoc;
  50.         private int _Intrari;
  51.  
  52.         [ImmediatePostData]
  53.         public int Iesiri
  54.         {
  55.             get
  56.             {
  57.                 return _Iesiri;
  58.             }
  59.             set
  60.             {
  61.                 SetPropertyValue("Iesiri", ref _Iesiri, value);
  62.                 SetStoc();
  63.                 OnChanged("Stoc");
  64.             }
  65.         }
  66.  
  67.         private void SetStoc()
  68.         {
  69.             if (IsLoading) return;
  70.             try
  71.             {
  72.                 Stoc = StocInitial + Intrari - Iesiri;
  73.             }
  74.             catch (Exception)
  75.             {
  76.                 //TODO: de rezolvat cu clone
  77.  
  78.                 throw new UserFriendlyException("Aceasta functionalitate nu este implementata");
  79.             }
  80.         }
  81.         #region Campuri
  82.         [ImmediatePostData]
  83.         public int StocInitial
  84.         {
  85.             get
  86.             {
  87.                 return _StocInitial;
  88.             }
  89.             set
  90.             {
  91.                 SetPropertyValue("Stoc Initial", ref _StocInitial, value);
  92.                 SetStoc();
  93.             }
  94.         }
  95.  
  96.         [ImmediatePostData]
  97.         public int Intrari
  98.         {
  99.             get
  100.             {
  101.                 return _Intrari;
  102.             }
  103.             set
  104.             {
  105.                 if (!SetPropertyValue("Intrari", ref _Intrari, value)) return;
  106.                 SetStoc();
  107.                 OnChanged("Stoc");
  108.             }
  109.         }
  110.  
  111.  
  112.         [PersistentAlias("StocInitial+ Intrari - Iesiri")]
  113.         public int Stoc
  114.         {
  115.             get
  116.             {
  117.                 object tempObject = EvaluateAlias("Stoc");
  118.                 if (tempObject != null)
  119.                 {
  120.                     return (int)tempObject;
  121.                 }
  122.                 else
  123.                 {
  124.                     return 0;
  125.                 }
  126.  
  127.  
  128.             }
  129.             set
  130.             {
  131.                 SetPropertyValue("Stoc", ref _Stoc, value);
  132.  
  133.             }
  134.         }
  135.         #endregion
  136.  
  137.  
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement