示例#1
0
        public WIPPurchOrderLine(Session session, PurchOrderLine poLine)
            : base(session)
        {
            _PurchOrderLine = poLine;
            OnChanged("PurchOrderLine");

            _Qty = poLine.BalQty + poLine.FreeSpareQty; // -poLine.PendingReceivedQty;
            OnChanged("Qty");

            _NeedQty = poLine.NeedQty + poLine.FreeSpareQty;
            OnChanged("NeedQty");

            _ReceivedQty = poLine.ReceivedQty + poLine.FreeSpareReceivedQty;
            OnChanged("ReceivedQty");
        }
示例#2
0
        public void PostPurchOrder(Session s)
        {
            if (this.NeedQty <= 0 || this.NeedDate == null || this.BomItem == null)
            {
                this._Result = ResultStatus.Error;
            }
            else
                if (this.selected && this.Result != ResultStatus.OK)
                {
                    try
                    {
                        PurchOrderLine poLine = new PurchOrderLine(Session);
                        poLine.WorkOrder = this.WorkOrder;
                        poLine.Item = this.BomItem;
                        poLine.NeedDate = this.NeedDate;
                        poLine.NeedQty = this.NeedQty;
                        poLine.FreeSpareQty = this.FreeSpareQty;

                        PriceDisc vendDisc = BomItem.GetPurchPrice(this.Vendor);

                        poLine.Price = this.Price;

                        if (vendDisc != null)
                        {
                            poLine.PriceQty = vendDisc.PriceQty;
                            poLine.PriceUnit = vendDisc.PriceUnit;
                        }
                        else
                        {
                            poLine.PriceQty = 1;
                            poLine.PriceUnit = Session.FindObject<Unit>(new BinaryOperator("UnitName", "HKD"));
                        }

                        poLine.Priority = 0;
                        poLine.Unit = this.BomItem.Unit;
                        poLine.Vendor = this.Vendor;
                        poLine.OrderType = this.WorkOrder.OrderType;
                        poLine.Warehouse = this.Warehouse;

                        if (ServerHelper.DevMode != ServerHelper.ServerDevMode.NWPRO)
                        {
                            poLine.Remark = this.WorkOrder.Remark;
                        }

                        poLine.Save();
                        this._Result = ResultStatus.OK;
                    }
                    catch
                    {
                        this._Result = ResultStatus.Error;
                    }
                }
        }
示例#3
0
        private void btnPO_Click(object sender, EventArgs e)
        {
            if (InitExcel("Purchase Order") == false)
                return;

            UnitOfWork uow = new UnitOfWork();
            PurchOrderLine poLine;
            int row = 3;
            uow.BeginTransaction();

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                poLine = new PurchOrderLine(uow);
                poLine.SetPurchOrderLineNo(ExcelHelper.GetCellStringValue(xlSht, row, 1));
                poLine.Item = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 2));
                poLine.OrderType = uow.FindObject<OrderType>(new BinaryOperator("Name", ExcelHelper.GetCellStringValue(xlSht, row, 3)));
                poLine.Vendor = uow.FindObject<Vendor>(new BinaryOperator("No", ExcelHelper.GetCellStringValue(xlSht, row, 4)));
                poLine.PriceUnit = uow.FindObject<Unit>(new BinaryOperator("UnitName", ExcelHelper.GetCellStringValue(xlSht, row, 5)));
                poLine.NeedQty = ExcelHelper.GetCellIntValue(xlSht, row, 8);
                poLine.NeedDate = ExcelHelper.GetCellDateTimeValue(xlSht, row, 9);
                poLine.Price = ExcelHelper.GetCellFloatValue(xlSht, row, 10);
                poLine.Save();
                poLine.ApproveOrder();
                poLine.IssuePurchOrder(uow);

                row++;
            }
            uow.CommitTransaction();
            ReleaseExcel();
        }
示例#4
0
 public void SetPurchOrderLine(PurchOrderLine pLine)
 {
     _PurchOrderLine = pLine;
 }
