private void srpSearch_OnSearchClick(object sender, EventArgs args)
        {
            DataSet   dsAll    = new DataSet();
            DataTable masterDt = getTempDataTable("row", 20);
            DataTable detailDt = getTempDataTable("row", 9);

            List <object> cells = new List <object>();

            List <Project> projList = MakeSQLWithSearchRule.getProjectList(srpSearch);

            foreach (Project proj in projList)
            {
                int subCounttt = 0;

                #region 生成从表数据
                if (proj != null && !string.IsNullOrEmpty(proj.ProjectID))
                {
                    List <Subject> subList = ConnectionManager.Context.table("Subject").where ("CatalogID = '" + proj.CatalogID + "' and ProjectID = '" + proj.ProjectID + "'").select("*").getList <Subject>(new Subject());
                    foreach (Subject sub in subList)
                    {
                        if (string.IsNullOrEmpty(srpSearch.Key1EditControl.Text) || ((srpSearch.getUsingRuleCount() == 0 || srpSearch.isUsingRule("课题")) && MakeSQLWithSearchRule.isDisplayData(typeof(Subject).Name, sub.SubjectID)) || proj.DutyUnit.Contains(srpSearch.Key1EditControl.Text) || proj.DutyNormalUnit.Contains(srpSearch.Key1EditControl.Text) || proj.DutyUnitAddress.Contains(srpSearch.Key1EditControl.Text))
                        {
                            if (srpSearch.Key2EditControl.Text == "全部" || sub.DutyUnitOrg == srpSearch.Key2EditControl.Text)
                            {
                                subCounttt++;

                                cells = new List <object>();
                                cells.Add(sub.SubjectName);
                                Person personObj = ConnectionManager.Context.table("Person").where ("CatalogID = '" + proj.CatalogID + "' and SubjectID = '" + sub.SubjectID + "' and JobInProject = '负责人'").select("*").getItem <Person>(new Person());
                                if (string.IsNullOrEmpty(personObj.PersonID))
                                {
                                    cells.Add(string.Empty);
                                }
                                else
                                {
                                    cells.Add(personObj.PersonName);
                                }
                                cells.Add(sub.DutyUnit);
                                cells.Add(sub.DutyUnitOrg);
                                cells.Add(sub.DutyUnitAddress);
                                cells.Add(proj.ProjectID);

                                if (string.IsNullOrEmpty(personObj.PersonID))
                                {
                                    cells.Add(string.Empty);
                                    cells.Add(string.Empty);
                                }
                                else
                                {
                                    cells.Add(personObj.Telephone);
                                    cells.Add(personObj.Mobilephone);
                                }

                                cells.Add(sub.SecretLevel);

                                detailDt.Rows.Add(cells.ToArray());
                            }
                        }
                    }
                }
                #endregion

                #region 主表数据
                if (srpSearch.Key2EditControl.Text == "全部" || proj.DutyUnitOrg == srpSearch.Key2EditControl.Text || subCounttt >= 1)
                {
                    cells = new List <object>();
                    cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogVersion").getValue <string>("未知"));
                    cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogType").getValue <string>("未知"));
                    cells.Add(proj.Domains);
                    cells.Add(proj.TaskNumber);
                    cells.Add(proj.ProjectNumber);
                    cells.Add(proj.ProjectName);
                    cells.Add(proj.TotalMoney);
                    cells.Add(proj.TotalTime);
                    cells.Add(proj.SecretLevel);
                    //显示仅为项目负责人
                    Person masterPerson = ConnectionManager.Context.table("Person").where ("CatalogID = '" + proj.CatalogID + "' and SubjectID = '' and IsProjectMaster = 'true'").select("*").getItem <Person>(new Person());
                    if (masterPerson != null && masterPerson.PersonID != null && masterPerson.PersonID.Length >= 1)
                    {
                        cells.Add(masterPerson.PersonName);
                    }
                    else
                    {
                        cells.Add(string.Empty);
                    }
                    cells.Add(proj.DutyUnit);
                    cells.Add(proj.DutyUnitOrg);
                    cells.Add(proj.DutyUnitAddress);
                    cells.Add(string.Empty);
                    cells.Add(proj.ProjectID);
                    cells.Add(proj.Keywords);

                    if (masterPerson != null && masterPerson.PersonID != null && masterPerson.PersonID.Length >= 1)
                    {
                        cells.Add(masterPerson.Telephone);
                        cells.Add(masterPerson.Mobilephone);
                    }
                    else
                    {
                        cells.Add(string.Empty);
                        cells.Add(string.Empty);
                    }

                    cells.Add(proj.DutyNormalUnit);

                    cells.Add(proj.ProjectRange);

                    masterDt.Rows.Add(cells.ToArray());
                }
                #endregion
            }

            #region 生成从属关系数据
            masterDt.TableName = "MainView";
            detailDt.TableName = "SubjectView";
            dsAll.Tables.Add(masterDt);
            dsAll.Tables.Add(detailDt);

            DataColumn keyColumn     = dsAll.Tables[masterDt.TableName].Columns["row15"];   //主键
            DataColumn foreignColumn = dsAll.Tables[detailDt.TableName].Columns["row6"];    //外键
            //
            //对于主从表,层次名至关重要,关系名必须和从表的层次名一致,
            //否则从表显示的是从表的所有字段,而不是所设计的显示字段
            //

            dsAll.Relations.Add(detailDt.TableName, keyColumn, foreignColumn, false);     //从表的层次名
            gcGrid.DataSource = dsAll.Tables[masterDt.TableName];
            #endregion
        }
