private void ProgrammerToDB() { if (!IfProgrammerGreedChanged()) return; DataManager dm = new DataManager(); MathManager mm = new MathManager(); int col = 3; int rows = programmerDataGridView.Rows.Count; string[] read = new string[col]; for (int i = 0; i < rows - 1; i++) { for (int j = 0; j < col; j++) { read[j] = programmerDataGridView.Rows[i].Cells[j + 1].Value.ToString(); } /*for (int j = 0; j < col; j++) { if (j == 2) continue; // description might be null if (read[j] == null) return; }*/ int programmer_ID = Convert.ToInt32(programmerDataGridView.Rows[i].Cells[0].Value.ToString()); if (mm.isProgrammer_Id_Exist(programmer_ID) >= 0) { // task already exist, therefore we need only to update if (mm.isProgrammerNameValid(read[0]) == true) { dm.ProgrammerUpdateProgrammerName(programmer_ID, read[0]); } else { MessageBox.Show("Invalid programmer name at line:" + (i + 1)); return; } dm.ProgrammerUpdateProgrammerExpectedWorkHours(programmer_ID,Convert.ToDouble(read[1])); dm.ProgrammerUpdateProgrammerCurrentWorkHours(programmer_ID, Convert.ToDouble(read[2])); } else { int ans = dm.ProgrammerAddNewProgrammer(read[0], Convert.ToInt32(read[1]), Convert.ToInt32(read[2])); if (ans == -1) { MessageBox.Show("Error adding new programmer"); return; } } } }
public void ProgrammerUpdateExpectedwork_hoursTest() { DataManager target = new DataManager(); // TODO: Initialize to an appropriate value int Programmer_ID = 6; // TODO: Initialize to an appropriate value int hours = 14; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.ProgrammerUpdateProgrammerExpectedWorkHours(Programmer_ID, hours); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }