Esempio n. 1
0
        public async void CompletedSettings()
        {
            PredictionWeek.Text = CurrentWeek();

            YearList      = FindTemplateElementByName <Picker>(this, "YearList");
            Activity      = FindTemplateElementByName <ActivityIndicator>(this, "Activity");
            SearchResults = FindTemplateElementByName <ResultsList>(this, "SearchResults");
            SearchResults.NavigationParent = this;

            SeasonList.Clear();
            Highlights.Clear();
            foreach (Year y in NetworkDatabase.YearList)
            {
                SeasonList.Add(y);
            }


            YearList.BindingContext = this;
            if (YearList.SelectedIndex == -1)
            {
                YearList.BindingContext = null;
                YearList.BindingContext = this;
            }

            YearList.IsVisible = true;
            //YearList.SelectedIndexChanged += YearList_SelectedIndexChanged;
            NetworkDatabase.CurrentYearUpdated += NetworkDatabase_CurrentYearUpdated;



            PredictionYear.Text = NetworkDatabase.YearList[NetworkDatabase.YearList.Count - 1].Season + " Predictions";

            CurrentStatus.IsVisible = false;

            LoadHighlights();

            Activity.IsRunning = false;
            Activity.IsVisible = false;
            UseMenu.IsVisible  = true;

            CurrentStatus.FormattedText = await FetchLabels();

            //if (Highlights.Count > 0)
            //{
            //    HighlightsTitle.IsVisible = true;
            //    ViewPost.IsVisible = true;
            //    TMDBNotice.IsVisible = true;
            //}
            //else
            //    CurrentStatus.IsVisible = true;

            Completed = true;
        }
