Exemplo n.º 1
0
        private void ImportSalesOrder()
        {
            UnitOfWork uow = new UnitOfWork();
            SalesOrder so;
            int row = 3;

            uow.BeginTransaction();

            while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "")
            {
                so = uow.FindObject<SalesOrder>(new BinaryOperator("OrderNo", ExcelHelper.GetCellStringValue(xlSht, row, 1)));

                if (so == null)
                {
                    so = new SalesOrder(uow);
                    so.OrderNo = ExcelHelper.GetCellStringValue(xlSht, row, 1);
                    so.Customer = uow.FindObject<Customer>(new BinaryOperator("No", ExcelHelper.GetCellStringValue(xlSht, row, 2)));
                    so.OrderType = SalesOrder.SalesOrderType.Normal;
                    so.PoDate = ExcelHelper.GetCellDateTimeValue(xlSht, row, 4);
                    so.Save();
                    uow.CommitChanges();
                }

                row++;
            }

            uow.CommitTransaction();
        }
Exemplo n.º 2
0
        public static SalesOrder Create(string orderNo, Customer customer, Session session)
        {
            SalesOrder so = session.FindObject<SalesOrder>(new BinaryOperator("OrderNo", orderNo));

            if (so == null)
            {
                so = new SalesOrder(session);
                so.OrderNo = orderNo;
                so.Customer = customer;
                so.Save();
            }
            return so;
        }
