Exemplo n.º 1
0
 private bool IsSimaliar(C2I3 x, C2I3 y)
 {
     if (x.a == y.a)
     {
         C2IPanel.C2I p = new C2IPanel.C2I()
         {
             SCell = x.b, NCell = x.c
         };
         C2IPanel.C2I q = new C2IPanel.C2I()
         {
             SCell = y.b, NCell = y.c
         };
         MatchType type = match(p, q);
         if (type == MatchType.NSBoth || type == MatchType.SNBoth)
         {
             return(true);
         }
     }
     else if (x.a == y.b)
     {
         C2IPanel.C2I p = new C2IPanel.C2I()
         {
             SCell = x.b, NCell = x.c
         };
         C2IPanel.C2I q = new C2IPanel.C2I()
         {
             SCell = y.a, NCell = y.c
         };
         MatchType type = match(p, q);
         if (type == MatchType.NSBoth || type == MatchType.SNBoth)
         {
             return(true);
         }
     }
     else if (x.a == y.c)
     {
         C2IPanel.C2I p = new C2IPanel.C2I()
         {
             SCell = x.b, NCell = x.c
         };
         C2IPanel.C2I q = new C2IPanel.C2I()
         {
             SCell = y.a, NCell = y.b
         };
         MatchType type = match(p, q);
         if (type == MatchType.NSBoth || type == MatchType.SNBoth)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double value = (double)numericUpDown1.Value / 100;

            C2I3List.Clear();

            foreach (C2IPanel.C2I c2i in C2IList)
            {
                C2I3 c2i3 = new C2I3();
                c2i3.a = c2i.SCell;
                c2i3.b = c2i.NCell;

                if (c2i.PrbABS6 < value)
                {
                    continue;
                }

                foreach (C2IPanel.C2I c2i_ in C2IList)
                {
                    if (c2i_.PrbABS6 < value)
                    {
                        continue;
                    }
                    if (match(c2i, c2i_) == MatchType.SS)
                    {
                        foreach (C2IPanel.C2I c2i__ in C2IList)
                        {
                            if (c2i__.PrbABS6 < value)
                            {
                                continue;
                            }
                            C2IPanel.C2I c2iTemp = new C2IPanel.C2I()
                            {
                                SCell = c2i.NCell, NCell = c2i_.NCell
                            };
                            MatchType type = match(c2i__, c2iTemp);
                            if (type == MatchType.NSBoth || type == MatchType.SNBoth)
                            {
                                c2i3.c = c2i_.NCell;
                                C2I3List.Add(c2i3);
                            }
                        }
                    }
                    else if (match(c2i, c2i_) == MatchType.SN)
                    {
                        foreach (C2IPanel.C2I c2i__ in C2IList)
                        {
                            if (c2i__.PrbABS6 < value)
                            {
                                continue;
                            }
                            C2IPanel.C2I c2iTemp = new C2IPanel.C2I()
                            {
                                SCell = c2i.SCell, NCell = c2i_.NCell
                            };
                            MatchType type = match(c2i__, c2iTemp);
                            if (type == MatchType.NSBoth || type == MatchType.SNBoth)
                            {
                                c2i3.c = c2i_.NCell;
                                C2I3List.Add(c2i3);
                            }
                        }
                    }
                    else if (match(c2i, c2i_) == MatchType.NN)
                    {
                        foreach (C2IPanel.C2I c2i__ in C2IList)
                        {
                            if (c2i__.PrbABS6 < value)
                            {
                                continue;
                            }
                            C2IPanel.C2I c2iTemp = new C2IPanel.C2I()
                            {
                                SCell = c2i.SCell, NCell = c2i_.SCell
                            };
                            MatchType type = match(c2i__, c2iTemp);
                            if (type == MatchType.NSBoth || type == MatchType.SNBoth)
                            {
                                c2i3.c = c2i_.SCell;
                                C2I3List.Add(c2i3);
                            }
                        }
                    }
                    else if (match(c2i, c2i_) == MatchType.NS)
                    {
                        foreach (C2IPanel.C2I c2i__ in C2IList)
                        {
                            if (c2i__.PrbABS6 < value)
                            {
                                continue;
                            }
                            C2IPanel.C2I c2iTemp = new C2IPanel.C2I()
                            {
                                SCell = c2i.NCell, NCell = c2i_.SCell
                            };
                            MatchType type = match(c2i__, c2iTemp);
                            if (type == MatchType.NSBoth || type == MatchType.SNBoth)
                            {
                                c2i3.c = c2i_.SCell;
                                C2I3List.Add(c2i3);
                            }
                        }
                    }
                }
            }

            cmd.CommandText = String.Format(@"
            IF OBJECT_ID(N'tbC2I3',N'U') is not null
	            DROP TABLE tbC2I3
            CREATE TABLE [dbo].[tbC2I3](
	            [aCell] [varchar](50) NULL,
	            [bCell] [varchar](50) NULL,
	            [cCell] [varchar](50) NULL
            )");
            cmd.ExecuteNonQuery();

            for (int i = 0; i < C2I3List.Count; i++)
            {
                for (int j = i + 1; j < C2I3List.Count; j++)
                {
                    if (IsSimaliar(C2I3List[i], C2I3List[j]))
                    {
                        C2I3List.RemoveAt(j);
                        j--;
                    }
                }
            }

            foreach (C2I3 c2i3 in C2I3List)
            {
                cmd.CommandText = String.Format(@"
                INSERT INTO [dbo].[tbC2I3]
                           ([aCell]
                           ,[bCell]
                           ,[cCell])
                VALUES('{0}','{1}','{2}')", c2i3.a, c2i3.b, c2i3.c);
                cmd.ExecuteNonQuery();
            }

            cmd.CommandText = "SELECT * FROM tbC2I3";
            reader          = cmd.ExecuteReader();
            ListViewTool.RefreshByDbDataReader(listview, reader);
            reader.Close();
        }