Esempio n. 1
0
        //-----------------------------------------------------------------------------------------------------//
        public Expert getExpert(string email)
        {
            Expert expDetail = null;

            string expUserName, expFName, expLName, expGender, expHp, expAddress;

            string        queryStr = "SELECT * FROM Expert WHERE Email = @Email";
            SqlConnection conn     = new SqlConnection(DbHelper.ConnectionString);
            SqlCommand    cmd      = new SqlCommand(queryStr, conn);

            cmd.Parameters.AddWithValue("@Email", email);
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            //Check if there are any resultsets
            if (dr.Read())
            {
                expUserName = dr["UserName"].ToString();
                expFName    = dr["FirstName"].ToString();
                expLName    = dr["LastName"].ToString();
                expAddress  = dr["Address"].ToString();
                //  userDateOfBirth = dr["DateOfBirth"].ToString();
                expGender = dr["Gender"].ToString();
                expHp     = dr["PhoneNumber"].ToString();
                expDetail = new Expert(expUserName, expFName, expLName, expAddress, expHp, expGender);
            }
            else
            {
                expDetail = null;
            }
            conn.Close();
            dr.Close();
            dr.Dispose();
            return(expDetail);
        }
Esempio n. 2
0
    protected void gvExpert_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int result = 0;

        Models.Expert exp       = new Models.Expert();
        GridViewRow   row       = (GridViewRow)gvExpert.Rows[e.RowIndex];
        string        id        = gvExpert.DataKeys[e.RowIndex].Value.ToString();
        int           tId       = int.Parse(((TextBox)row.Cells[0].Controls[0]).Text);
        string        tUserName = ((TextBox)row.Cells[1].Controls[0]).Text;
        string        tFName    = ((TextBox)row.Cells[2].Controls[0]).Text;
        string        tLName    = ((TextBox)row.Cells[3].Controls[0]).Text;
        string        tEmail    = ((TextBox)row.Cells[4].Controls[0]).Text;
        string        tPassword = ((TextBox)row.Cells[5].Controls[0]).Text;
        string        tAddress  = ((TextBox)row.Cells[6].Controls[0]).Text;
        string        tPhoneNo  = ((TextBox)row.Cells[7].Controls[0]).Text;
        string        tGender   = ((TextBox)row.Cells[8].Controls[0]).Text;

        result = exp.ExpertUpdate(tId, tUserName, tFName, tLName, tEmail, tPassword, tAddress, tPhoneNo, tGender);
        if (result > 0)
        {
            Response.Write("<script>alert('Updated successfully');</script>");
        }
        else
        {
            Response.Write("<script>alert('NOT successfully updated');</script>");
        }
        gvExpert.EditIndex = -1;
        bind();
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Models.Expert expDetails = new Models.Expert();
        // Get Product ID from querystring

        expDetails       = exp.getExpert(Session["Email"].ToString());
        lblExpEmail.Text = exp.ExpEmail;
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        expDetails       = exp.getExpert(Session["Email"].ToString());
        lblUsername.Text = expDetails.ExpUserName;

        if (lblUsername.Text != null)
        {
            //Retrieve username from session
            lblWelcome.Text = "Hi, " + lblUsername.Text + " !";
        }
        else
        {
            //do something else
        }
    }
