public ActionResult SpiltBill(SplitBillReport model) { if (ModelState.IsValid) { model.CrUser = CurrentUserModel.Current.UserID; model.StationID = CurrentUserModel.Current.StationID; model.Year = DateTime.Now.Year; new BLReports().SpiltBill(model); return(Content("<script>alert('添加成功');window.location.href='/report/SpiltBill';</script>")); } return(View(model)); }
public void SpiltBill(SplitBillReport model) { try { string strSQL = @" if exists (select id from SplitBillReport where stationid=@stationid and Year=@year and Month=@Month) begin update SplitBillReport set Amount=@Amount, CrUser=@CrUser, crtime=getdate() where stationid=@stationid and Year=@year and Month=@Month end else begin insert into SplitBillReport(year,Month,StationID,Amount,CrUser) values(@year,@Month,@StationID,@Amount,@CrUser) end "; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@Year", SqlDbType.Int), new SqlParameter("@Month", SqlDbType.Int), new SqlParameter("@Amount", 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.Amount; parms[3].Value = model.CrUser; parms[4].Value = model.StationID; SqlHelper.ExecuteNonQuery(SqlHelper.SQLConnectString, CommandType.Text, strSQL, parms); } catch (Exception ex) { throw; } }
public void SpiltBill(SplitBillReport model) { dareport.SpiltBill(model); }