Esempio n. 1
0
        internal int SaveParent(SalesOrderViewModel view)
        {
            Order order = new Order();

            order.ATTRIBUTE15 = Convert.ToString(_Model.RntIncidentId);
            order.ContactId   = _Model.RntContactId;
            order.IncidentId  = _Model.RntIncidentId;
            foreach (var i in view.Items)
            {
                var item = new OrderItem();
                item.INVENTORY_ITEM_ID  = i.InventoryItemId;
                item.ORDERED_QUANTITY   = i.Quantity;
                item.UNIT_SELLING_PRICE = i.UnitSellingPrice;
                order.Items.Add(item);
            }
            try
            {
                order.Save();
            }
            catch (Exception e)
            {
                NoticeLog("There was a problem while saving the order. " + e.Message, null);
            }
            view.DateCreated = order.CREATION_DATE;
            view.DateUpdated = order.LAST_UPDATE_DATE;
            view.OrderStatus = order.FLOW_STATUS_CODE;
            return(null == order.HEADER_ID ? 0 : (int)order.HEADER_ID);
        }
Esempio n. 2
0
 internal SalesItemViewModel(
     SalesOrderViewModel file,
     decimal serviceRequestId,
     string problemDescription,
     decimal inventoryItemID,
     string approvalRequiredFlag,
     decimal typeID,
     decimal quantity,
     string unit,
     string currency,
     decimal?resourceID
     )
 {
     _File                = file;
     _serviceRequestId    = serviceRequestId;
     ItemName             = problemDescription;
     InventoryItemId      = inventoryItemID;
     ApprovalRequiredFlag = approvalRequiredFlag;
     _UnitSellingPrice    = typeID;
     _Quantity            = quantity;
     UnitOfMeasure        = unit;
     Currency             = currency;
     ResourceId           = resourceID;
     _Status              = ImportStatus.ENTERED;
 }
Esempio n. 3
0
 // construct the view model
 internal OrderManagementViewModel(Proxy proxy, OrderManagementControl control)
 {
     _Control        = control;
     _Proxy          = proxy;
     _Filter         = String.Empty;
     _FilterUpper    = string.Empty;
     _IsExpanded     = true;
     _ParentList     = new ObservableCollection <SalesOrderViewModel>();
     _FileList       = new ListCollectionView(ParentList);
     FileList.Filter = FileList_Filter;
     using (FileList.DeferRefresh())
     {
         _AddSortDescription();
     }
     _LoadedAvailableItems         = false;
     _AvailableItems               = new ObservableCollection <SalesItemViewModel>();
     _AvailableItemsFiltered       = new ListCollectionView(_AvailableItems);
     AvailableItemsFiltered.Filter = AvailableItemsFilter;
     using (AvailableItemsFiltered.DeferRefresh())
     {
         ItemsAddSortDescription();
     }
     ItemsFilter = "";
     _Proxy._InitializedControl(this);
     _DefaultFile = new SalesOrderViewModel(this, 0, string.Empty, string.Empty, string.Empty);
 }
Esempio n. 4
0
        internal Collection <SalesItemViewModel> LoadParent(SalesOrderViewModel orderVM)
        {
            Collection <SalesItemViewModel> items = new Collection <SalesItemViewModel>();

            Order order = Order.GetOrderDetails(orderVM.HeaderId, _Model.RntIncidentId, _Model.RntContactId);

            foreach (var item in order.Items)
            {
                var itemVM = new SalesItemViewModel(
                    orderVM,
                    _Model.EbsSrId,
                    "",
                    (decimal)item.INVENTORY_ITEM_ID,
                    "Y",
                    5,
                    (decimal)item.ORDERED_QUANTITY,
                    "Ea",
                    "USD",
                    _Model.EbsOwnerId
                    );
                itemVM.UnitSellingPrice = item.UNIT_SELLING_PRICE;
                itemVM.ItemName         = item.INVENTORY_ITEM;
                itemVM.LineID           = (int)item.LINE_ID;
                itemVM.SerialNumber     = "EM1234567";
                items.Add(itemVM);
            }
            orderVM._LoadedAll = true;
            orderVM.RefreshStatus();
            return(items);
        }
