综合查询示例
来源:互联网 发布:淘宝联盟提现钱到哪里 编辑:程序博客网 时间:2024/05/05 06:54
private void clearPart()
{
try
{
ds.Clear();
if (flag1)
{
bindingSource1.DataSource = ds.Tables[0];
this.bindingNavigator1.BindingSource = bindingSource1;
this.dataGridView1.DataSource = bindingSource1;
}
else
{
flag1 = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnQuery_Click(object sender, EventArgs e) //查询
clearPart();
ds = new DataSet();
ds.Clear();
try
{
string strY = System.DateTime.Now.ToString("yyyy-MM-dd-HH:mm");
string Sql = "SELECT DISTINCT OutBound_no,OutputTime,Class,Sequence,OutBounder_no,DeliveryMan_no FROM T_BJ_OutBound ";
string WhereStr = " Where OutBound_no is not null";
if (OutBound_no.Text.Trim() != string.Empty)
{
WhereStr = WhereStr + " and OutBound_no ='" + OutBound_no.Text.Trim() + "'";
}
if (CK_no.Text.Trim() != string.Empty)
{
WhereStr = WhereStr + " and CK_no ='" + CK_no.Text.Trim() + "'";
}
if (OutputMode.Text.Trim() != string.Empty)
{
WhereStr = WhereStr + " and OutputMode ='" + OutputMode.Text.Trim() + "'";
}
if (Start_Time.Text.Trim() != string.Empty)
{
if (End_Time.Text.Trim() != string.Empty)
{
WhereStr = WhereStr + " and OutputTime between '" + Start_Time.Text + "' AND '" + End_Time.Text + "' ";
}
}
if (Start_Time.Text.Trim() != string.Empty)
{
if (End_Time.Text.Trim() == string.Empty)
{
WhereStr = WhereStr + " and OutputTime between '" + Start_Time.Text + "' AND '" + strY + "'";
}
}
if (Start_Time.Text.Trim() == string.Empty)
{
if (End_Time.Text.Trim() != string.Empty)
{
string star = "2011-07-15";
WhereStr = WhereStr + " and OutputTime between '" + star + "' AND '" + End_Time.Text + "' ";
}
}
Sql = Sql + WhereStr;
conn = new OracleConnection(ConnectionString);
conn.Open();
OracleDataAdapter da = new OracleDataAdapter(Sql, conn);
da.Fill(ds, "T_BJ_OutBound");
da.Dispose();
bindingSource1.DataSource = ds.Tables[0];
this.bindingNavigator1.BindingSource = bindingSource1;
this.dataGridView1.DataSource = bindingSource1;
flag2 = true;
if (ds.Tables[0].Rows.Count == 0)
{
DetailClearPart();
MessageBox.Show("没有符合条件的数据");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
conn.Dispose();
ds.Dispose();
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string strSQL = null;
int rowIndex = e.RowIndex;
if (rowIndex < 0)
{
rowIndex = 0;
}
tempOutBound_no = dataGridView1.Rows[rowIndex].Cells[0].Value.ToString();
//创建一个新连接
DetailClearPart();
Detailds.Clear();
conn = new OracleConnection(ConnectionString);
try
{
strSQL = "SELECT OutBound_no,Spareparts_no,Spareparts_name,TotalNumber,TotalWeight,CK_no,Shelve_no,OutputMode,OutputTime,Class,Sequence,OutBounder_no,DeliveryMan_no,
+ "Other FROM T_BJ_OutBound Where OutBound_no = '" + tempOutBound_no + "' order by OutBound_no";
//创建数据提供者
OracleDataAdapter DataAdapter = new OracleDataAdapter(strSQL, conn);
DataAdapter.Fill(Detailds, "T_BJ_OutInfor");
DataAdapter.Dispose();
bindingSource2.DataSource = Detailds.Tables[0];
this.bindingNavigator2.BindingSource = bindingSource2;
this.dataGridView2.DataSource = bindingSource2;
flag2 = true;
if (Detailds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("没有符合条件的数据!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
conn.Dispose();
Detailds.Dispose();
}
}
private void DetailClearPart()
{
try
{
Detailds.Clear();
if (flag3)
{
Detailds.Clear();
this.bindingNavigator2.BindingSource = bindingSource2;
this.dataGridView2.DataSource = bindingSource2;
}
else
{
flag3 = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
- 综合查询示例
- Oracle基础查询综合示例
- Oracle分页查询综合示例
- LinqToSql 动态查询条件,join, isnull 综合示例
- 综合查询
- SWT综合布局示例
- python step1综合示例
- GCD 综合使用示例
- STL-综合示例
- 霍夫线变换综合示例
- 依赖注入综合示例
- Hibernate综合查询解决方案
- javascript事件查询综合
- javascript事件查询综合
- javascript事件查询综合
- JavaScript事件综合查询
- javascript事件查询综合
- javascript事件查询综合
- 关于IE的内存泄漏与JavaScript内存释放
- android四个重要的组件Service
- 从svn上回滚版本
- hdoj 1334(暴力)
- 在IE下的JS编程需注意的内存释放问题
- 综合查询示例
- android 电话窃听器
- Java静态代码检查工具
- A re-introduction to JavaScript
- IE6-内存无法释放问题
- hibernate中Annotation中manyToOne使用:
- C++编程 之 5分钟做出一个游戏--MFC五子棋源码
- 嵌入式wpa_supplicant的移植
- 对立,从批判开始