public static FormData FormActions(string action, FormData data) { var productInput = (ProduceInput)data.MainObject; var bl = BIFactory.Create <IProduceInputBL>(); switch (action) { case FormActionNames.Load: var dom = bl.Load(productInput.ID); data.MainObject = dom; break; case FormActionNames.Save: if (productInput.ID == 0) { bl.InitNewDmo(productInput); bl.Insert(productInput); data.MainObject = productInput; return(FormActions(FormActionNames.Load, data)); } bl.Update(productInput); return(FormActions(FormActionNames.Load, data)); case FormActionNames.New: var dmo = new ProduceInput(); data.MainObject = dmo; break; case FormActionNames.Prev: var prevDmo = GetPrevOrNext(productInput.ID); if (prevDmo == null) { throw new IndexOutOfRangeException("Current is first"); } data.MainObject = prevDmo; break; case FormActionNames.Next: var nextDmo = GetPrevOrNext(productInput.ID, false); if (nextDmo == null) { throw new IndexOutOfRangeException("Current is last"); } data.MainObject = nextDmo; break; //case "LoadDetail": // LoadDetail(productInput); // break; default: throw new ArgumentException("Unknown action: " + action); } return(data); }
public static void InsertProduceInput(ProduceInput dmo) { using (var context = new TransactionContext()) { foreach (var d in dmo.Details) { d.Price = 0; d.Money = 0; } var bl = BIFactory.Create <IProduceInputBL>(context); dmo.Time = BLContext.Today; dmo.BillState = 单据状态.已审核; dmo.IsHandsetSend = true; bl.Insert(dmo); context.Commit(); } }