浏览代码

Merge branch 'release2.2' into ZJX

zhangjiaxin 3 年之前
父节点
当前提交
c6e5a7cea2

+ 2 - 0
OTSIncAReportApp/Control_Grids/ParticlesGridDevidePage.Designer.cs

@@ -226,6 +226,7 @@
             this.cbB_order.Name = "cbB_order";
             this.cbB_order.Name = "cbB_order";
             this.cbB_order.Size = new System.Drawing.Size(160, 26);
             this.cbB_order.Size = new System.Drawing.Size(160, 26);
             this.cbB_order.TabIndex = 1;
             this.cbB_order.TabIndex = 1;
+            this.cbB_order.Visible = false;
             this.cbB_order.SelectedIndexChanged += new System.EventHandler(this.cbB_order_SelectedIndexChanged);
             this.cbB_order.SelectedIndexChanged += new System.EventHandler(this.cbB_order_SelectedIndexChanged);
             // 
             // 
             // label_order
             // label_order
@@ -237,6 +238,7 @@
             this.label_order.Size = new System.Drawing.Size(89, 18);
             this.label_order.Size = new System.Drawing.Size(89, 18);
             this.label_order.TabIndex = 0;
             this.label_order.TabIndex = 0;
             this.label_order.Text = "排序方式:";
             this.label_order.Text = "排序方式:";
+            this.label_order.Visible = false;
             // 
             // 
             // panel1
             // panel1
             // 
             // 

+ 92 - 76
OTSIncAReportApp/Control_Grids/ParticlesGridDevidePage.cs

@@ -16,6 +16,7 @@ using System.Drawing;
 using System.Drawing.Imaging;
 using System.Drawing.Imaging;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using System.Reflection;
 using System.Threading;
 using System.Threading;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
@@ -77,8 +78,8 @@ namespace OTSIncAReportGrids
 
 
 
 
         FieldData fieldData;
         FieldData fieldData;
-
-        private string m_filename = "";
+        DataTable particlesAll;
+        ParticleData Particledata;
 
 
         #region 分页器相关
         #region 分页器相关
 
 
@@ -161,17 +162,26 @@ namespace OTSIncAReportGrids
         {
         {
             m_ReportApp = ReportApp;
             m_ReportApp = ReportApp;
             result = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
             result = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
-            InitializeComponent();
 
 
-            m_frm_userprogress = new Frm_UserProgress();
+            //设置窗体的双缓冲,以保证大数据时拖动不卡
+            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
+            this.UpdateStyles();
 
 
-            m_mythread_state = false;
-            m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
+            InitializeComponent();
+
+            //利用反射设置DataGridView的双缓冲
+            Type dgvType = this.dgV_ParticlesDevidePage.GetType();
+            PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
+            pi.SetValue(this.dgV_ParticlesDevidePage, true, null);
 
 
             lan = new Language(this);
             lan = new Language(this);
             table = lan.GetNameTable(this.Name);
             table = lan.GetNameTable(this.Name);
 
 
+            m_mythread_state = false;
+            m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
+            //m_frm_userprogress = new Frm_UserProgress();
             fieldData = new FieldData(result.FilePath);
             fieldData = new FieldData(result.FilePath);
+            Particledata = new ParticleData(result.FilePath);
         }
         }
 
 
         private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
         private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
@@ -179,25 +189,9 @@ namespace OTSIncAReportGrids
             //初始化底层操作类
             //初始化底层操作类
             m_OTSIncAReportGridsFun = new OTSIncAReportGridsFun(m_ReportApp, this);
             m_OTSIncAReportGridsFun = new OTSIncAReportGridsFun(m_ReportApp, this);
 
 