Exemplo n.º 3
0
        public void ImportSalesOrder()
        {
            string soPath = "http://nwszmail/public/namwah/Sales/Timex/PurchaseOrders/";
            string strSQL = "";

            Dictionary<string, SalesOrder> dictSo = new Dictionary<string, SalesOrder>();

            ADODB.Connection cnn = new ADODB.Connection();
            ADODB.Recordset rst = new ADODB.Recordset();
            Item item;

            /*
            XPCollection<SalesOrderLine> soLines = new XPCollection<SalesOrderLine>(session);
            session.BeginTransaction();
            session.Delete(soLines);
            session.CommitTransaction();

            return;
            */

            string partNo;
            string soLineIndex;

            CacheItem();
            CacheSalesOrderLine(Namwah.Module.BO.SalesOrder.SalesOrderType.Normal);

            ConnectDB(cnn, soPath);

            strSQL = "SELECT \"nw:partno\" , \"nw:cpo:item:ignore\", \"nw:cpo:item:index\", \"nw:cpo:item:initneeddate\", \"nw:cpo:date\" ";
            strSQL = strSQL + " , \"nw:cpo:item:needqty\", \"nw:cpo:item:needdate\", \"nw:cpo:item:priority\", \"nw:cpo:item:shippedqty\" ";
            strSQL = strSQL + " , \"nw:cpo:item:remark\", \"nw:cpo:no\", \"nw:customer\", \"nw:part:tmxrefno\" ";
            strSQL = strSQL + " FROM \"" + soPath;
            strSQL = strSQL + "\" WHERE (\"DAV:ishidden\" = false AND \"nw:customer\" = 'Timex' )";
            return ;
            rst.Open(strSQL, cnn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockBatchOptimistic, 1);

            session.BeginTransaction();
            DateTime sTime = DateTime.Now;
            string poNo;

            while (!rst.EOF)
            {
                partNo = rst.Fields["nw:partno"].Value.ToString();
                soLineIndex = rst.Fields["nw:cpo:no"].Value.ToString() + "-" + rst.Fields["nw:cpo:item:index"].Value.ToString();
                poNo = rst.Fields["nw:cpo:no"].Value.ToString();

                if (poNo.StartsWith("PoHistory") == false)
                {
                    if (dictItem.ContainsKey(partNo))
                    {
                        if (dictSalesOrderLine.ContainsKey(soLineIndex))
                        {
                            SalesOrderLine soLine = dictSalesOrderLine[soLineIndex];

                            soLine.NeedQty = float.Parse(rst.Fields["nw:cpo:item:needqty"].Value.ToString());
                            soLine.Priority = int.Parse(rst.Fields["nw:cpo:item:priority"].Value.ToString());
                            soLine.NeedQty = float.Parse(rst.Fields["nw:cpo:item:needqty"].Value.ToString());
                            soLine.SetShipQty(float.Parse(rst.Fields["nw:cpo:item:shippedqty"].Value.ToString()));
                            soLine.Save();
                        }
                        else
                        {
                            item = dictItem[partNo];
                            SalesOrder so;

                            if (dictSo.ContainsKey(rst.Fields["nw:cpo:no"].Value.ToString()))
                            {
                                so = dictSo[rst.Fields["nw:cpo:no"].Value.ToString()];
                            }
                            else
                            {
                                so = session.FindObject<SalesOrder>(new BinaryOperator("OrderNo", rst.Fields["nw:cpo:no"].Value.ToString()));

                                if (so == null)
                                {
                                    so = new SalesOrder(session);
                                    so.SetOrderNo(rst.Fields["nw:cpo:no"].Value.ToString());
                                    so.Customer = GetCustomer(rst.Fields["nw:customer"].Value.ToString());
                                    so.Save();
                                }
                                dictSo.Add(rst.Fields["nw:cpo:no"].Value.ToString(), so);
                            }

                            SalesOrderLine soLine = new SalesOrderLine(session);
                            soLine.SalesOrder = so;
                            soLine.Item = item;
                            soLine.SetOrderLineNo(int.Parse(rst.Fields["nw:cpo:item:index"].Value.ToString()));
                            soLine.CustomerItemNo = rst.Fields["nw:part:tmxrefno"].Value.ToString();
                            soLine.CustomerOrderNo = rst.Fields["nw:cpo:no"].Value.ToString();
                            if (rst.Fields["nw:cpo:item:ignore"].Value.ToString() != "")
                                soLine.IgnorePlanningReport = bool.Parse(rst.Fields["nw:cpo:item:ignore"].Value.ToString());

                            if (rst.Fields["nw:cpo:item:initneeddate"].Value.ToString() != "")
                                soLine.InitNeedDate = DateTime.Parse(rst.Fields["nw:cpo:item:initneeddate"].Value.ToString());

                            soLine.NeedDate = DateTime.Parse(rst.Fields["nw:cpo:item:needdate"].Value.ToString());
                            soLine.NeedQty = float.Parse(rst.Fields["nw:cpo:item:needqty"].Value.ToString());
                            soLine.PoDate = DateTime.Parse(rst.Fields["nw:cpo:date"].Value.ToString());
                            soLine.Priority = int.Parse(rst.Fields["nw:cpo:item:priority"].Value.ToString());
                            soLine.SetShipQty(float.Parse(rst.Fields["nw:cpo:item:shippedqty"].Value.ToString()));
                            soLine.ApprovedSalesOrderLine();
                            soLine.Save();
                        }
                    }
                }
                rst.MoveNext();
            }

            System.Diagnostics.Debug.WriteLine("Start Time : " + sTime.ToString() + ".  End Time : " + DateTime.Now.ToString());
            session.CommitTransaction();
            System.Diagnostics.Debug.WriteLine("Commit Time : " + DateTime.Now.ToString());
        }
