Example #1
0
 private void Students_UC_MouseClick(object sender, MouseEventArgs e)
 {
     AddedLabel.Hide();
     UpdateStatusLabel.Hide();
     DeleteStatusLabel.Hide();
     RefreshedLabel.Hide();
     ClearedLabel.Hide();
     SearchStatusLabel.Text = "";
 }
Example #2
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (USNTextField.Text != "" && NameTextField.Text != "" && AddressTextField.Text != "" && GenderComboBox.Text != "Choose one...")
            {
                using (SqlCommand cmd = new SqlCommand("AddStudent_SP", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@usn", USNTextField.Text);
                    cmd.Parameters.AddWithValue("@name", NameTextField.Text);
                    cmd.Parameters.AddWithValue("@address", AddressTextField.Text);
                    cmd.Parameters.AddWithValue("@phone", PhoneTextField.Text);
                    cmd.Parameters.AddWithValue("@gender", GenderComboBox.Text);

                    con.Open();
                    try
                    {
                        cmd.ExecuteNonQuery();
                        AddedLabel.ForeColor = Color.Green;
                        AddedLabel.Text      = "Added successfully";
                        AddedLabel.Show();
                        USNTextField.Text     = "";
                        NameTextField.Text    = "";
                        AddressTextField.Text = "";
                        PhoneTextField.Text   = "";
                        GenderComboBox.Text   = "";
                    }
                    catch (Exception)
                    {
                        AddedLabel.ForeColor = Color.Red;
                        AddedLabel.Text      = "Error!";
                        AddedLabel.Show();
                    }
                    con.Close();
                    StudentdataGridView();
                }
            }
            else
            {
                AddedLabel.ForeColor = Color.Red;
                AddedLabel.Text      = "Empty!";
                AddedLabel.Show();
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            String a  = AccNoField.Text;
            String b  = BookNameField.Text;
            String c  = AuthorNameField.Text;
            String d  = PublisherField.Text;
            String ee = IsbnField.Text;
            String f  = DepartmentField.Text;

            if (a != "" && b != "" && c != "" && d != "" && ee != "" && f != "")
            {
                SqlCommand cmd = new SqlCommand("AddBooks_SP", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@accNo", AccNoField.Text);
                cmd.Parameters.AddWithValue("@isbn", IsbnField.Text);
                cmd.Parameters.AddWithValue("@Name", BookNameField.Text);
                cmd.Parameters.AddWithValue("@Author", AuthorNameField.Text);
                cmd.Parameters.AddWithValue("@publisher", PublisherField.Text);
                cmd.Parameters.AddWithValue("@dept_id", DepartmentField.Text);

                con.Open();
                try
                {
                    cmd.ExecuteNonQuery();
                    AddedLabel.ForeColor = Color.DarkGreen;
                    AddedLabel.Text      = "Book added successfully!";
                    AddedLabel.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
                con.Close();
                BooksdataGridView();
            }
            else
            {
                AddedLabel.ForeColor = Color.Red;
                AddedLabel.Text      = "Values cannot be empty!";
                AddedLabel.Show();
            }
        }