private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new unit name!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a IP Address for the unit!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Configuration.Unit DAO = new data.DAO.Configuration.Unit(); DAO.ConnectionString = _connectionString; DAO.Insert(zoneId, txtZoneName.Text, DateTime.Now,textBox1.Text); HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new unit name!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a IP Address for the unit!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Configuration.Unit DAO = new data.DAO.Configuration.Unit(); DAO.ConnectionString = _connectionString; DAO.Insert(zoneId, txtZoneName.Text, DateTime.Now, textBox1.Text); HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new unit name!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a IP Address for the unit!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Configuration.Unit DAO = new data.DAO.Configuration.Unit(); DAO.ConnectionString = _connectionString; DAO.Insert(zoneId, txtZoneName.Text, DateTime.Now, textBox1.Text); int insertedId = DAO.GetLastInsertedUnit(zoneId); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(_unitId); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { deviceDAO.Insert(insertedId, device.Name, DateTime.Now, device.Switch); } HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new unit name!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a IP Address for the unit!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Configuration.Unit DAO = new data.DAO.Configuration.Unit(); DAO.ConnectionString = _connectionString; DAO.Insert(zoneId, txtZoneName.Text, DateTime.Now,textBox1.Text); int insertedId = DAO.GetLastInsertedUnit(zoneId); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(_unitId); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { deviceDAO.Insert(insertedId, device.Name, DateTime.Now, device.Switch); } HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }