private void process1_Load(object sender, EventArgs e) { this.Resize += new EventHandler(Form1_Resize); //窗体调整大小时引发事件 X = this.Width; //获取窗体的宽度 Y = this.Height; //获取窗体的高度 setTag(this); //调用方法 label2.Left = label1.Right; dataGridView1.DataSource = helper.SelectMysqlreturnDataset("select process,product,type from Keyprocess").ToString(); string path1 = helper.ExecuteScalar("select PathProcess from T_OKKEN where product_type='" + label2.Text + "'").ToString(); MessageBox.Show(path1); DirectoryInfo dir = new DirectoryInfo(@"c:\\123"); FileInfo[] fil = dir.GetFiles(); process1 pro = new process1(); foreach (FileInfo f in fil) { long size = f.Length; //listBox1.Items.Add(f.Name);//添加文件路径到列表中 } }
//创建文件夹 private void button2_Click(object sender, EventArgs e) { string id = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); string path1 = helper.ExecuteScalar("select Path from T_OKKEN where product_type='" + id + "'").ToString(); string creatPath = path1 + @"\" + id; //MessageBox.Show(creatPath); //Directory.CreateDirectory(creatPath); bool exist = Directory.Exists(creatPath); if (exist == false && textBox2.Text != "") { Directory.CreateDirectory(creatPath); MessageBox.Show("创建成功!"); } else { MessageBox.Show("文件夹已存在或路径未设置!"); } }
//ClassLibrary3.DBHelper dbhelper = new ClassLibrary3.DBHelper(); private void OkkenBOM_Load(object sender, EventArgs e) { //dataGridView1.DataSource = helper.SelectMysqlreturnDataset("SELECT * FROM [" + label1.Text + "]").Tables[0]; dataGridView1.DataSource = ClassLibrary3.DBHelper.GetDatasByAdapter("SELECT * FROM [" + label1.Text + "]").Tables[0]; string pathR = helper.ExecuteScalar("SELECT Path from T_OKKEN where Product_Type= '" + label1.Text + "' ").ToString(); }