Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        private void 编辑项目信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
                currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址
                Form3.FormType_enum flag = Form3.FormType_enum.EDIT;
                if (pd == null)
                {
                    pd = new ProjectDetails();

                    int pos_int = listView1.Items[currentRowIndex].Text.LastIndexOf("】");
                    pd.Pname = listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1);
                    flag     = Form3.FormType_enum.CREATE;
                }
                pd.FolderName(listView1.Items[currentRowIndex].Text);
                OpenForm3(flag);
                ShowOnListview();
                listView1.Items[currentRowIndex].Selected = true;//设定选中
            }
            catch
            {
                MessageBox.Show("未选择项目。", " 提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 3
0
        private void 编辑项目信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
                currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址
                FmNewInfo.FormType_enum flag = FmNewInfo.FormType_enum.EDIT;
                if (currentPD == null)
                {
                    currentPD = new ProjectDetails();

                    int pos_int = listView1.Items[currentRowIndex].Text.LastIndexOf("】");
                    currentPD.Pname = listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1);
                    flag            = FmNewInfo.FormType_enum.CREATE;
                }
                currentPD.FolderName(listView1.Items[currentRowIndex].Text);
                if (OpenFmNewInfo(flag) == DialogResult.OK)
                {
                    ShowOnListview();
                }

                listView1.Items[currentRowIndex].Selected = true;//设定选中
            }
            catch
            {
                this.isActived = false;
                MessageBox.Show("未选择项目。", " 提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.isActived = true;
            }
        }
Exemplo n.º 4
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 XMLpath = listView1.Items[currentRowIndex].SubItems[1].Text + listView1.Items[currentRowIndex].Text +
                                 @"\" + listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1) + ".xml";//组装XML文件绝对地址
                ProjectDetails tPD = mscCtrl.getPD(XMLpath);
                currentPD      = tPD;
                currentXMLpath = XMLpath;
                if (tPD == null)
                {
                    XMLpath = listView1.Items[currentRowIndex].SubItems[1].Text + listView1.Items[currentRowIndex].Text +
                              @"\foldersPD.xml";//组装XML文件绝对地址
                    tPD            = mscCtrl.getPD(XMLpath);
                    currentPD      = tPD;
                    currentXMLpath = XMLpath;
                }
                ShowDetailsOnDV(tPD);
            }
        }
Exemplo n.º 5
0
 public FmNewInfo(string pPath, FormType_enum pType, ProjectDetails pPD)
 {
     InitializeComponent();
     xmlPath  = pType == FormType_enum.NEW ? null : pPath;
     formType = pType;
     Pdetails = pPD;
 }
