protected override void onLoad() { var productTxt = Document.GetElementById <InputElement>("productTxt"); productTxt.Focus(); var quantityTxt = Document.GetElementById <InputElement>("quantityTxt"); quantityTxt.Value = "0"; quantityTxt.OnChange = (ev) => { Quantity = int.Parse(quantityTxt.Value); }; var toDownBtn = Document.GetElementById <ButtonElement>("toDownBtn"); toDownBtn.OnClick = (ev) => { if (Quantity > 0) { Quantity--; quantityTxt.Value = Quantity.ToString(); } }; var toUpBtn = Document.GetElementById <ButtonElement>("toUpBtn"); toUpBtn.OnClick = (ev) => { Quantity++; quantityTxt.Value = Quantity.ToString(); }; var backBtn = Document.GetElementById <ButtonElement>("backBtn"); backBtn.OnClick = (ev) => { Navigation <Main> .Go(); }; var saveBtn = Document.GetElementById <ButtonElement>("saveBtn"); saveBtn.OnClick = (ev) => { var dynamodb = new DynamoDB(); var paramGet = new GetParams { TableName = "stock", Key = new { product = new DynamoItem { S = productTxt.Value } } }; dynamodb.getItem(paramGet, (errGet, dataGet) => { if (dataGet.Item == null) { var paramPut = new ItemParams { TableName = "stock", Item = new { product = new DynamoItem { S = productTxt.Value }, quantity = new DynamoItem { N = Quantity.ToString() } } }; dynamodb.putItem(paramPut, (errPut, dataPut) => { if (errPut != null) { Toast.Error("A Error ocorred on include the product!"); } else { productTxt.Value = String.Empty; quantityTxt.Value = "0"; Quantity = 0; productTxt.Focus(); Toast.Success("Sucess included product!"); } }); } else { Toast.Error("Product alredy exist!"); } }); }; }
protected override void onLoad() { var productP = Document.GetElementById("productP"); productP.InnerHTML = product; var quantityTxt = Document.GetElementById <InputElement>("quantityTxt"); quantityTxt.Value = quantity.ToString(); quantityTxt.OnChange = (ev) => { quantity = int.Parse(quantityTxt.Value); }; var toDownBtn = Document.GetElementById <ButtonElement>("toDownBtn"); toDownBtn.OnClick = (ev) => { if (quantity > 0) { quantity--; quantityTxt.Value = quantity.ToString(); } }; var toUpBtn = Document.GetElementById <ButtonElement>("toUpBtn"); toUpBtn.OnClick = (ev) => { quantity++; quantityTxt.Value = quantity.ToString(); }; var backBtn = Document.GetElementById <ButtonElement>("backBtn"); backBtn.OnClick = (ev) => { Navigation <Main> .Go(); }; var saveBtn = Document.GetElementById <ButtonElement>("saveBtn"); saveBtn.OnClick = (ev) => { var param = new ItemParams { TableName = "stock", Item = new { product = new DynamoItem { S = product }, quantity = new DynamoItem { N = quantity.ToString() } } }; var dynamodb = new DynamoDB(); dynamodb.putItem(param, (err, data) => { if (err != null) { Toast.Error("Error on edit the product!"); } else { Toast.Success("Success on edit the product!"); } }); }; var excludeBtn = Document.GetElementById <ButtonElement>("excludeBtn"); excludeBtn.OnClick = (ev) => { var param = new DeleteParams { TableName = "stock", Key = new { product = new DynamoItem { S = product } } }; var dynamodb = new DynamoDB(); dynamodb.deleteItem(param, (err, data) => { if (err != null) { Toast.Error("Error on exclude the product!"); } else { Toast.Error("Success on exclude the product!"); Navigation <Main> .Go(); } }); }; }