Пример #1
0
        private void GrabCustomer_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            if (e.SelectedObjects.Count > 0)
            {
                if (this.GetAvailableSnatchLimit(SecuritySystem.CurrentUserName) >= e.SelectedObjects.Count)
                {
                    using (IObjectSpace os = Application.CreateObjectSpace())
                    {
                        SalesRep SR = os.FindObject <SalesRep>(new BinaryOperator("SalesRepCode", SecuritySystem.CurrentUserName.ToUpper()));
                        if (SR == null)
                        {
                            SR = os.CreateObject <SalesRep>();
                            SR.SalesRepCode = SecuritySystem.CurrentUserName;
                            os.CommitChanges();
                        }

                        foreach (CustomerRelease selectedCustomer in e.SelectedObjects)
                        {
                            CustomerRelease custr = os.GetObject <CustomerRelease>(selectedCustomer);
                            custr.AquiredBy   = SecuritySystem.CurrentUserName.ToUpper();
                            custr.AquiredDate = DateTime.Now;
                            Customer cust = os.FindObject <Customer>(new BinaryOperator("Oid", custr.Customer));

                            cust.SalesRep           = SR;
                            cust.SalesRepAssignedDt = DateTime.Now;
                        }
                        os.CommitChanges();
                        ((ListView)View).CollectionSource.Reload();
                    }
                }
            }
        }
Пример #2
0
        private void ReleaseCustomer_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            //  IObjectSpace objectSpace = Application.CreateObjectSpace();
            // SalesRep SR = objectSpace.FindObject<SalesRep>(new BinaryOperator("SalesRepCode", "GOLD MINE"));

            //            if (SR != null)
            //          {
            if (e.SelectedObjects.Count > 0)
            {
                using (IObjectSpace os = Application.CreateObjectSpace())
                {
                    SalesRep SR    = os.FindObject <SalesRep>(new BinaryOperator("SalesRepCode", "GOLD MINE"));
                    int      count = 0;
                    foreach (Customer selectedCustomer in e.SelectedObjects)
                    {
                        Customer cust = os.GetObject <Customer>(selectedCustomer);
                        cust.SalesRep = SR;

                        CustomerRelease custr = os.CreateObject <CustomerRelease>();

                        custr.Customer     = cust;
                        custr.ReleasedBy   = SecuritySystem.CurrentUserName;
                        custr.ReleasedDate = DateTime.Now;
                        custr.Customer.AddNote(custr.Customer, string.Format("Customer was released by {0}", SecuritySystem.CurrentUserName));
                        count++;
                    }
                    os.CommitChanges();
                    MessageOptions options = new MessageOptions();
                    options.Duration     = 3000;
                    options.Message      = string.Format("{0} Customers have been released!", count.ToString());
                    options.Type         = InformationType.Success;
                    options.Web.Position = InformationPosition.Right;
                    options.Win.Caption  = "Success";
                    options.Win.Type     = WinMessageType.Alert;
                    //options.OkDelegate = () => {
                    //    IObjectSpace os1 = Application.CreateObjectSpace(typeof(Customer));
                    // DetailView newTaskDetailView = Application.CreateDetailView(os1, os1.CreateObject<Customer>());
                    // Application.ShowViewStrategy.ShowViewInPopupWindow(newTaskDetailView);
                    //};
                    Application.ShowViewStrategy.ShowMessage(options);
                    View.ObjectSpace.Refresh();
                    View.Refresh();
                }
            }
        }