示例#5
0
        public static PurchOrderLine CreateReturnOrder(Session session, string itemNo, string vendorNo, string orderTypeName, float returnQty)
        {
            PurchOrderLine poLine = new PurchOrderLine(session);

            Item item = Item.FindItem(session, itemNo);
            Vendor vendor = Vendor.FindVendor(session, vendorNo);

            poLine.Item = item;
            poLine.NeedDate = DateTime.Today.AddDays(3);
            poLine.NeedQty = returnQty;
            poLine.Price = 0;

            PriceDisc vendDisc = item.GetPurchPrice(vendor);

            if (vendDisc != null)
            {
                poLine.PriceQty = vendDisc.PriceQty;
                poLine.PriceUnit = vendDisc.PriceUnit;
            }
            else
            {
                poLine.PriceQty = 1;
                poLine.PriceUnit = Unit.FindUnit(session, "HKD");
            }

            poLine.Priority = 0;
            poLine.Unit = item.Unit;
            poLine.Vendor = vendor;

            OrderType orderType = OrderType.FindOrderType(session, orderTypeName);
            poLine.OrderType = orderType ;
            poLine.Warehouse = orderType.WareHouse;
            poLine.SetReturnOrder();
            poLine.Save();

            return poLine;
        }
示例#6
0
        public void CreatePurchaseOrder(UnitOfWork uow)
        {
            if (bomItem.MainVendor == null)
            {
                throw new Exception(string.Format("此產品({0})沒有設定主供應商", bomItem.ItemNo));
            }
            PriceDisc priceDisc = null;

            foreach (PriceDisc pDisc in bomItem.PriceDiscs)
            {
                if (pDisc.Type == PriceDisc.PriceType.Purch &&  bomItem.MainVendor == (Vendor)pDisc.ExternalContact)
                {
                    priceDisc = pDisc;
                    break;
                }
            }

            if (priceDisc == null)
            {
                foreach (PriceDisc pDisc in bomItem.PriceDiscs)
                {
                    if (pDisc.Type == PriceDisc.PriceType.Purch)
                    {
                        priceDisc = pDisc;
                        break;
                    }
                }
            }

            if (priceDisc == null)
            {
                throw new Exception(string.Format("此产品({0})没有设定采购资料", bomItem.ItemNo));
            }
            PurchOrderLine newPurchOrderLine = new PurchOrderLine(uow);

            newPurchOrderLine.Item = bomItem;
            newPurchOrderLine.NeedDate = ProdOrder.NeedDate;
            newPurchOrderLine.Priority = ProdOrder.Priority;
            newPurchOrderLine.Warehouse = Warehouse;
            newPurchOrderLine.Vendor = bomItem.MainVendor;
            newPurchOrderLine.VendorItemNo = priceDisc.ExternalNo;
            newPurchOrderLine.Unit = Unit;
            newPurchOrderLine.PriceQty = priceDisc.PriceQty;
            newPurchOrderLine.Price = priceDisc.Price;
            newPurchOrderLine.PriceUnit = priceDisc.PriceUnit;
            newPurchOrderLine.NeedQty = RecommendQty;
            newPurchOrderLine.Save();

            _RefNo = newPurchOrderLine.PurchOrderNo;
            _RefType = ReferenceType.Purch;
            //_RefOid = newPurchOrderLine;
            //OnChanged("RefOid");

            OnChanged("RefNo");
            OnChanged("RefType");
            this.Save();
        }
