public void ImportWorkOrder() { string woPath = "http://nwszmail/public/namwah/WorkOrders/"; string strSQL = ""; ADODB.Connection cnn = new ADODB.Connection(); ADODB.Recordset rst = new ADODB.Recordset(); Item item; WorkOrder wo; string partNo; string woNo; session.BeginTransaction(); CacheItem(); CacheWo(); ConnectDB(cnn, woPath); strSQL = "SELECT \"nw:partno\" , \"nw:partname\", \"nw:parttype\", \"nw:wo:no\", "; strSQL = strSQL + " \"nw:wo:needqty\", \"nw:wo:needdate\", \"nw:wo:ssblankuseqty\", \"nw:wo:extra\" "; strSQL = strSQL + " FROM \"" + woPath; 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(); if (dictItem.ContainsKey(partNo)) { if (dictWo.ContainsKey(woNo)) { WorkOrder oldWo = dictWo[woNo]; if (oldWo.NeedQty != float.Parse(rst.Fields["nw:wo:needqty"].Value.ToString())) { oldWo.NeedQty = float.Parse(rst.Fields["nw:wo:needqty"].Value.ToString()); oldWo.Save(); } } else { item = dictItem[partNo]; wo = new WorkOrder(session, woNo); wo.Item = item; wo.NeedDate = DateTime.Parse(rst.Fields["nw:wo:needdate"].Value.ToString()); wo.NeedQty = float.Parse(rst.Fields["nw:wo:needqty"].Value.ToString()); if (rst.Fields["nw:wo:extra"].Value.ToString() != "") wo.ExtraQty = float.Parse(rst.Fields["nw:wo:extra"].Value.ToString()); if (rst.Fields["nw:wo:ssblankuseqty"].Value.ToString() != "") wo.ssBlankUseQty = float.Parse(rst.Fields["nw:wo:ssblankuseqty"].Value.ToString()); wo.Save(); } } rst.MoveNext(); } session.CommitTransaction(); }
public static SalesOrderLine Create(SalesOrder order, WorkOrder wo, string remark, Session session) { SalesOrderLine orderLine = new SalesOrderLine(session); orderLine.SalesOrder = order; orderLine.Item = wo.Item; if (wo.Item.CustomerItemNo == "") orderLine.CustomerItemNo = wo.Item.ItemNo; else orderLine.CustomerItemNo = wo.Item.CustomerItemNo; orderLine.CustomerItemName = wo.Item.ItemName; orderLine.CustomerPrice = wo.Item.SalesPrice; orderLine.OrderType = wo.OrderType; orderLine.PriceUnit = order.Customer.Currency; orderLine.InitNeedDate = wo.NeedDate; orderLine.NeedDate = wo.NeedDate; orderLine.NeedQty = wo.NeedQty; orderLine.WorkOrder = wo; orderLine.Save(); wo.SalesOrderLine = orderLine; wo.Save(); return orderLine; }
public static WorkOrder Create(String ItemNo, String OrderTypeName, DateTime needDate, float needQty, Session session) { WorkOrder wo = new WorkOrder(session); Item item = Item.FindItem(session, ItemNo); OrderType orderType = session.FindObject<OrderType>(new BinaryOperator("Name", OrderTypeName)); wo.Item = item; wo.OrderType = orderType; wo.NeedDate = needDate; wo.NeedQty = needQty; wo.Save(); return wo; }
public void PostWorkOrder(Session session) { if (Result == ResultStatus.OK) return; if (WoNeedDate == null) { _Result = ResultStatus.Error; return; } if (OrderType == null) { _Result = ResultStatus.Error; return; } if (WoNeedQty != 0) { WorkOrder wo = new WorkOrder(session); wo.Item = this.Item; wo.NeedDate = this.WoNeedDate; wo.NeedQty = this.WoNeedQty; wo.ssBlankUseQty = this.ssBlankUseQty; wo.ExtraQty = this.WoExtraQty; wo.OrderType = OrderType; wo.SalesOrderLine = this.SalesOrderLine; wo.Save(); this._Result = ResultStatus.OK; } }