private static string GetMaxOrderNo() { DataSource.SQLServerSource sql = new DataSource.SQLServerSource(); var max = sql.ExecuteScalar("select MAX(OrderOn) from dbo.P_Order"); return(max.ToString()); }
public int Save() { int result = 0; DataSource.SQLServerSource ss = new DataSource.SQLServerSource(); ss.BeginTransaction(); try { int id = DataSource.ORMHelper.InsertModelId <P_Order>(Order, ss); Order.OrderId = id; for (int i = 0; i < Part.Count; i++) { int pid = DataSource.ORMHelper.InsertModelId <OrderPart>(Part[i], ss); for (int j = 0; j < Process.Count; j++) { if (Process[j].PartId == i) { Process[j].PartId = pid; DataSource.ORMHelper.InsertModel <P_ProcessList2>(Process[j], ss); } if (Material[j].PartId == i) { Material[j].PartId = pid; DataSource.ORMHelper.InsertModel <P_MaterialList2>(Material[j], ss); } } result++; } ss.Commit(); } catch { ss.Rollback(); result = -1; } return(result); }