private void BindDataSource()
{
//显示在DataGrid里的数据,点击某一条数据,可以进行修改、删除
string strSql="select cir_id,well_versed_add,start_date,recovery_date,break_time,break_cause_analyze,flag from rpt_carr_cir_break";

string connStr =  DataSetting.connectionString;
using (OracleConnection conn = new OracleConnection(connStr))
{
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = strSql;
OracleDataAdapter da = new OracleDataAdapter();
da.SelectCommand = cmd;
DataSet ds =new DataSet();
da.Fill(ds,"TempTable"); try
{
conn.Open();
this.dgList.DataSource=ds.Tables["TempTable"]; }
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
da.Dispose();
ds.Dispose();
}
}
this.currencyManager = (CurrencyManager)this.dgList.BindingContext[this.dgList.DataSource];
this.currencyManager.PositionChanged +=new EventHandler(CurrencyManager_PositionChanged);
}
private void CurrencyManager_PositionChanged(object sender, EventArgs e)
{
///让行数据的操作状态恢复
DataTable table = (DataTable)this.dgList.DataSource;
DataRow selectedRow = null;
if(this.currencyManager.Position != -1)
selectedRow = table.Rows[this.currencyManager.Position];
this.tbxCirId.Text = selectedRow["cir_id"].ToString();
this.tbxWellVersedAdd.Text = selectedRow["well_versed_add"].ToString();
this.dtpStartDate.Value = (DateTime)selectedRow["start_date"];
this.dtpRecoveryDate.Value = (DateTime)selectedRow["recovery_date"];
this.tbxBreakTime.Text  = selectedRow["break_time"].ToString();
this.tbxBreakCauseAnalyze.Text  = selectedRow["break_cause_analyze"].ToString();
this.btnAdd.Enabled = true;
this.btnDelete.Enabled = true;
this.btnModify.Enabled = true;
this.btnSave.Enabled = false;
SetControlReadOnlyAttribut(true);
}