Example #1
0
        private void linkLabel9_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ViewStudents vs = new ViewStudents();

            vs.Show();
            this.Hide();
        }
Example #2
0
        private void cmdEdit_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(conStr);

            con.Open();
            try
            {
                if (con.State == ConnectionState.Open)
                {
                    string Update;
                    if (cmbgender.SelectedIndex == 0)
                    {
                        Update = "UPDATE Person SET FirstName = '" + Convert.ToString(txtFname.Text) + "', LastName = '" + Convert.ToString(txtLname.Text) + "', Contact = '" + Convert.ToString(txtContact.Text) + "', Email = '" + Convert.ToString(txtmail.Text) + "', DateOfBirth = '" + Convert.ToDateTime(dtpDOB.Value) + "', Gender = '" + 1 + "' WHERE ID = '" + ViewStudents.studentid + "'";
                    }
                    else
                    {
                        Update = "UPDATE Person SET FirstName = '" + Convert.ToString(txtFname.Text) + "', LastName = '" + Convert.ToString(txtLname.Text) + "', Contact = '" + Convert.ToString(txtContact.Text) + "', Email = '" + Convert.ToString(txtmail.Text) + "', DateOfBirth = '" + Convert.ToDateTime(dtpDOB.Value) + "', Gender = '" + 2 + "' WHERE ID = '" + ViewStudents.studentid + "'";
                    }
                    string     Update_Student = "UPDATE Student SET RegistrationNo = '" + Convert.ToString(txtregNo.Text) + "' WHERE Id = '" + ViewStudents.studentid + "'";
                    SqlCommand cmd            = new SqlCommand(Update, con);
                    cmd.ExecuteNonQuery();
                    SqlCommand sqlCommand = new SqlCommand(Update_Student, con);
                    sqlCommand.ExecuteNonQuery();
                }

                //setGrid();

                MessageBox.Show("Succesfully Updated");
                ViewStudents vs = new ViewStudents();
                vs.Show();
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex);
            }
        }
Example #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selected = dataGridView1.CurrentCell.RowIndex;
            DataGridViewRow row = dataGridView1.Rows[selected];

            if (e.ColumnIndex == 0)
            {
                Students s = StudentsUtile.updateSt;
                studentid      = (int)row.Cells[2].Value;
                s.FirstName1   = row.Cells[3].Value.ToString();
                s.LastName1    = row.Cells[4].Value.ToString();
                s.Contact1     = row.Cells[5].Value.ToString();
                s.Email1       = row.Cells[6].Value.ToString();
                s.DateOfBirth1 = (DateTime)row.Cells[7].Value;
                //s.Gender = row.Cells[8].Value.ToString();
                int temp = Convert.ToInt32(row.Cells[8].Value);
                if (temp == 1)
                {
                    s.Gender = "Male";
                }
                else
                {
                    s.Gender = "Female";
                }
                s.RegisterationNo1 = row.Cells[9].Value.ToString();
                EditStudents es = new EditStudents();
                es.Show();
                this.Hide();
            }
            if (e.ColumnIndex == 1)
            {
                int          Id  = Convert.ToInt32(row.Cells[2].Value);
                DialogResult res = MessageBox.Show("Are you sure you want  to Delete " + Id, "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (res == DialogResult.OK)
                {
                    try
                    {
                        SqlConnection con = new SqlConnection(conStr);
                        con.Open();
                        if (con.State == ConnectionState.Open)
                        {
                            string     Delete_Group = "DELETE FROM GroupStudent WHERE StudentId = '" + Id + "'";
                            SqlCommand sql          = new SqlCommand(Delete_Group, con);
                            sql.ExecuteNonQuery();
                            string     Delete_Student = "DELETE FROM Student WHERE Id = '" + Id + "'";
                            SqlCommand connection     = new SqlCommand(Delete_Student, con);
                            connection.ExecuteNonQuery();
                            string     Delete = "DELETE FROM Person WHERE Id = '" + Id + "'";
                            SqlCommand cmd    = new SqlCommand(Delete, con);
                            cmd.ExecuteNonQuery();
                        }
                        //setGrid();
                        MessageBox.Show("Succesfully Deleted");
                        this.Hide();
                        ViewStudents vs = new ViewStudents();
                        vs.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error:" + ex);
                    }
                }
            }
        }