设为首页
加入收藏夹

通过c#连结oracle数据库(三)
浏览选项:

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(576, 317);

this.Controls.AddRange(new System.Windows.Forms.Control[] {

this.BtnExit,

this.BtnDelete,

this.BtnEdit,

this.BtnSave,

this.BtnAddNew,

this.TxtDeptNo,

this.TxtESal,

this.TxtEName,

this.TxtEmpNo,

this.label4,

this.label3,

this.label2,

this.label1});

this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.Name = "FrmEmp";

this.Text = "Employee Data Form";

this.Load += new System.EventHandler(this.FrmEmp_Load);

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

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

}

}

[首页]    [上一页]    [下一页]    [末页]    

Copyright © 2004 wanxu.com All Rights Reserved