Esempio n. 5
0
        private Collection <SalesItemViewModel> GetDummyRecords(SalesOrderViewModel order)
        {
            var items = new Collection <SalesItemViewModel>();
            int n     = _Model.MaxPreview == 0 ? 5 : _Model.MaxPreview;

            for (int i = 0; i < n; i++)
            {
                Thread.Sleep(10);
                var item = new SalesItemViewModel(
                    order,
                    60932,
                    string.Format("AS100{0:000}", i + 1),
                    67661,
                    "Y",
                    5,
                    (i + 1),
                    "Ea",
                    "USD",
                    100003628
                    );
                item.SerialNumber = "EM1234567";
                items.Add(item);
            }
            order._LoadedAll = true;
            order.RefreshStatus();
            return(items);
        }
Esempio n. 6
0
 private void AddDummyRecords(SalesOrderViewModel importFile)
 {
     foreach (var item in GetDummyRecords(importFile))
     {
         importFile.Items.Add(item);
     }
 }
Esempio n. 7
0
        internal SalesOrderViewModel StartNewOrder()
        {
            SalesOrderViewModel order = new SalesOrderViewModel(this, 0, "New Order", "New Order", "New Order");

            order._LoadedAll = true;
            order._JobStatus = SalesOrderViewModel.JobStatus.Done;
            return(order);
        }
Esempio n. 8
0
        internal SalesOrderViewModel GetDummyFile()
        {
            string name = string.Format("Sales_Order_{0:000}", 2);
            var    file = new SalesOrderViewModel(this._Model, 2, name, name, name);

            AddDummyRecords(file);
            return(file);
        }
Esempio n. 9
0
        internal Collection <SalesItemViewModel> GetAvailableItems(int limit = 0, SalesOrderViewModel parent = null)
        {
            var    items = new Collection <SalesItemViewModel>();
            String query = @"SELECT sp.PartNumber, sp.Name , sp.Schedules.SalesProductScheduleList.Price.Value 
                FROM SalesProduct sp 
                WHERE sp.Folder.Name = 'EBS Products' 
                AND sp.Schedules.SalesProductScheduleList.Price.Currency.Name = 'USD' 
                AND sp.Schedules.SalesProductScheduleList.Price.Value > 0 
                LIMIT 1000";

            String[] rows = null;
            string   row  = null;

            try
            {
                rows = workspaceAddIn._rnSrv.queryData(query);
            }
            catch (Exception e)
            {
                string logMessage = "Error in getting products from CWSS. Error query: " + query;
                ErrorLog(logMessage, e.Message);
            }
            try
            {
                foreach (string r in rows)
                {
                    row = r;
                    string[] s    = r.Split(',');
                    int      id   = Convert.ToInt32(s[0]);
                    string   name = s[1];
                    decimal  usp  = Math.Round(Convert.ToDecimal(s[2]), 2);
                    var      item = new SalesItemViewModel(
                        parent,
                        _Model.EbsSrId,
                        name,
                        id,
                        "Y",
                        0,
                        1,
                        "Ea",
                        "USD",
                        _Model.EbsOwnerId
                        );
                    item.UnitSellingPrice = usp;
                    item.SerialNumber     = "EM1234567";
                    items.Add(item);
                }
            }
            catch (Exception e)
            {
                string logMessage = "Bad data returned by products query. Data: " + row;
                NoticeLog(logMessage, e.Message);
            }
            return(items);
        }
