I want to update data in the table where the username matches with the one already in table but I am unable to do so far. Suggest the changes.
index.html
<script id="my-popover.html" type="text/ng-template">
<ion-popover-view>
<ion-header-bar>
<h1 class="title">Settings</h1>
</ion-header-bar>
<ion-content>
<div class="list">
<a class="item" ui-sref="changepassword" ng-click="hidePopover()">
Change Password
</a>
<a class="item" ui-sref="login" ng-click="hidePopover()">
Logout
</a>
</div>
</ion-content>
</ion-popover-view>
</script>
<ion-view view-title="Add Item">
<ion-nav-buttons side="secondary">
<button class="button button-icon ion-ios-gear" ng-click="openPopover($event)">
</button>
</ion-nav-buttons>
<ion-content>
<div class="list"><br>
<form name="myForm" ng-submit="createSlide(addslide,formadd_slide)">
<h4> <input type="radio" ng-model="rad1" value="precious" > Precious
<input type="radio" ng-model="rad1" value="semi-precious"> Semi-Precious</h4> <br/>
<label class="item item-input item-stacked-label">
<span class="input-label">Username</span>
<input type="text" ng-model="text1">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Type Of Purchase</span>
<input type="text" ng-model="purchasetype">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Name Of Stone</span>
<input type="text" ng-model="stonename">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Size</span>
<input type="text" ng-model="size">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Total Weight(Cts)</span>
<input type="text" ng-model="weight">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Pieces</span>
<input type="text" ng-model="pieces">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Dimension</span>
<input type="text" ng-model="dimension">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Color</span>
<input type="text" ng-model="color">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Shape</span>
<input type="text" ng-model="shape">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Origin</span>
<input type="text" ng-model="origin">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Treatment Remark</span>
<input type="text" ng-model="treatment">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Certificate Agency</span>
<input type="text"ng-model="certi">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Expected Sales Price/Carat</span>
<input type="text" ng-model="salesPrice">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Stock ID</span>
<input type="text" ng-model="stockid">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Supplier reference certificate number</span>
<input type="text" ng-model="certificatenum">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Purchase Price</span>
<input type="text" ng-model="purchase">
</label>
</form>
</div>
<div class="padding">
<button ng-click="takePicture()" class="button button-block button-calm">Take Picture</button>
<button ng-click="takePhoto()" class="button button-block button-positive">Choose Picture</button>
</div>
<div class="list card">
<div class="item item-image">
<img src="{{pictureUrl}}">
</div>
</div>
<p>
<button class="button button-block button-calm" ng-click="enter(text1,rad1,purchasetype,stonename,size,weight,pieces,dimension,color,shape,origin,treatment,certi,salesPrice,stockid,certificatenum,purchase,pictureUrl)">Submit</button>
<!--<input type="submit" ng-click="enter(purchasetype,stonename,Size,weight,pieces,dimension,Color,Shape,Origin,treatment,certi,salesPrice,stockid,certificatenum,purchase)"> -->
</p>
</ion-content>
</ion-view>
App.js
$scope.enter = function (userName,precious,purchasetype, stonename, size, weight, pieces, dimension, color, shape, origin, treatment, certi, salesprice,
stockid, certificatenum, purchase, image) {
var query20 = "UPDATE gems_item_list set precious=?,purchasetype=?,stonename=?,size=?,weight=?,pieces=?,dimension=?,color=?,shape=?,origin=?,treatment=?,certi=?,salesprice=?,stockid=?,certificatenum=?,purchase=?, image=? where username=?";
$cordovaSQLite.execute(db, query20, [userName,precious,purchasetype, stonename, size, weight, pieces, dimension, color, shape, origin, treatment, certi, salesprice, stockid, certificatenum, purchase, image]).then(function (res) {
var alertPopup = $ionicPopup.alert({
title: 'Successful!',
template: 'Record entered!'
});
$scope.createSlide = function(slide,myForm){
$scope.myForm.$setPristine();
$scope.myForm.$setUntouched();
}
}, function (err) {
console.log(err);
window.alert(err);
});
};
Please help me . I am stuck here. Thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire