Exemplo n.º 1
0
        private void btnSubPurchOrder_Click(object sender, EventArgs e)
        {
            if (InitExcel("SubPurchOrder") == false)
                return;

            UnitOfWork uow = new UnitOfWork();
            int row = 2;
            uow.BeginTransaction();

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                Customer customer = uow.FindObject<Customer>(new BinaryOperator("No", ExcelHelper.GetCellStringValue(xlSht, row, 1)));
                SubItem item = SubItem.Find(uow, ExcelHelper.GetCellStringValue(xlSht, row, 4));
                if (customer != null)
                {
                    if (item != null)
                    {
                        SubPurchOrderLine poLine = new SubPurchOrderLine(uow);
                        poLine.Customer = customer;
                        poLine.PurchOrderNo = ExcelHelper.GetCellStringValue(xlSht, row, 2);
                        poLine.LotNo = ExcelHelper.GetCellStringValue(xlSht, row, 3);
                        poLine.SubItem = item;
                        poLine.NeedDate = ExcelHelper.GetCellDateTimeValue(xlSht, row, 5);
                        poLine.NeedQty = ExcelHelper.GetCellFloatValue(xlSht, row, 6);
                        poLine.Save();

                        xlSht.Cells[row, 7] = "ok";
                    }
                    else
                    {
                        xlSht.Cells[row, 7] = "no item";
                    }
                }
                else
                {
                    xlSht.Cells[row, 7] = "no customer";
                }

                row++;
            }
            uow.CommitTransaction();
            xlWb.Save();
            ReleaseExcel();
        }
Exemplo n.º 2
0
 public void UpdateQty(SubPurchOrderLine.OrderType orderType)
 {
     foreach (SubItemSummary itemSummary in SubItemSummarys)
     {
         if (itemSummary.OrderType == orderType)
             itemSummary.UpdateQty();
     }
 }
Exemplo n.º 3
0
 public static List<SubPurchOrderLine> LoadOpenBalance(UnitOfWork uow, SubItem SubItem, 
     SubPurchOrderLine.OrderType PoType)
 {
     XPCollection<SubPurchOrderLine> PoLines = new XPCollection<SubPurchOrderLine>(uow);
     var PoList = PoLines.Where(Po => Po.SubItem.ItemNo == SubItem.ItemNo &&
                             Po.OrderStatus == PurchOrderStatus.Active &&
                             Po.PurchOrderLineType == PoType).OrderBy(Po => Po.NeedDate);
     return PoList.ToList();
 }
Exemplo n.º 4
0
        public static void IssuesPOReceiveByPurchOrder(SubItemSummary subItemSummary, SubPurchOrderLine.OrderType OrderType)
        {
            float remainQty = 0;
            float remainDefectQty = 0;
            float remainNWDefectQty = 0;

            // ���Ŀͻ�Ҫ��ֿ���Ʒ, ���ϲ���, ��������Ϊ3��.
            if (subItemSummary.CanShipQty > 0)
            {
                remainQty = subItemSummary.CanShipQty;
                remainDefectQty = 0;
                remainNWDefectQty = 0;

                SubPurchOrderReceive.IssuePOReceive(subItemSummary.SubItem, OrderType, null,
                                                    ref remainQty, ref remainDefectQty, ref remainNWDefectQty);
            }

            if (subItemSummary.CanShipDefectQty > 0)
            {
                remainQty = 0;
                remainDefectQty = subItemSummary.CanShipDefectQty;
                remainNWDefectQty = 0;

                SubPurchOrderReceive.IssuePOReceive(subItemSummary.SubItem, OrderType, null,
                                                    ref remainQty, ref remainDefectQty, ref remainNWDefectQty);
            }

            if (subItemSummary.CanShipNWDefectQty > 0)
            {
                remainQty = 0;
                remainDefectQty = 0;
                remainNWDefectQty = subItemSummary.CanShipNWDefectQty;

                SubPurchOrderReceive.IssuePOReceive(subItemSummary.SubItem, OrderType, null,
                                                    ref remainQty, ref remainDefectQty, ref remainNWDefectQty);
            }
        }
Exemplo n.º 5
0
        public static void IssuePOReceive(SubItem subItem, SubPurchOrderLine.OrderType poType, SubSalesOrderLine soLine,
                                                     ref float Qty, ref float DefectQty, ref float NWDefectQty)
        {
            UnitOfWork uow = new UnitOfWork();
            uow.BeginTransaction();
            List<SubPurchOrderLine> PoLines = SubPurchOrderLine.LoadOpenBalance(uow, subItem, poType);

            try
            {
                for (int i = 0; i < PoLines.Count; i++)
                {
                    if (Qty == 0 && DefectQty == 0 && NWDefectQty == 0)
                        break;

                    SubPurchOrderLine poLine = PoLines[i];
                    SubPurchOrderReceive poReceive = new SubPurchOrderReceive(uow);
                    poReceive.PurchOrderLine = poLine;

                    if (soLine != null)
                    {
                        poReceive.SalesOrderLine = uow.FindObject<SubSalesOrderLine>(new BinaryOperator("Oid", soLine.Oid));
                    }

                    float poBal = poLine.BalQty;
                    poReceive.Qty = UDFunction.AssignSmallQty(ref poBal, ref Qty);
                    poReceive.DefectQty = UDFunction.AssignSmallQty(ref poBal, ref DefectQty);
                    poReceive.NWDefectQty = UDFunction.AssignSmallQty(ref poBal, ref NWDefectQty);

                    poReceive.Save();
                    poReceive.Post();

                }

                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                uow.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 6
0
 public static SubItemSummary Find(Session session, string ItemNo, SubPurchOrderLine.OrderType orderType)
 {
     SubItemSummary subItemSummary = session.FindObject<SubItemSummary>(CriteriaOperator.Parse(string.Format("SubItem.ItemNo = '{0}' AND OrderType = '{1}'", ItemNo, orderType)));
     return subItemSummary;
 }