create database ZhouKaoA
use ZhouKaoA
create table UserInfo --yonghu
(
UserId int primary key identity,
UserNum nvarchar(50),
UserPwd nvarchar(50)
)
[HttpGet]
public int Proc(string DelReson, string DelPicture, int OrderId)
{
int result = 0;
SqlParameter[] spa = new SqlParameter[]
{
new SqlParameter(){ ParameterName="@DelReson",SqlDbType=SqlDbType.NVarChar,SqlValue=DelReson},
new SqlParameter(){ ParameterName="@DelPicture",SqlDbType=SqlDbType.NVarChar,SqlValue=DelPicture},
new SqlParameter(){ ParameterName="@OrderId",SqlDbType=SqlDbType.Int,SqlValue=OrderId},
new SqlParameter(){ ParameterName="@Rults",SqlDbType=SqlDbType.Int,Direction = ParameterDirection.Output}
};
var list = DBHelper.Do_Proc("My_proc", spa);
result = Convert.ToInt32(spa[3].Value);
return result;
}
}
function Submits(url) {
var str = url;
var obj = {
DelReson: $("#reson").val(),
DelPicture: str,
OrderId:ids
}
$.ajax({
url: '
http://localhost:7202/api/Default/Proc',
type: 'get',
data: obj,
dataType: 'json',
success: function (d) {
if (d > 0) {
alert('TiJiaoChengGong');
}
else {
alert('ShiBai');
}
}
})
}
create table Shopping --shangpin
(
ShopId int primary key identity,
ShopName nvarchar(50),
ShopPrice decimal,
ShoNum int,
)
create table OrderInfo --Dingdan
(
Oid int primary key identity,
Oname nvarchar(50),
Otime datetime,
OZhuangtai int,
ShopWid int
)
create table delOrderInfo --DingdanTuihuo
(
DelId int primary key identity,
DelReson nvarchar(100),
DelPicture nvarchar(100),
OrderId int
)
select * from OrderInfo as o join Shopping as s on o.ShopWid = s.ShopId where Oname = 'GuoQi'
go
alter proc My_proc
(
@DelReson nvarchar(100),
@DelPicture nvarchar(100),
@OrderId int,
@Rults int output
)
as
begin
begin try
begin tran
insert into delOrderInfo values(@DelReson,@DelPicture,@OrderId)
update Shopping set ShoNum+=1 where ShopId = (select ShopId from Shopping as s join OrderInfo as o on s.ShopId = o.ShopWid where o.Oid = @OrderId)
commit tran
set @Rults = 1
end try
begin catch
rollback tran
end catch
end
declare @rest int
exec My_proc 'asdas','asdas',1,@rest
select @rest
[HttpGet]
public int Proc(string DelReson, string DelPicture, int OrderId)
{
int result = 0;
SqlParameter[] spa = new SqlParameter[]
{
new SqlParameter(){ ParameterName="@DelReson",SqlDbType=SqlDbType.NVarChar,SqlValue=DelReson},
new SqlParameter(){ ParameterName="@DelPicture",SqlDbType=SqlDbType.NVarChar,SqlValue=DelPicture},
new SqlParameter(){ ParameterName="@OrderId",SqlDbType=SqlDbType.Int,SqlValue=OrderId},
new SqlParameter(){ ParameterName="@Rults",SqlDbType=SqlDbType.Int,Direction = ParameterDirection.Output}
};
var list = DBHelper.Do_Proc("My_proc", spa);
result = Convert.ToInt32(spa[3].Value);
return result;
}
}
function Submits(url) {
var str = url;
var obj = {
DelReson: $("#reson").val(),
DelPicture: str,
OrderId:ids
}
$.ajax({
url: '
http://localhost:7202/api/Default/Proc',
type: 'get',
data: obj,
dataType: 'json',
success: function (d) {
if (d > 0) {
alert('TiJiaoChengGong');
}
else {
alert('ShiBai');
}
}
})
}