Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从两个表中复制引用号以进行登录时出错_C#_Asp.net_Webforms - Fatal编程技术网

C# 从两个表中复制引用号以进行登录时出错

C# 从两个表中复制引用号以进行登录时出错,c#,asp.net,webforms,C#,Asp.net,Webforms,我有两个表经销商和客户。管理员将添加经销商字段并向客户提供参考编号。客户在网站注册时必须使用该参考编号和类型。在后端,客户编写的参考号应该与他提供的参考号匹配。如果是相同的,那么他可以登录。否则,他将看到错误消息 在这里,我无法比较参考号。值没有传递 protected void SignInButton_Click(object sender, EventArgs e) { int customerID; Customer customer = new

我有两个表经销商和客户。管理员将添加经销商字段并向客户提供参考编号。客户在网站注册时必须使用该参考编号和类型。在后端,客户编写的参考号应该与他提供的参考号匹配。如果是相同的,那么他可以登录。否则,他将看到错误消息

在这里,我无法比较参考号。值没有传递

protected void SignInButton_Click(object sender, EventArgs e)
    {
        int customerID;

        Customer customer = new Customer();

        customer.CustomerName = CustomerNameTextBox.Text;
        customer.ShopName = ShopNameTextBox.Text;
        customer.Address = AddressTextBox.Text;
        customer.Mobile1 = Mobile1TextBox.Text;
        customer.Mobile2 = Mobile2TextBox.Text;
        customer.ReferenceNumber = ReferenceNumberTextBox.Text;
        customer.LoginID = Mobile1TextBox.Text;
        customer.Password = RandomNoGenerator.GenerateRandomNo();
        customer.SignUpDate = DateTime.Now;
        customer.Enabled = true;


        try
        {
            Reseller reseller = new Reseller();

            if (customer.ReferenceNumber == reseller.ReferenceNumber)
            {
                //MessageLabel.Text = "Customer successfully added";
                customerID = CustomerBL.AddCustomer(customer);
                MessageLabel.Text = "You've successfully signed up!";
                Response.Redirect("UserSignUpSuccess.aspx?CustomerID=" + customerID);
            }
            else
            {
                MessageLabel.Text = "Please Provide Same Reference Number";
            }
            //customerID = CustomerBL.AddCustomer(customer);
            //MessageLabel.Text = "You've successfully signed up!";
            //Response.Redirect("UserSignUpSuccess.aspx?CustomerID=" + customerID);
        }
        catch (Exception ex)
        {
            MessageLabel.Text = "Some error occured while processing the request. Error Description <br/>" + ex.Message;
        }

您正在创建
分销商
实例,但在使用它之前没有初始化它

Reseller reseller = new Reseller();

            if (customer.ReferenceNumber == reseller.ReferenceNumber)
            {

假设默认构造函数没有为
分销商
实例设置
参考编号
,您可能希望在使用它之前对其进行初始化。

这是不符合逻辑的,您将
参考编号
设置为
客户
,然后,您要比较设置为
customer
referenceNumber
s。这永远是真的吗?
Reseller reseller = new Reseller();

            if (customer.ReferenceNumber == reseller.ReferenceNumber)
            {