我有两个中继器。第一个返回所有客户交易,而第二个返回系统中为该特定客户输入的票据。问题是当客户在特定月份有多个票据时,支付交易表将根据票据表重复交易。例如,如果票据表具有3月10日的票据,那么我将在支付表10中看到交易(全部相同)。如何生成与付款交易分开的票据?
谢谢!
protected void FillNotesTable()
{
string connection = @"Data Source=###; User ID = ###; Password=###; Initial Catalog = ###; Persist Security Info=True; Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connection))
using (SqlCommand cmd = new SqlCommand("GetCurrentCustomerNotes", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
if (conn.State != ConnectionState.Open)
conn.Open();
// User input
cmd.Parameters.Add("@CID", SqlDbType.VarChar);
cmd.Parameters["@CID"].Value = tbCustomerID.Text;
repeaterNotes.DataSource = cmd.ExecuteReader();
repeaterNotes.DataBind();
conn.Close();
conn.Dispose();
}
}
protected void GetDataUnit()
{
string userName = Environment.UserName;
userName = Request.Cookies["###"]["User"];
tbFPN.Text = userName;
string connection = @"Data Source=###t; User ID = ###; Password=###; Initial Catalog = ###; Persist Security Info=True; Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connection))
using (SqlCommand cmd = new SqlCommand("GetCurrentCustomerByUnit", conn))
try
{
cmd.CommandType = CommandType.StoredProcedure;
if (conn.State != ConnectionState.Open)
conn.Open();
// User input
cmd.Parameters.Add("@UN", SqlDbType.VarChar);
cmd.Parameters["@UN"].Value = tbSearchNumber.Text;
cmd.Parameters.Add(new SqlParameter("@FPN", userName));
// Return info
SqlDataReader objDR;
objDR = cmd.ExecuteReader();
if (objDR.Read())
{
tbCustomerID.Text = objDR["ID"].ToString();
tbCertNumber.Text = objDR["Cert_Number"].ToString();
tbReturnUnit.Text = objDR["Unit_Number"].ToString();
tbReturnName.Text = objDR["Customer_Name"].ToString();
tbReturnAddress.Text = objDR["Address"].ToString();
tbReturnCity.Text = objDR["City"].ToString();
tbReturnState.Text = objDR["State_Abbr"].ToString();
tbReturnZipCode.Text = objDR["ZIP_Code"].ToString();
tbReturnPhone.Text = objDR["Phone_Number"].ToString();
tbReturnEmail.Text = objDR["Email_Address"].ToString();
}
objDR.Close();
repeaterPayments.DataSource = cmd.ExecuteReader();
repeaterPayments.DataBind();
}
catch (Exception ex)
{
lblMessage1.Text = ex.Message;
lblMessage1.Visible = true;
}
finally
{
conn.Close();
conn.Dispose();
}
}