コード例 #1
0
 public void SortByName(ref List <ProjectStruct> tempMyProjectDetailCollection)
 {
     ProjectStruct[] tempNameListt = new ProjectStruct[tempMyProjectDetailCollection.Count];
     tempNameListt = tempMyProjectDetailCollection.ToArray();
     string[] tempstringNameList = new string[tempMyProjectDetailCollection.Count];
     for (int i = 0; i < tempMyProjectDetailCollection.Count; i++)
     {
         tempstringNameList[i] = tempMyProjectDetailCollection[i].ProjectStaffName;
     }
     Array.Sort(tempstringNameList, tempNameListt);
     tempMyProjectDetailCollection.Clear();
     tempMyProjectDetailCollection = tempNameListt.ToList();
 }
コード例 #2
0
 public void SortByDep()
 {
     ProjectStruct[] tempNameListt = new ProjectStruct[MyProjectDetailCollection.Count];
     tempNameListt = MyProjectDetailCollection.ToArray();
     string[] tempstringNameList = new string[MyProjectDetailCollection.Count];
     for (int i = 0; i < MyProjectDetailCollection.Count; i++)
     {
         tempstringNameList[i] = MyProjectDetailCollection[i].ProjectStaffDep;
     }
     Array.Sort(tempstringNameList, tempNameListt);
     MyProjectDetailCollection.Clear();
     MyProjectDetailCollection = tempNameListt.ToList();
 }
コード例 #3
0
        public List <ProjectStruct> GetMergeredTarget(List <ProjectStruct> MergerSource)
        {
            List <ProjectStruct> MergerTarget = new List <ProjectStruct>();

            for (int i = 0; i < MergerSource.Count; i++)
            {
                ProjectStruct tempProjectStruct = MergerSource[i];
                for (int j = i + 1; j < MergerSource.Count; j++)
                {
                    if (tempProjectStruct.ProjectStaffName.Equals(MergerSource[j].ProjectStaffName) && tempProjectStruct.ProjectStaffDep.Equals(MergerSource[j].ProjectStaffDep))
                    {
                        tempProjectStruct.ProjectStaffMoney += MergerSource[j].ProjectStaffMoney;
                        MergerSource.RemoveAt(j);
                        j--;
                    }
                }
                MergerTarget.Add(tempProjectStruct);
            }
            return(MergerTarget);
        }
コード例 #4
0
        public void SetInMemory(Action <int> percent)
        {
            int ProcessPos = 0;

            mExcel = new Excel(ExportFile, false);
            int   sheetnums = WaitQuerySheets.Count;
            float proc      = (float)0.0;

            foreach (string SheetName in WaitQuerySheets)
            {
                proc = (float)ProcessPos / (float)sheetnums * (float)100;
                mExcel.SetCurrentWorksheet(SheetName); //mExcel.SetCurrentWorksheet("Test");
                #region start import excel
                for (int i = 1; i <= mExcel.RowCount; i++)
                {
                    string LineInfo = mExcel.GetCell(i, 1);
                    if (LineInfo.IndexOf(splitchar) != -1)
                    {
                        string[]    ProjectLineInfos = LineInfo.Split(splitchar);
                        ProjectInfo mtempProjectInfo = new ProjectInfo();

                        mtempProjectInfo.ProjectName = ProjectLineInfos[0];
                        mtempProjectInfo.ProjectId   = ProjectLineInfos[1].Equals("") ? mtempProjectInfo.ProjectName : ProjectLineInfos[1];
                        LineInfo = mExcel.GetCell(++i, 1); //读取姓名,部门,加班费
                        while (!LineInfo.Equals(""))
                        {
                            ProjectStruct mtempProjectStruct = new ProjectStruct();
                            i++;
                            LineInfo = mExcel.GetCell(i, 1); //读取姓名,部门,加班费
                            if (LineInfo.Equals(""))
                            {
                                break;
                            }
                            for (int j = 1; j <= ProjectInfoNumbers; j++)
                            {
                                float money;

                                if (j == 1)
                                {
                                    mtempProjectStruct.ProjectStaffName = mExcel.GetCell(i, j);
                                }
                                else if (j == 2)
                                {
                                    mtempProjectStruct.ProjectStaffDep = mExcel.GetCell(i, j);
                                }
                                else if (j == 3)
                                {
                                    float.TryParse(mExcel.GetCell(i, j), out money);
                                    mtempProjectStruct.ProjectStaffMoney = money;
                                }
                            }
                            mtempProjectInfo.MyProjectDetailCollection.Add(mtempProjectStruct);
                        }
                        mProjectInfoArray.Add(mtempProjectInfo);
                    }
                    else
                    {
                        continue;
                    }
                }
                #endregion start import excel

                ProcessPos++;
                percent((int)proc);

                //  break;test
            }
            GetTargetResult();
            percent((int)proc);
        }
