代码如下 | 复制代码 |
public void NewRecord()
{ IsGetData = true; try { Cursor.Current = Cursors.WaitCursor; string strSQL = ""; //m_State = 0; this.tb_storeTableAdapter.Connection.ConnectionString = GlobalVariable.m_Conn;
if (GlobalVariable.Conn.State == ConnectionState.Closed) GlobalVariable.Conn.Open();
SqlCommand cmd = GlobalVariable.Conn.CreateCommand(); System.Data.SqlClient.SqlDataAdapter da = null; DataSet ds = new DataSet(); string ls_gcode="";
this.LblGCode.Text = ""; this.LblName.Text = ""; this.LblModel.Text = ""; if (this.hHDataSet.Tables["tb_store"] != null) { this.hHDataSet.Tables["tb_store"].Clear(); } if (this.TxtBarcode.Text.Trim().Length < 10)
{ strSQL = "Select c_gcode from tb_gds (nolock) " + " where c_gcode='" + this.TxtBarcode.Text.Trim() + "'"; cmd.CommandText = strSQL; cmd.CommandType = CommandType.Text; da = new SqlDataAdapter(cmd); da.Fill(ds, "tb_gds"); if (ds.Tables["tb_gds"].Rows.Count > 0) { ls_gcode = ds.Tables["tb_gds"].Rows[0]["c_gcode"].ToString(); } if (ls_gcode.Length <= 0)
{ //this.LblName.Text = "扫描的商品未找到!"; if (this.TxtBarcode.Text.Length > 0) MessageBox.Show("扫描的商品未找到!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } else { strSQL = "Select c_gcode from tb_barcode (nolock) " + " where c_barcode='" + this.TxtBarcode.Text.Trim() + "'"; cmd.CommandText = strSQL; cmd.CommandType = CommandType.Text; da = new SqlDataAdapter(cmd); da.Fill(ds, "c_barcode"); if (ds.Tables["c_barcode"].Rows.Count > 0) { ls_gcode = ds.Tables["c_barcode"].Rows[0]["c_gcode"].ToString(); } if (ls_gcode.Length <= 0)
{ //this.LblName.Text = "扫描的商品未找到!"; if (this.TxtBarcode.Text.Length > 0) MessageBox.Show("扫描的商品未找到!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } strSQL = "Select a.c_gcode,a.c_name,a.c_model,b.c_number,b.c_move_in_number,b.c_move_out_number,b.c_onway_sale_number,b.c_onway_w_number " +
" from tb_gds a (nolock),tb_gdsadno b(nolock) " + " where a.c_gcode=b.c_gcode and b.c_gcode='" + ls_gcode + "' and b.c_store_id='" + GlobalVariable.m_CompID + "' "; cmd.CommandText = strSQL; cmd.CommandType = CommandType.Text; da = new SqlDataAdapter(cmd); if (this.hHDataSet.Tables["tb_store"] != null) { this.hHDataSet.Tables["tb_store"].Clear(); } da.Fill(this.hHDataSet, "tb_store"); GetDataList();
SumTotal(); da.Dispose();
ds.Dispose(); cmd.Dispose(); } catch (Exception ex) { MessageBox.Show("数据库连接失败! " + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } IsGetData = false;
Cursor.Current = Cursors.Default; } |