-            if (Language.ReadDefaultLanguage() == "EN")
-            {
-                cbB_order.Items.Add("Default");
-                cbB_order.Items.Add("ParticlesName");
-                cbB_order.Items.Add("Dmax Ascend");
-                cbB_order.Items.Add("Dmax Descend");
-                cbB_order.Items.Add("Area Ascend");
-                cbB_order.Items.Add("Area Descend");
-            }
-            else
-            {
-                cbB_order.Items.Add("默认");
-                cbB_order.Items.Add("颗粒名称");
-                cbB_order.Items.Add("最大直径 升序");
-                cbB_order.Items.Add("最大直径 降序");
-                cbB_order.Items.Add("面积 升序");
-                cbB_order.Items.Add("面积 降序");
-            }
-            cbB_order.SelectedIndex = 0;
+            ProgressStart();
+
+            UpdateTable();
 
 
             cbB_PageSize.Items.Add("20");
             cbB_PageSize.Items.Add("20");
             cbB_PageSize.Items.Add("100");
             cbB_PageSize.Items.Add("100");
@@ -205,13 +199,30 @@ namespace OTSIncAReportGrids
             cbB_PageSize.Items.Add("1000");
             cbB_PageSize.Items.Add("1000");
             cbB_PageSize.Items.Add("5000");
             cbB_PageSize.Items.Add("5000");
             cbB_PageSize.Items.Add("All");
             cbB_PageSize.Items.Add("All");
-            cbB_PageSize.SelectedIndexChanged -= new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
             cbB_PageSize.SelectedIndex = 0;
             cbB_PageSize.SelectedIndex = 0;
-            cbB_PageSize.SelectedIndexChanged += new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
 
 
         }
         }
 
 
         #region 自定义方法
         #region 自定义方法
+        void UpdateTable()
+        {
+            //多次测试发现 读取数据库时间耗时长,但读取条数目对读取数据库时长影响不大,故此处直接读取所有数据库信息,以取代多次连接数据库方式,优化分页速度
+            particlesAll = new DataTable();
+            particlesAll = Particledata.GetInfoForPartucleDevidePage2(condition);
+            DataTable elementchemistry = Particledata.GetElementChemistry();
+
+            for (int i = 0; i < particlesAll.Rows.Count; i++)
+            {
+                string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
+                DataRow[] drs = elementchemistry.Select(str);
+                string ConcatenatedString = "";
+                for (int j = 0; j < drs.Length; j++)
+                {
+                    ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
+                }
+                particlesAll.Rows[i]["Element"] = ConcatenatedString;
+            }
+        }
 
 
         /// <summary>
         /// <summary>
         /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
         /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
@@ -366,25 +377,12 @@ namespace OTSIncAReportGrids
 
 
         private void BindDataGridView()
         private void BindDataGridView()
         {
         {
-            #region 加载显示进度条部份
-            this.Cursor = Cursors.WaitCursor;
-            m_frm_userprogress = new Frm_UserProgress();
+            dgV_ParticlesDevidePage.Visible = false;
 
 
-            //显示进度条,计算进度条应该显示的位置和宽度
-            Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
-            if (ls_main_form == null)
+            if (m_frm_userprogress.IsDisposed)
             {
             {
-                m_frm_userprogress.Visible = false;
+                ProgressStart();
             }
             }
-            else
-            {
-                string str7 = table["str7"].ToString();
-                m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
-                m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
-                m_frm_userprogress.Show();
-                m_frm_userprogress.SetProgressValueAndText(0, str7);
-            }
-            #endregion
 
 
             dgV_ParticlesDevidePage.Rows.Clear();
             dgV_ParticlesDevidePage.Rows.Clear();
             dgV_ParticlesDevidePage.Columns.Clear();
             dgV_ParticlesDevidePage.Columns.Clear();
@@ -419,7 +417,6 @@ namespace OTSIncAReportGrids
             keyValues.Add("ParticleImage", table["str5"].ToString());
             keyValues.Add("ParticleImage", table["str5"].ToString());
             keyValues.Add("SEMPosX", "SEMPosX");
             keyValues.Add("SEMPosX", "SEMPosX");
             keyValues.Add("SEMPosY", "SEMPosY");
             keyValues.Add("SEMPosY", "SEMPosY");
-
             for (int i = 0; i < strs.Count(); i++)
             for (int i = 0; i < strs.Count(); i++)
             {
             {
                 if (strs[i] == "Area")
                 if (strs[i] == "Area")
@@ -501,19 +498,25 @@ namespace OTSIncAReportGrids
 
 
                 }
                 }
             }
             }
