예제 #1
0
        private void DELETEbutton_Click(object sender, EventArgs e)
        {
            SqlConnection con   = new SqlConnection(cs);
            string        query = "delete from item_tbl where item_id = @id";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.AddWithValue("@id", IDtextBox.Text);



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

            if (a > 0)
            {
                MessageBox.Show("Item Deleted Successfully  !!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridView();
                IDtextBox.Clear();
                NAMEtextBox.Clear();
                PRICEtextBox.Clear();
                DISCOUNTtextBox.Clear();
                NAMEtextBox.Focus();
            }
            else
            {
                MessageBox.Show("Item is not Deleted !!", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            con.Close();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con   = new SqlConnection(cs);
            string        query = "insert into item_tbl values(@name,@price,@discount)";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.AddWithValue("@name", NAMEtextBox.Text);
            cmd.Parameters.AddWithValue("@price", PRICEtextBox.Text);
            cmd.Parameters.AddWithValue("@discount", DISCOUNTtextBox.Text);


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

            if (a > 0)
            {
                MessageBox.Show("Item Added Successfully  !!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NAMEtextBox.Clear();
                PRICEtextBox.Clear();
                DISCOUNTtextBox.Clear();
                NAMEtextBox.Focus();
            }
            else
            {
                MessageBox.Show("Item is not Added !!", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            con.Close();
        }
예제 #3
0
        private void UPDATEbutton_Click(object sender, EventArgs e)
        {
            SqlConnection con   = new SqlConnection(cs);
            string        query = "update item_tbl set item_name = @name, item_price = @price, item_discount = @discount where item_id = @id";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.AddWithValue("@id", IDtextBox.Text);
            cmd.Parameters.AddWithValue("@name", NAMEtextBox.Text);
            cmd.Parameters.AddWithValue("@price", PRICEtextBox.Text);
            cmd.Parameters.AddWithValue("@discount", DISCOUNTtextBox.Text);


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

            if (a > 0)
            {
                MessageBox.Show("Item Updated Successfully  !!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridView();
                IDtextBox.Clear();
                NAMEtextBox.Clear();
                PRICEtextBox.Clear();
                DISCOUNTtextBox.Clear();
                NAMEtextBox.Focus();
            }
            else
            {
                MessageBox.Show("Item is not Updated !!", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            con.Close();
        }