public async Task InitAsync() { Utils utils = new Utils(); try { StockOnline.Models.Product pro = await productbaseHelper.GetProduct(new Guid(product_id)); StockOnline.Models.MaterialHeader header = await headerfirebaseHelper.GetMaterialByProductId(product_id); Lbl_FoodLabel.Text = pro.NameEn; listMatrialView.ItemsSource = await sourcefirebaseHelper.GetAllMaterialSource(); } catch (Exception ee) { } }
async void OnSaveButtonClicked(object sender, EventArgs e) { bool valid = true; decimal quantity = 0; if (valid && this.Entry_Quantity.Text.Trim().Length == 0) { valid = false; await DisplayAlert("Error", "กรุณาระบุ Cost", "OK"); } if (valid && this.Entry_Quantity.Text.Trim().Length > 0) { try { quantity = decimal.Parse(this.Entry_Quantity.Text.Trim()); } catch (Exception ee) { valid = false; await DisplayAlert("Error", "กรุณาระบุ จำนวน ให้ถูกต้อง", "OK"); } } if (valid && this.source_select == null) { valid = false; } Utils utils = new Utils(); //StockOnline.Models.Product pro = await productbaseHelper.GetProductByNameEn(this.source_select.NameEn); StockOnline.Models.MaterialHeader header = await headerfirebaseHelper.GetMaterial(this.header_id); StockOnline.Models.Product pro = await productbaseHelper.GetProduct(new Guid(header.ProductID)); Lbl_FoodLabel.Text = this.source_select.NameEn; if (valid) { if (this.type.Equals("Update")) { /* * detailbaseHelper.UpdateMaterial() * //Update * await sourcefirebaseHelper.UpdateMaterialSource(this.material_id,this.Entry_MaterialName.Text.Trim(), this.Entry_MaterialNameEn.Text.Trim(), unitType, int.Parse(this.Entry_Quantity.Text.Trim()), int.Parse(this.Entry_QuantityAlert.Text.Trim()), utils.convertObject(this.Entry_Remark.Text)); * await DisplayAlert("Complete", "Update Complete", "OK"); * bt_Confirm.Text = "Confirm"; * * await Navigation.PushAsync(new ListMaterialAdmin()); */ } else { //Insert await detailbaseHelper.AddMaterialDetail(utils.convertObject(header_id), source_select.ID, source_select.UnitName, quantity); await DisplayAlert("Complete", "Insert Complete", "OK"); bt_Confirm.Text = "Confirm"; //await Navigation.PushAsync(new ListMaterialF()); } //end if } //end if }