private WorkOrder createWO(Style style, string itemNoType, string orderTypeName, DateTime needDate, int needQty, SalesOrder so,bool issueSO, UnitOfWork uow, StringBuilder sbMsg) { string itemNo; if (itemNoType == "WA编码") { if (style.WANo == null) { sbMsg.AppendLine(string.Format("不能发单, Style {0} 没有设定WA编码 !!", style.StyleNo)); return null; } else itemNo = style.WANo.ItemNo; } else if (itemNoType == "CA编码") { if (style.CANo == null) { sbMsg.AppendLine(string.Format("不能发单, Style {0} 没有设定CA编码 !!", style.StyleNo)); return null; } else itemNo = style.CANo.ItemNo; } else { if (style.FANo == null) { sbMsg.AppendLine(string.Format("不能发单, Style {0} 没有设定FA编码 !!", style.StyleNo)); return null; } else itemNo = style.FANo.ItemNo; } //uow.FindObject<Customer>(new BinaryOperator("No", ((Project)lueProject.EditValue).Lot.Customer.No)); WorkOrder wo = WorkOrder.Create(itemNo, orderTypeName, needDate, needQty, uow); Style s = uow.FindObject<Style>(new BinaryOperator("Oid", style.Oid)); wo.Style = s; wo.Save(); if (issueSO) { SalesOrderLine soLine = SalesOrderLine.Create(so, wo, "", uow); soLine.WareHouse = WareHouse.Find(uow, "HK良品仓"); soLine.ShipMethod = ShipMethod.Find(uow, "交香港"); soLine.Style = s; soLine.CustomerItemNo = style.ProjectLineNo; soLine.CustomerItemName = style.Project.Name; soLine.Save(); soLine.ApprovedSalesOrderLine(); } return wo; }
private void btnStyle_Click(object sender, EventArgs e) { if (InitExcel("Style") == false) return; UnitOfWork uow = new UnitOfWork(); Style style; int row = 3; uow.BeginTransaction(); while (ExcelHelper.GetCellStringValue(xlSht, row, 1) != "") { style = new Style(uow); style.Project = uow.FindObject<Project>(new BinaryOperator("No", ExcelHelper.GetCellStringValue(xlSht, row, 1))); style.ProjectLineNo = ExcelHelper.GetCellStringValue(xlSht, row, 2); style.StyleNo = ExcelHelper.GetCellStringValue(xlSht, row, 3); if (ExcelHelper.GetCellStringValue(xlSht, row, 4) == "New") style.NewMature = Style.NM.New; else style.NewMature = Style.NM.Mature; if (ExcelHelper.GetCellStringValue(xlSht, row, 5) != "") style.CANo = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 5)); if (ExcelHelper.GetCellStringValue(xlSht, row, 6) != "") style.WANo = Item.FindItem(uow, ExcelHelper.GetCellStringValue(xlSht, row, 6)); style.Remark = ExcelHelper.GetCellStringValue(xlSht, row, 7); style.var = ExcelHelper.GetCellStringValue(xlSht, row, 8); if (ExcelHelper.GetCellStringValue(xlSht, row, 9) != "") style.DroppedDate = ExcelHelper.GetCellDateTimeValue(xlSht, row, 9); style.Strap = ExcelHelper.GetCellStringValue(xlSht, row, 10); style.Save(); row++; } uow.CommitTransaction(); ReleaseExcel(); }