public void LoadFormData()
 {
     try
     {
         clsUserMaster objLoad = new clsUserMaster();
         objLoad.Mode      = "SELECTONE";
         objLoad.CompanyID = cId;
         var lstUser = objLoad.GetUserData().FirstOrDefault();
         if (lstUser != null)
         {
             txtFirstName.Text     = lstUser.UserFirstName;
             txtLastName.Text      = lstUser.UserLastName;
             txtAddress.Text       = lstUser.UserAddress;
             txtEmail.Text         = lstUser.UserEmail;
             txtUserName.Text      = lstUser.UserName;
             txtUserPassword.Text  = lstUser.UserPassword;
             chkActive.Checked     = lstUser.UserIsActive == 1 ? true : false;
             lblAccountHeader.Text = "Welcome To";
             lblAccountHeader.Text = lblAccountHeader.Text + " " + txtFirstName.Text + " " + txtLastName.Text;
             txtKey.Text           = lstUser.UserID.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "LoadFormData", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         String        msg     = String.Empty;
         clsUserMaster objAuth = new clsUserMaster();
         objAuth.UserName     = txtUserName.Text;
         objAuth.UserPassword = txtPassword.Text;
         objAuth.CompanyID    = Convert.ToInt32(cmbCompany.SelectedValue);
         objAuth.Mode         = "AUTHONTICATE";
         msg = objAuth.AuthenticateValidate();
         if (msg.Length > 0)
         {
             MessageBox.Show(msg, "Authonticate Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             var lstUser = objAuth.GetUserData().FirstOrDefault();
             if (lstUser != null)
             {
                 frmMainMaster objMainMaster = new frmMainMaster(lstUser.UserRollFKey, Convert.ToInt32(cmbCompany.SelectedValue));
                 this.Hide();
                 objMainMaster.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Invalid User Name and Password", "Authonticate Aler", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "btnLogin_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }