大家帮忙看看这是怎么会事??
zxd35 2003-08-20 11:28:35 在form1中定义了几个botton控件,按下以后进入form2,form2定义了一个toolbar控件,一个datagrid控件,在toolbal控件的“增加”按下后进入form3,form3定义了“保存”和“取消”按钮,输入完数据以后,按“取消”,我想退到form2,可却退到了form1,请问这是怎么回事??
以下是toolbar控件程序
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0:
AddBrch AddBrchForm = new AddBrch();
AddBrchForm.myParent=this;
AddBrchForm.Show();
brchDataSet = lib.ExecuteGet("select brno,brname from brtable order by brno","brtable");
lib.FillDataGridbyDataSet(dataGrid1,brchDataSet,ftpFieldName,ftpFieldLenth);
break;
case 1:
string brchDel,brchDelSql;
brchDel=dataGrid1[dataGrid1.CurrentRowIndex,0].ToString();
string SavePath="c:\\\\mapsgl\\\\data\\\\"+brchDel;
brchDelSql="delete from brtable where brno = "+lib.rep(brchDel);
MessageBox.Show(SavePath);
MessageBox.Show(brchDelSql);
lib.ExecuteUpdate(brchDelSql);
Directory.Delete(SavePath);
brchDataSet = lib.ExecuteGet("select brno,brname from brtable","brtable");
lib.FillDataGridbyDataSet(dataGrid1,brchDataSet,ftpFieldName,ftpFieldLenth);
break;
case 2:
this.Close();
break;
}
以下为保存和取消的程序
private void button1_Click(object sender, System.EventArgs e)
{
string SavePath="c:\\\\mapsgl\\\\data\\\\"+textBox1.Text.Trim();
string SavePath1="\'"+"c:\\\\mapsgl\\\\data\\\\"+textBox1.Text.Trim()+"\'";
string addBrchSql="insert into brtable values ("+brchLib.rep(textBox1.Text)+","+brchLib.rep(textBox2.Text)+","+SavePath1+")";
//MessageBox.Show(SavePath1);
Directory.CreateDirectory(SavePath);
//MessageBox.Show(addBrchSql);
brchLib.ExecuteUpdate(addBrchSql);
textBox1.Text="";
textBox2.Text="";
MessageBox.Show("增加成功");
this.textBox1.Focus();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}