Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PurchaseOrderListViewModel"/> class.
        /// </summary>
        public RefundFromSupplierViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
            : base()
        {
            this.regionManager   = regionManager;
            this.eventAggregator = eventAggregator;
            this.LoadSupplierBackground();

            NavigateToClientCommand  = new RelayCommand(NavigatetoSupplier);
            SaveCommand              = new RelayCommand(OnSavePS, CanSave);
            RefreshCommand           = new RelayCommand(refreshcommand);
            SelectChangedCommand     = new RelayCommand(GetPSData);
            NewPSCommand             = new RelayCommand(GetNewPS);
            NavigaetoPurchaseCommand = new RelayCommand(NavigatetoPurchaseOrder);
            NavigaetoOrderCommand    = new RelayCommand(NavigatetoPurchaseOrder);
            PurchaseNoChangedCommand = new RelayCommand(OnPurchaseNoChange);
            CashCheckedCommand       = new RelayCommand(OnCashChecked);
            ChequeCheckedCommand     = new RelayCommand(OnChequeChecked);
            List <SupplierDetailEntity> lst1 = new List <SupplierDetailEntity>();
            List <SupplierDetailEntity> lst  = new List <SupplierDetailEntity>();

            IRefundFromSupplierRepository purchaseRepository = new RefundFromSupplierRepository();

            //this.ListSuppliers = supplierRepository.GetAllSupplier().ToList();

            POCount = psRepository.GetCountOfPOSuppliers(out lst1);
            DNCount = psRepository.GetCountOfDNSuppliers(out lst);
            if (lst != null)
            {
                var result = lst.Concat(lst1).GroupBy(t => t.ID).Select(t => t.First()).ToList();
                ListSuppliers = result.OrderBy(t => t.SupplierName).ToList();
            }
            this.AccountDetails = payRepository.GetAccountDetails().Where(e => e.AccountType == 2 || e.AccountType == 3).ToList();
            if (!String.IsNullOrEmpty(SharedValues.NewClick))
            {
                if (SharedValues.NewClick != "New")
                {
                    IsCashChequeEnabled = false;
                    IsTextBoxReadOnly   = true;
                    IsSupplierEnabled   = false;
                    GetRefundFromSupplierDetails(SharedValues.NewClick);
                }
                else if (SharedValues.NewClick == "New")
                {
                    IsCashChequeEnabled = true;
                    IsTextBoxReadOnly   = false;
                    IsSupplierEnabled   = true;
                    GetNewPS();
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PurchaseOrderListViewModel"/> class.
        /// </summary>
        public RefundFromSupplierViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
            : base()
        {
            this.regionManager   = regionManager;
            this.eventAggregator = eventAggregator;
            this.LoadSupplierBackground();
            CloseCommand             = new DelegateCommand(Close);
            NavigateToClientCommand  = new RelayCommand(NavigatetoSupplier);
            SaveCommand              = new RelayCommand(OnSavePS, CanSave);
            RefreshCommand           = new RelayCommand(refreshcommand);
            SelectChangedCommand     = new RelayCommand(GetPSData);
            NewPSCommand             = new RelayCommand(GetNewPS);
            NavigaetoPurchaseCommand = new RelayCommand(NavigatetoPurchaseOrder);
            NavigaetoOrderCommand    = new RelayCommand(NavigatetoPurchaseOrder);
            PurchaseNoChangedCommand = new RelayCommand(OnPurchaseNoChange);
            CashCheckedCommand       = new RelayCommand(OnCashChecked);
            ChequeCheckedCommand     = new RelayCommand(OnChequeChecked);
            List <SupplierDetailEntity> lst1 = new List <SupplierDetailEntity>();
            List <SupplierDetailEntity> lst  = new List <SupplierDetailEntity>();
            int custId = 0;
            IRefundFromSupplierRepository purchaseRepository = new RefundFromSupplierRepository();

            //this.ListSuppliers = supplierRepository.GetAllSupplier().ToList();

            POCount = psRepository.GetCountOfPOSuppliers(out lst1);
            DNCount = psRepository.GetCountOfDNSuppliers(out lst);
            if (lst != null)
            {
                var result = lst.Concat(lst1).GroupBy(t => t.ID).Select(t => t.First()).ToList();
                ListSuppliers = result.OrderBy(t => t.SupplierName).ToList();
            }
            if (ListSuppliers.Count > 0)
            {
                int SupplierSelectedId = 0;
                if (SharedValues.getValue != null)
                {
                    bool isValid = Int32.TryParse(SharedValues.getValue, out SupplierSelectedId);
                }
                if (SupplierSelectedId != 0)
                {
                    this.SelectedSupplierID = SupplierSelectedId;
                }
                else
                {
                    //custId = ListSuppliers[0].ID;
                    //this.SelectedSupplierID = custId;
                    //GetPSData(this.SelectedSupplierID);
                }
            }
            this.AccountDetails = rmRepository.GetAccountDetails().Where(e => e.AccountType == Convert.ToInt32(Account_Type.Bank) || e.AccountType == Convert.ToInt32(Account_Type.Cash) || e.AccountType == Convert.ToByte(Account_Type.CreditCard)).ToList();
            if (!String.IsNullOrEmpty(SharedValues.NewClick))
            {
                if (SharedValues.NewClick != "New")
                {
                    MustCompare         = false;
                    IsCashChequeEnabled = false;
                    IsTextBoxReadOnly   = true;
                    IsSupplierEnabled   = false;
                    GetRefundFromSupplierDetails(SharedValues.NewClick);
                }
                else if (SharedValues.NewClick == "New")
                {
                    MustCompare         = true;
                    IsCashChequeEnabled = true;
                    IsTextBoxReadOnly   = false;
                    IsSupplierEnabled   = true;
                    GetNewPS();
                }
            }
        }