c# double time confirm message step by step



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 database
        {
            public partial class DoubleConfirmation : Form
            {
                public DoubleConfirmation()
                {
                    InitializeComponent();
                }
                SqlConnection conns = new SqlConnection("Data Source=.;Initial Catalog=dataentry;Integrated Security=True;Pooling=False");
                private void label2_Click(object sender, EventArgs e)
                {
                   
                }

                private void button1_Click(object sender, EventArgs e)
                {
                    conns.Open();
                    SqlDataAdapter sdaa = new SqlDataAdapter("insert into LOGINWINDOW (username,pass) values ('" + textBox4.Text + "','" + textBox3.Text + "')", conns);
                    sdaa.SelectCommand.ExecuteNonQuery();
                    conns.Close();
                    display();
                }

                private void button2_Click(object sender, EventArgs e)
                {
                    DialogResult del = MessageBox.Show("Are you sure Want to Delete","Delete",MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (del == DialogResult.Yes)
                    {
                        DialogResult confim=MessageBox.Show( "You Delete Confirmlly...!!","Confirm Delete",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
                        if (confim == DialogResult.Yes)
                        {
                            SqlDataAdapter asd = new SqlDataAdapter("delete from LOGINWINDOW where username='" + textBox4.Text + "'", conns);
                            DataTable data = new DataTable();
                            asd.Fill(data);
                            display();
                        }
                        if (confim == DialogResult.No)
                        {
                            MessageBox.Show("Not Delete Any Records", "Not Confirm Delete", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                        }
                        if (confim == DialogResult.Cancel)
                        {
                            MessageBox.Show(" Delete Canceld", "Cancel", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                        }
                    }
                    else
                    {
                        MessageBox.Show("Not Delete Any Records", "Not Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    }
                    
                 
                }
                void display()
                {
                    SqlDataAdapter dis = new SqlDataAdapter("select * from LOGINWINDOW", conns);
                    DataTable ss = new DataTable();
                    dis.Fill(ss);
                    dataGridView1.DataSource = ss;

                }

                private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
                {

                }
            }
        }


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