我有一个用于申请编号的组合框。在从组合框中选择申请编号时,我们应该得到申请该特定申请的成本中心。这是代码:
cmd.Connection = con;
if (con.State != ConnectionState.Open)
{
con.Open();
}
txtcc.Text = "";
if (cmbreqno.SelectedValue != null || Convert.ToString(cmbreqno.SelectedValue) != "")
{
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_displaycostcenter";
cmd.Parameters.AddWithValue("@req_no", cmbreqno.SelectedValue);
SqlDataReader rdr = cmd.ExecuteReader();
adp.Fill(dsreqno,"selectedpurchase");
if (dsreqno.Tables["selectedpurchase"].Rows.Count > 0)
{
txtcc.Text = dsreqno.Tables["selectedpurchase"].Rows[0]["req_no"].ToString();
}
dsreqno.Tables["selectedpurchase"].Clear();
}
cmd.Parameters.Clear();
//rdr.Close();
con.Close();