private void btnSubmit_Click(object sender, EventArgs e) { try { Terminal terminal = GetTerminalUserInput(); if (terminal == null) //invalid input { return; } if (_terminalID == -1) //add { //check for duplicated teminal if (_dtCtrl.IsDuplicateTerminal(terminal, false)) { MessageBox.Show("This name or IP Address has been used by another Terminal."); return; } if (_dtCtrl.AddTerminal(terminal) > 0) { MessageBox.Show("Terminal added."); SetState(0); LoadData(); } else { MessageBox.Show("Terminal could not be added. Please try again"); } } else //update { terminal.ID = _terminalID; //check for duplicated teminal if (_dtCtrl.IsDuplicateTerminal(terminal, true)) { MessageBox.Show("This name or IP Address has been used by another Terminal."); return; } if (_dtCtrl.UpdateTerminal(terminal)) { MessageBox.Show("Terminal updated."); SetState(0); LoadData(); } else { MessageBox.Show("Terminal could not be updated. Please try again"); } } } catch (Exception ex) { Util.ShowErrorMessage(ex); } }
public void TestAddTerminal() { ter1.Name = "Ter1"; ter1.IPAddress = "10.0.0.101"; ter1.ID = _dtCtrl.AddTerminal(ter1); Assert.Greater(ter1.ID, 0); //add again Assert.Less(_dtCtrl.AddTerminal(ter1), 0); //add null Assert.Less(_dtCtrl.AddTerminal(null), 0); //add empty name ter2.Name = ""; ter2.IPAddress = "10.0.0.102"; Assert.Less(_dtCtrl.AddTerminal(ter2), 0); //add duplicate name ter2.Name = "Ter1"; ter2.IPAddress = "10.0.0.102"; Assert.Less(_dtCtrl.AddTerminal(ter2), 0); //empty ip add ter2.Name = "Ter2"; ter2.IPAddress = ""; Assert.Less(_dtCtrl.AddTerminal(ter2), 0); //duplicate ip add ter2.Name = "Ter2"; ter2.IPAddress = "10.0.0.101"; Assert.Less(_dtCtrl.AddTerminal(ter2), 0); //invalid ter2.Name = "Ter2"; ter2.IPAddress = "10.0.0.999"; Assert.Less(_dtCtrl.AddTerminal(ter2), 0); }
private void AddTerminal() { ter1.Name = DateTime.Now.Ticks.ToString(); ter1.IPAddress = "10.0.0.199"; ter1.ID = _dtCtrl.AddTerminal(ter1); emp1 = new Employee(); emp1.Active = true; emp1.ActiveFrom = DateTime.Today; emp1.ActiveTo = DateTime.Today.AddDays(1); emp1.Address = DateTime.Now.Ticks.ToString(); emp1.Birthday = DateTime.Today.AddYears(-20); emp1.DepartmentID = _dtCtrl.GetDepartmentList()[0].ID; emp1.EmployeeNumber = 0; emp1.FirstName = DateTime.Now.Ticks.ToString(); emp1.JobDescription = DateTime.Now.Ticks.ToString(); emp1.HiredDate = DateTime.Today; emp1.LeftDate = DateTime.Today.AddYears(1); emp1.LastName = DateTime.Now.Ticks.ToString(); emp1.PhoneNumber = DateTime.Now.Ticks.ToString(); emp1.WorkingCalendarID = _dtCtrl.GetWorkingCalendarList()[0].ID; emp1.FaceData1 = ""; emp1.FaceData2 = ""; emp1.FaceData3 = ""; emp1.FaceData4 = ""; emp1.FaceData5 = ""; emp1.FaceData6 = ""; emp1.FaceData7 = ""; emp1.FaceData8 = ""; emp1.FaceData9 = ""; emp1.FaceData10 = ""; emp1.FaceData11 = ""; emp1.FaceData12 = ""; emp1.FaceData13 = ""; emp1.FaceData14 = ""; emp1.FaceData15 = ""; emp1.FaceData16 = ""; emp1.FaceData17 = ""; emp1.FaceData18 = ""; emp1.PayrollNumber = _dtCtrl.AddEmployee(emp1, new List <Terminal>() { ter1 }); }