Beispiel #1
0
        private void CreateProdOrderEntry(UnitOfWork uow)
        {
            SubProdOrder prodOrder = new SubProdOrder(uow);
            SubItem subItem = uow.FindObject<SubItem>(new BinaryOperator("Oid", poLine.SubItem.Oid));

            prodOrder.ProdOrderType = poLine.PurchOrderLineType;
            prodOrder.SubItem = subItem;
            prodOrder.Qty = float.Parse(txtDefectQty.Text);
            prodOrder.OrderStatus = SubProdOrder.ProdOrderStatus.Active;
            prodOrder.Save();

            SubProdOrderReceive prodOrderReceive = new SubProdOrderReceive(uow);
            prodOrderReceive.SubProdOrder = prodOrder;
            prodOrderReceive.DefectQty = prodOrder.Qty;
            prodOrderReceive.Save();
            prodOrderReceive.Post();
        }
        private void IssueSubConProdOrder()
        {
            UnitOfWork uow = new UnitOfWork();
            Dictionary<string, float> dictDeductQty = new Dictionary<string, float>();  // �ѷ���������
            Dictionary<string , float> dictIssueQty = new Dictionary<string , float>();
            SubItem.SubItemType subItemType = SubItem.SubItemType.Subcon;

            float prodQty = 1000;
            float maxShtQty = 10;
            float shtQty = 0;

            #region   ��ȡ��������������
            SubItemSetting itemSetting = SubItemSetting.GetInstance(uow, subItemType);

            if (itemSetting != null)
            {
                prodQty = itemSetting.DefaultProdQty;
                maxShtQty = itemSetting.DefaultMaxProdShtQty;
            }

            uow = null;

            try
            {
                shtQty = float.Parse(Microsoft.VisualBasic.Interaction.InputBox(string.Format("������Ҫ��������������, Ԥ��ÿ������������Ϊ{0}\n����0��ȡ������", prodQty), "��������", "0", 0, 0));

                if (shtQty > maxShtQty)
                {
                    XtraMessageBox.Show(string.Format("��������({0})���������Է�������({1})", shtQty, maxShtQty), "����", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("������������������ !!!");
                return;
            }

            #endregion

            try
            {
                if (shtQty > 0)
                {
                    for (int i = 0; i < shtQty; i++)
                    {
                        uow = new UnitOfWork();

                        dictIssueQty.Clear();
                        dictDeductQty.Clear();

                        XPCollection<SubPurchOrderLine> poLines = new XPCollection<SubPurchOrderLine>(uow);
                        SortingCollection sortProps;
                        sortProps = new SortingCollection(null);
                        sortProps.Add(new SortProperty("PurchOrderLineType", SortingDirection.Descending ));
                        sortProps.Add(new SortProperty("NeedDate", SortingDirection.Ascending));
                        sortProps.Add(new SortProperty("SubItem", SortingDirection.Ascending));
                        poLines.Criteria = CriteriaOperator.Parse(string.Format("OrderStatus == '{0}'AND SubItem.ItemType == '{1}' ", SubPurchOrderLine.PurchOrderStatus.Active, subItemType));
                        poLines.Sorting = sortProps;

                        uow.BeginTransaction();
                        float tmpProdQty = prodQty;

                        foreach (SubPurchOrderLine poLine in poLines)
                        {
                            float deductQty = 0;
                            float issueQty = 0;
                            string key = poLine.SubItem.ItemNo + "_" + poLine.PurchOrderLineType.ToString();

                            if (dictDeductQty.ContainsKey(key))  // Ҫ��ȥ�ѷ���������
                            {
                                deductQty = dictDeductQty[key];
                                dictDeductQty.Remove(key);
                            }
                            else
                            {
                                // TODO
                                SubItemSummary itemSummary = SubItemSummary.Find(uow, poLine.SubItem.ItemNo, poLine.PurchOrderLineType);

                                deductQty = itemSummary.ProdOrderBalQty + itemSummary.CanShipQty + itemSummary.CanShipDefectQty + itemSummary.CanShipNWDefectQty;
                                //deductQty = poLine.SubItem.ProdOrderBalQty + poLine.SubItem.CanShipQty + poLine.SubItem.CanShipDefectQty + poLine.SubItem.CanShipNWDefectQty;
                            }

                            if (poLine.BalQty <= deductQty)
                            {
                                deductQty = deductQty - poLine.BalQty;
                            }
                            else
                            {
                                issueQty = poLine.BalQty - deductQty;
                                deductQty = 0;
                            }

                            if (issueQty > 0)
                            {
                                if (tmpProdQty > issueQty)
                                {
                                    tmpProdQty = prodQty - issueQty;
                                }
                                else
                                {
                                    issueQty = tmpProdQty;
                                    tmpProdQty = 0;
                                }

                                // Ҫ�������� / �˻�
                                if (dictIssueQty.ContainsKey(key))
                                {
                                    dictIssueQty[key] = dictIssueQty[key] + issueQty;
                                }
                                else
                                {
                                    dictIssueQty.Add(key, issueQty);
                                }

                                if (tmpProdQty == 0)
                                    break;
                            }

                            dictDeductQty.Add(key, deductQty);
                        }

                        foreach (KeyValuePair<string , float> issue in dictIssueQty)
                        {
                            SubProdOrder prodOrder = new SubProdOrder(uow);
                            string[] key = issue.Key.Split('_') ;
                            string itemNo = key[0];
                            string orderType = key[1];

                            prodOrder.SubItem = SubItem.Find(uow, itemNo);

                            if (orderType == "Return")
                                prodOrder.ProdOrderType = SubPurchOrderLine.OrderType.Return;
                            else
                                prodOrder.ProdOrderType = SubPurchOrderLine.OrderType.Normal;

                            prodOrder.Qty = issue.Value;
                            prodOrder.Save();
                        }

                        uow.CommitChanges();
                    }
                }

                View.ObjectSpace.Refresh();
            }
            catch
            {
                uow.RollbackTransaction();
                XtraMessageBox.Show("ϵͳ���ⲻ�ܷ���, ���˳����� !!!");
            }
        }
Beispiel #3
0
        private void btnSubProdOrder_Click(object sender, EventArgs e)
        {
            if (InitExcel("SubProdOrder") == false)
                return;

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

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                SubItem item = SubItem.Find(uow, ExcelHelper.GetCellStringValue(xlSht, row, 2));

                if (item != null)
                {
                    SubProdOrder prodOrder = new SubProdOrder(uow);
                    prodOrder.SetOrderNo(ExcelHelper.GetCellStringValue(xlSht, row, 1));
                    prodOrder.SubItem = item;
                    prodOrder.Date = ExcelHelper.GetCellDateTimeValue(xlSht, row, 3);
                    prodOrder.Qty = ExcelHelper.GetCellFloatValue(xlSht, row, 4);
                    prodOrder.Save();
                }
                else
                {
                    xlSht.Cells[row, 5] = "no item";
                }

                row++;
            }
            uow.CommitTransaction();
            xlWb.Save();
            ReleaseExcel();
        }