protected void btnsubmit_Click(object sender, EventArgs e)
    {
        //validate data
        try
        {
            if (TxtDisplayName.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter name."; return;
            }
            if (objValidation.IsValideCharacter(TxtDisplayName.Text) == false)
            {
                lblmsg.Text = "Special characters not allowed in name."; return;
            }
            if (TxtMobile.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter mobile no."; return;
            }
            if (objValidation.IsNumeric(TxtMobile.Text) == false)
            {
                lblmsg.Text = "Only enter numbers in mobile no."; return;
            }

            if (TxtWebsite.Text.Length > 0)
            {
                if (Uri.IsWellFormedUriString(TxtWebsite.Text, UriKind.Absolute) == false)
                {
                    lblmsg.Text = "Invalid web site url."; return;
                }
            }
            //update user profile
            string strqry = "";
            strqry = "update usermaster set displayname='" + TxtDisplayName.Text.Replace("'", "''") + "', mobileno='" + TxtMobile.Text + "',officeno='" + TxtOfficeNo.Text.Replace("'", "''") + "', Extension='" + TxtExt.Text.Replace("'", "''") + "', Address='" + TxtAddress.Text.Replace("'", "''") + "',website='" + TxtWebsite.Text.Replace("'", "''") + "' where emailid = '" + Convert.ToString(Session["EmailID"]) + "'";
            string ret = objDb.ExecuteInsertUpdate(strqry);
            if (ret == "" || ret == null || ret == "0")
            {
                lblmsg.Text = "Error : " + objDb.returnMsg; return;
            }
            lblmsg.Text = "User profile updated successfully!.";
        }
        catch (Exception ex)
        {
            lblmsg.Text = "Error : " + ex.Message.ToString();
        }
    }
Exemplo n.º 2
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        lblmsg.Text = "";
        try
        {
            // Validation Area
            if (TxtEmailID.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter email id."; return;
            }
            if (objValidation.IsEmail(TxtEmailID.Text) == false)
            {
                lblmsg.Text = "Email id you have entered not in correct format."; return;
            }

            if (TxtEmailID.Text.Trim() != "")
            {
                string str = objDb.ExecuteScaler("select count(*) from usermaster where emailid='" + TxtEmailID.Text + "'");
                if (str != "" && str != null && str != "0")
                {
                    lblmsg.Text     = "Email id already registered, please enter other email id.";
                    TxtEmailID.Text = "";
                    TxtEmailID.Focus();
                }
            }

            if (TxtPassword.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter password."; return;
            }
            if (TxtPassword.Text != TxtPassword1.Text)
            {
                lblmsg.Text = "Passwords are not matched, please check."; return;
            }
            if (TxtDisplayName.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter name."; return;
            }
            if (objValidation.IsValideCharacter(TxtDisplayName.Text) == false)
            {
                lblmsg.Text = "Special characters not allowed in name."; return;
            }
            if (TxtMobile.Text.Trim() == "")
            {
                lblmsg.Text = "Please enter mobile no."; return;
            }
            if (objValidation.IsNumeric(TxtMobile.Text) == false)
            {
                lblmsg.Text = "Only enter numbers in mobile no."; return;
            }
            if (TxtWebsite.Text.Length > 0)
            {
                if (Uri.IsWellFormedUriString(TxtWebsite.Text, UriKind.RelativeOrAbsolute) == false)
                {
                    lblmsg.Text = "Invalid web site url."; return;
                }
            }
            //------------------



            string strInsert = "Insert into usermaster (EmailID, TypeID,DisplayName,Password,MobileNo,OfficeNo,Extension,Address,Website,JoinDate,LastLoginDate,ChangePasswordDate,Active) " +
                               "values ('" + TxtEmailID.Text + "'," + ddlUserType.SelectedItem.Value + ",'" + TxtDisplayName.Text.Replace("'", "''") + "','" + TxtPassword.Text + "','" + TxtMobile.Text.Replace("'", "''") + "','" + TxtOfficeNo.Text.Replace("'", "''") + "','" + TxtExt.Text.Replace("'", "''") +
                               "','" + TxtAddress.Text.Replace("'", "''") + "','" + TxtWebsite.Text.Replace("'", "''") + "',getdate(),null,null,1)";

            strInsert = objDb.ExecuteInsertUpdate(strInsert);
            if (strInsert == "" || strInsert == null || strInsert == "0")
            {
                lblmsg.Text = "Error : " + objDb.returnMsg; return;
            }
            this.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script language=\"javaScript\">" + "alert('User registration done successfully!, please login!');" + "window.location.href='login.aspx';" + "<" + "/script>");


            //lblmsg.Text = "User registration done successfully!.";
            //btnreset_Click(null, null);
        }
        catch (Exception ex) {
            lblmsg.Text = "Error in Submit : " + ex.Message.ToString();
        }
    }