private void Subjects_UC_MouseClick(object sender, MouseEventArgs e)
 {
     SearchStatusLabel.Hide();
     AddStatusLabel.Hide();
     DeleteStatusLabel.Hide();
     RefreshedLabel.Hide();
     ClearedLabel.Hide();
 }
예제 #2
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            tempUSN  = SearchUSNTextField.Text;
            tempName = SearchNameTextField.Text;
            try
            {
                using (SqlCommand cmd = new SqlCommand("SearchStudent_SP", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (SearchUSNTextField.Text != "" || SearchNameTextField.Text != "")
                    {
                        cmd.Parameters.AddWithValue("@usn", tempUSN);
                        cmd.Parameters.AddWithValue("@name", tempName);

                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            using (DataSet ds = new DataSet())
                            {
                                da.Fill(ds);

                                con.Open();
                                try
                                {
                                    cmd.ExecuteNonQuery();
                                    SearchStatusLabel.ForeColor = Color.Green;
                                    SearchStatusLabel.Text      = "Search completed!";
                                    SearchStatusLabel.Show();
                                }
                                catch (Exception er)
                                {
                                    MessageBox.Show("" + er);
                                }
                                con.Close();

                                dataGridView1.DataSource = ds.Tables[0];

                                this.dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                                this.dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                                this.dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                                this.dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                                this.dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                            }
                        }
                    }
                    else
                    {
                        SearchStatusLabel.ForeColor = Color.Red;
                        SearchStatusLabel.Text      = "Value is empty!!";
                        SearchStatusLabel.Show();
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show("" + er);
            }
        }
예제 #3
0
 private void SearchNameTextField_MouseClick(object sender, MouseEventArgs e)
 {
     SearchUSNTextField.Text = "";
     SearchStatusLabel.Hide();
     UpdateStatusLabel.Hide();
 }