Exemple #1
0
        private BindingList<ProdOrderP> CalcProdOrderPs(Session session)
        {
            UnitOfWork uow = (UnitOfWork)session;

            Vendor vendor = session.FindObject<Vendor>(new BinaryOperator("No", "NWC"));
            WareHouse defaultWH = session.FindObject<WareHouse>(CriteriaOperator.Parse("WarehouseName == 'KP'"));

            XPClassInfo poLineClass;
            CriteriaOperator criteria;
            SortingCollection sortProps;

            poLineClass = uow.GetClassInfo(typeof(PurchOrderLine));
            criteria = CriteriaOperator.Parse(string.Format("Vendor.Oid = '{0}' AND OrderStatus = '{1}' ", vendor.Oid, PurchOrderLine.PurchOrderStatus.Active));
            sortProps = new SortingCollection(null);
            sortProps.Add(new SortProperty("NeedDate", SortingDirection.Descending));
            ICollection poLines = uow.GetObjects(poLineClass, criteria, sortProps, int.MaxValue, false, true);

            BindingList<ProdOrderP> ProdOrderPs = new BindingList<ProdOrderP>();
            Dictionary<string, float> dictWHQty = new Dictionary<string, float>();
            Dictionary<string, float> dictProdOrderQty;

            dictProdOrderQty = GetDictProdOrderQty(uow);

            // dictProdOrderQty.Add(WorkCenterNo-PartNo-Status)

            foreach (PurchOrderLine poLine in poLines)
            {
                ProdOrderP pop = new ProdOrderP(uow);
                pop.SetDefaultWH(defaultWH);
                pop.SetPurchOrderLine(poLine);
                pop.SetupRouteList();
                pop.SetDictWH(dictWHQty);
                pop.SetDictProdOrderQty(dictProdOrderQty);
                pop.CalcNeed();
                ProdOrderPs.Add(pop);
            }

            return ProdOrderPs;
        }
        private void ProdOrderP_View_ViewControlsCreated(object sender, EventArgs e)
        {
            detailView = (DetailView)View;
            prodOrderP = (ProdOrderP)detailView.CurrentObject;

            foreach (ControlDetailItem cdi in detailView.GetItems<ControlDetailItem>())
            {
                switch (cdi.Id)
                {
                    case "btnOK":
                        btnOK = (SimpleButton)cdi.Control;
                        btnOK.Text = "出單";
                        btnOK.Click += new EventHandler(btnOK_Click);
                        break;
                    case "btnClose":
                        btnClose = (SimpleButton)cdi.Control;
                        btnClose.Text = "取消";
                        btnClose.Click += new EventHandler(btnClose_Click);
                        break;
                    case "txtAvailQty":
                        txtAvailQty = (TextEdit)cdi.Control;
                        txtAvailQty.Enabled = false;
                        break;
                    case "txtDailyQty":
                        txtDailyQty = (TextEdit)cdi.Control;
                        txtDailyQty.Enabled = false;
                        break;
                    case "txtMachine":
                        txtMachine = (TextEdit)cdi.Control;
                        break;
                    case "txtNeedQty":
                        txtNeedQty = (SpinEdit)cdi.Control;
                        break;
                    case "txtPartName":
                        txtPartName = (TextEdit)cdi.Control;
                        txtPartName.Enabled = false;
                        break;
                    case "txtPartNo":
                        txtPartNo = (TextEdit)cdi.Control;
                        txtPartNo.Enabled = false;
                        break;
                    case "txtResName":
                        txtResName = (TextEdit)cdi.Control;
                        txtResName.Enabled = false;
                        break;
                    case "txtResNo":
                        txtResNo = (TextEdit)cdi.Control;
                        txtResNo.Enabled = false;
                        break;
                    case "txtLackQty":
                        txtLackQty = (TextEdit)cdi.Control;
                        txtLackQty.Enabled = false;
                        break;
                    case "cboWorkOper":
                        cboWorkOper = (ComboBoxEdit)cdi.Control;
                        cboWorkOper.SelectedValueChanged += new EventHandler(cboWorkOper_SelectedValueChanged);
                        break;
                    case "datNeedDate":
                        datNeedDate = (DateEdit)cdi.Control;
                        break;
                }
            }

            initComboBox();
        }