insert data by using radiobutton and checkbox in dot net



This is A C# Practice code:
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Linq;
        using System.Text;
        using System.Windows.Forms;
        using System.Data.SqlClient;

        namespace dataentry
        {
            public partial class insertButton : Form
            {
                public insertButton()
                {
                    InitializeComponent();
                }
                SqlConnection CON = new SqlConnection("Data Source=.;Initial Catalog=DATAENTRY;Integrated Security=True;Pooling=False");


                string GENDER;
                string STATUS;
                private void button9_Click(object sender, EventArgs e)
                {
                    CON.Open();
                    SqlDataAdapter SDA = new SqlDataAdapter("INSERT INTO REGISTER (ID,NAME,GENDER,STATUS,AGE,SALARY,TAX) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + GENDER + "','" + STATUS + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')", CON);
                    SDA.SelectCommand.ExecuteNonQuery();
                    CON.Close();
                    MessageBox.Show("SAVED SUCCEESSFULLY !!!!!");
                }

                private void radioButton1_CheckedChanged(object sender, EventArgs e)
                {
                    GENDER = "MALE";
                }

                private void radioButton2_CheckedChanged(object sender, EventArgs e)
                {
                    GENDER = "FEMALE";
                }

                private void insertButton_Load(object sender, EventArgs e)
                {

                }

                private void checkBox1_CheckedChanged(object sender, EventArgs e)
                {
                    STATUS = "MARRIED";
                }

                private void checkBox2_CheckedChanged(object sender, EventArgs e)
                {
                    STATUS = "UNMARRIED";
                }
            }
        }


Video For Result:



Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Facebook Comment