Exemplo n.º 6
0
        //==================================自定义函数================================================================
        /// <summary>
        /// 切换窗体类型,NEW/EDIT
        /// </summary>
        private void shiftFormStyle()
        {
            int i = (int)(formType);

            switch (i)
            {
            case (int)(FormType_enum.NEW):
                btnNew.Visible     = true;
                btnOK.Visible      = false;
                text_Pname.Enabled = true;
                Pdetails           = null;
                this.Text          = "新建项目";
                break;

            case (int)(FormType_enum.EDIT):
                btnNew.Visible     = false;
                btnOK.Visible      = true;
                text_Pname.Enabled = true;
                setTexts();
                this.Text = "编辑项目信息";
                break;

            case (int)(FormType_enum.CREATE):
                btnNew.Visible = false;
                btnOK.Visible  = true;
                setTexts();
                this.Text = "创建项目信息";
                break;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 编写新的XML文件,此函数需根据实际情况重构
 /// </summary>
 /// <param name="pd">本项目自定义的项目细节类,别处使用需根据实际情况重构</param>
 public void WriteXml(ProjectDetails pd)
 {
     xe = new XElement("root",
                       new XElement("Project",
                                    new XElement("Name", pd.Pname),                     //项目名称
                                    new XElement("Index", pd.Pindex),                   //项目编号
                                    new XElement("Province", pd.P),                     //项目所在省市
                                    new XElement("City", pd.C),                         //项目所在城市
                                    new XElement("ProjectLeader", pd.Pincharge),        //项目负责人
                                    new XElement("ProfessionalDirector", pd.Cincharge), //专业负责人
                                    new XElement("SubjectDepartment", pd.Pdep),         //主体部门
                                    new XElement("ProjectNote", pd.Pnote)               //备注
                                    )
                       );
     if (pd.Contacts != null)
     {
         foreach (string tmp_str in pd.Contacts)
         {
             string[] sArray  = Regex.Split(tmp_str, ",", RegexOptions.IgnoreCase);
             XElement contact = new XElement("Contacts",
                                             new XElement("Name", sArray[0]),
                                             new XElement("CellPhone", sArray[1]),
                                             new XElement("FixedTele", sArray[2]),
                                             new XElement("Department", sArray[3]),
                                             new XElement("Major", sArray[4]),
                                             new XElement("Note", sArray[5])
                                             );
             xe.Add(contact);
         }
     }
 }
Exemplo n.º 8
0
 private void FmNewInfo_Load(object sender, EventArgs e)
 {
     btnOK.Top = btnNew.Top;
     shiftFormStyle();
     SetComboBox();
     if (Pdetails == null)
     {
         Pdetails = new ProjectDetails();
     }
     checkBox1.Checked = !string.IsNullOrEmpty(Pdetails.Pnote);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 读取XML文件,此函数需根据实际情况重构
        /// </summary>
        /// <param name="strPath">XML文件地址</param>
        /// <returns></returns>
        public ProjectDetails ReadXml(string strPath)
        {
            try
            {
                xe = XElement.Load(strPath);
                IEnumerable <XElement> elements = from ele in xe.Elements("Project")
                                                  select ele;

                ProjectDetails tmp_Pd = new ProjectDetails();
                foreach (XElement element in elements)
                {
                    tmp_Pd.Pname     = element.Element("Name").Value;
                    tmp_Pd.Pindex    = element.Element("Index").Value;
                    tmp_Pd.P         = element.Element("Province").Value;
                    tmp_Pd.C         = element.Element("City").Value;
                    tmp_Pd.Pincharge = element.Element("ProjectLeader").Value;
                    tmp_Pd.Cincharge = element.Element("ProfessionalDirector").Value;
                    tmp_Pd.Pdep      = element.Element("SubjectDepartment").Value;
                    try
                    {
                        tmp_Pd.Pnote = element.Element("ProjectNote").Value;
                    }
                    catch
                    {
                        tmp_Pd.Pnote = "";
                    }
                }

                elements = null;
                elements = from ele in xe.Elements("Contacts")
                           select ele;

                List <string> contacts = new List <string>();
                foreach (XElement element in elements)
                {
                    string tmp_str = element.Element("Name").Value + ",";
                    tmp_str += element.Element("CellPhone").Value + ",";
                    tmp_str += element.Element("FixedTele").Value + ",";
                    tmp_str += element.Element("Department").Value + ",";
                    tmp_str += element.Element("Major").Value + ",";
                    tmp_str += element.Element("Note").Value;
                    contacts.Add(tmp_str);
                }
                tmp_Pd.Contacts = contacts.ToArray();
                return(tmp_Pd);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 10
0
 private void getPdetailsFromTexts()
 {
     if (Pdetails == null)
     {
         Pdetails = new ProjectDetails();
     }
     Pdetails.Pname     = text_Pname.Text;
     Pdetails.Pindex    = text_Pindex.Text;
     Pdetails.Pincharge = text_Pincharge.Text;
     Pdetails.Cincharge = text_Cincharge.Text;
     Pdetails.P         = msc_FolderList.RemoveSuffix(comboBox1.Text);
     Pdetails.C         = msc_FolderList.RemoveSuffix(comboBox2.Text);
     Pdetails.Pdep      = comboBox4.Text;
     Pdetails.Pnote     = textBox1.Text;
 }
Exemplo n.º 11
0
        /// <summary>
        /// 显示项目详细信息
        /// </summary>
        /// <param name="pd">XML文件中读取的详细信息数据</param>
        private void ShowDetailsOnDV(ProjectDetails pd)
        {
            dataGridView2.Rows.Clear();
            dataGridView2.Columns.Clear();


            if ((pd == null) || (pd.Pname == ""))
            {
                dataGridView1.DataSource = null;
            }
            else
            {
                DataGridViewTextBoxColumn c1 = new DataGridViewTextBoxColumn();
                c1.HeaderText = "姓名";
                //c1.Width = 70;
                DataGridViewTextBoxColumn c2 = new DataGridViewTextBoxColumn();
                c2.HeaderText = "联系方式";
                dataGridView2.Columns.Add(c1);
                dataGridView2.Columns.Add(c2);

                //this.Text = pd.Pname;
                dataGridView1.DataSource = new List <Fruit>()
                {
                    new Fruit()
                    {
                        项 = "项目名称", 值 = pd.Pname
                    },
                    new Fruit()
                    {
                        项 = "项目编号", 值 = pd.Pindex
                    },
                    new Fruit()
                    {
                        项 = "项目所在省市", 值 = pd.P
                    },
                    new Fruit()
                    {
                        项 = "项目所在城市", 值 = pd.C
                    },
                    new Fruit()
                    {
                        项 = "项目负责人", 值 = pd.Pincharge
                    },
                    new Fruit()
                    {
                        项 = "专业负责人", 值 = pd.Cincharge
                    },
                    new Fruit()
                    {
                        项 = "主体部门", 值 = pd.Pdep
                    },
                    new Fruit()
                    {
                        项 = "备注", 值 = pd.Pnote
                    }
                };


                foreach (string tmp_str in pd.Contacts)
                {
                    string[] sArray = Regex.Split(tmp_str, ",", RegexOptions.IgnoreCase);

                    int index = dataGridView2.Rows.Add();
                    dataGridView2.Rows[index].Cells[0].Value = sArray[0];
                    dataGridView2.Rows[index].Cells[1].Value = sArray[1];
                }
            }
        }
Exemplo n.º 12
0
        public static void updatePD(ProjectDetails pPD, string pPath)
        {
            mc_FolderInfoType tmFIT = fList.Find(t => t.Path + t.Name == pPath);

            tmFIT.PD = pPD;
        }