//------------------------------------------------------------------------------
// written by: Shivangi C
// assisted by: NA
// debugged by:Shivangi C
//
// summary: This file has the binding of the UI controls and display with the 
//          bussiness layer functions for the Page for registration of the member
//          
//------------------------------------------------------------------------------


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace StockForecasterClient
{
    public partial class Registration : System.Web.UI.Page
    {
        /// <summary>
        /// make the webservice object to call the web methods required
        /// </summary>
        SFSService.StockInfo serviceObj;

        /// <summary>
        /// The functions to be called and controls to be loaded on Page load event 
        /// are initialize/called here
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            serviceObj = new SFSService.StockInfo();
            lnkGoLoginbtn.Visible = false;
        }
        /// <summary>
        /// Code for on Button Click event for the Member Registration functionality
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            // call to webservice method RegisterUser
            int output = serviceObj.RegisterUser(txtFirst.Text, txtLast.Text,  txtUid.Text, txtPwd.Text, txtEmail.Text);
            if (output == 1)
            {
                lblMsg.Text = "Registered Successfully";
                lnkGoLoginbtn.Visible = true;                
            }
            else if (output == 0)
            {
                lblMsg.Text = "Registration Unsuccessful";
            }
            else
                lblMsg.Text = "User ID is already used by other User, Please Use Unique ID";

        }
        /// <summary>
        /// Code to redirect user to Login after Registration
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkGoLoginbtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("Login.aspx");
        }
    }
}