Exemple #2
0
        private void srpSearch_OnSearchClick(object sender, EventArgs args)
        {
            DataTable dt = getTempDataTable("row", 13);

            List <Project> projList = MakeSQLWithSearchRule.getProjectList(srpSearch);

            foreach (Project proj in projList)
            {
                //显示仅为项目负责人
                Person masterPersonObj = ConnectionManager.Context.table("Person").where ("CatalogID = '" + proj.CatalogID + "' and SubjectID = '' and IsProjectMaster = 'true'").select("*").getItem <Person>(new Person());
                if (masterPersonObj != null && masterPersonObj.PersonID != null && masterPersonObj.PersonID.Length >= 1)
                {
                    if (string.IsNullOrEmpty(srpSearch.Key1EditControl.Text) || ((srpSearch.getUsingRuleCount() == 0 || srpSearch.isUsingRule("人员")) && MakeSQLWithSearchRule.isDisplayData(typeof(Person).Name, masterPersonObj.PersonID)) || proj.ProjectName.Contains(srpSearch.Key1EditControl.Text))
                    {
                        //存在仅为负责人的记录
                        List <object> cells = new List <object>();
                        cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogVersion").getValue <string>("未知"));
                        cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogType").getValue <string>("未知"));
                        cells.Add(proj.ProjectName);
                        cells.Add("-");
                        cells.Add(masterPersonObj.PersonName);
                        cells.Add(masterPersonObj.PersonIDCard);
                        cells.Add(masterPersonObj.PersonSex);
                        cells.Add(masterPersonObj.WorkUnit);
                        cells.Add(masterPersonObj.PersonJob);
                        cells.Add(masterPersonObj.PersonSpecialty);
                        cells.Add(masterPersonObj.TotalTime);
                        cells.Add(masterPersonObj.TaskContent);

                        cells.Add("项目负责人");

                        dt.Rows.Add(cells.ToArray());
                    }
                }

                //显示课题成员
                List <Subject> subList = ConnectionManager.Context.table("Subject").where ("CatalogID = '" + proj.CatalogID + "' and ProjectID = '" + proj.ProjectID + "'").select("*").getList <Subject>(new Subject());
                foreach (Subject sub in subList)
                {
                    if (string.IsNullOrEmpty(srpSearch.Key1EditControl.Text) || MakeSQLWithSearchRule.isDisplayData(typeof(Subject).Name, sub.SubjectID) || proj.ProjectName.Contains(srpSearch.Key1EditControl.Text))
                    {
                        List <Person> perList = ConnectionManager.Context.table("Person").where ("CatalogID = '" + proj.CatalogID + "' and SubjectID = '" + sub.SubjectID + "'").select("*").getList <Person>(new Person());
                        foreach (Person p in perList)
                        {
                            if (string.IsNullOrEmpty(srpSearch.Key1EditControl.Text) || ((srpSearch.getUsingRuleCount() == 0 || srpSearch.isUsingRule("人员")) && MakeSQLWithSearchRule.isDisplayData(typeof(Person).Name, p.PersonID)) || sub.SubjectName.Contains(srpSearch.Key1EditControl.Text) || proj.ProjectName.Contains(srpSearch.Key1EditControl.Text))
                            {
                                List <object> cells = new List <object>();
                                cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogVersion").getValue <string>("未知"));
                                cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogType").getValue <string>("未知"));
                                cells.Add(proj.ProjectName);
                                cells.Add(sub.SubjectName);
                                cells.Add(p.PersonName);
                                cells.Add(p.PersonIDCard);
                                cells.Add(p.PersonSex);
                                cells.Add(p.WorkUnit);
                                cells.Add(p.PersonJob);
                                cells.Add(p.PersonSpecialty);
                                cells.Add(p.TotalTime);
                                cells.Add(p.TaskContent);

                                string roleStr = "未知";
                                //if (p.IsProjectMaster == "true")
                                //{
                                //    roleStr = "项目负责人兼" + sub.SubjectName + "的" + p.JobInProject;
                                //}
                                //else
                                //{
                                //    roleStr = sub.SubjectName + "的" + p.JobInProject;
                                //}
                                if (p.IsProjectMaster == "true")
                                {
                                    roleStr = "项目负责人兼课题" + p.JobInProject;
                                }
                                else
                                {
                                    if (p.JobInProject == "负责人")
                                    {
                                        roleStr = "课题负责人";
                                    }
                                    else
                                    {
                                        roleStr = p.JobInProject;
                                    }
                                }

                                cells.Add(roleStr);

                                dt.Rows.Add(cells.ToArray());
                            }
                        }
                    }
                }
            }
            gcData.DataSource = dt;
        }
