Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Constructor is passing null value

my senario is that, once I logged in it should show the user details related to the username it should show the view user once I press the button. But in my case it is just passing a null value. I am adding the parts what I did. This is the Login Part.

if ((string)reader["tbl_user_type"] == "Farmer")

                        {
                                if ((int)reader["tbl_user_status"] == 0)

                                {
                                    MessageBox.Show("Your Account beign Verified !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                }

                                else

                                {
                                    User user = new User();
                                    user.USERNAME = reader.GetString("tbl_user_username");
                                    FPanel fpanel = new FPanel(user);
                                    fpanel.Show();
                                    this.Hide();
                                }

                        }

This is the button code. I created a constructor with parameters.

public FPanel(User user)
    {
        InitializeComponent();
        label1.Text = user.USERNAME;


    }

Then I executed the button click process.

 User user = new User();
        label1.Text = user.USERNAME;
        //label1.Text = user.USERNAME;
        U_Account uaccount = new U_Account(user);
        uaccount.Show();
        this.Hide();

As I did earlier I created a constructor to the U_Account

 public U_Account(User user)
    {
        InitializeComponent();

        label17F_Username.Text = user.USERNAME;

    }

// User class //

public class User
{
    private string U_F_Name;
    private string U_L_Name;
    private string U_NIC;
    private string U_Mobile_No;
    private string U_Address;
    private string U_Type;
    private string U_Email;
    private string U_Username;
    private string U_Password;

    public string ADDRESS
    {
        get
        {
            return this.U_Address;
        }

        set
        {
            this.U_Address = value;
        }
    }

    public string FNAME
    {
        get
        {
            return this.U_F_Name;
        }

        set
        {
            this.U_F_Name = value;
        }
    }

    public string LNAME
    {
        get 
        {
            return this.U_L_Name;
        }

        set
        {
            this.U_L_Name = value;
        }
    }

    public string MOBILE
    {
        get 
        {
            return this.U_Mobile_No;
        }

        set
        {
            this.U_Mobile_No = value;
        }
    }

    public string NIC
    {
        get
        {
            return this.U_NIC;
        }

        set
        {
            this.U_NIC = value;
        }
    }

    public string TYPE
    {
        get
        {
            return this.U_Type;
        }

        set
        {
            this.U_Type = value;
        }
    }

    public string EMAIL
    {
        get
        {
            return this.U_Email;
        }

        set
        {
            this.U_Email = value;
        }
    }

    public string USERNAME
    {
        get
        {
            return this.U_Username;
        }

        set
        {
            this.U_Username = value;
        }
    }

    public string PASSWORD
    {
        get
        {
            return this.U_Password;
        }

        set
        {
            this.U_Password = value;
        }
    }

    public void user()
    {
        throw new System.NotImplementedException();
    }
}

But still when I debug label17F_Username.Text = 'null' Hope anyone can explain me. Thanks.

Comments