日期:2014-05-18 浏览次数:20799 次
private void 复制厂站ToolStripMenuItem_Click(object sender, EventArgs e) { //treeView1.SuspendLayout(); Device _device = new Device();//这个是数据库的表的类 TreeNode tn = new TreeNode(); tn.Text = GetString("厂站名称");//这个就是赋值 tn.Tag = "FactoryName"; _factory.FactoryName = tn.Text; _factory.SetFactory(); DataTable ds = _device.SelectAllNote(treeView1.SelectedNode.Text);//这个是查询数据库并读出大量数据 if(ds .Rows.Count !=0) { [color=#FF0000]//下面是把数据逐行插入数据库[/color] for (int n = 0; n < ds .Rows .Count ; n++) { _device.LockMainType =Convert.ToString(ds.Rows[n][8].ToString()); _device.VoltageGrade = Convert.ToString(ds.Rows[n][3].ToString()); _device.Code = Convert.ToString(ds.Rows[n][1].ToString()); _device.Name = Convert.ToString(ds.Rows[n][2].ToString()); //VoltageGrade = Convert.ToString(ds.Tables["s"].Rows[0][3].ToString()); _device.Room = Convert.ToString(ds.Rows[n][4].ToString()) ; _device.MasterDevice = Convert.ToString(ds.Rows[n][5].ToString()); _device.Region = Convert.ToString(ds.Rows[n][6].ToString()); _device.RelatedLock = Convert.ToString(ds.Rows[n][7].ToString()); //LockMainType = Convert.ToString(ds.Rows[0][8].ToString()); _device.Lock = Convert.ToString(ds.Rows[n][9].ToString()); _device.LockType = Convert.ToString(ds.Rows[n][10].ToString()); _device.DeviceSort = Convert.ToString(ds.Rows[n][11].ToString()); _device.DeviceType = Convert.ToString(ds.Rows[n][12].ToString()); _device.Transmit = Convert.ToString(ds.Rows[n][13].ToString()); _device.PointNo = Convert.ToString(ds.Rows[n][14].ToString()); _device.DisplayNo = Convert.ToString(ds.Rows[n][15].ToString()); _device.MultiPosition = Convert.ToString(ds.Rows[n][16].ToString()); _device.InitStatus = Convert.ToString(ds.Rows[n][17].ToString()); _device.Position = Convert.ToString(ds.Rows[n][18].ToString()); _device.Note = tn.Text; _device.SetDeviceCopy();//这个调用数据插入的方法 } } _factoryName = tn.Text; GetNodeT(tn); treeView1.Nodes.Add(tn); treeView1.ResumeLayout(); } }