Beispiel #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ServiceReference1.ServiceClient sClient = new ServiceReference1.ServiceClient();

        if (!(sClient.checkLogin(txtLoginName.Text, txtPassword.Text)))
        {
            if (txtPassword.Text == txtCfPassword.Text)
            {
                SqlConnection con = new SqlConnection();
                con.ConnectionString = @"Data Source=(LocalDb)\MSSqlLocalDb;Initial Catalog=DotNet;Integrated Security=True;Pooling=False";
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "InsertUserMaster";
                cmd.Connection  = con;
                cmd.Parameters.AddWithValue("@LoginName", txtLoginName.Text);
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                cmd.Parameters.AddWithValue("@EmailId", txtEmailId.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@CityId", ddlCity.SelectedValue);
                cmd.Parameters.AddWithValue("@PaymentModeId", ddlPaymentMode.SelectedValue);
                con.Open();
                int i = cmd.ExecuteNonQuery();
                con.Close();
                lblAlradyExist.Text = "User Registered SuccessFully..";
            }
        }
        else
        {
            lblAlradyExist.Text = "User Alreday Exist..";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ServiceReference1.ServiceClient sClient = new ServiceReference1.ServiceClient();

        if (!IsPostBack)
        {
            if (Request.Cookies["Login"] != null)
            {
                var cookie = Request.Cookies["Login"].Values;
                if (sClient.checkLogin(cookie.Get("LoginName"), cookie.Get("Password")))
                {
                    Session["LoginName"] = cookie.Get("LoginName");
                    Session["Password"]  = cookie.Get("Password");
                    Response.Redirect("HomePage.aspx");
                }
            }
        }
    }