private static void AddToGlacialList1(GlacialList xListView, string xSql)
        {
            xListView.BeginUpdate();
            //xListView.Items.Clear();

            if (Program.DBConn.State.ToString().ToUpper() == "CLOSED")
            {
                Program.DBConn.Open();
            }
            SqlDataReader xRtn = Program.SqlReader(xSql);
            if (xRtn == null)
            {
                xRtn.Dispose();
                xListView.Update();
                xListView.EndUpdate();
                return;
            }
            if (xRtn.HasRows == false)
            {
                xRtn.Close();
                xRtn.Dispose();
                xListView.Update();
                xListView.EndUpdate();
                return;
            }
            int xFieldCount;
            xFieldCount = xRtn.FieldCount;
            GLItem lvi;
            xListView.Update();
            //xListView.BeginUpdate();
            while (xRtn.Read())
            {

                lvi = new GLItem();
                for (int col = 0; col < xFieldCount; col++)
                {
                    if (col == 0)
                    {
                        lvi = xListView.Items.Add(xRtn.GetValue(col).ToString().Trim());

                    }
                    else
                    {
                        lvi.SubItems[col].Text = xRtn.GetValue(col).ToString().Trim();

                    }
                }

            }
            xListView.EndUpdate();
            xRtn.Close();
            xRtn.Dispose();
            return;
        }
 private static void ClearGlacialList(GlacialList xGlacialList, GLItem xItem)
 {
     xGlacialList.BeginUpdate();
     xGlacialList.Items.Remove(xItem);
     xGlacialList.EndUpdate();
 }
 private static void ClearGlacialList(GlacialList xGlacialList)
 {
     xGlacialList.BeginUpdate();
     xGlacialList.Items.Clear();
     xGlacialList.EndUpdate();
 }
Esempio n. 4
0
 //public static bool CheckPunctuation(string xstr)
 //{
 //    //验证输入字符串是否包含单引号
 //    bool flag = true;
 //    if (xstr.Length == 0)
 //    {
 //        flag = false;
 //    }
 //    else
 //    {
 //        char[] x = xstr.ToCharArray();
 //        for (int i = 0; i < xstr.Length; i++)
 //        {
 //            if (x[i] == (char)39)
 //            {
 //                flag = false; break;
 //            }
 //        }
 //    }
 //    return flag;
 //}
 //public static void ReadTreeNode(TreeView xTree)     //传递的参数是treeview
 //{
 //    TreeNode tn = null;                 //节点赋为空值
 //    if (xTree.Nodes.Count == 0)             //节点总数为0
 //    {
 //        tn = new TreeNode("用户类别信息");
 //        tn.Name = Program.RootCode + Program.RootCode; //
 //        tn.ImageIndex = 0;
 //        xTree.Nodes.Add(tn);
 //        return;
 //    }
 //    if (xTree.SelectedNode.GetNodeCount(true) != 0)
 //    {
 //        //xTree.SelectedNode.Expand();
 //        return;
 //    }
 //    //在当前视图控件中选定的树节点的名称,以字符串的形式显示,截取从0开始的10个字符
 //    string xParentKey = xTree.SelectedNode.Name.ToString().Substring(0, 10);
 //    //SQL语句从AddressDict表中查询Parent_='xParentKey'的所有记录
 //    string xSql = "select * from MemberType where Parent_='" + xParentKey + "'";
 //    //读取数据
 //    SqlDataReader xRec = Program.SqlReader(xSql);
 //    if (xRec == null)
 //    {
 //        return;
 //    }
 //    if (xRec.HasRows == false)
 //    {
 //        xRec.Close();
 //        return;
 //    }
 //    while (xRec.Read())
 //    {
 //        tn = new TreeNode(xRec["Nam"].ToString());
 //        tn.Name = xRec["Code"].ToString() + xRec["SysNo"].ToString();  //两个字段值以字符串形式连接
 //        if (Int32.Parse(xRec["SysNo"].ToString()) == 0)
 //        {
 //            tn.ImageIndex = 0;
 //        }
 //        else
 //        {
 //            tn.ImageIndex = 1;
 //        }
 //        xTree.SelectedNode.Nodes.Add(tn);
 //    }
 //    xTree.SelectedNode.Expand();
 //    xRec.Close();
 //    return;
 //}
 public static void ReadGlacialList(GlacialList xGlacialList, SqlDataReader xRec)
 {
     int i, x;
     x = xRec.FieldCount;
     if (x > xGlacialList.Columns.Count)
     {
         return;
     }
     x = x - 1;
     xGlacialList.Items.Clear();
     xGlacialList.BeginUpdate();
     if (xRec == null)
     {
         xGlacialList.EndUpdate();
         return;
     }
     if (xRec.HasRows == false)
     {
         xGlacialList.EndUpdate();
         return;
     }
     while (xRec.Read())
     {
         GLItem xList = new GLItem();
         xList.SubItems.Clear();
         xList.SubItems[0].Text = xRec[0].ToString().Trim();
         for (i = 1; i <= x; i++)
         {
             xList.SubItems[i].Text = xRec[i].ToString().Trim();
         }
         xGlacialList.Items.Add(xList);
     }
     xGlacialList.EndUpdate();
     return;
 }