public async Task <PurchaseIdViewModel> GetNewPurchaseId(DateTime PurchaseTime) { PurchaseIdViewModel ret = null; try { using (SqlConnection con = new SqlConnection(constr)) { var p = new DynamicParameters(); p.Add("@PurchaseTime", PurchaseTime, dbType: DbType.DateTime, direction: ParameterDirection.Input); p.Add("@r", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); await con.OpenAsync(); IEnumerable <PurchaseIdViewModel> tmp = await con.QueryAsync <PurchaseIdViewModel>("sp_GetNewPurchaseId", p, commandType : CommandType.StoredProcedure); ret = tmp.FirstOrDefault <PurchaseIdViewModel>(); } } catch (Exception ex) { string msg = ex.Message; ret = null; } return(ret); }
public async Task <IActionResult> Id(string id) { var user = await this.userManager.GetUserAsync(this.User); var viewMoodel = new PurchaseIdViewModel { Order = this.orderService.GetById <OrderInspectViewModel>(id), Items = this.orderService.GetAllItems <OrderItemViewModel>(id), }; return(this.View(viewMoodel)); }
public async Task <string> GetNewPurchaseId(DateTime PurchaseTime) { // 6-2.系統在Get Action[Purchase/GetNewPurchaseId]讀取當日最後一張進貨單號。 PurchaseIdViewModel lCVM = await IAR.GetNewPurchaseId(PurchaseTime); string PurchaseId = ""; if (lCVM != null) { // 6-3.系統判斷6-2傳回值!=null。 // 6-4.系統設定PurchaseId=年月日+<6-2讀取值最後4碼加1>。 PurchaseId = Data.GetNewId(lCVM.PurchaseId, 9, 4); } else { // 6-3a.系統判斷6-2傳回值==null。 // 6-3a-1.系統設定PurchaseId=年月日0001。 // 6-3a-2.回6-5。 PurchaseId = Data.GetStartId("A", PurchaseTime); } // 6-5.系統回傳string PurchaseId。 return(PurchaseId); }