Ejemplo n.º 1
0
        private void ContinueButton_Click(object sender, RoutedEventArgs e)
        {
            string selectedidstring = "";
            List <PromotionPAG> promotionpagneedupdate = new List <PromotionPAG>();

            foreach (var item in (ObservableCollection <PromotionPAG>)PAGGrid.ItemsSource)
            {
                if (item.Selected) // here reuse this column to hold the selection of check box
                {
                    if (selectedidstring == "")
                    {
                        selectedidstring = item.RevisionDetailsID.ToString();
                    }
                    else
                    {
                        selectedidstring = selectedidstring + "," + item.RevisionDetailsID.ToString();
                    }
                }
                else
                {
                    if (!item.IsInMultiplePromotion)
                    {
                        promotionpagneedupdate.Add(item);
                    }
                }
            }
            RemoveParameterClass p = new RemoveParameterClass();

            p.LeftPAG = promotionpagneedupdate;
            if (selectedidstring != "")// if select any product, then get the list first then remove from screen data source
            {
                _mrsClient.GetEstimateDetailsByIDStringCompleted += delegate(object o, GetEstimateDetailsByIDStringCompletedEventArgs es2)
                {
                    if (es2.Error == null)
                    {
                        if (es2.Result != null)
                        {
                            p.RemovedPAG = es2.Result.ToList();
                            _mrsClient.DeleteMasterPromotionItemCompleted += delegate(object o2, DeleteMasterPromotionItemCompletedEventArgs es)
                            {
                                if (es.Error == null)
                                {
                                    RadWindow window = this.ParentOfType <RadWindow>();
                                    window.DataContext = p;
                                    if (window != null)
                                    {
                                        window.DialogResult = true;
                                        window.Close();
                                    }
                                }
                                else
                                {
                                    ExceptionHandler.PopUpErrorMessage(es.Error, "DeleteMasterPromotionItemCompleted");
                                }
                            };

                            _mrsClient.DeleteMasterPromotionItemAsync(pag.EstimateRevisionDetailsId.ToString(), selectedidstring, (App.Current as App).CurrentUserId);
                        }
                    }
                    else
                    {
                        ExceptionHandler.PopUpErrorMessage(es2.Error, "GetEstimateDetailsByIDStringCompleted");
                    }
                };

                _mrsClient.GetEstimateDetailsByIDStringAsync(selectedidstring);
            }
            else
            {
                p.RemovedPAG = new List <EstimateDetails>();
                _mrsClient.DeleteMasterPromotionItemCompleted += delegate(object o2, DeleteMasterPromotionItemCompletedEventArgs es)
                {
                    if (es.Error == null)
                    {
                        RadWindow window = this.ParentOfType <RadWindow>();
                        window.DataContext = p;
                        if (window != null)
                        {
                            window.DialogResult = true;
                            window.Close();
                        }
                    }
                    else
                    {
                        ExceptionHandler.PopUpErrorMessage(es.Error, "DeleteMasterPromotionItemCompleted");
                    }
                };

                _mrsClient.DeleteMasterPromotionItemAsync(pag.EstimateRevisionDetailsId.ToString(), selectedidstring, (App.Current as App).CurrentUserId);
            }
        }