Esempio n. 2
0
        public TradeAgreementViewModel() : base(PermissionItemName.TradeAgreementFabricView)
        {
            // ده هيحتاج تعديل
            productionServiceClient.GetTblTradeAgreementDetailListFabricViewCompleted += (s, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TradeAgreementDetailModel();
                    newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial;
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.ColorPerRow   = new CRUDManagerService.TblColor();
                    if (row.TblColor1 != null)
                    {
                        newrow.ColorPerRow.InjectFrom(row.TblColor1);
                    }
                    newrow.ItemPerRow = new CRUDManagerService.ItemsDto();
                    newrow.ItemPerRow.InjectFrom(sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType));
                    newrow.ItemType     = row.ItemType;
                    newrow.VendorPerRow = new CRUDManagerService.Vendor {
                        vendor_code = row.TblTradeAgreementHeader1.Vendor
                    };
                    newrow.VendorPurchaseGroupPerRow = new CRUDManagerService.GenericTable();
                    newrow.VendorPerRow.InjectFrom(sv.VendorList.FirstOrDefault(x => x.vendor_code == row.TblTradeAgreementHeader1.Vendor));
                    if (row.TblVendorPurchaseGroup1 != null)
                    {
                        newrow.VendorPurchaseGroupPerRow.InjectFrom(row.TblVendorPurchaseGroup1);
                    }
                    newrow.TradeAgreementTransactionIserial = row.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value;
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.InjectFrom(row);
                    SelectedMainRow.DetailsList.Insert(0, newrow);
                }

                Loading = false;

                if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                {
                    AddNewDetailRow(false);
                }
                if (Export)
                {
                    Export = false;
                    ExportGrid.ExportExcel("TradeAgreement");
                }
            }
            ;
            calculationClient.GetGenericCompleted += (s, sv) =>
            {
                VendorPurchaseGroupList = sv.Result;
            };

            Client.GetAxCurrencyAsync("CCM");
            Client.GetAxCurrencyCompleted += (s, sv) =>
            {
                AxCurrencyList = sv.Result;
            };
            Client.SearchForColorCompleted += (s, sv) =>
            {
                if (sv.Error != null)
                {
                    return;
                }

                SelectedDetailRow.Colors = sv.Result;
            };

            var currentUi = Thread.CurrentThread.CurrentUICulture;

            productionServiceClient.GetTblTradeAgreementDetailListCompleted += (d, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TradeAgreementDetailModel();
                    newrow.InjectFrom(row);
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial;
                    newrow.ColorPerRow = new CRUDManagerService.TblColor();
                    if (row.TblColor1 != null)
                    {
                        newrow.ColorPerRow.InjectFrom(row.TblColor1);
                    }
                    newrow.TblColor   = row.TblColor;
                    newrow.ItemPerRow = new CRUDManagerService.ItemsDto();
                    var itemsDto = sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType);
                    if (itemsDto != null)
                    {
                        newrow.ItemPerRow.InjectFrom(itemsDto);
                    }
                    newrow.ItemCode = row.ItemCode;
                    newrow.ItemType = row.ItemType;
                    newrow.FromDate = row.TblTradeAgreementHeader1.FromDate;
                    newrow.ToDate   = row.TblTradeAgreementHeader1.ToDate;
                    newrow.VendorPurchaseGroupPerRow = VendorPurchaseGroupList.FirstOrDefault(vpg => vpg.Iserial == newrow.TblVendorPurchaseGroup);
                    newrow.VendorPerRow = new CRUDManagerService.Vendor();
                    newrow.VendorPerRow.InjectFrom(sv.vendorsList.FirstOrDefault(v => v.vendor_code == row.TblTradeAgreementHeader1.Vendor));
                    newrow.Vendor = row.TblTradeAgreementHeader1.Vendor;
                    SelectedMainRow.DetailsList.Add(newrow);
                }

                Loading         = false;
                DetailFullCount = sv.fullCount;
                if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                {
                    AddNewDetailRow(false);
                }
            };

            productionServiceClient.UpdateOrInsertTblTradeAgreementDetailCompleted += (s, x) =>
            {
                var savedRow = SelectedMainRow.DetailsList.ElementAtOrDefault(x.outindex);

                if (savedRow != null)
                {
                    savedRow.InjectFrom(x.Result);
                }
            };

            productionServiceClient.GetTblTradeAgreementTransactionCompleted += (d, s) =>
            {
                foreach (var variable in s.Result)
                {
                    var newrow = new TradeAgreementTransaction();
                    newrow.InjectFrom(variable);
                    MainRowList.Add(newrow);
                }
                Loading   = false;
                FullCount = s.fullCount;
                if (SearchWindow != null)
                {
                    SearchWindow.FullCount = s.fullCount;
                    SearchWindow.Loading   = false;
                }
                if (FullCount == 0 && MainRowList.Count == 0)
                {
                    AddNewMainRow(true);
                }
            };

            productionServiceClient.DeleteTblTradeAgreementDetailCompleted += (s, ev) =>
            {
                Loading = false;
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);

                if (oldrow != null)
                {
                    SelectedMainRow.DetailsList.Remove(oldrow);
                }
            };

            productionServiceClient.SaveTradeAgreementCompleted += (s, sv) =>
            {
                if (SelectedMainRow == null)
                {
                    SelectedMainRow = new TradeAgreementTransaction();
                }
                SelectedMainRow.InjectFrom(sv.savedHeader);
                SelectedMainRow.TblLkpSeason  = sv.savedHeader.TblLkpSeason;
                SelectedMainRow.TblLkpSeason1 = SeasonList.FirstOrDefault(r => r.Iserial == SelectedMainRow.TblLkpSeason);
                //SelectedMainRow.DetailsList.Clear();
                foreach (var item in SelectedMainRow.DetailsList)
                {
                    var newRow = sv.Result.FirstOrDefault(d => d.ItemCode == item.ItemCode && d.TblColor == item.TblColor &&
                                                          d.TblTradeAgreementHeader == item.HeaderIserial && d.AccSize == item.AccSize);
                    if (newRow != null)
                    {
                        item.Iserial       = newRow.Iserial;
                        item.HeaderIserial = newRow.TblTradeAgreementHeader;
                        item.TradeAgreementTransactionIserial = newRow.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value;
                    }
                }
                RaisePropertyChanged(nameof(IsHeaderSaved));
                MessageBox.Show(strings.Saved);
                Loading = true;
            };
            productionServiceClient.DeleteTradeAgreementHeaderCompleted += (d, s) =>
            {
                SelectedMainRow = new TradeAgreementTransaction();

                if (currentUi.DisplayName == "العربية")
                {
                    MessageBox.Show("Deleted");
                }
                else
                {
                    MessageBox.Show("Deleted");
                }
            };
            // ده هيحتاج تعديل
            LoadingDetail = new RelayCommand <DataGridRowEventArgs>((e) =>
            {
                if (SelectedMainRow.DetailsList.Count < PageSize)
                {
                    return;
                }
                if (SelectedMainRow.DetailsList.Count - 2 < e.Row.GetIndex() && SelectedMainRow.DetailsList.Count < DetailFullCount &&
                    !Loading)
                {
                    string size = null, vendor = null, color = null, ItemType = null, ItemCode = null;
                    string key  = "AccSize";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "Vendor";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }

                    key = "Color";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "ItemType";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "ItemCode";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value);
                    }
                    productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync(
                        SelectedMainRow.DetailsList.Count, PageSize, SelectedMainRow.Iserial, ItemCode,
                        color, size, vendor, ItemType);
                }
            });
            // ده هيحتاج تعديل
            FilterCommand = new RelayCommand <FilterEvent>((e) =>
            {
                SelectedMainRow.DetailsList.Clear();

                valueObjecttemp.Clear();

                foreach (var f in e.FiltersPredicate)
                {
                    valueObjecttemp.Add(f.FilterColumnInfo.PropertyPath, f.FilterText);
                }

                string size = null, vendor = null, color = null, ItemType = null, ItemCode = null;
                string key  = "AccSize";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "Vendor";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }

                key = "Color";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "ItemType";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "ItemCode";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value);
                }
                productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync(
                    0, PageSize, SelectedMainRow.Iserial, ItemCode, color, size, vendor, ItemType);
            });
            NewDetail = new RelayCommand <KeyEventArgs>((e) =>
            {
                if (e.Key == Key.Down)
                {
                    //var currentRowIndex = (SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow));
                    //if (currentRowIndex == (SelectedMainRow.DetailsList.Count - 1))
                    //{
                    //    AddNewDetailRow(true);
                    //}
                }
            });
            DeleteDetail = new RelayCommand <KeyEventArgs>((e) =>
            {
                if (e.Key == Key.Delete)
                {
                    var DetailGrid = e.OriginalSource as OsGrid;
                    SelectedDetailRows.Clear();
                    foreach (var row in DetailGrid.SelectedItems)
                    {
                        SelectedDetailRows.Add(row as TradeAgreementDetailModel);
                    }
                    DeleteDetailRow();
                }
            });
            SaveDetail = new RelayCommand <DataGridRowEditEndedEventArgs>((e) => { SaveDetailRow(); });
            Client.GetAllSeasonsCompleted += (s, e) =>
            {
                SeasonList.Clear();
                foreach (var row in e.Result)
                {
                    TblLkpSeason temp = new TblLkpSeason();
                    temp.InjectFrom(row);
                    SeasonList.Add(temp);
                }
            };

            AddNewMainRow(false);
            GetComboData();
            GetMaindata();
        }