示例#1
0
        public static void Show(Form mdiParent, PurOrderId orderId)
        {
            PurLineForm existingForm = FindOrder(orderId);

            if (existingForm != null)
            {
                existingForm.Activate();
                if (existingForm.WindowState == FormWindowState.Minimized)
                {
                    existingForm.WindowState = FormWindowState.Normal;
                }
                return;
            }
            PurLineForm newForm = new PurLineForm();
            PurOrder    order;

            using (Ambient.DbSession.Activate())
            {
                order            = OrderingRepositories.PurOrder.Get(orderId);
                newForm.VendorId = order.VendorId;
                Vendor vendor = OrderingRepositories.Vendor.Get(order.VendorId);
                newForm.Text = "Order: " + vendor.VendorName + " " + order.OrderDate.ToString("MM/dd/yyyy");
            }
            newForm.OrderId   = orderId;
            newForm.Order     = order;
            newForm.MdiParent = mdiParent;
            mInstances.Add(newForm);
            newForm.Show();
        }
示例#2
0
        private void btnShowOrder_Click(object sender, EventArgs e)
        {
            PurOrder order = mHelper.CurrentEntity;

            if (order.IsPersisted)
            {
                PurLineForm.Show(this.MdiParent, mHelper.CurrentEntity.Id);
            }
            else
            {
                MessageBox.Show("You cannot show order details for an order which has not been saved. " +
                                "Click on another line in the order list to save the current order.", "Cannot Show Details");
            }
        }
示例#3
0
        private void btnSetCategories_Click(object sender, EventArgs e)
        {
            PurOrder order      = mHelper.CurrentEntity;
            int      notRemoved = 0;

            if (order.IsPersisted)
            {
                using (ITranScope tran = Ambient.DbSession.CreateTranScope())
                {
                    using (Ambient.DbSession.Activate())
                    {
                        for (int index = 0; index < lstCategories.Items.Count; index++)
                        {
                            ProductCategory category = (ProductCategory)lstCategories.Items[index];
                            if (lstCategories.GetSelected(index))
                            {
                                OrderingRepositories.PurLine.AddCategory(order.Id, category.Id, chkIncludeInactive.Checked);
                            }
                            else
                            {
                                notRemoved += OrderingRepositories.PurLine.RemoveCategory(order.Id, category.Id);
                            }
                        }
                        tran.Complete();
                    }
                }
                ShowOrderCategories(order.Id);
                PurLineForm purLineForm = PurLineForm.FindOrder(order.Id);
                if (purLineForm != null)
                {
                    purLineForm.ShowLines();
                }
                if (notRemoved > 0)
                {
                    MessageBox.Show(string.Format(
                                        "Unable to remove {0} lines from order because you have used those items.", notRemoved),
                                    "Order Updated");
                }
                MessageBox.Show("Product categories updated for order.", "Order Updated");
            }
            else
            {
                MessageBox.Show("You cannot set categories on an order which has not been saved. " +
                                "Click on another line in the order list to save the current order.", "Order Not Updated");
            }
        }