-
-            ParticleData fielddata = new ParticleData(result.FilePath);
-            DataTable particles = fielddata.GetInfoForPartucleDevidePage(PageIndex, pageSize, OrderFunction, condition);
             if(PageSize==-1)
             if(PageSize==-1)
             {
             {
-                PageSize = particles.Rows.Count;
+                PageSize = particlesAll.Rows.Count;
             }
             }
 
 
-            if (particles == null)
+            if (particlesAll == null)
             {
             {
                 return;
                 return;
             }
             }
-
+            RecordCount = particlesAll.Rows.Count;
+            DataTable particles = particlesAll.Clone();
+            for (int fi = (PageIndex - 1) * pageSize; fi < PageIndex * pageSize; fi++)
+            {
+                if (fi > RecordCount - 1)
+                {
+                    break;
+                }
+                particles.ImportRow(particlesAll.Rows[fi]);
+            }
             string particleM = "";
             string particleM = "";
             //获取需要显示的元素名
             //获取需要显示的元素名
             List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
             List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
@@ -525,13 +528,10 @@ namespace OTSIncAReportGrids
 
 
             string filePath = result.FilePath + "\\FIELD_FILES\\";
             string filePath = result.FilePath + "\\FIELD_FILES\\";
             KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
             KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
-            int DelParticlesCount = 0;        //此值= 合成拼接颗粒的所有子颗粒数目-拼接颗粒数目 , 颗粒总数 = 所有子颗粒数目 - 合成拼接颗粒的所有子颗粒数目 + 拼接颗粒数目;
-
             for (int i = 0; i < particles.Rows.Count; i++)
             for (int i = 0; i < particles.Rows.Count; i++)
             {
             {
                 //更新进度,每100条记录加载完,更新一次进度
                 //更新进度,每100条记录加载完,更新一次进度
-                if (i % 5 == 0)
-                    
+                if (i % 10 == 0)
                     m_frm_userprogress.SetProgressValueAndText((int)(jd * i), "loading..");
                     m_frm_userprogress.SetProgressValueAndText((int)(jd * i), "loading..");
 
 
                 Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
                 Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
@@ -556,12 +556,12 @@ namespace OTSIncAReportGrids
                                 string filePatht = result.FilePath + "\\FIELD_FILES\\";
                                 string filePatht = result.FilePath + "\\FIELD_FILES\\";
                                 string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
                                 string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
                                 //然后将取出的数据,转换成Bitmap对象
                                 //然后将取出的数据,转换成Bitmap对象
-                                Bitmap tempbit = fielddata.ReadImageFile(imagePatht);
+                                Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
                                 int pixw = tempbit.Width;
                                 int pixw = tempbit.Width;
                                 double xs = pixw / ScanFieldSize;
                                 double xs = pixw / ScanFieldSize;
 
 
                                 particleM = particleM + "," + subt;
                                 particleM = particleM + "," + subt;
-                                Bitmap bmap = fielddata.GetBitmapForBig(subt, xs, result.FilePath);
+                                Bitmap bmap = Particledata.GetBitmapForBig(subt, xs, result.FilePath);
                                 if (bmap != null)
                                 if (bmap != null)
                                 {
                                 {
                                     string[] str = subt.Split(',');
                                     string[] str = subt.Split(',');
@@ -570,20 +570,6 @@ namespace OTSIncAReportGrids
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
                                     dgV_ParticlesDevidePage.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
-
-                                    DelParticlesCount+= str.Length-1;
-
-                                    //在颗粒总数中去除合成拼接颗粒的所有子颗粒数目
-                                    foreach (var part in str)
-                                    {
-                                        DataRow[] foundRow;
-                                        foundRow = particles.Select("fieldid = "+part.Split(':')[0]+ "and particleid = "+ part.Split(':')[1], "");
-                                        foreach (DataRow row in foundRow)
-                                        {
-                                            particles.Rows.Remove(row);
-                                        }
-                                    }
-
                                 }
                                 }
                                 else
                                 else
                                 {
                                 {
@@ -597,11 +583,11 @@ namespace OTSIncAReportGrids
                                 if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
                                 if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
                                 {
                                 {
                                     string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
                                     string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-                                    FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), fielddata.ReadImageFile(imagePath));
+                                    FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
                                 }
                                 }
 
 
                                 Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
                                 Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
-                                Bitmap bmap = fielddata.GetBitmapByParticle(FieldImage.Value, rectangle);
+                                Bitmap bmap = Particledata.GetBitmapByParticle(FieldImage.Value, rectangle);
                                 bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString() };
                                 bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString() };
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
@@ -661,7 +647,8 @@ namespace OTSIncAReportGrids
                     }
                     }
                 }
                 }
             }
             }
