protected void Update_Click(object sender, EventArgs e) { int id = 0; if (string.IsNullOrEmpty(ID.Text)) { errormsgs.Add("Search for a Player to update"); } else if (!int.TryParse(ID.Text, out id)) { errormsgs.Add("Id is invalid"); } Validation(sender, e); if (errormsgs.Count > 0) { LoadMessageDisplay(errormsgs, "alert alert-info"); } else { try { Controller02 sysmgr = new Controller02(); Entity02 item = new Entity02(); item.PlayerID = int.Parse(ID.Text); item.FirstName = FirstName.Text.Trim(); item.LastName = LastName.Text.Trim(); item.Gender = Gender.Text.ToUpper().Trim(); item.Age = int.Parse(Age.Text); item.AlbertaHealthCareNumber = AlbertaHealthCareNumber.Text.Trim(); item.MedicalAlertDetails = MedicalAlertDetails.Text.Trim(); if (SupplierList.SelectedIndex == 0) { item.TeamID = null; } else { item.TeamID = int.Parse(SupplierList.SelectedValue); } item.GuardianID = int.Parse(CategoryList.SelectedValue); int rowsaffected = sysmgr.Update(item); if (rowsaffected > 0) { errormsgs.Add("Record has been updated"); LoadMessageDisplay(errormsgs, "alert alert-success"); } else { errormsgs.Add("Record was not found"); LoadMessageDisplay(errormsgs, "alert alert-warning"); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }
protected void Update_Click(object sender, EventArgs e) { int id = 0; if (string.IsNullOrEmpty(ID.Text)) { errormsgs.Add("Search for a player to update"); } else if (!int.TryParse(ID.Text, out id)) { errormsgs.Add("Id is invalid"); } Validation(sender, e); if (errormsgs.Count > 0) { LoadMessageDisplay(errormsgs, "alert alert-info"); } else { try { Controller02 sysmgr = new Controller02(); Entity02 player = new Entity02(); player.PlayerID = int.Parse(ID.Text); player.FirstName = FirstName.Text; player.LastName = LastName.Text; player.GuardianID = int.Parse(GuardianList.SelectedValue); player.TeamID = int.Parse(TeamList.SelectedValue); player.Age = int.Parse(Age.Text); player.Gender = Gender.Text.ToUpper(); player.AlbertaHealthCareNumber = AlbertaHealthCareNumber.Text; if (string.IsNullOrEmpty(MedicalAlertDetails.Text)) { player.MedicalAlertDetails = null; } else { player.MedicalAlertDetails = MedicalAlertDetails.Text; } //item.Discontinued = Discontinued.Checked; int rowsaffected = sysmgr.Update(player); if (rowsaffected > 0) { errormsgs.Add("Player has been updated"); LoadMessageDisplay(errormsgs, "alert alert-success"); } else { errormsgs.Add("Player was not found"); LoadMessageDisplay(errormsgs, "alert alert-warning"); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }
protected void Update_Click(object sender, EventArgs e) { int id = 0; if (string.IsNullOrEmpty(ID.Text)) { errormsgs.Add("Search for a record to update"); } else if (!int.TryParse(ID.Text, out id)) { errormsgs.Add("Id is invalid"); } Validation(sender, e); if (errormsgs.Count > 1) { LoadMessageDisplay(errormsgs, "alert alert-info"); } else { try { Controller02 sysmgr = new Controller02(); Entity02 item = new Entity02(); item.ProductID = int.Parse(ID.Text); item.ProductName = Name.Text.Trim(); if (SupplierList.SelectedIndex == 0) { item.SupplierID = null; } else { item.SupplierID = int.Parse(SupplierList.SelectedValue); } item.CategoryID = int.Parse(CategoryList.SelectedValue); item.QuantityPerUnit = string.IsNullOrEmpty(QuantityPerUnit.Text) ? null : QuantityPerUnit.Text; if (string.IsNullOrEmpty(UnitPrice.Text)) { item.UnitPrice = null; } else { item.UnitPrice = decimal.Parse(UnitPrice.Text); } if (string.IsNullOrEmpty(UnitsInStock.Text)) { item.UnitsInStock = null; } else { item.UnitsInStock = Int16.Parse(UnitsInStock.Text); } if (string.IsNullOrEmpty(UnitsOnOrder.Text)) { item.UnitsOnOrder = null; } else { item.UnitsOnOrder = Int16.Parse(UnitsOnOrder.Text); } if (string.IsNullOrEmpty(ReorderLevel.Text)) { item.ReorderLevel = null; } else { item.ReorderLevel = Int16.Parse(ReorderLevel.Text); } item.Discontinued = Discontinued.Checked; int rowsaffected = sysmgr.Update(item); if (rowsaffected > 0) { errormsgs.Add("Record has been updated"); LoadMessageDisplay(errormsgs, "alert alert-success"); } else { errormsgs.Add("Record was not found"); LoadMessageDisplay(errormsgs, "alert alert-warning"); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }