private async void btnAdd_Click(object sender, EventArgs e) { if (btnAdd.Text == "Add") { if (IsValid()) { HealthRecommendationList obj = new HealthRecommendationList(); obj.ListHealthRecommendation = txtHealthRecommendation.Text; await healthRecommedationList.Create(obj); this.Close(); } } if (btnAdd.Text == "Update") { if (IsValidUpdate()) { HealthRecommendationList obj = await healthRecommedationList.Get(frmSettings.HealthRecommendationID); obj.ListHealthRecommendation = txtHealthRecommendation.Text; await healthRecommedationList.Update(obj); frmSettings setting = (frmSettings)Application.OpenForms["frmSettings"]; await setting.LoadHealthRecommendation(); this.Close(); } } }
private async void frmAddHealthRecommendation_Load(object sender, EventArgs e) { await CallLoad(); if (frmSettings.OnEdit == true) { this.Text = "Update Info"; btnAdd.Text = "Update"; HealthRecommendationList obj = await healthRecommedationList.Get(frmSettings.HealthRecommendationID); txtHealthRecommendation.Text = obj.ListHealthRecommendation; } }