-            RecordCount = fielddata.GetCountOfPsrticles(condition)- DelParticlesCount;
+            
+
             #region 加载进度条进度部份结束
             #region 加载进度条进度部份结束
             //加载完成设置鼠标为默认
             //加载完成设置鼠标为默认
             this.Cursor = Cursors.Default;
             this.Cursor = Cursors.Default;
@@ -670,6 +657,8 @@ namespace OTSIncAReportGrids
             //加载完成,关闭进度条
             //加载完成,关闭进度条
             m_frm_userprogress.Close();
             m_frm_userprogress.Close();
             #endregion
             #endregion
+
+            dgV_ParticlesDevidePage.Visible = true;
         }
         }
 
 
 
 
@@ -685,9 +674,6 @@ namespace OTSIncAReportGrids
             //用户不能调整 行高
             //用户不能调整 行高
             dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
             dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
 
 
-            //改变行的高度;
-            //Gview_gz.RowTemplate.Height = 20;
-
             //点击选择整行
             //点击选择整行
             dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
             dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
 
 
@@ -1235,10 +1221,39 @@ namespace OTSIncAReportGrids
                 condition += " and TypeName Like \"%" + tbx_Type.Text + "%\" ";
                 condition += " and TypeName Like \"%" + tbx_Type.Text + "%\" ";
             }
             }
 
 
+            if (m_frm_userprogress.IsDisposed)
+            {
+                ProgressStart();
+            }
+
+            UpdateTable();
+
             lnkFirst_Click(null, null);
             lnkFirst_Click(null, null);
             SetDataGridViewStyle();
             SetDataGridViewStyle();
         }
         }
 
 
+        void ProgressStart()
+        {
+            #region 加载显示进度条部份
+            this.Cursor = Cursors.WaitCursor;
+            m_frm_userprogress = new Frm_UserProgress();
+
+            //显示进度条,计算进度条应该显示的位置和宽度
+            Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
+            if (ls_main_form == null)
+            {
+                m_frm_userprogress.Visible = false;
+            }
+            else
+            {
+                m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
+                m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 200, ls_main_form.Location.Y + 200 + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
+                m_frm_userprogress.Show();
+                m_frm_userprogress.SetProgressValueAndText(0, "Loading data of particles...");
+            }
+            #endregion
+        }
+
         private void cbB_order_SelectedIndexChanged(object sender, EventArgs e)
         private void cbB_order_SelectedIndexChanged(object sender, EventArgs e)
         {
         {
             int ordernum = cbB_order.SelectedIndex;
             int ordernum = cbB_order.SelectedIndex;
@@ -1379,6 +1394,7 @@ namespace OTSIncAReportGrids
                 pageSize = int.Parse(cbB_PageSize.SelectedItem.ToString());
                 pageSize = int.Parse(cbB_PageSize.SelectedItem.ToString());
             }
             }
             lnkFirst_Click(null, null);
             lnkFirst_Click(null, null);
+            SetDataGridViewStyle();
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 15 - 39
OTSIncAReportApp/DataOperation/DataAccess/ParticleData.cs

