public void addSegmentToTM() { //Console.WriteLine(editorGrid.CurrentRow.Index); editorGrid.EndEdit(); int Index = editorGrid.CurrentRow.Index; if (editorGrid.Rows[Index].Cells["targetColumn"].Value != null && editorGrid.Rows[Index].Cells["sourceColumn"].Value != null) { string targetText = editorGrid.Rows[Index].Cells["targetColumn"].Value.ToString(); string sourceText = editorGrid.Rows[Index].Cells["sourceColumn"].Value.ToString(); DAOTM daotm = new DAOTM(); if (mainForm.project != null) { string tmname = mainForm.project.getTMName(); tm tmp = new tm() { Source = sourceText, Target = targetText }; Segment segment = new Segment(); segment.setTM(tmp); if (tmp.Source != string.Empty && tmp.Target != string.Empty && tmname != string.Empty) { int result = daotm.addSegmentToTM(segment, tmname); if (result != 1) { TextOfMessageBox a = new TextOfMessageBox(); MessageBox.Show(a.ADD_SEGMENT_FAILED, "Cảnh báo", MessageBoxButtons.YesNo); } else { if (result == 1) { lblStatus.Text = "Đã lưu thành công"; editorGrid.Rows[Index].Cells["confirmColumn"].Value = true; } } } else { TextOfMessageBox a = new TextOfMessageBox(); MessageBox.Show(a.EMPTY_TARGET, "Cảnh báo", MessageBoxButtons.YesNo); } } } else { TextOfMessageBox a = new TextOfMessageBox(); MessageBox.Show(a.EMPTY_TARGET, "Cảnh báo", MessageBoxButtons.YesNo); } }
public void addAllSegmentToTM() { List <Segment> segments = getListSegment(); string tmname = mainForm.project.getTMName(); DAOTM daotm = new DAOTM(); int index = 0; if (segments.Count > 0) { try { foreach (Segment segment in segments) { string source = segment.getTMSource(); string target = segment.getTMTarget(); int result = 0; if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target)) { result = daotm.addSegmentToTM(segment, tmname); } if (result != 1) { break; } else { editorGrid.Rows[index].Cells["confirmColumn"].Value = true; } index++; } } catch (Exception ex) { Console.WriteLine(ex); } } }