I'm using a stored procedure to pull a list of items from a database however I keep getting this error:
Procedure or function 'requisition_sp_getItemNum' expects parameter '#reqNumber', which was not supplied.
I have use the hiddenfor in order to supply the reqNumber but that throws the same error message
Stored procedure:
ALTER PROCEDURE [dbo].[requisition_sp_getItemNum]
#reqNumber VARCHAR(50)
AS
BEGIN
SELECT
a.ITEMNMBR, a.ITEMDESC, ab.employee_id,
ab.department, ab.employee_name, quantity_requested,
b.expense_acc, c.ACTDESCR + '/' + c.ACTNUMBR_1 + '-' + c.ACTNUMBR_2 [Expense_Acc],
b.unit_of_measure
FROM
[TWCL].[dbo].IV00101 a
INNER JOIN
RequisitionItem b ON a.ITEMNMBR = b.item_no
INNER JOIN
Requisition ab ON ab.Req_No = b.Req_No
INNER JOIN
[TWCL].dbo.GL00100 c ON b.expense_acc = c.ACTINDX
WHERE
b.Req_No = #reqNumber AND ab.status = -1
END
View
#using (Html.BeginForm())
{
#Html.AntiForgeryToken()
<hr/>
<table id="data">
<thead>
<tr>
<th></th>
<th >#Html.CheckBox("TheOneCheckBoxToRuleThemAll")Select All</th>
<th class="col-lg-1 ">Date</th>
<th class="col-lg-1 ">Requisition Number</th>
<th class="col-lg-1 ">Expense Account</th>
<th class="col-lg-1">Requestor</th>
<th class="col-lg-1">Department</th>
<th class="col-lg-1">LoggedinAs</th>
<th class="col-lg-1 ">Item Number</th>
<th class="col-lg-1 ">Description</th>
<th class="col-sm-1">Quantity</th>
<th class="col-sm-1 ">UOM</th>
</tr>
<tbody>
#for (int i = 0; i < Model.Count; i++)
{
foreach (var item in Model[i].items)
{
#Html.HiddenFor(m => m[i].reqNumber)
<tr>
<td>#Html.HiddenFor(m => m[i].reqNumber)</td>
<td>#Html.CheckBoxFor(m => m[i].postTrnx, new { #class = "checkGroup1" })</td>
<td class="col-lg-1 tabledata" >#Html.DisplayFor(m => m[i].reqDate)</td>
<td class="col-lg-1 tabledata" >#Html.DisplayFor(m => m[i].reqNumber)</td>
<td class="col-lg-1 tabledata">#item.expense_account.account_desc</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.employeeNum</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.department</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.LoggedInUserName</td>
<td class="col-lg-1 tabledata">#item.itemNumber</td>
<td class="col-lg-1 tabledata">#item.description</td>
<td class="col-sm-1 tabledata">#item.quantity</td>
<td class="col-sm-1 tabledata">#item.selecteduomtext </td>
#*<td>#Html.ActionLink("Edit", "Edit", new { id = #item.lineNum, name = Model[i].reqNumber })</td>*#
</tr>
}
}
</tbody>
</table>
Model
public List<Item> getRequestItemByRquisition(string reqNumber)
{
List<Item> items = new List<Item>();
SqlConnection TWCLOPConnect = new SqlConnection(connectionString.ToString());
SqlCommand itemscommand = new SqlCommand();
SqlDataReader itemRdr;
itemscommand.CommandText = "requisition_sp_getItemNum ";
itemscommand.CommandType = CommandType.StoredProcedure;
itemscommand.Connection = TWCLOPConnect;
itemscommand.Parameters.Add("#reqNumber", SqlDbType.VarChar).Value = reqNumber;
try
{
TWCLOPConnect.Open();
itemRdr = itemscommand.ExecuteReader();
while (itemRdr.Read())
{
Item item = new Item();
item.itemNumber = itemRdr.GetString(0);
item.description = itemRdr.GetString(1);
item.employeeDetails.employeeNum = Convert.ToInt32(itemRdr.GetString(2));
item.employeeDetails.department = itemRdr.GetString(3);
item.employeeDetails.LoggedInUserName = itemRdr.GetString(4);
item.quantity = Convert.ToDouble(itemRdr[5]);
item.expense_account.index = itemRdr.GetInt32(6);
item.expense_account.account_desc = itemRdr.GetString(7);
item.selecteduomtext = itemRdr.GetString(8);
items.Add(item);
}
itemRdr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
TWCLOPConnect.Close();
}
return items;
}
You variable from stored procedure #reqNumber:
#reqNumber varchar (50)
and the variable #Req_No you added here
itemscommand.Parameters.Add("#Req_No", SqlDbType.VarChar).Value = Req_No;
must match.
Change this:
itemscommand.Parameters.Add("#reqNumber", SqlDbType.VarChar).Value = reqNumber;
to this:
itemscommand.Parameters.Add("#reqNumber", reqNumber);
New way: can you change your code to this
SqlConnection TWCLOPConnect = new SqlConnection(connectionString.ToString());
SqlCommand itemscommand = new SqlCommand("requisition_sp_getItemNum", TWCLOPConnect);
itemscommand.CommandType = CommandType.StoredProcedure;
itemscommand.Parameters.Add("#reqNumber", reqNumber);
SqlDataReader itemRdr;
try
{
}
Related
When I change the quantity, the quantity focus is lost..
click here to see image
AngularJS Code: ng-change code
$scope.txtqty = function (item) {
var id = item.Id;
$http.put("/api/Products/txtqty/" + id, item).then(function (response) {
$scope.gridproducts = response.data;
})
}
HTML table code
<table>
<tbody>
<tr ng-repeat="item in gridproducts">
<td ng-click="griddelete(item.Id)"><a class="delete"><i class="fa fa-times-circle-o"></i></a></td>
<td class="name">{{item.ProductName}}</td>
<td>{{item.ProductRate}}</td>
<td><input class="form-control qty" type="text" style="width:50px" ng-change="txtqty(item)" ng-model="item.ProductQty" value="{{item.ProductQty}}"></td>
<td>{{item.TotalAmount}}</td>
</tr>
<tr></tr>
<tfoot>
<tr>
<th colspan="2"></th>
<th colspan="2"><b>Total</b></th>
<th><b>{{gridproducts[0].TotalBill}}</b></th>
</tr><tr>
<th colspan="2"><b></b></th>
<th colspan="2"><b>Total Items</b></th>
<th><b>25</b></th>
</tr>
</tfoot>
</table>
Webapi Controller code this is webapi controller here you can see the
[System.Web.Http.Route("api/Products/txtqty/{id}")]
[ResponseType(typeof(void))]
public IHttpActionResult PuttxtQTY(int id, Product Pro)
{
var q = gridlist.Where(x => x.Id == id).FirstOrDefault();
if (q != null)
{
q.ProductQty = Pro.ProductQty;
q.TotalAmount = q.ProductQty * q.ProductRate;
q.TotalBill = gridlist.Sum(x => x.TotalAmount);
foreach (var item in gridlist)
{
item.TotalBill = q.TotalBill;
}
}
return Ok(gridlist);
}
You could give each input a unique ID and manually re-focus it as such:
HTML with ID on input
<td><input class="form-control qty" type="text" id="productQty_{{item.id}}" style="width:50px" ng-change="txtqty(item)" ng-model="item.ProductQty" value="{{item.ProductQty}}"></td>
Function adjusted with re-focus logic
$scope.txtqty = function (item) {
var id = item.Id;
$http.put("/api/Products/txtqty/" + id, item).then(function (response) {
$scope.gridproducts = response.data;
document.getElementById("productQty_" + id).focus();
})
}
Hope this does the job :)
I'm having problems getting my dataTable columnFilter select boxes to appear.
I have similar code blocks working on several other pages within the application, but for some reason, the <select> dropdown boxes won't appear. I have validated that the list of values (statusValues and seasonValues) have the correct values in the array and there are no errors in the console.
The column count is correct (I had that problem before). I'm using dataTables 1.10.9.
What am I missing?
Here's my code:
#using ApolloAMS.Business.Models;
#model List<Tournament>
#{
ViewBag.Title = "Manage Tournaments";
ViewBag.TournamentName = "";
List<Season> seasons = ViewBag.Seasons;
}
<div class="row" style="margin-bottom: 20px;">
<div class="col-md-2">
<span style="float: left; font-weight: bold;">Tournament Status:</span>
<span style="float: left; width: 100%;" id="statusFilter" class="filter"></span>
</div>
<div class="col-md-2">
<span style="float: left; font-weight: bold;">Season:</span>
<span style="float: left; width: 100%;" id="seasonFilter" class="filter"></span>
</div>
</div>
<table id="tblData" class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>Action</th>
<th>Name</th>
<th>Status</th>
<th>Season</th>
<th>Dates</th>
<th># Flights /# Lanes / Max Shooters</th>
</tr>
</thead>
<tbody>
#foreach (Tournament tourn in Model)
{
Season season = seasons.Where(s => s.ID.Equals(tourn.SeasonID)).FirstOrDefault();
<tr>
<td>
#{Html.RenderPartial("TournamentActions", tourn.ID);}
</td>
<td>#tourn.Name</td>
<td><span class="statusCell">#tourn.TournStatusName</span></td>
<td><span class="seasonCell">#season.Name</span></td>
<td>#tourn.DateStart.ToShortDateString() - #tourn.DateEnd.ToShortDateString()</td>
<td>#tourn.NumberOfFlights / #tourn.NumberOfLanes / #tourn.MaxShooters</td>
</tr>
}
</tbody>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
#section Scripts
{
<script type="text/javascript">
var statusValues = [];
var seasonValues = [];
$('.statusCell').each(function () {
var found = false;
var text = $(this).text();
for (i = 0; i < statusValues.length; i++) {
if (statusValues[i] == text) {
found = true;
break;
}
}
if (!found) {
statusValues.push(text);
}
});
$('.seasonCell').each(function () {
var found = false;
var text = $(this).text();
for (i = 0; i < seasonValues.length; i++) {
if (seasonValues[i] == text) {
found = true;
break;
}
}
if (!found) {
seasonValues.push(text);
}
});
statusValues.sort();
seasonValues.sort();
$("#tblData").dataTable(
{
"aLengthMenu": [[10, 25, -1], [10, 25, "All"]]
, "iDisplayLength": -1
, "scrollX": true
, "stateSave": true
, "oLanguage": {"sSearch": "Search: "}
, "order": [[4, "desc"]]
}).columnFilter({
aoColumns: [
null,
null,
{ type: "select", values: statusValues, sSelector: "#statusFilter" },
{ type: "select", values: seasonValues, sSelector: "#seasonFilter" },
null,
null,
]
});
//addl layout/config for datatable
$('input[type=search]').css("background-color", "yellow");
$('input[type=search]').css("font-weight", "bold");
$('input[type=search]').css("font-size", "large");
$('#tblData_filter label').css("font-size", "large");
$('#tblData_filter label').css("font-weight", "bold");
</script>
}
What am I missing? Clearly, my brain is what's missing. Gotta have the footer elements with matching columns.
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
Correct you need to have the <tfoot></tfoot> with matching columns. If you have the names of the columns in the <thead></thead> it might be helpful to have the names also in the <tfoot></tfoot>.
And since you have solved your problem please mark your answer as correct so that everyone can see that the question has an answer.
<div class="table-responsive">
<table class="table table-striped table-hover table-bordered table-condensed">
<thead>
<tr style="text-align: left!important;">
<th width="4%">Part#</th>
<th width="5%">Description</th>
<th width="3.8%">{{title}}</th>
</tr>
</thead>
<tbody>
<tr ng-if="show" ng-repeat="item in dataElemet |orderBy:orderByField:reverseSort" class="PartData">
<td>
<div ng-if="item.isWarningIconShow == true"><img ng-src="../cim/images/projIcons/warning.png"/></div><span ng-bind="item.number"></span>
</td>
<td ng-bind="item.description"></td>
<td ng-bind="item.Number"></td>
<td ng-bind="item.prodCategory"></td>
</tr>
<tr ng-if="show" ng-repeat="item in dataElemet |orderBy:orderByField:reverseSort" class="PartData">
<td>
<div ng-if="item.isWarningIconShow == true"><img ng-src="../cim/images/projIcons/warning.png"/></div><span ng-bind="item.number"></span>
</td>
<td ng-bind="item.description"></td>
<td ng-bind="item.prodCategory"></td>
</tr>
</tbody>
</table>
$scope.intializePartsData = function(objId, dataType){
$scope.loading = true;
$scope.dataElemet = null;
$scope.dataElemet2 = null;
if($scope.show == true && $scope.title == "Show Non Prod"){
objectService.getParts(objId).then(function(parts){
if(dataType == "Elemet") {
$scope.dataElemet = parts.data;
$scope.partsOriginalElemet = angular.copy($scope.dataElemet);
} else {
$scope.dataElemet2 = parts.data;
$scope.partsOriginalElemet2 = angular.copy($scope.dataElemet2);
}
});
} else {
objectService.getPartsProduction(objId).then(function(parts){
if(dataType == "Elemet") {
$scope.dataElemet = parts.data;
$scope.partsOriginalElemet = angular.copy($scope.dataElemet);
} else {
$scope.dataElemet2 = parts.data;
$scope.partsOriginalElemet2 = angular.copy($scope.dataElemet2);
}
});
}
$scope.loading = false;
}
$scope.showHideParts = function(dataType){
$scope.intializePartsData($scope.objId, dataType);
if($scope.show == true && $scope.title == "Show Non Prod"){
$scope.title = "Hide Non Prod";
$scope.show = false;
}else{
$scope.title = "Show Non Prod";
$scope.show = true;
}
}
This is my code its work fine normally . But When there is more data it takes time. So I want to implement lazy loading but as client not interested in scrolling, i need to to do lazy loading without scroll. Is it any way to do lazy loading in angularjs without any event from user.
I have a complex ng-repeat table,which I need to set the select all function for the checkbox of each row.He is my code:
JS:
$scope.getCCGenie = function(){
CCGenieService.transactionList().then(function(list){
$scope.CreditCardsList = list;
$scope.CorporateCardsNum = $scope.CreditCardsList.transactionInfo.corpCardCount;
$scope.PersonalCardsNum = $scope.CreditCardsList.transactionInfo.personalCardCount;
});
}
$scope.hasExpenseTypeLabel = false;
$scope.getCCGenie();
$scope.checkAllcorp = function(copcards) {
console.log(copcards);
if (copcards.selectedAllcorp) {
copcards.selectedAllcorp = true;
$scope.hasSelectedExpense = true;
} else {
copcards.selectedAllcorp = false;
$scope.hasSelectedExpense = false;
}
angular.forEach('copcards.transactions',function(v,k){
v.corpisSelected = copcards.selectedAllcorp;
})
};
// I need to loop the selected table to reset each corpisSelected,assign them the new value selectedAllcorp. but how?
};
Html:
<ul>
<li ng-repeat='copcards in CreditCardsList.transactionInfo.corporateCards'>
<span class='creditcardsubtitle'>{{copcards.cardName}} (****{{copcards.cardNumber}})</span>
<table class='table col-xs-12 col-md-12 col-lg-12' border="0" cellpadding="10" cellspacing="0" width="100%">
<thead>
<th class='text-center'><input type="checkbox" ng-model="copcards.selectedAllcorp" ng-change="checkAllcorp(copcards)"/></th>
<th class='text-left'>Date</th>
<th class='text-left'>Merchant</th>
<th class='text-right'>Amount</th>
<th class='text-center'>Expense Type</th>
<th class='text-left'><input type="checkbox" ng-model="selectedAllBill" ng-change="checkAllBillable()" style='margin-right:3px;'/> Billable</th>
<th class='text-center'>Attachment</th>
<th class='text-center'>Description</th>
</thead>
<tbody><tr ng-show='noExpense'><td colspan="8" align="center" style="text-align: center;" >No any Personal Cards!</td>
</tr>
<tr ng-repeat='componentObject in copcards.transactions' ng-class="{'selectedrow':componentObject.corpisSelected}">
<td type='checkbox' class='text-center'><input type='checkbox' ng-model='componentObject.corpisSelected' class='deletebox'/>{{componentObject.corpisSelected}}</td>
<td class='text-left tdwidth'>{{componentObject.transactionDateString | parseDateFormat | date}}</td>
<td class='text-left tdwidth'>{{componentObject.merchant}}</td>
<td class='text-right tdwidth'>${{componentObject.amount}}</td>
<td class='text-center tdwidth'><smart-expense-type></smart-expense-type></td>
<td class='text-left tdwidth'><input type='checkbox' ng-model='componentObject.isBillable'/></td>
<td class='text-center tdwidth'>{{componentObject.hasImage}}</td>
<td class='text-center tdwidth'><input type='text'ng-model='componentObject.description'/></td>
</tr>
</tbody>
</table>
</li>
</ul>
As you can see, I use nasted ng-repeat the loop data, there may be many tables over there, I want each table has his own selectAll function which works independently. Now the code is partly working fine, the problem is if you check the single checkbox in row, the checkall function will not work.I know I need to do something like this:
$scope.checkAllcorp = function() {
if (this.selectedAllcorp) {
$scope.hasSelectedExpense = true
this.selectedRow = true;
this.corpisSelected = true;
} else {
$scope.hasSelectedExpense = false;
this.selectedRow = false;
this.corpisSelected = false;
}
angular.forEach('selectedTable',function(v,k){
v.corpisSelected = this.selectedAllcorp;
})
};
But how can I access this 'selectedTable'?
Pass copcards to your function and then operate on that object instead of this:
ng-change="checkAllcorp(copcards)"
And then in your controller:
$scope.checkAllcorp = function(copcards) {
if (copcards.selectedAllcorp) {
$scope.hasSelectedExpense = true
copcards.selectedRow = true;
copcards.corpisSelected = true;
} else {
$scope.hasSelectedExpense = false;
copcards.selectedRow = false;
copcards.corpisSelected = false;
}
angular.forEach('selectedTable',function(v,k){
v.corpisSelected = copcards.selectedAllcorp;
})
};
you can pass the object you are on by calling it thru the function itself like this
ng-change="checkAllcorp(copcards)
and then use it as a parameter for you checkAllcorp function instead of this in you function
example :
<div ng-repeat="name in names"><button ng-click="msg(name)"></button></div>
controller scope :
$scope.msg = function(name) { alert(name.first)};
I am making a table where I can show data from 3 arrays (2 has identical properties, 1 different).
<table class="table table-striped table-condensed table-hover">
<thead>
<tr ng-bind-html="head">
</tr>
</thead>
<tbody>
<tr ng-repeat="item in book[bigCurrentPage]">
<td ng-bind="{{row.item1}}"></td>
<td ng-bind="{{row.item2}}"></td>
<td ng-bind="{{row.item3}}"></td>
<td ng-bind="{{row.item4}}"></td>
<td ng-bind="{{row.item5}}"></td>
<td ng-bind="{{row.item6}}"></td>
<td ng-bind="{{row.item7}}"></td>
</tr>
</tbody>
</table>
$scope.row = { item1: "item.code", item2: "item.name" };
$scope.row = { item1: "item.num", item2: "item.name", item3: "item.category", item4: "item.location.name", item5: "item.toloc.name", item6: "item.department", item7: "item.adm", item8: "item.person.name" };
First array has 7 properties (num,name,category,location,department,adm,person) and other 2 arrays has 2 properties (code,name)
The problem lies in that when I use 2 of cells in a row, then other cells are still visible without any content. Is there a way to have one table which can ngRepeat arrays with different properties and property count?
Solution:
<table class="table table-striped table-condensed table-hover">
<thead>
<tr ng-bind-html="head"></tr>
</thead>
<tbody ng-include=activeTable>
</tbody>
</table>
<script type="text/ng-template" id="assets.html">
<tr ng-repeat="item in book[bigCurrentPage]">
<td ng-bind=item.num></td>
<td ng-bind=item.name></td>
<td ng-bind=item.category></td>
<td ng-bind=item.location.name></td>
<td ng-bind=item.department></td>
<td ng-bind=item.adm></td>
<td ng-bind=item.person.name></td>
</tr>
</script>
<script type="text/ng-template" id="persons.html">
<tr ng-repeat="item in book[bigCurrentPage]">
<td ng-bind=item.code></td>
<td ng-bind=item.name></td>
</tr>
</script>
<script type="text/ng-template" id="locations.html">
<tr ng-repeat="item in book[bigCurrentPage]">
<td ng-bind=item.code></td>
<td ng-bind=item.name></td>
</tr>
</script>
$scope.assetshow = function () {
$scope.asse = true;
$scope.pers = false;
$scope.loca = false;
$scope.bigTotalItems = $scope.copy.data.assets.length;
$scope.book = PageItems($scope.copy.data.assets, 17);
console.log($scope.bigCurrentPage)
$scope.row = { item1: "item.num", item2: "item.name", item3: "item.category", item4: "item.location.name", item5: "item.toloc.name", item6: "item.department", item7: "item.adm", item8: "item.person.name" };
$scope.head = '<th>Asset code</th><th>Asset name</th><th>Category</th>'
+ '<th>Location</th><th>Department</th><th>Administration</th><th>Person in charge</th>';
$scope.activeTable = "assets.html";
},
$scope.locationshow = function () {
$scope.asse = false;
$scope.pers = false;
$scope.loca = true;
//produce pages.
$scope.bigTotalItems = PageItems($scope.copy.data.locations);
$scope.book = PageItems($scope.copy.data.locations, 17);
$scope.head = '<th>Kods</th><th>Nosaukums</th>';
$scope.row = { item1: "item.code", item2: "item.name" };
$scope.activeTable = "locations.html";
},
$scope.personshow = function () {
$scope.asse = false;
$scope.pers = true;
$scope.loca = false;
//produce pages.
$scope.bigTotalItems = PageItems($scope.copy.data.persons);
$scope.book = PageItems($scope.copy.data.persons, 17);
$scope.head = '<th>Kods</th><th>Nosaukums</th></tr>';
$scope.row = { item1: "item.code", item2: "item.name" };
$scope.activeTable = "persons.html";
};
By changing activeTable string value table content changes.
DEMO: plnkr