@@ -371,55 +371,31 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
 
         #region 分页添加读取数据库函数
         #region 分页添加读取数据库函数
         /// <summary>
         /// <summary>
-        /// 获取颗粒全部所需信息
+        /// 获取分页查询所需信息
         /// </summary>
         /// </summary>
         /// <param name=""></param>
         /// <param name=""></param>
         /// <param name=""></param>
         /// <param name=""></param>
         /// <returns></returns>
         /// <returns></returns>
-        public DataTable GetAllInfo(string condition)
+        public DataTable GetInfoForPartucleDevidePage(int currentPage, int pagesize, string OrderFunction, string condition)
         {
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = INcAData.XRayId and fieldid = INcAData.fieldid  ) as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, '&'),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition;
-            DataTable DT = dbHelper.ExecuteQuery(sqliteString);
+            int p = (currentPage - 1) * pagesize;
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX as 'SEMPosX',FieldPosY as 'SEMPosY',ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,(select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = INcAData.XRayId and fieldid = INcAData.fieldid  ) as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition + " order by " + OrderFunction + " limit " + pagesize.ToString() + " offset " + p.ToString();
+            DataTable DT=new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
             return DT;
             return DT;
         }
         }
-        /// <summary>
-        /// 获取合并颗粒总数
-        /// </summary>
-        /// <param name="condition"></param>
-        /// <returns></returns>
-        public int GetCountOfMergedPsrticles(string condition)
-        {
-            string sqliteString = "select count(*) from MergedParticleInfo " + condition;
-            DataTable DT = dbHelper.ExecuteQuery(sqliteString);
-            int Count = int.Parse(DT.Rows[0]["Count"].ToString());
-            return Count;
-        }
-
-        /// <summary>
-        /// 获取正常颗粒总数,包含组成合并颗粒的几个部分
-        /// </summary>
-        /// <param name="condition"></param>
-        /// <returns></returns>
-        public int GetCountOfPsrticles(string condition)
+        public DataTable GetInfoForPartucleDevidePage2(string condition)
         {
         {
-            string sqliteString = "select count(*) from INcAData where 1=1 " + condition;
-            DataTable DT = dbHelper.ExecuteQuery(sqliteString);
-            int Count = int.Parse(DT.Rows[0][0].ToString());
-            return Count;
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX as 'SEMPosX',FieldPosY as 'SEMPosY',ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,'' as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition;
+            DataTable DT = new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
+            return DT;
         }
         }
-
-
-        /// <summary>
-        /// 获取分页查询所需信息
-        /// </summary>
-        /// <param name=""></param>
-        /// <param name=""></param>
-        /// <returns></returns>
-        public DataTable GetInfoForPartucleDevidePage(int currentPage, int pagesize, string OrderFunction, string condition)
+        public DataTable GetElementChemistry()
         {
         {
-            int p = (currentPage - 1) * pagesize;
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX as 'SEMPosX',FieldPosY as 'SEMPosY',ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,(select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = INcAData.XRayId and fieldid = INcAData.fieldid  ) as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, '&'),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition + " order by " + OrderFunction + " limit " + pagesize.ToString() + " offset " + p.ToString();
-            DataTable DT = dbHelper.ExecuteQuery(sqliteString);
+            string sqliteString = "select * from ElementChemistry";
+            DataTable DT = new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
             return DT;
             return DT;
         }
         }
 
 

+ 15 - 0
OTSIncAReportApp/DataOperation/DataAccess/SqlHelper.cs

@@ -129,6 +129,21 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return dt;
             return dt;
         }
         }
 
 
+        public DataTable ExecuteQuery2(string queryString)
+        {
+            SQLiteCommand sqlCommand = new SQLiteCommand(queryString,dbConnection);
+            try
+            {
+                SQLiteDataReader reader = sqlCommand.ExecuteReader();
+                dt = new DataTable();
+                dt.Load(reader);
+            }
+            catch (Exception ee)
+            {
+
+            }
+            return dt;
+        }
 
 
         /// <summary>
         /// <summary>
         /// 关闭数据库连接
         /// 关闭数据库连接