Exemple #3
0
        private void srpSearch_OnSearchClick(object sender, EventArgs args)
        {
            DataTable dt = getTempDataTable("row", 12);

            List <Project> projList = MakeSQLWithSearchRule.getProjectList(srpSearch);

            foreach (Project proj in projList)
            {
                List <Subject> subList = ConnectionManager.Context.table("Subject").where ("CatalogID = '" + proj.CatalogID + "' and ProjectID = '" + proj.ProjectID + "'").select("*").getList <Subject>(new Subject());
                foreach (Subject sub in subList)
                {
                    if (string.IsNullOrEmpty(srpSearch.Key1EditControl.Text) || ((srpSearch.getUsingRuleCount() == 0 || srpSearch.isUsingRule("课题")) && MakeSQLWithSearchRule.isDisplayData(typeof(Subject).Name, sub.SubjectID)) || proj.ProjectName.Contains(srpSearch.Key1EditControl.Text))
                    {
                        List <object> cells = new List <object>();
                        cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogVersion").getValue <string>("未知"));
                        cells.Add(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("CatalogType").getValue <string>("未知"));
                        cells.Add(proj.ProjectName);
                        cells.Add(sub.SubjectName);

                        Person personObj = ConnectionManager.Context.table("Person").where ("CatalogID = '" + proj.CatalogID + "' and SubjectID = '" + sub.SubjectID + "' and JobInProject = '负责人'").select("*").getItem <Person>(new Person());
                        if (string.IsNullOrEmpty(personObj.PersonID))
                        {
                            cells.Add(string.Empty);
                        }
                        else
                        {
                            cells.Add(personObj.PersonName);
                        }

                        cells.Add(sub.DutyUnit);
                        cells.Add(sub.DutyUnitOrg);
                        cells.Add(sub.DutyUnitAddress);

                        if (cells[1] != null && cells[1].ToString() == "合同书")
                        {
                            //合同书总经费
                            //cells.Add(ConnectionManager.Context.table("Dicts").where("CatalogID = '" + proj.CatalogID + "' and SubjectID ='" + sub.SubjectID + "' and DictType='SubjectMoney,SubjectMoneyInfo' and DictName = 'Money1'").select("DictValue").getValue<string>(""));
                            cells.Add(sub.TotalMoney);
                        }
                        else
                        {
                            //建议书总经费
                            cells.Add(sub.TotalMoney);
                        }

                        if (string.IsNullOrEmpty(personObj.PersonID))
                        {
                            cells.Add(string.Empty);
                            cells.Add(string.Empty);
                        }
                        else
                        {
                            cells.Add(personObj.Telephone);
                            cells.Add(personObj.Mobilephone);
                        }

                        cells.Add(sub.SecretLevel);

                        dt.Rows.Add(cells.ToArray());
                    }
                }
            }
            gcGrid.DataSource = dt;
        }