private void btnOk_Click(object sender, EventArgs e) { TextOfMessageBox a = new TextOfMessageBox(); DAOTM daoTM = new DAOTM(); List <tablename> tmnames = daoTM.GetTablenames(); if (txtLocation.Text != "" && txtProjectName.Text != "" && ((ckbCreateNewTM.Checked && txtTMName.Text != "") || (ckbUseTMCreated.Checked && cboTMName.SelectedValue != null))) { if (checkExistsTM(tmnames, txtTMName.Text)) { string root = Path.Combine(txtLocation.Text, txtProjectName.Text); if (Directory.Exists(root)) { MessageBox.Show(a.FOLDER_EXISTING_MESAGEBOX, "Cảnh báo", MessageBoxButtons.YesNo); } else { createProject(); } } else { MessageBox.Show(a.EXISTS_TM, "Cảnh báo", MessageBoxButtons.YesNo); } } else { MessageBox.Show(a.CREATE_NEW_PROJECT_MESSAGEBOX, "Cảnh báo", MessageBoxButtons.YesNo); } }
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); } }
private void createProject() { DAOTM tmdao = new DAOTM(); TextOfMessageBox a = new TextOfMessageBox(); string name = txtProjectName.Text; string sourceFileLanguge = cboSourceFilesLanguage.Text; string translatedFileLanguge = cboTranslatedFilesLanguage.Text; //string locationFolder = txtLocation.Text + "\\" + txtProjectName.Text; string locationFolder = Path.Combine(txtLocation.Text, txtProjectName.Text); DateTime now = new DateTime(); now = DateTime.Now; Project project = new Project(); project.setLanguage(sourceFileLanguge, translatedFileLanguge); project.setNameProject(name); project.setPathProject(locationFolder); project.setCreationTime(now); if (ckbUseTMCreated.Checked) { tablename tbn = cboTMName.SelectedItem as tablename; project.setTMName(tbn.name); mainForm.setProject(project); closeForm(); mainForm.createNewProject(); //mainForm.creatNewProjectForm = null; //closeForm(); } if (ckbCreateNewTM.Checked) { string tmname = txtTMName.Text; project.setTMName(tmname); int result = tmdao.createTable(project.getTMName()); if (result == 0) { mainForm.setProject(project); closeForm(); mainForm.createNewProject(); //mainForm.creatNewProjectForm = null; closeForm(); } else { MessageBox.Show(a.CREATE_TM_FAILED, "Cảnh báo", MessageBoxButtons.YesNo); } } }
private void createNewProject_Load(object sender, EventArgs e) { LanguageList listLanguage1 = new LanguageList(); LanguageList listLanguage2 = new LanguageList(); cboSourceFilesLanguage.DataSource = listLanguage1.getListLanguage(); cboSourceFilesLanguage.DisplayMember = "name"; cboTranslatedFilesLanguage.DataSource = listLanguage2.getListLanguage(); cboTranslatedFilesLanguage.DisplayMember = "name"; DAOTM daoTM = new DAOTM(); cboTMName.Items.Insert(0, string.Empty); cboTMName.DataSource = daoTM.GetTablenames(); cboTMName.DisplayMember = "name"; txtLocation.Text = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); }
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); } } }