Esempio n. 10
0
 private bool AlreadyPresent(SalesOrderViewModel file)
 {
     foreach (var f in ParentList)
     {
         if (f.FileId == file.FileId)
         {
             return(true);
         }
     }
     return(false);
 }
        private void newParentButton_Click(object sender, RoutedEventArgs e)
        {
            if (_Model.IsRunning)
            {
                System.Windows.MessageBox.Show("Please wait for the current operation to complete.",
                                               string.Format("{0} Order Management", _Model.ServerType), MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            _Model.Filter = "";
            SalesOrderViewModel order = _Model.StartNewOrder();

            _Model.ParentList.Add(order);
            _Model.CurrentParent     = order;
            parentList.SelectedItem  = order;
            parentList.SelectedIndex = _Model.ParentList.Count - 1;
            ResetGrid(false, index: parentList.SelectedIndex);
        }
        private void SwitchFile(ListView aList, RoutedEventArgs e)
        {
            SalesOrderViewModel importFile = aList.SelectedItem as SalesOrderViewModel;

            if (aList.SelectedIndex == -1)
            {
                return;
            }
            if (FileIsNotCurrent())
            {
                return;
            }
            _Model.CurrentParent        = importFile;
            repairOrderList.ItemsSource = importFile.Items;
            importFile._ShowAll         = false;
            _Model.loadFile(importFile);
            if (null != e)
            {
                e.Handled = true;
            }
        }
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.DataContext = _Model;
     if (_Model.IsRecordLoaded || _Model.InDesignMode || _Model.InDemo)
     {
         _Model.Refresh();
     }
     if (_Model.InDesignMode)
     {
         SalesOrderViewModel importFile = _Model._Proxy.GetDummyFile();
         importFile._ShowAll         = false;
         repairOrderList.ItemsSource = importFile.Items;
         _Model.CurrentParent        = importFile;
         importFile.IsNewItemEnabled = true;
         _Model.InDemo = true;
         importFile.SelectAll();
         _Model._Filter   = "Search";
         _Model.IsRunning = true;
     }
     _Model._Proxy.MainWindowLoaded();
 }
     // construct the view model
 internal OrderManagementViewModel(Proxy proxy, OrderManagementControl control)
 {
     _Control = control;
     _Proxy = proxy;
     _Filter = String.Empty;
     _FilterUpper = string.Empty;
     _IsExpanded = true;
     _ParentList = new ObservableCollection<SalesOrderViewModel>();
     _FileList = new ListCollectionView(ParentList);
     FileList.Filter = FileList_Filter;
     using (FileList.DeferRefresh())
     {
         _AddSortDescription();
     }
     _LoadedAvailableItems = false;
     _AvailableItems = new ObservableCollection<SalesItemViewModel>();
     _AvailableItemsFiltered = new ListCollectionView(_AvailableItems);
     AvailableItemsFiltered.Filter = AvailableItemsFilter;
     using (AvailableItemsFiltered.DeferRefresh())
     {
         ItemsAddSortDescription();
     }
     ItemsFilter = "";
     _Proxy._InitializedControl(this);
     _DefaultFile = new SalesOrderViewModel(this, 0, string.Empty, string.Empty, string.Empty);
 }
Esempio n. 15
0
 internal Collection<SalesItemViewModel> GetAvailableItems(int limit = 0, SalesOrderViewModel parent = null)
 {
     var items = new Collection<SalesItemViewModel>();
     String query = @"SELECT sp.PartNumber, sp.Name , sp.Schedules.SalesProductScheduleList.Price.Value 
         FROM SalesProduct sp 
         WHERE sp.Folder.Name = 'EBS Products' 
         AND sp.Schedules.SalesProductScheduleList.Price.Currency.Name = 'USD' 
         AND sp.Schedules.SalesProductScheduleList.Price.Value > 0 
         LIMIT 1000";
     String[] rows = null;
     string row = null;
     try
     {
         rows = workspaceAddIn._rnSrv.queryData(query);
     }
     catch (Exception e)
     {
         string logMessage = "Error in getting products from CWSS. Error query: " + query;
         ErrorLog(logMessage, e.Message);                
     }
     try
     {
         foreach (string r in rows)
         {
             row = r;
             string[] s = r.Split(',');
             int id = Convert.ToInt32(s[0]);
             string name = s[1];
             decimal usp = Math.Round(Convert.ToDecimal(s[2]), 2);
             var item = new SalesItemViewModel(
                     parent,
                     _Model.EbsSrId,
                     name,
                     id,
                     "Y",
                     0,
                     1,
                     "Ea",
                     "USD",
                     _Model.EbsOwnerId
                 );
             item.UnitSellingPrice = usp;
             item.SerialNumber = "EM1234567";
             items.Add(item);
         }
     }
     catch (Exception e)
     {
         string logMessage = "Bad data returned by products query. Data: " + row;
         NoticeLog(logMessage, e.Message);
     }
     return items;
 }
Esempio n. 16
0
 internal void MarkFileImported(SalesOrderViewModel file)
 {
     // intentionally left blank
 }
Esempio n. 17
0
 internal int SaveParent(SalesOrderViewModel view)
 {
     Order order = new Order();
     order.ATTRIBUTE15 = Convert.ToString(_Model.RntIncidentId);
     order.ContactId = _Model.RntContactId;
     order.IncidentId = _Model.RntIncidentId; 
     foreach (var i in view.Items)
     {
         var item = new OrderItem();
         item.INVENTORY_ITEM_ID = i.InventoryItemId;
         item.ORDERED_QUANTITY = i.Quantity;
         item.UNIT_SELLING_PRICE = i.UnitSellingPrice;
         order.Items.Add(item);
     }
     try
     {
         order.Save();
     }
     catch (Exception e)
     {
         NoticeLog("There was a problem while saving the order. " + e.Message, null);
     }
     view.DateCreated = order.CREATION_DATE;
     view.DateUpdated = order.LAST_UPDATE_DATE;
     view.OrderStatus = order.FLOW_STATUS_CODE;
     return null == order.HEADER_ID ? 0 : (int) order.HEADER_ID;
 }
Esempio n. 18
0
 // load the file
 internal void loadFile(SalesOrderViewModel importFile)
 {
     importFile.Load();
 }
Esempio n. 19
0
 internal Collection<SalesOrderViewModel> GetParentList()
 {
     Collection<SalesOrderViewModel> result = new Collection<SalesOrderViewModel>();
     if (_Model.InDesignMode)
     {
         for (int i = 1; i < 10; i++)
         {
             string name = string.Format("Sales_Order_{0:000}", i);
             SalesOrderViewModel order;
             order = new SalesOrderViewModel(_Model, i, name, name, name);
             switch (i)
             {
                 case 1:
                     order._JobStatus = SalesOrderViewModel.JobStatus.Load;
                     break;
                 case 2:
                     order._JobStatus = SalesOrderViewModel.JobStatus.Loaded;
                     AddDummyRecords(order);
                     break;
                 case 3:
                     order._JobStatus = SalesOrderViewModel.JobStatus.ParseError;
                     break;
                 case 4:
                     order._JobStatus = SalesOrderViewModel.JobStatus.Loading;
                     break;
                 case 5:
                     order._JobStatus = SalesOrderViewModel.JobStatus.Importing;
                     order.ProgressPercent = 50;
                     break;
                 case 6:
                     order._JobStatus = SalesOrderViewModel.JobStatus.Done;
                     order.ProgressPercent = 100;
                     break;
                 case 7:
                     order._JobStatus = SalesOrderViewModel.JobStatus.DoneError;
                     order.ProgressPercent = 100;
                     break;
                 case 8:
                     order._JobStatus = SalesOrderViewModel.JobStatus.AllDone;
                     order.ProgressPercent = 100;
                     break;
                 case 9:
                     order._JobStatus = SalesOrderViewModel.JobStatus.AllDoneError;
                     order.ProgressPercent = 100;
                     break;
                 default:
                     break;
             }
             order.RefreshStatus();
             result.Add(order);
         }
     }
     else
     {
         foreach (var order in Order.GetOrdersByIncident(_Model.RntIncidentId, _Model.RntContactId))
         {
             string name = string.Format("Order {0}", order.HEADER_ID);
             string description = name;
             var vm = new SalesOrderViewModel(_Model, (int)order.HEADER_ID, name, name, description);
             vm.OrderStatus = order.FLOW_STATUS_CODE;
             vm.DateCreated = order.CREATION_DATE;
             vm.DateUpdated = order.LAST_UPDATE_DATE;
             result.Add(vm);
         }
     }
     return result;
 }
 internal SalesOrderViewModel StartNewOrder()
 {
     SalesOrderViewModel order = new SalesOrderViewModel(this, 0, "New Order", "New Order", "New Order");
     order._LoadedAll = true;
     order._JobStatus = SalesOrderViewModel.JobStatus.Done;
     return order;
 }
Esempio n. 21
0
 private Collection<SalesItemViewModel> GetDummyRecords(SalesOrderViewModel order)
 {
     var items = new Collection<SalesItemViewModel>();
     int n = _Model.MaxPreview == 0 ? 5 : _Model.MaxPreview;
     for (int i = 0; i < n; i++)
     {
         Thread.Sleep(10);
         var item = new SalesItemViewModel(
                 order,
                 60932,
                 string.Format("AS100{0:000}", i + 1),
                 67661,
                 "Y",
                 5,
                 (i + 1),
                 "Ea",
                 "USD",
                 100003628
             );
         item.SerialNumber = "EM1234567";
         items.Add(item);
     }
     order._LoadedAll = true;
     order.RefreshStatus();
     return items;
 }
Esempio n. 22
0
 internal void MarkFileImported(SalesOrderViewModel file)
 {
     // intentionally left blank
 }
 internal SalesItemViewModel(
     SalesOrderViewModel file,
     decimal serviceRequestId, 
     string problemDescription,
     decimal inventoryItemID,
     string approvalRequiredFlag,
     decimal typeID,
     decimal quantity,
     string unit,
     string currency,
     decimal? resourceID
     )
 {
     _File = file;
     _serviceRequestId = serviceRequestId;
     ItemName = problemDescription;
     InventoryItemId = inventoryItemID;
     ApprovalRequiredFlag = approvalRequiredFlag;
     _UnitSellingPrice = typeID;
     _Quantity = quantity;
     UnitOfMeasure = unit;
     Currency = currency;
     ResourceId = resourceID;
     _Status = ImportStatus.ENTERED;
 }
Esempio n. 24
0
        internal Collection <SalesOrderViewModel> GetParentList()
        {
            Collection <SalesOrderViewModel> result = new Collection <SalesOrderViewModel>();

            if (_Model.InDesignMode)
            {
                for (int i = 1; i < 10; i++)
                {
                    string name = string.Format("Sales_Order_{0:000}", i);
                    SalesOrderViewModel order;
                    order = new SalesOrderViewModel(_Model, i, name, name, name);
                    switch (i)
                    {
                    case 1:
                        order._JobStatus = SalesOrderViewModel.JobStatus.Load;
                        break;

                    case 2:
                        order._JobStatus = SalesOrderViewModel.JobStatus.Loaded;
                        AddDummyRecords(order);
                        break;

                    case 3:
                        order._JobStatus = SalesOrderViewModel.JobStatus.ParseError;
                        break;

                    case 4:
                        order._JobStatus = SalesOrderViewModel.JobStatus.Loading;
                        break;

                    case 5:
                        order._JobStatus      = SalesOrderViewModel.JobStatus.Importing;
                        order.ProgressPercent = 50;
                        break;

                    case 6:
                        order._JobStatus      = SalesOrderViewModel.JobStatus.Done;
                        order.ProgressPercent = 100;
                        break;

                    case 7:
                        order._JobStatus      = SalesOrderViewModel.JobStatus.DoneError;
                        order.ProgressPercent = 100;
                        break;

                    case 8:
                        order._JobStatus      = SalesOrderViewModel.JobStatus.AllDone;
                        order.ProgressPercent = 100;
                        break;

                    case 9:
                        order._JobStatus      = SalesOrderViewModel.JobStatus.AllDoneError;
                        order.ProgressPercent = 100;
                        break;

                    default:
                        break;
                    }
                    order.RefreshStatus();
                    result.Add(order);
                }
            }
            else
            {
                foreach (var order in Order.GetOrdersByIncident(_Model.RntIncidentId, _Model.RntContactId))
                {
                    string name        = string.Format("Order {0}", order.HEADER_ID);
                    string description = name;
                    var    vm          = new SalesOrderViewModel(_Model, (int)order.HEADER_ID, name, name, description);
                    vm.OrderStatus = order.FLOW_STATUS_CODE;
                    vm.DateCreated = order.CREATION_DATE;
                    vm.DateUpdated = order.LAST_UPDATE_DATE;
                    result.Add(vm);
                }
            }
            return(result);
        }
Esempio n. 25
0
 internal SalesOrderViewModel GetDummyFile()
 {
     string name = string.Format("Sales_Order_{0:000}", 2);
     var file = new SalesOrderViewModel(this._Model, 2, name, name, name);
     AddDummyRecords(file);
     return file;
 }
     // load the file
 internal void loadFile(SalesOrderViewModel importFile)
 {
     importFile.Load();
 }
Esempio n. 27
0
 private void AddDummyRecords(SalesOrderViewModel importFile)
 {
     foreach (var item in GetDummyRecords(importFile))
     {
         importFile.Items.Add(item);
     }
 }
 private bool AlreadyPresent(SalesOrderViewModel file)
 {
     foreach (var f in ParentList)
     {
         if (f.FileId == file.FileId)
             return true;
     }
     return false;
 }
Esempio n. 29
0
        internal Collection<SalesItemViewModel> LoadParent(SalesOrderViewModel orderVM)
        {
            Collection<SalesItemViewModel> items = new Collection<SalesItemViewModel>();

            Order order = Order.GetOrderDetails(orderVM.HeaderId, _Model.RntIncidentId, _Model.RntContactId);
            foreach (var item in order.Items)
            {
                var itemVM = new SalesItemViewModel(
                        orderVM,
                        _Model.EbsSrId,
                        "",
                        (decimal) item.INVENTORY_ITEM_ID,
                        "Y",
                        5,
                        (decimal) item.ORDERED_QUANTITY,
                        "Ea",
                        "USD",
                        _Model.EbsOwnerId
                    );
                itemVM.UnitSellingPrice = item.UNIT_SELLING_PRICE;
                itemVM.ItemName = item.INVENTORY_ITEM;
                itemVM.LineID = (int) item.LINE_ID;
                itemVM.SerialNumber = "EM1234567";
                items.Add(itemVM);
            }
            orderVM._LoadedAll = true;
            orderVM.RefreshStatus();
            return items;
        }