public void AddTruck6Report(Truck6ReportModel model) { dareport.AddTruck6Report(model); }
public ActionResult Truck6Report(Truck6ReportModel model) { if (ModelState.IsValid) { model.CrUser = CurrentUserModel.Current.UserID; model.StationID = CurrentUserModel.Current.StationID; model.Year = DateTime.Now.Year; new BLReports().AddTruck6Report(model); return Content("<script>alert('添加成功');window.location.href='/report/Truck6Report';</script>"); } return View(model); }
public void AddTruck6Report(Truck6ReportModel model) { try { string strSQL = @" if exists (select id from Truck6Report where stationid=@stationid and Year=@year and Month=@Month) begin update Truck5Report set DownAmount=@DownAmount, TruckAmount=@TruckAmount, MoreThan30=@MoreThan30, MoreThan100=@MoreThan100, MoreThan0=@MoreThan0, CrUser=@CrUser, crtime=getdate() where stationid=@stationid and Year=@year and Month=@Month end else begin insert into Truck6Report(year,Month,StationID,DownAmount,TruckAmount,MoreThan30,MoreThan100,MoreThan0,CrUser) values(@year,@Month,@stationid,@DownAmount,@TruckAmount,@MoreThan30,@MoreThan100,@MoreThan0,@CrUser) end "; SqlParameter[] parms = new SqlParameter[]{ new SqlParameter("@Year",SqlDbType.Int), new SqlParameter("@Month",SqlDbType.Int), new SqlParameter("@DownAmount",SqlDbType.Int), new SqlParameter("@TruckAmount",SqlDbType.Int), new SqlParameter("@MoreThan30",SqlDbType.Int), new SqlParameter("@MoreThan100",SqlDbType.Int), new SqlParameter("@MoreThan0",SqlDbType.Int), new SqlParameter("@cruser",SqlDbType.Int), new SqlParameter("@stationid",SqlDbType.Int), }; parms[0].Value = model.Year; parms[1].Value = model.Month; parms[2].Value = model.DownAmount; parms[3].Value = model.TruckAmount; parms[4].Value = model.MoreThan30; parms[5].Value = model.MoreThan100; parms[6].Value = model.MoreThan0; parms[7].Value = model.CrUser; parms[8].Value = model.StationID; SqlHelper.ExecuteNonQuery(SqlHelper.SQLConnectString, CommandType.Text, strSQL, parms); } catch (Exception ex) { throw; } }