示例#7
0
        public void ImportHKIPO()
        {
            string ipoPath = "http://nwszmail/public/namwah/WorkOrders/Purchasing/InternalPurchaseOrders";
            string strSQL = "";

            ADODB.Connection cnn = new ADODB.Connection();
            ADODB.Recordset rst = new ADODB.Recordset();
            Item item;
            PurchOrderLine poLine;
            WorkOrder wo;

            string partNo;
            string woNo;
            string ipoNo;

            session.BeginTransaction();

            CacheItem();
            CacheWo();
            CacheIpo();

            ConnectDB(cnn, ipoPath);

            strSQL = "SELECT \"nw:partno\" , \"nw:partname\", \"nw:parttype\", \"nw:wo:no\", \"nw:supplier\",  ";
            strSQL = strSQL + " \"nw:jo:needqty\", \"nw:jo:needdate\", \"nw:jo:arrivedqty\", \"nw:jo:no\" ";
            strSQL = strSQL + " FROM \"" + ipoPath;
            strSQL = strSQL + "\" WHERE (\"DAV:ishidden\" = false)";

            rst.Open(strSQL, cnn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockBatchOptimistic, 1);

            while (!rst.EOF)
            {
                partNo = rst.Fields["nw:partno"].Value.ToString();
                woNo = rst.Fields["nw:wo:no"].Value.ToString();
                ipoNo = rst.Fields["nw:jo:no"].Value.ToString();

                if (dictPoLine.ContainsKey(ipoNo))
                {
                    PurchOrderLine oldPoLine = dictPoLine[ipoNo];

                    if (oldPoLine.NeedQty != float.Parse(rst.Fields["nw:jo:needqty"].Value.ToString()) ||
                    oldPoLine.ReceivedQty != float.Parse(rst.Fields["nw:jo:arrivedqty"].Value.ToString()))
                    {
                        oldPoLine.NeedQty = float.Parse(rst.Fields["nw:jo:needqty"].Value.ToString());
                        oldPoLine.SetReceivedQty(float.Parse(rst.Fields["nw:jo:arrivedqty"].Value.ToString()));
                        oldPoLine.Save();
                    }
                }
                else
                {
                    if (dictItem.ContainsKey(partNo) && dictWo.ContainsKey(woNo))
                    {
                        item = dictItem[partNo];
                        wo = dictWo[woNo];

                        poLine = new PurchOrderLine(session);
                        poLine.WorkOrder = wo;
                        poLine.Item = item;
                        poLine.SetPurchOrderLineNo(ipoNo);
                        poLine.NeedDate = DateTime.Parse(rst.Fields["nw:jo:needdate"].Value.ToString());
                        poLine.NeedQty = float.Parse(rst.Fields["nw:jo:needqty"].Value.ToString());
                        poLine.Vendor = GetVendor(rst.Fields["nw:supplier"].Value.ToString());
                        poLine.SetReceivedQty(float.Parse(rst.Fields["nw:jo:arrivedqty"].Value.ToString()));
                        poLine.Unit = item.Unit;
                        poLine.Warehouse = item.Warehouse;
                        poLine.Save();
                    }
                }
                rst.MoveNext();
            }

            session.CommitTransaction();
        }
示例#8
0
        public void SetPurchOrderLine(PurchOrderLine pLine)
        {
            _PurchOrderLine = pLine;

            if (PurchOrderLine != null)
                _PoItem = PurchOrderLine.Item;
        }
示例#9
0
        public void IssuePurchOrderLine()
        {
            PurchOrderLine poLine = new PurchOrderLine(Session);
            Vendor vendor = this.Item.MainVendor;

            if (vendor == null)
            {
                throw new Exception(string.Format("补料单 {0}. {1}此产品({2})没有预设的供应商资料, 所以不能发采购单", this.OrderNo, Environment.NewLine, Item.ItemNo));
            }

            poLine.WorkOrder = this.WorkOrder;
            poLine.Item = this.Item;
            poLine.NeedDate = this.NeedDate;
            poLine.NeedQty = this.NeedQty;

            if (vendor.FreeSpareRate > 0)
                poLine.FreeSpareQty = (this.NeedQty * vendor.FreeSpareRate) / 100;
            else
                poLine.FreeSpareQty = 0;

            PriceDisc vendDisc = Item.GetPurchPrice(vendor);

            if (vendDisc != null)
            {
                poLine.Price = vendDisc.Price;
                poLine.PriceQty = vendDisc.PriceQty;
                poLine.PriceUnit = vendDisc.PriceUnit;
            }

            poLine.Priority = 0;
            poLine.Unit = Item.Unit;
            poLine.Vendor = vendor;
            poLine.Warehouse = Item.Warehouse;
            poLine.OrderType = OrderType;
            poLine.ReplenishOrder = this;
            poLine.Save();

            _PurchOrderLine = poLine;
            OnChanged("PurchOrderLine");

            _Status = ReplenishStatus.Complete;
            OnChanged("Status");
            Save();
        }