| 网站首页 | 行业资讯 | 操作系统 | 网络技术 | 网页设计 | 平面设计 | 媒体制作 | 编程开发 | 
 | 办公软件 | 网络安全 | 电脑技术 | 数 据 库 | 课程在线 | 成功案例 | 项目合作 | 团队简介 | 
蓝色极速感谢大家的支持!站长:干戈 QQ:495979847     IAS网上答疑系统V1.0发布  [Sunpeople  2007年9月15日]        
  您现在的位置: 蓝色极速 >> 网络技术 >> ASP.NET >> 教程正文
 

首页所应该达到的几个…

          ★★★ 
通过c#连结oracle数据库(五)
作者:佚名    教程来源:编程学习    点击数:    更新时间:2007-5-10    

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();

 

if (DtRead.Read())

{

blnEdit = true;

//drEdit = DataSet1.Tables["Emp"].Rows.Find(Int16.Parse(TxtEmpNo.Text));

TxtEName.Text = DtRead["EName"].ToString();

TxtESal.Text = DtRead["Sal"].ToString();

TxtDeptNo.Text = DtRead["DeptNo"].ToString();

TxtEName.Focus();

}

else

{

TxtEName.Text = "";

TxtESal.Text = "";

TxtDeptNo.Text = "";

MessageBox.Show("Record Not found!");

TxtEmpNo.Focus();

}

DtRead.Close();

}

catch(Exception e1)

{

MessageBox.Show(e1.ToString());

}

}

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

{

try

{

object Str1;

string Str2;

Str1 = MessageBox.Show("Do you want to delete the record","Delete Box", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning);
//==DialogResult.Yes)

if (Str1.ToString() == "Yes")

{

Str2 = "Delete from Emp Where EmpNo=" + Int16.Parse(TxtEmpNo.Text);

Comm = new OleDbCommand(Str2,Conn);

Comm.ExecuteNonQuery();

MessageBox.Show("Record has been deleted!");

TxtEmpNo.Text = "";

TxtEName.Text = "";

TxtESal.Text = "";

TxtDeptNo.Text = "";

TxtEmpNo.Focus();

}

}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

}

}

}

教程录入:Sunpeople    责任编辑:Sunpeople  
  • 上一个教程:

  • 下一个教程:

  •      
    点击申请点击申请点击申请点击申请点击申请点击申请点击申请
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 |

    Copyright(C)2006-2009 Exploit Team All Rights Reserved
    QQ:495979847 网络备案号:陇ICP备07001585号