打印本文 打印本文 关闭窗口 关闭窗口
通过c#连结oracle数据库(五)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1997  更新时间:2009/4/22 22:10:37  文章录入:mintao  责任编辑:mintao

Application.Run(new FrmEmp());

}

private void FrmEmp_Load(object sender, System.EventArgs e)

{

}

private void BtnExit_Click(object sender, System.EventArgs e)

{

Conn.Close();

this.Close();

}

private void BtnAddNew_Click(object sender, System.EventArgs e)

{

TxtEmpNo.Text = "";

TxtEName.Text = "";

TxtESal.Text = "";

TxtDeptNo.Text = "";

TxtEmpNo.Focus();

}

private void BtnSave_Click(object sender, System.EventArgs e)

{

try

{

if (blnEdit == false)

{

DataRow1 = DataSet1.Tables["Emp"].NewRow();

DataRow1["EmpNo"] = Int16.Parse(TxtEmpNo.Text);

DataRow1["EName"] = TxtEName.Text;

DataRow1["Sal"] = Double.Parse(TxtESal.Text);

DataRow1["DeptNo"] = Int32.Parse(TxtDeptNo.Text);

DataSet1.Tables["Emp"].Rows.Add(DataRow1);

DataAdpt.Update(DataSet1,"Emp");

 

MessageBox.Show("record saved!");

}

else

{

string Str1;

Str1 = "Update Emp set EName=''''" + TxtEName.Text + "'''',Sal=" + double.Parse(TxtESal.Text) + ",";

Str1 = Str1 + "DeptNo=" + Int16.Parse(TxtDeptNo.Text) + " Where EmpNo=" + Int16.Parse(TxtEmpNo.Text);

Comm = new OleDbCommand(Str1,Conn);

Comm.ExecuteNonQuery();

 

/*drEdit.BeginEdit();

drEdit["EName"] = TxtEName.Text;

drEdit["Sal"] = double.Parse(TxtESal.Text);

drEdit["DeptNo"] = Int16.Parse(TxtDeptNo.Text);

drEdit.EndEdit();

DataAdpt.Update(DataSet1,"Emp");*/

MessageBox.Show("Record Modified!");

}

}

catch(Exception e1)

{

MessageBox.Show(e1.ToString());

}

}

private void BtnEdit_Click(object sender, System.EventArgs e)

{

string Str1;

try

{

Str1 = "Select * from Emp Where EmpNo=" + Int16.Parse(TxtEmpNo.Text);

Comm = new OleDbCommand(Str1, Conn);

DtRead = Comm.ExecuteReader();

[1] [2]  下一页

打印本文 打印本文 关闭窗口 关闭窗口