예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CLO s = new CLO();

            this.Hide();
            s.Show();
        }
예제 #2
0
 private void btn_submit_Click(object sender, EventArgs e)
 {
     if (txt_name.Text != "")
     {
         SqlConnection conn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True");
         if (update == 1)
         {
             conn.Open();
             string     query2         = "Update Clo set Name = '" + txt_name.Text + " ', DateCreated = '" + this.date + "' , DateUpdated = '" + DateTime.Today + "' where Id = '" + this.id + "'";
             SqlCommand update_command = new SqlCommand(query2, conn);
             int        j = update_command.ExecuteNonQuery();
             if (j != 0)
             {
                 MessageBox.Show("CLO Record Updated Successfully");
                 CLO ff = new CLO();
                 ff.Close();
                 CLO_details ss = new CLO_details();
                 ss.Show();
                 this.Hide();
             }
             conn.Close();
         }
         else
         {
             conn.Open();
             string     query   = "Insert into Clo (Name, DateCreated, DateUpdated) values('" + txt_name.Text + "', '" + DateTime.Today + "', '" + DateTime.Now + "')";
             SqlCommand command = new SqlCommand(query, conn);
             int        i       = command.ExecuteNonQuery();
             if (i != 0)
             {
                 MessageBox.Show("CLO Record Inserted Successfully");
                 CLO f = new CLO();
                 f.Close();
                 CLO_details s = new CLO_details();
                 this.Hide();
                 s.Show();
             }
             conn.Close();
         }
     }
     else
     {
         error_msg.Show();
     }
 }
예제 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True");

            conn.Open();
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && e.ColumnIndex == 0)
            {
                int             row_index   = e.RowIndex;
                DataGridViewRow selectedRow = dataGridView1.Rows[row_index];
                string          a           = Convert.ToString(selectedRow.Cells["Id"].Value);
                string[]        values;
                values = new string[7];
                using (SqlConnection con = new SqlConnection("Data Source = DESKTOP - M9PBVHQ; Initial Catalog = ProjectB; Integrated Security = True"))
                {
                    string     oString = "Select * from Clo where Id='" + a + "'";
                    SqlCommand oCmd    = new SqlCommand(oString, conn);
                    using (SqlDataReader oReader = oCmd.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            values[0] = oReader["Id"].ToString();
                            values[1] = oReader["Name"].ToString();
                            values[2] = oReader["DateCreated"].ToString();
                            values[3] = oReader["DateUpdated"].ToString();
                            break;
                        }

                        conn.Close();
                    }
                }
                CLO s = new CLO(values[0], values[1], values[2], values[3]);
                this.Hide();
                s.Show();
            }
            else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                     e.RowIndex >= 0 && e.ColumnIndex == 1)
            {
                int             row_index   = e.RowIndex;
                DataGridViewRow selectedRow = dataGridView1.Rows[row_index];
                string          a           = Convert.ToString(selectedRow.Cells["Id"].Value);
                string          q2          = "DELETE FROM Rubric where CloId = '" + a + "'";
                string          query       = "DELETE FROM Clo WHERE Id = '" + a + "'";
                SqlCommand      command     = new SqlCommand(query, conn);
                SqlCommand      s           = new SqlCommand(q2, conn);
                s.ExecuteNonQuery();
                MessageBox.Show("Rubrics deleted of this CLO");
                command.ExecuteNonQuery();
                MessageBox.Show("Row Deleted");
                conn.Close();

                SqlConnection cnn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True");
                conn.Open();
                string query1 = "select * from Clo";
                using (SqlDataAdapter am = new SqlDataAdapter(query1, cnn))
                {
                    DataTable t = new DataTable();
                    am.Fill(t);
                    dataGridView1.DataSource = t;
                }
            }
            else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                     e.RowIndex >= 0 && e.ColumnIndex == 2)
            {
                int             row_index   = e.RowIndex;
                DataGridViewRow selectedRow = dataGridView1.Rows[row_index];
                string          a           = Convert.ToString(selectedRow.Cells["Id"].Value);
                Rubrics         r           = new Rubrics(a);
                this.Hide();
                Rubric_details rr = new Rubric_details(a);
                rr.Show();
                CLO_details c = new CLO_details();
                c.Hide();
            }
        }