无法使用post方法将数据插入数据库
这仅用于将一个字段插入数据库
仅应在单击“提交”按钮后插入数据
$scope.btntext = "Submit";
$scope.submit = function () {
debugger;
var post = $http({
method: "POST",
url: "http://stagingserver:85/EBSApi/api/Warehouse/AddInvoiceDetails",
data: $scope.InvoiceId,
dataType: 'json',
headers: { "Content-Type": "application/json" }
});
post.success(function (data) {
debugger;
$scope.id = data;
//$scope.Selectedinvoice.originalObject.InvoiceId = $scope.data;
alert('Data Submitted...!');
});
//$scope.mydata = "";
post.error(function (data) {
debugger;
alert('Failed');
});
}
[HttpPost]
[ActionName("AddInvoiceDetails")]
public void insertInvoiceDetails(int InvoiceId)
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString;
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "INSERT_WAREHOUSE";
sqlCmd.Connection = myConnection;
sqlCmd.Parameters.AddWithValue("@InvoiceId", InvoiceId);
//InvoiceDetails id = new InvoiceDetails();
//sqlCmd.Parameters.AddWithValue("@PartNo", id.PartNo);
//sqlCmd.Parameters.AddWithValue("@PartName", id.PartName);
//sqlCmd.Parameters.AddWithValue("@NoOfPallets", id.NoOfPallets);
//sqlCmd.Parameters.AddWithValue("@PalletCapacity", id.PalletCapacity);
//sqlCmd.Parameters.AddWithValue("@Numbers", id.Numbers);
myConnection.Open();
int rowInserted = sqlCmd.ExecuteNonQuery();
myConnection.Close();
}
我在控制台中找不到404。在angularjs代码中定义的范围变量未定义。