public bool InputLotNumber6(LotNumber6 data) { var sql = @" INSERT INTO [dbo].[HkLot49] ([期數] ,[開獎日期] ,[號碼1] ,[號碼2] ,[號碼3] ,[號碼4] ,[號碼5] ,[號碼6] ,[特別號]) VALUES (@期數 ,@開獎日期 ,@號碼1 ,@號碼2 ,@號碼3 ,@號碼4 ,@號碼5 ,@號碼6 ,@特別號) "; return(_dbDapper.NonQuerySQL(sql, data) > 0); }
public ActionResult AddNumber6() { LotNumber6 model = new LotNumber6(); model.開獎日期 = DateTime.Now.ToString("yyyyMMdd"); SetMaxNo6(); return(View(model)); }
/// <summary> /// 去掉前面0 /// </summary> /// <param name="data"></param> private void TrimStartZone(LotNumber6 data) { data.號碼1 = data.號碼1.TrimStart('0'); data.號碼2 = data.號碼2.TrimStart('0'); data.號碼3 = data.號碼3.TrimStart('0'); data.號碼4 = data.號碼4.TrimStart('0'); data.號碼5 = data.號碼5.TrimStart('0'); data.號碼6 = data.號碼6.TrimStart('0'); data.特別號 = data.特別號.TrimStart('0'); }
public bool AddNumber6Services(LotNumber6 data) { bool success = false; using (var scope = new TransactionScope()) { success = _sqlRepository.InputLotNumber6(data) && _sqlRepository.InsertCopyNumber6(data.開獎日期) && _sqlRepository.UpdateCopyNumber6(data); if (success) { scope.Complete(); } } return(success); }
public ActionResult AddNumber6(LotNumber6 data) { SetMaxNo6(); //CheckRepeatFun(data); TrimStartZone(data); if (ModelState.IsValid) { if (_HkLot49Services.AddNumber6Services(data)) { TempData["message"] = "寫入成功"; } else { TempData["message"] = "寫入失敗"; } return(RedirectToAction("AddNumber6")); } return(View()); }
public bool UpdateCopyNumber6(LotNumber6 data) { var sql = @" DECLARE @TSQL NVARCHAR(4000) SET @TSQL = 'update [dbo].[HkLot49_StoredCount] set ' + @num1 + '=0,' + @num2 + '=0,' + @num3 +'=0,' + @num4 + '=0,' + @num5 + '=0,' + @num6 + '=0,' + @num7 + '=0 where 日期=' + @date EXEC SP_EXECUTESQL @TSQL"; var param = new Dictionary <string, object>(); param.Add("num1", "[" + data.號碼1 + "]"); param.Add("num2", "[" + data.號碼2 + "]"); param.Add("num3", "[" + data.號碼3 + "]"); param.Add("num4", "[" + data.號碼4 + "]"); param.Add("num5", "[" + data.號碼5 + "]"); param.Add("num6", "[" + data.號碼6 + "]"); param.Add("num7", "[" + data.特別號 + "]"); param.Add("date", data.開獎日期); return(_dbDapper.NonQuerySQL(sql, param) > 0); }