Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            dbc obj = new dbc();

            if (!IsPostBack)
            {
                string sql = "spGetAllStateName";
                obj.connect(sql);
                if (obj.ds.Tables[0].Rows.Count > 0)
                {
                    DDstate.Items.Add("Select State");
                    for (int i = 0; i < obj.ds.Tables[0].Rows.Count; i++)
                    {
                        DDstate.Items.Add(obj.ds.Tables[0].Rows[i][0].ToString());
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string firstname   = txtFirstName.Text;
            string lastname    = txtLastName.Text;
            string username    = txtUserName.Text;
            string password    = txtPassword.Text;
            string emailid     = txtEmailId.Text;
            string state       = DDstate.SelectedValue;
            string city        = DDcity.SelectedValue;
            string pincode     = txtPin.Text;
            string gender      = string.Empty;
            string programming = string.Empty;

            if (rdbMale.Checked)
            {
                gender = "Male";
            }
            else if (rdbFemale.Checked)
            {
                gender = "Female";
            }
            if (chbJava.Checked)
            {
                programming = chbJava.Text;
            }
            if (chbDotNet.Checked)
            {
                programming = programming + "," + chbDotNet.Text;
            }
            if (chbPython.Checked)
            {
                programming = programming + "," + chbPython.Text;
            }
            if (chbCpp.Checked)
            {
                programming = programming + "," + chbCpp.Text;
            }
            dbc obj = new dbc();

            if (String.IsNullOrEmpty(firstname))
            {
                lblSubmit.Text = "Please insert firstname";
            }
            else if (String.IsNullOrEmpty(lastname))
            {
                lblSubmit.Text += "Please insert lastname";
                return;
            }
            else if (String.IsNullOrEmpty(username))
            {
                lblSubmit.Text = "Please insert username";
                return;
            }
            else if (String.IsNullOrEmpty(password))
            {
                lblSubmit.Text = "Please insert password";
                return;
            }
            else if (String.IsNullOrEmpty(emailid))
            {
                lblSubmit.Text = "Please insert emailid";
                return;
            }

            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();
            // string sql = "insert into registration values('"+firstname+"','"+lastname+"','"+username+"','"+password+"','"+emailid+"')";
            string     sql = "spInsertRegistrationData";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FirstName", firstname);
            cmd.Parameters.AddWithValue("@LastName", lastname);
            cmd.Parameters.AddWithValue("@UserName", username);
            cmd.Parameters.AddWithValue("@Password", password);
            cmd.Parameters.AddWithValue("@EmailId", emailid);
            cmd.Parameters.AddWithValue("@State", state);
            cmd.Parameters.AddWithValue("@City", city);
            cmd.Parameters.AddWithValue("@Pincode", pincode);
            cmd.Parameters.AddWithValue("@Gender", gender);
            cmd.Parameters.AddWithValue("@Programming", programming);

            int Result = cmd.ExecuteNonQuery();

            if (Result == 1)
            {
                lblSubmit.Text = "Registration done Successfully!";
                this.ClearTextBox();
            }
            else
            {
                lblSubmit.Text = "Error Occurred  !!! Response not generated....";
            }
            conn.Close();
        }