private void btnUpdateShipper_Click(object sender, EventArgs e) { try { int shipperId; if (int.TryParse(tboShipperID.Text, out shipperId)) { //Do the update var info = new Shipper() { ShipperID = shipperId, CompanyName = tboCompanyName.Text, Phone = tboPhone.Text }; var mgr = new NorthwindManager(); mgr.UpdateShipper(info); PopulateShippersComboBox(); cboShippers.SelectedValue = info.ShipperID; } else { MessageBox.Show("Please lookup a shipper before trying to update."); } } catch (Exception ex) { //TODO: Log the exception MessageBox.Show(ex.Message); } }
private void UpdateShipper_Click(object sender, EventArgs e) { try { int tempShipper; if (int.TryParse(ShipperId.Text, out tempShipper)) { // do the update...this is an initializer list, constructor runs, properties of the Shipper Object get values var info = new Shipper() { ShipperID = tempShipper, CompanyName = CompanyName.Text, Phone = Phone.Text }; var mgr = new NorthwindManager(); mgr.UpdateShipper(info); PopulateShippersComboBox(); cboShippers.SelectedValue = info.ShipperID; } else { MessageBox.Show("Please look up a shipper before trying to update."); } } catch (Exception ex) { // TODO: Update logging MessageBox.Show(ex.Message); } }
private void btnUpdateShipper_Click(object sender, EventArgs e) { try { int shipperId; if (int.TryParse(lblShipperID.Text, out shipperId)) { var info = new Shipper() { ShipperID = shipperId, CompanyName = txtCompanyName.Text, Phone = txtPhone.Text }; var mgr = new NorthwindManager(); mgr.UpdateShipper(info); PopulateShippersComboBox(); cboShippers.SelectedValue = info.ShipperID; // Maybe there should be some indication to the user that the update was successful. MessageBox? Label? } else { MessageBox.Show("Please lookup a shipper before trying to update."); } } catch (Exception ex) { // TODO: log exception MessageBox.Show(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { int shipperId; if (int.TryParse(lblShipperID.Text, out shipperId)) { //do the update... var info = new Shipper() { ShipperID = shipperId, CompanyName = txtCompanyName.Text, Phone = txtPhone.Text }; NorthwindManager mgr = new NorthwindManager(); mgr.UpdateShipper(info); PopulateShippersComboBox(); cboShippers.SelectedValue = shipperId; } else { MessageBox.Show("Please select a shipper before clicking [Lookup Shipper]"); } } catch (Exception ex) { //TODO: Log the exception MessageBox.Show("Error: " + ex.Message); } }
public void Should_Update_Shipper(Shipper existing) { //arrange existing.Phone = "780.999.9999"; var sut = new NorthwindManager(); //act sut.UpdateShipper(existing); //assert var actual = sut.GetShipper(existing.ShipperID); Assert.NotNull(actual); Assert.Equal(existing.Phone, actual.Phone); }
public void Should_Update_Shipper(Shipper existing) { //Arrange existing.Phone = "780.999.999"; var sut = new NorthwindManager(); //sut is short for 'Scenario Under Test' existing.Phone = "780.555.1212"; //Act sut.UpdateShipper(existing); //Assert var actual = sut.GetShipper(existing.ShipperID); Assert.NotNull(actual); Assert.Equal(existing.CompanyName, actual.CompanyName); Assert.Equal(existing.Phone, actual.Phone); }
private void UpdateShipper_Click(object sender, EventArgs e) { // todo: add logging int shipperId; if (int.TryParse(ShipperID.Text, out shipperId)) { var info = new Shipper() { ShipperID = shipperId, CompanyName = CompanyName.Text, Phone = Phone.Text }; var mgr = new NorthwindManager(); mgr.UpdateShipper(info); //PopulateShippersComboBox(); cboShippers.SelectedValue = info.ShipperID; } else { MessageBox.Show("Please lookup a shipper before trying to update."); } }