예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Pdetails.Contacts = null;
            List <string> contacts = new List <string>();

            foreach (DataGridViewRow r in dataGridView1.Rows)
            {
                string tmp_str = "";
                for (int i = 0; i <= 5; i++)
                {
                    string v = "";
                    if (r.Cells[i].Value != null)
                    {
                        v = r.Cells[i].Value.ToString();
                    }
                    tmp_str += v + ",";
                }
                tmp_str = tmp_str.Remove(tmp_str.Length - 1, 1);
                if (tmp_str.Replace(",", "") != "")
                {
                    contacts.Add(tmp_str);
                }
            }
            Pdetails.Contacts = contacts.ToArray();

            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = currentXMLpath;
            XmlFile.WriteXml(Pdetails);
            XmlFile.SaveXml();

            this.Close();
        }
예제 #2
0
        }//打开双击文件夹

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //在此处设断点,发现点击不同的Item后,此事件居然执行了2次
            //第一次是取消当前Item选中状态,导致整个ListView的SelectedIndices变为 空集
            //第二次才将新选中的Item设置为选中状态,SelectedIndices变为 非空集
            //如果不加listview.SelectedIndices.Count>0判断,将导致获取listview.Items[]索引超界的异常
            if (listView1.SelectedIndices.Count > 0)
            {
                int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
                currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址

                int    pos_int = listView1.Items[currentRowIndex].Text.LastIndexOf("】");
                string tmp_str = listView1.Items[currentRowIndex].SubItems[1].Text + listView1.Items[currentRowIndex].Text +
                                 @"\" + listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1) + ".xml";//组装XML文件绝对地址
                if (File.Exists(tmp_str))
                {
                    XML_Class x = new XML_Class();
                    pd = x.ReadXml(tmp_str);
                }
                else
                {
                    pd = null;
                }
                if (pd != null)
                {
                    tmp_str = listView1.Items[currentRowIndex].Text.ToString();
                    tmp_str = pd.FolderName(tmp_str);
                }
                ShowDetailsOnDV(pd);
            }
        }
예제 #3
0
        public static ProjectDetails getPD(string pPath)
        {
            ProjectDetails rtPD = new Folders.ProjectDetails();

            if (File.Exists(pPath))
            {
                XML_Class x = new XML_Class();
                rtPD = x.ReadXml(pPath);
            }
            else
            {
                rtPD = null;
            }
            return(rtPD);
        }
예제 #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            getPdetailsFromTexts();
            //DirectoryInfo Dinfo = new DirectoryInfo(@"E:\项目文件\" + Pdetails.FolderName());//创建文件夹地址字符串
            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = xmlPath;
            this.Text        = Pdetails.Pnote;
            XmlFile.WriteXml(Pdetails);
            this.Text = this.Text + " " + Pdetails.Pnote;
            XmlFile.SaveXml();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #5
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentCell.ColumnIndex == 0)
            {
                listView1.Focus(); return;
            }
            switch (dataGridView1.CurrentCell.RowIndex)
            {
            case 0:
                pd.Pname = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 1:
                pd.Pindex = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 2:
                pd.P = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 3:
                pd.C = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 4:
                pd.Pincharge = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 5:
                pd.Cincharge = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 6:
                pd.Pdep = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 7:
                pd.Pnote = dataGridView1.CurrentCell.Value.ToString();
                break;
            }

            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = @"E:\项目文件\" + pd.FolderName(1) + @"\" + pd.Pname + @".xml";
            XmlFile.WriteXml(pd);
            XmlFile.SaveXml();
            listView1.Focus();
        }
예제 #6
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentCell.ColumnIndex == 0)
            {
                listView1.Focus(); return;
            }
            switch (dataGridView1.CurrentCell.RowIndex)
            {
            case 0:
                currentPD.Pname = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 1:
                currentPD.Pindex = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 2:
                currentPD.P = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 3:
                currentPD.C = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 4:
                currentPD.Pincharge = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 5:
                currentPD.Cincharge = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 6:
                currentPD.Pdep = dataGridView1.CurrentCell.Value.ToString();
                break;

            case 7:
                currentPD.Pnote = dataGridView1.CurrentCell.Value.ToString();
                break;
            }
            msc_FolderList.updatePD(currentPD, currentFolder);
            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = currentXMLpath;
            XmlFile.WriteXml(currentPD);
            XmlFile.SaveXml();
            listView1.Focus();
        }
예제 #7
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            getPdetailsFromTexts();

            //DirectoryInfo Dinfo = new DirectoryInfo(@"E:\项目文件\" + Pdetails.FolderName());//创建文件夹地址字符串
            DirectoryInfo Dinfo = new DirectoryInfo(msc_FolderList.defaultPath + @"\" + Pdetails.FolderName()); //创建文件夹地址字符串

            Dinfo.Create();                                                                                     //创建文件夹

            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = xmlPath == null ? msc_FolderList.defaultPath + Pdetails.FolderName() + @"\foldersPD.xml" : xmlPath;
            XmlFile.WriteXml(Pdetails);
            XmlFile.SaveXml();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #8
0
        private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView2.CurrentCell.Value == null)
            {
                return;
            }
            try
            {
                string tmp = currentPD.Contacts[dataGridView2.CurrentCell.RowIndex];
            }
            catch
            {
                List <string> contacts = new List <string>();
                foreach (string str in currentPD.Contacts)
                {
                    contacts.Add(str);
                }
                contacts.Add(",,,,,");
                currentPD.Contacts = contacts.ToArray();
            }

            string tmp_str = currentPD.Contacts[dataGridView2.CurrentCell.RowIndex];

            string[] sArray = Regex.Split(tmp_str, ",", RegexOptions.IgnoreCase);
            sArray[dataGridView2.CurrentCell.ColumnIndex] = dataGridView2.CurrentCell.Value.ToString();
            tmp_str = "";
            for (int i = 0; i <= sArray.GetUpperBound(0); i++)
            {
                tmp_str += sArray[i] + ",";
            }
            currentPD.Contacts[dataGridView2.CurrentCell.RowIndex] = tmp_str.Remove(tmp_str.Length - 1, 1);

            msc_FolderList.updatePD(currentPD, currentFolder);
            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = currentXMLpath;
            XmlFile.WriteXml(currentPD);
            XmlFile.SaveXml();
            listView1.Focus();
        }