Esempio n. 5
0
    protected void gvExpert_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int result = 0;

        Models.Expert exp   = new Models.Expert();
        string        ExpId = gvExpert.DataKeys[e.RowIndex].Value.ToString();

        result = exp.ExpertDelete(ExpId);



        Response.Redirect("~/AdminPages/ViewExpertDetails.aspx");

        // string categoryID = gvProduct.DataKeys[e.RowIndex].Value.ToString();
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Models.Expert aExp = new Models.Expert();
        // Get Product ID from querystring
        int expID = Convert.ToInt32(Session["ExpertId"]);

        //int expID = int.Parse(Request.QueryString["ExpertId"].ToString());
        exp = aExp.getExpert(expID);
        //Display product details on web form
        lblExpUsername.Text  = exp.ExpUserName;
        lblExpFirstName.Text = exp.ExpFName;
        lblExpLastName.Text  = exp.ExpLName;
        //   img_Product.ImageUrl = "~\\Images\\" + prod.Product_Image;
        //Store the value in invsible fields
        lblExpEmail.Text       = exp.ExpEmail;
        lblExpPhoneNumber.Text = exp.ExpHp;
        lblExpGender.Text      = exp.ExpGender.ToString();
        lblExpId.Text          = expID.ToString();
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Models.Expert expDetails = new Models.Expert();

        expDetails          = exp.getExpert(Session["Email"].ToString());
        lblExpUserName.Text = expDetails.ExpUserName;
        lblExpFName.Text    = expDetails.ExpFName;
        lblExpLName.Text    = expDetails.ExpLName;
        lblExpEmail.Text    = (string)Session["Email"];
        lblExpAddr.Text     = expDetails.ExpAddress;
        lblExpPhone.Text    = expDetails.ExpHp;
        lblExpGender.Text   = expDetails.ExpGender;
        lblWelcome.Text     = expDetails.ExpUserName;

        String        strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con     = new SqlConnection(strConn);
        SqlCommand    cmd     = new SqlCommand("select Id from Expert where Email=@Email", con);

        //cmd.Parameters.AddWithValue("@Id", lblUserId.Text);
        cmd.Parameters.AddWithValue("@Email", lblExpEmail.Text);
        SqlDataAdapter sda = new SqlDataAdapter(cmd);

        con.Open();
        int i = cmd.ExecuteNonQuery();

        con.Close();

        //check whether session is null or not
        if (lblExpUserName.Text != null)
        {
            //Retrieve username from session
            lblWelcome.Text = "Welcome, " + lblExpUserName.Text;
        }
        else
        {
            //do something else
        }
    }
Esempio n. 8
0
        //-----------------------------------------------------------------------------------------------------//
        public List <Expert> getExpertAll()
        {
            List <Expert> expList = new List <Expert>();
            int           expId;
            string        expUserName, expFName, expLName, expEmail, expPassword, expHp, expGender, expAddress;

            string        queryStr = "SELECT * FROM Expert Order By Id";
            SqlConnection conn     = new SqlConnection(DbHelper.ConnectionString);
            SqlCommand    cmd      = new SqlCommand(queryStr, conn);

            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            //Continue to read the resultsets row by row if not the end
            while (dr.Read())
            {
                expId       = int.Parse(dr["Id"].ToString());
                expUserName = dr["UserName"].ToString();
                expFName    = dr["FirstName"].ToString();
                expLName    = dr["LastName"].ToString();
                expEmail    = dr["Email"].ToString();
                expPassword = dr["Password"].ToString();
                expAddress  = dr["Address"].ToString();
                expHp       = dr["PhoneNumber"].ToString();
                expGender   = dr["Gender"].ToString();
                //   expDay = dr["DateOfBirth"].ToString();
                //  expMonth = dr["DateOfBirth"].ToString();
                //  expYear = dr["DateOfBirth"].ToString();

                Expert a = new Expert(expId, expUserName, expFName, expLName, expEmail, expPassword, expAddress, expHp, expGender);
                expList.Add(a);
            }
            conn.Close();
            dr.Close();
            dr.Dispose();
            return(expList);
        }
Esempio n. 9
0
    protected void btnSignUp_Click(object sender, EventArgs e)
    {
        int result = 0;

        //   Expert exp = new Expert(int.Parse(lblExpertID.Text), tbExpUserName.Text, tbExpFName.Text, tbExpLName.Text, tbExpEmail.Text, tbExpPwd.Text, tbExpPhoneNo.Text, rblExpGender.Text, tbExpAddr1.Text, tbExpAddr2.Text, tbExpPC.Text, ddlDay.Text, ddlMonth.Text, ddlYear.Text);

        try
        {
            Models.Expert exp = new Models.Expert(tbExpUserName.Text, tbExpFName.Text, tbExpLName.Text, tbExpEmail.Text, tbExpPwd.Text, tbExpAddress.Text, tbExpPhoneNo.Text, rblExpGender.SelectedValue);
            result = exp.ExpertInsert();
            Session["ExpertRegistration"] = exp;
            Session["Email"] = tbExpEmail.Text;

            if (Page.IsValid)
            {
                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("*****@*****.**");     //GET USER'S EMAIL FROM DATABASE
                mailMessage.To.Add(exp.ExpEmail);
                mailMessage.Subject = "Thank you for signing up with us.";

                mailMessage.Body       = "You have successfully created your account. Click on this link&nbsp;http://localhost:52050/ExpertPages/ExpertVerifyAccount.aspx &nbsp;to complete the activation.";
                mailMessage.IsBodyHtml = true;

                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.EnableSsl   = true;
                smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ernestleslie");
                smtpClient.Send(mailMessage);


                Response.Redirect("~/GuestPages/ScheduleMeeting.aspx");
            }
        }
        catch
        {
        }
    }