예제 #1
0
        //DataGridView下のボタンをクリックした際の処理
        private void buttons_click(object sender, EventArgs e) {
            Button btn = (Button)sender;
            DialogResult result;
            Project pj;
            DataRow row;
            int vrow_index;
            switch (btn.Name) {
                //新規プロジェクト
                case "btnAddProject":
                    log.Write("addProjectBEGIN");
                    log.Write("step1");

                    ShellBrowseForFolderDialog fbdProject = new ShellBrowseForFolderDialog();
                    fbdProject.RootType = ShellBrowseForFolderDialog.RootTypeOptions.ByPath;
                    fbdProject.RootPath = env_data.Master.Folder;
                    fbdProject.DetailsFlags = ShellBrowseForFolderDialog.BrowseInfoFlag.BIF_NONEWFOLDERBUTTON;
                    fbdProject.Title = "業務パックフォルダを選択してください";
                    try {
                        if (!fbdProject.ShowDialog()) return;
                    } catch (Exception ex) {
                        MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    string master = fbdProject.FullName + @"\master.xml";
                    if (!File.Exists(master)) {
                        string xls = fbdProject.FullName + @"\master.xls";
                        if (!File.Exists(xls)) {
                            MessageBox.Show("このフォルダは業務パックフォルダではありません");
                            log.Close();
                            return;
                        }
                        XMLConverter xml;
                        try {
                            xml = new XMLConverter(XmlType.Master, xls);
                            xml.Convert();
                        } catch (Exception ex) {
                            MessageBox.Show(ex.Message,"エラー",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            return;
                        }
                    }
                    log.Write("Step2");
                    log.Close();
                    Master env_master = env_data.Master;
                    env_master.SelectedFolder = fbdProject.DisplayName;
                    env_data.Master = env_master;
                    frm_sub = new frmSubWindow(env_data, log, OpenWindowType.CREATE_PROJECT);
                    frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                    frm_sub.Show();
                    this.Enabled = false;
                    log.Write("addProjectEnd");
                    log.Close();
                    break;
                //プロジェクト詳細、プロジェクト変更、プロジェクト削除
                case "btnDetailProject":
                case "btnChangeProject":
                case "btnDeleteProject":
                    if (dgvMain.SelectedRows.Count == 0 || dgvMain.SelectedRows[0].Cells[0].Value == null) return;
                    row = GetDataRowByDataGridViewRow("ProjectData", dgvMain.SelectedRows[0]);
                    if (row == null) return;
                    pj = env_data.Project;
                    pj.SelectedFolder = row[2].ToString();
                    env_data.Project = pj;
                    if (btn.Name == "btnDetailProject")
                        AddTab(row);
                    else if (btn.Name == "btnChangeProject") {
                        frm_sub = new frmSubWindow(env_data, log, OpenWindowType.PROJECT_DATA);
                        frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                        frm_sub.Show();
                        this.Enabled = false;
                    } else if (btn.Name == "btnDeleteProject") {
                        frm_sub = new frmSubWindow(env_data, log, OpenWindowType.DELETE_PROJECT);
                        frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                        frm_sub.Show();
                    }
                    break;
                //プロジェクト取り込み
                case "btnGetProject":
                    frm_sub = new frmSubWindow(env_data, log, OpenWindowType.GET_PROJECT);
                    frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                    frm_sub.Show();
                    this.Enabled = false;
                    break;
                //プロジェクト取り出し
                case "btnPutProject":
                    if (dgvMain.SelectedRows.Count == 0) return;
                    if (env_data.Project.TortoiseSVN || env_data.Project.DropBox)
                        ExportProjectData();
                    else
                        MessageBox.Show("この機能は、TortoiseSVNあるいはDropBoxでプロジェクト共有している場合のみ有効です", "確認", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    break;
                //フォルダ表示
                case "btnViewFolder":
                    if (tabControl.SelectedIndex == 0) {
                        if (dgvMain.SelectedRows.Count == 0 || dgvMain.SelectedRows[0].Cells[0].Value == null) return;
                        string folder = dgvMain.SelectedRows[0].Cells[0].Value.ToString();
                        if (folder == "") return;
                        if (!Directory.Exists(env_data.Project.Folder + folder)) return;
                        Process.Start("explorer.exe", "/e /select," + env_data.Project.Folder + folder);
                    } else
                        Process.Start("explorer.exe", "/e /select," + env_data.Project.Folder + env_data.Project.SelectedFolder);
                    break;
                //終了
                case "btnQuit":
                    CloseApplication();
                    break;
                //タスク追加
                case "btnAddTask":
                    frm_sub = new frmSubWindow(env_data, log, OpenWindowType.ADD_TASK);
                    frm_sub.TaskDataSet = ds_main;
                    frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                    frm_sub.Show();
                    this.Enabled = false;
                    break;
                //タスク詳細
                case "btnTaskDetail":
                    if (dgvMain.SelectedRows.Count == 0) return;
                    vrow_index = dgvMain.SelectedRows[0].Index;
                    if (vrow_index < 0 || vrow_index >= ds_main.Tables["Task"].Rows.Count) return;
                    log.Write("ShowFileBegin");
                    log.Write("Step1");
                    log.Close();
                    row = GetDataRowByDataGridViewRow("Task", dgvMain.Rows[vrow_index]);
                    if (row == null) return;
                    CallWindow(ds_main.Tables["Task"].Rows.IndexOf(row));
                    break;
                //タスク変更
                case "btnTaskChange":
                    if (dgvMain.SelectedRows.Count == 0) return;

                    if (dgvMain.SelectedRows[0].Index < 0 || dgvMain.SelectedRows[0].Index >= ds_main.Tables["Task"].Rows.Count) return;
                    frm_sub = new frmSubWindow(env_data, log, OpenWindowType.CHANGE_TASK);
                    frm_sub.TaskDataSet = ds_main;
                    frm_sub.CurrentTask = ds_main.Tables["Task"].Rows[dgvMain.SelectedRows[0].Index];
                    frm_sub.CurrentTaskRowIndex = dgvMain.SelectedRows[0].Index;
                    frm_sub.FormClosed += new FormClosedEventHandler(frmSubWindow_Closed);
                    frm_sub.Show();
                    this.Enabled = false;
                    break;
                //タスクコピー
                case "btnTaskCopy":
                    int row_index=0;
                    List<int> row_indexes = new List<int>();
                    DataGridViewRow[] rows=new DataGridViewRow[dgvMain.SelectedRows.Count];
                    dgvMain.SelectedRows.CopyTo(rows,0);
                    Array.Sort(rows,delegate(DataGridViewRow row1, DataGridViewRow row2) { return dgvMain.Rows.IndexOf(row1).CompareTo(dgvMain.Rows.IndexOf(row2)); });
                    foreach (DataGridViewRow dr in rows) {
                        Console.WriteLine(dr.Cells[0].Value.ToString());
                        row_index = GetRowIndexByDataViewRow(dr);
                        if (row_index < 0) return;
                        CopyTask(row_index,ref row_indexes);
                    }
                    ShowDetail();
                    dgvMain.ClearSelection();
                    foreach (int idx in row_indexes) {
                        dgvMain.Rows[idx].Selected = true;
                    }
                    break;
                //タスク削除
                case "btnTaskDelete":
                    row_index =0;
                    foreach (DataGridViewRow dr in dgvMain.SelectedRows) {
                        row_index = GetRowIndexByDataViewRow(dr);
                        DeleteTask(row_index);
                    }
                    ShowDetail();
                    break;
                //閉じる
                case "btnExit":
                    result = MessageBox.Show("現在のプロジェクトを閉じますが、よろしいですか?", "確認", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result == DialogResult.Yes) {
                        tabs.RemoveAt(tabControl.SelectedIndex);
                        ShowProjectData();
                        tabControl.SelectedIndex = 0;
                    }
                    break;
            }
        }
예제 #2
0
        //タスク一覧の表示
        private void ShowDetail() {
            dgvMain.MultiSelect = true;
            log.Write("ShowDetailBEGIN");
            log.Write("Step1");
            log.Close();
            if (env_data.Project.SelectedFolder == "") {
                MessageBox.Show("プロジェクトが選択されていません。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string task = env_data.Project.Folder + env_data.Project.SelectedFolder + @"\task.xml";
            if (!File.Exists(task)) {
                string excel = task.Replace(".xml", ".xls");
                if (!File.Exists(excel)) {
                    MessageBox.Show("タスクマスタが見つかりません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tabs[tabs.Count - 1].Controls.Remove(mainView);
                    DeleteTab(tabs.Count - 1);
                    tabs[0].Controls.Add(mainView);
                    tabControl.SelectedIndex = 0;
                    ShowProjectData();
                    return;
                } else {
                    XMLConverter xml = new XMLConverter(XmlType.TaskList, excel);
                    xml.Convert();
                }
            }

            if (env_data.Project.TortoiseSVN) {
                if (svn == null) svn = new SvnManager(env_data);
                if (task == "")
                    svn.TortoiseSvn("Project", "checkout", env_data.Project.Folder + @"\" + env_data.Project.SelectedFolder, env_data.Project.URL + env_data.Project.SelectedFolder);
                else
                    svn.TortoiseSvn("Project", "update", env_data.Project.Folder + @"\" + env_data.Project.SelectedFolder, "");
            }
            log.Write("Step2");
            log.Close();
            ds_main = new DataSet();
            ds_main.ReadXml(task);
            DataView dv = new DataView(ds_main.Tables["Task"].Copy());
            InitDatagridView(dv);
            dgvMain.DataSource = dv;
            DataGridViewTextBoxColumn dvc = new DataGridViewTextBoxColumn();
            dvc.ValueType = Type.GetType("System.Datetime");
            dvc.Name = "最終更新日";
            dgvMain.Columns.Insert(5, dvc);
            int[] widths = {60, 345, 80, 60, 80, 100, 85, 85, 60 };
            while (dgvMain.Columns.Count > 9) { dgvMain.Columns.RemoveAt(dgvMain.Columns.Count - 1); }
            for (int i = 0; i < dgvMain.Columns.Count; i++) {
                dgvMain.Columns[i].Width = widths[i];
                if (i == 3) {
                    dgvMain.Columns[i].HeaderText="様式";
                    foreach (DataGridViewRow dr in dgvMain.Rows) {
                        if (dr.Cells[i].Value != null)
                            dr.Cells[i].Value = Path.GetExtension(dr.Cells[i].Value.ToString());
                    }
                } else if (i == 5) {
                    string f_name;
                    foreach (DataGridViewRow dr in dgvMain.Rows) {
                        if (dr.Cells[3].Value == null) continue;
                        f_name = env_data.Project.Folder + env_data.Project.SelectedFolder + @"\" + ds_main.Tables["Task"].Rows[dr.Index][3];
                        if (File.Exists(f_name))
                            dr.Cells[i].Value = File.GetLastAccessTime(f_name).ToString(@"yyyy/MM/dd");
                    }
                }
            }
            dgvMain.Rows[0].Selected = true;
            SetTaskRowsColor();
            SetButtons();
            log.Write("ShowDetailEND");
            log.Close();
            
        }
예제 #3
0
        //新規プロジェクトリストの作成
        private void CreateIndex() {
            log.Write("CreateIndexBEGIN");
            data_set = new DataSet();
            if (File.Exists(env.Documents.Path))
                data_set.ReadXml(env.Documents.Path, XmlReadMode.ReadSchema);
            else {
                XMLConverter conv = new XMLConverter(XmlType.Index, "");
                data_set = conv.CreateNewDataSet();
            }
            DataSet new_index = data_set.Clone();
            new_index.Tables["ProjectData"].Rows.Clear();
            DataRow dr;
            string[] persons = new string[] { tbxWizard0201.Text, "スタッフ1", "スタッフ2", "未定", "申請者" };
            int i;
            for (i = 0; i < persons.Length; i++) {
                dr = new_index.Tables["担当者"].NewRow();
                dr[0] = persons[i];
                new_index.Tables["担当者"].Rows.Add(dr);
            }
            string[] statuses = new string[] { "作業中", "処理済", "未着手" };
            for (i = 0; i < statuses.Length; i++) {
                dr = new_index.Tables["状態"].NewRow();
                dr[0] = statuses[i];
                new_index.Tables["状態"].Rows.Add(dr);
            }
            string[] kinds = new string[] { "書類作成", "準備書類", "行動" };
            for (i = 0; i < kinds.Length; i++) {
                dr = new_index.Tables["タスク種別"].NewRow();
                dr[0] = kinds[i];
                new_index.Tables["タスク種別"].Rows.Add(dr);
            }
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "プロジェクト一覧を保存";
            sfd.FileName ="index.xml";
            sfd.Filter = "docmakerPM プロジェクト一覧|index.xml";
            DialogResult result = sfd.ShowDialog();
            if (result == DialogResult.OK) {
                new_index.WriteXml(sfd.FileName, XmlWriteMode.WriteSchema);
                Documents documents = env.Documents;
                documents.Path = sfd.FileName;
                env.Documents = documents;
                env.SaveEnvData();
            }

            log.Write("CreateIndexEND");
            log.Close();
        }
예제 #4
0
        //プロジェクト情報を取り込む
        private void GetProjectFolder() {
            log.Write("GetProjectFolderBEGIN");

            string strProjectFolder;
            string strProjectName;
            string strCopyFromProjectName;
            if (lviewProjectList.SelectedItems.Count > 0) {
                strProjectFolder = env.Project.Folder + lviewProjectList.SelectedItems[0].SubItems[2].Text;
                strProjectName = lviewProjectList.SelectedItems[0].SubItems[1].Text;
            } else {
                strProjectFolder = tbxProjectFolder.Text;
                strProjectName = "";
            }

            if (strProjectFolder.IndexOf(".dpr") > 0) {
                tbxProjectFolder.Text = strProjectFolder;
                strCopyFromProjectName = "未設定";
            } else {
                log.Write("Step2");
                if (!File.Exists(strProjectFolder + @"\task.xml") && !File.Exists(strProjectFolder + @"\task.xls")) {
                    MessageBox.Show("取り込み元のプロジェクトデータが存在しません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    log.Close();
                    return;
                }
                tbxProjectFolder.Text = strProjectFolder;
                strCopyFromProjectName = strProjectName;
                Project pj = env.Project;
                pj.SelectedFolder =Path.GetFileName(strProjectFolder);
                env.Project = pj;
                env.SaveEnvData();
            }
            pnlGetProject.Visible = false;
            InitProjectData();
            this.Text = "プロジェクト情報取り込み";
            label26.Text = "プロジェクト情報取り込み";
            label28.Text = "プロジェクトの情報を外部フォルダ/ファイルから取り込み、下記のとおり設定します。";
            btnChange2.Text = "取り込み";

            if (tbxProjectFolder.Text.IndexOf(".dpr") > 0) {
                DataSet ds_project = new DataSet();
                if (tbxProjectFolder.Text.IndexOf(".dprx") > 0) {
                    ds_project.ReadXml(tbxProjectFolder.Text, XmlReadMode.ReadSchema);
                } else {
                    XMLConverter cvtr = new XMLConverter(XmlType.Dpr, tbxProjectFolder.Text);
                    cvtr.Convert(out ds_project);
                }
                DataRow dr;
                try {
                    dr = ds_project.Tables["ProjectData"].Rows[0];
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    log.Close();
                    return;
                }
                if (ds_project.Tables["ProjectData"].Columns.Count < 8) {
                    MessageBox.Show("ファイルが正しくありません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    log.Close();
                    return;
                }
                tbxProjectName.Text = dr[1].ToString();
                label28.Text += "\n元フォルダ:" + dr[2].ToString();
                tbxProjectFolder.Text += ";" + dr[2].ToString();
                cmbPerson.Text = dr[3].ToString();
                tbxStartDate.Text = dr[4].ToString();
                tbxEndDate.Text = dr[5].ToString();
                tbxRenewalDate.Text = dr[6].ToString();
                cmbStatus.Text = dr[7].ToString();
                ds_project.Dispose();
            } else {
                label28.Text += "\n元ファイル:" + tbxProjectFolder.Text;
                tbxProjectName.Text = "(コピー)" + strCopyFromProjectName;
            }
            pnlProjectData.Visible = true;

            log.Write("GetProjectFolderEND");
            log.Close();
        }
예제 #5
0
        //環境設定ファイルの保存
        private bool SaveEnvData() {
            bool flag = true;
            DialogResult result = MessageBox.Show("この環境設定を保存しますか", "環境設定保存の確認", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes) {
                string ext = Path.GetExtension(tbx0101.Text);
                if (ext == "" || !File.Exists(tbx0101.Text)) {
                    flag = false;
                    MessageBox.Show("プロジェクト一覧ファイルが見つかりません", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                } else if (ext == ".xls") {
                    string xml = "index.xml";
                    string dir = Directory.GetParent(tbx0101.Text).FullName + "\\";
                    if (!File.Exists(dir + xml)) {
                        try {
                            XMLConverter conv = new XMLConverter(XmlType.Index, tbx0101.Text);
                            conv.Convert();
                            tbx0101.Text = tbx0101.Text.Replace(".xls", ".xml");
                        } catch (Exception ex) {
                            flag = false;
                            MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return flag;
                        }

                    }
                }

                if (!Directory.Exists(tbx0201.Text)) {
                    flag = false;
                    MessageBox.Show("プロジェクト保存フォルダが見つかりません", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                if (tbx0202.Text.Length > 6 && tbx0202.Text.Substring(0, 4) != "http") {
                    flag = false;
                    MessageBox.Show("プロジェクトのURLが正しくありません", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                if (!cbxEditor.Checked && !File.Exists(txtEditor.Text)) {
                    flag = false;
                    MessageBox.Show("テキストエディタが見つかりません");
                }
                if (!Directory.Exists(tbx0301.Text)) {
                    flag = false;
                    MessageBox.Show("業務パックフォルダが見つかりません", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                if (tbx0302.Text.Length > 6 && tbx0302.Text.Substring(0, 4) != "http") {
                    flag = false;
                    MessageBox.Show("業務パックのURLが正しくありません", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                if (flag) {
                    if (cbxEditor.Checked) txtEditor.Text = "";
                    env.Documents = new Documents(tbx0101.Text, txtEditor.Text);
                    env.Project = new Project(tbx0201.Text, checkBox1.Checked, tbx0202.Text, checkBox3.Checked);
                    env.Master = new Master(tbx0301.Text, checkBox2.Checked, tbx0302.Text);
                    env.SaveEnvData();
                }
            }
            return flag;
        }