Exemplo n.º 4
0
        public void ImportSSTK()
        {
            string soPath = "http://nwszmail/public/namwah/Parts2/SafetyStock/";
            string strSQL = "";

            Dictionary<string, SalesOrder> dictSo = new Dictionary<string, SalesOrder>();

            ADODB.Connection cnn = new ADODB.Connection();
            ADODB.Recordset rst = new ADODB.Recordset();
            Item item;
            string partNo;
            string soLineIndex;

            CacheItem();
            ConnectDB(cnn, soPath);

            strSQL = "SELECT \"nw:cpo:item:initneeddate\", \"nw:cpo:date\" ";
            strSQL = strSQL + " , \"nw:cpo:item:needqty\", \"nw:cpo:item:needdate\", \"nw:cpo:item:priority\", \"nw:part:sstqty\" ";
            strSQL = strSQL + " , \"nw:cpo:no\", \"nw:part:tmxrefno\" ";
            strSQL = strSQL + " FROM \"" + soPath;
            strSQL = strSQL + "\" WHERE (\"DAV:ishidden\" = false )";

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

            session.BeginTransaction();

            XPCollection<SalesOrderLine> soLines = new XPCollection<SalesOrderLine>(session);
            soLines.Criteria = CriteriaOperator.Parse("SalesOrder.OrderType == SalesOrder.SalesOrderType.SSTK");
            session.BeginTransaction();
            session.Delete(soLines);
            session.CommitTransaction();

            DateTime sTime = DateTime.Now;
            string poNo;

            while (!rst.EOF)
            {
                partNo = rst.Fields["nw:part:tmxrefno"].Value.ToString();
                soLineIndex = rst.Fields["nw:cpo:no"].Value.ToString() + "-" + rst.Fields["nw:part:tmxrefno"].Value.ToString();
                poNo = rst.Fields["nw:cpo:no"].Value.ToString();

                if (dictItem.ContainsKey(partNo))
                {
                    item = dictItem[partNo];
                    SalesOrder so;
                    if (dictSo.ContainsKey(rst.Fields["nw:cpo:no"].Value.ToString()))
                    {
                        so = dictSo[rst.Fields["nw:cpo:no"].Value.ToString()];
                    }
                    else
                    {
                        so = session.FindObject<SalesOrder>(new BinaryOperator("OrderNo", rst.Fields["nw:cpo:no"].Value.ToString()));

                        if (so == null)
                        {
                            so = new SalesOrder(session);
                            so.SetOrderNo(rst.Fields["nw:cpo:no"].Value.ToString());
                            so.OrderType = SalesOrder.SalesOrderType.SSTK;
                            so.Customer = GetCustomer("TIMEX");
                            so.Save();
                        }
                        dictSo.Add(rst.Fields["nw:cpo:no"].Value.ToString(), so);
                    }

                    SalesOrderLine soLine = new SalesOrderLine(session);
                    soLine.SalesOrder = so;
                    soLine.Item = item;
                    so.AddLineNo();
                    soLine.SetOrderLineNo(so.LastLineNo);
                    soLine.CustomerItemNo = rst.Fields["nw:part:tmxrefno"].Value.ToString();
                    soLine.CustomerOrderNo = rst.Fields["nw:cpo:no"].Value.ToString();
                    //soLine.InitNeedDate = DateTime.Parse(rst.Fields["nw:cpo:item:initneeddate"].Value.ToString());
                    soLine.NeedDate = DateTime.Parse(rst.Fields["nw:cpo:item:needdate"].Value.ToString());
                    soLine.NeedQty = float.Parse(rst.Fields["nw:part:sstqty"].Value.ToString());
                    soLine.PoDate = DateTime.Parse(rst.Fields["nw:cpo:date"].Value.ToString());
                    soLine.Priority = int.Parse(rst.Fields["nw:cpo:item:priority"].Value.ToString());
                    soLine.ApprovedSalesOrderLine();
                    soLine.Save();
                }
                rst.MoveNext();
            }

            System.Diagnostics.Debug.WriteLine("Start Time : " + sTime.ToString() + ".  End Time : " + DateTime.Now.ToString());
            session.CommitTransaction();
            System.Diagnostics.Debug.WriteLine("Commit Time : " + DateTime.Now.ToString());
        }
Exemplo n.º 5
0
        public static SalesOrderLine Create(string poNo, string customerNo, string cItemNo, string cItemName,
        float price, float needQty, DateTime needDate, string remark,
        ref string errMsg, Session session)
        {
            SalesOrder order = session.FindObject<SalesOrder>(new BinaryOperator("OrderNo", poNo));
            errMsg = "";

            if (order == null)
            {
                Customer customer = session.FindObject<Customer>(new BinaryOperator("No", customerNo));

                if (customer == null)
                {
                    errMsg = string.Format("找不到此人客资料, 人客编码 : {0}", customerNo);
                    return null;
                }
                order = new SalesOrder(session);
                order.Customer = customer;
                order.OrderNo = poNo;
                order.Save();
            }

            return SalesOrderLine.Create(order, cItemNo, cItemName, price, needQty, needDate, remark, ref errMsg, session);
        }