コード例 #5
0
        public void SetInMemory(Action <int> percent)
        {
            int ProcessPos = 0;

            mExcel = new Excel(ExportFile, false);
            int   sheetnums = WaitQuerySheets.Count;
            float proc      = (float)0.0;

            foreach (string SheetName in WaitQuerySheets)
            {
                proc = (float)ProcessPos / (float)sheetnums * (float)100;
                mExcel.SetCurrentWorksheet(SheetName); //mExcel.SetCurrentWorksheet("Test");
                #region start import excel
                for (int i = 1; i <= mExcel.RowCount; i++)
                {
                    string LineInfo = mExcel.GetCell(i, 1);

                    if (LineInfo.IndexOf("项目名称") != -1 && LineInfo.IndexOf(splitchar) == -1)
                    {
                        MessageBox.Show("Sheet " + SheetName + "第" + i + "行 格式不正确(缺少" + splitchar + ")");
                        mExcel.SetCellSelect(i, 1, i, 1);
                        mExcel.Visible = true;
                        System.Environment.Exit(0);
                    }
                    if (LineInfo.IndexOf(splitchar) != -1)
                    {
                        string[]    ProjectLineInfos = LineInfo.Split(splitchar);
                        ProjectInfo mtempProjectInfo = new ProjectInfo();

                        mtempProjectInfo.ProjectName = ProjectLineInfos[0].Trim();
                        mtempProjectInfo.ProjectId   = ProjectLineInfos[1].Trim().Equals("") ? mtempProjectInfo.ProjectName : ProjectLineInfos[1].Trim();
                        LineInfo = mExcel.GetCell(++i, 1); //读取姓名,部门,加班费
                        while (!LineInfo.Equals(""))
                        {
                            ProjectStruct mtempProjectStruct = new ProjectStruct();
                            i++;
                            LineInfo = mExcel.GetCell(i, 1); //读取姓名,部门,加班费 real value
                            if (LineInfo.Equals(""))
                            {
                                break;
                            }
                            for (int j = 1; j <= ProjectInfoNumbers; j++)
                            {
                                float money;

                                if (j == 1)
                                {
                                    mtempProjectStruct.ProjectStaffName = mExcel.GetCell(i, j);
                                }
                                else if (j == 2)
                                {
                                    mtempProjectStruct.ProjectStaffDep = mExcel.GetCell(i, j);
                                }
                                else if (j == 3)
                                {
                                    float.TryParse(mExcel.GetCell(i, j), out money);
                                    mtempProjectStruct.ProjectStaffMoney = money;
                                }
                            }
                            mtempProjectInfo.MyProjectDetailCollection.Add(mtempProjectStruct);
                        }
                        mProjectInfoArray.Add(mtempProjectInfo);
                    }
                    else
                    {
                        continue;
                    }
                }
                #endregion start import excel

                ProcessPos++;
                percent((int)proc);

                //  break;test
            }
            GetTargetResult();
            percent((int)proc);
            ExcelOutResult();
            ProcessPos++;
            percent(100);
            // MessageBox.Show("合并完成!");
            mExcel.Visible = true;
        }