Beispiel #1
0
        protected override void Find()
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }

            for (int i = 0; i < DBGrid.Rows.Count; i++)
            {
                DBGrid.Rows[i].Visible = true;
            }
            int startindex = 0;

            if (DBGrid.CurrentRow.Index < DBGrid.RowCount - 1)
            {
                startindex = DBGrid.CurrentRow.Index + 1;
            }

            string[] finds = FindText.ToUpper().Split('*');
            string   flag  = clsLxms.GetParameterValue("HIDE_NOT_MATCH_PRODUCT");

            if (flag == "F")   //不隐藏不匹配的
            {
                bool find = false;
                for (int i = startindex; i < DBGrid.Rows.Count; i++)
                {
                    bool            found = true;
                    modCustomerList mod   = (modCustomerList)DBGrid.Rows[i].DataBoundItem;
                    for (int j = 0; j < finds.Length; j++)
                    {
                        if (mod.FullName.IndexOf(finds[j]) < 0)
                        {
                            found = false;
                        }
                    }
                    if (found)
                    {
                        DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
                        DBGrid_SelectionChanged(null, null);
                        find = true;
                        return;
                    }
                }
                if (!find)
                {
                    for (int i = 0; i < DBGrid.Rows.Count; i++)
                    {
                        bool            found = true;
                        modCustomerList mod   = (modCustomerList)DBGrid.Rows[i].DataBoundItem;
                        for (int j = 0; j < finds.Length; j++)
                        {
                            if (mod.FullName.IndexOf(finds[j]) < 0)
                            {
                                found = false;
                            }
                        }
                        if (found)
                        {
                            DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
                            DBGrid_SelectionChanged(null, null);
                            find = true;
                            return;
                        }
                    }
                }
            }
            else   //隐藏不匹配的
            {
                DBGrid.CurrentCell = null;
                for (int i = 0; i < DBGrid.Rows.Count; i++)
                {
                    bool            found = true;
                    modCustomerList mod   = (modCustomerList)DBGrid.Rows[i].DataBoundItem;
                    for (int j = 0; j < finds.Length; j++)
                    {
                        if (mod.FullName.IndexOf(finds[j]) < 0)
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        DBGrid.Rows[i].Visible = true;
                    }
                    else
                    {
                        DBGrid.Rows[i].Visible = false;
                    }
                }
            }
        }