Пример #1
0
        private void btn_evaluate_Click(object sender, EventArgs e)
        {
            try
            {
                if (val() == 0)
                {
                    GroupStudent std = new GroupStudent();


                    int key = Convert.ToInt32(txt_groupid.Text);

                    SqlConnection con = new SqlConnection(conStr);
                    con.Open();
                    if (con.State == ConnectionState.Open)
                    {
                        string p = "UPDATE [ProjectA].[dbo].[GroupStudent] SET Status= (SELECT Id FROM [ProjectA].[dbo].[Lookup] WHERE [ProjectA].[dbo].[Lookup].Value = '" + (com_sta.Text) + "'),AssignmentDate =('" + Convert.ToDateTime(dtp_assign.Value) + "')WHERE GroupId ='" + Convert.ToInt32(txt_groupid.Text) + "';";

                        SqlCommand cmd = new SqlCommand(p, con);
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Congrats! Data Update Successfully");

                        con.Close();
                    }
                    // Student std = new Student();
                    //this.Hide();
                    //    std.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            GroupStudent std = new GroupStudent();

            this.Hide();
            std.Show();
        }
Пример #3
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = new SqlConnection(conStr);
         con.Open();
         if (con.State == ConnectionState.Open)
         {
             for (int i = 0; i < dataGridView1.Rows.Count; i++)
             {
                 if ((dataGridView1.Rows[i].Cells[2].Value) != null)
                 {
                     if ((Boolean)dataGridView1.Rows[i].Cells[2].Value == true)
                     {
                         String     query = "INSERT INTO GroupStudent (GroupId,StudentId,Status,AssignmentDate)VALUES((select MAX(Id) FROM [Group]),('" + dataGridView1.Rows[i].Cells[0].Value + "'),(Select Id from Lookup Where Lookup.Value = '" + com_sta.Text + "'),('" + Convert.ToDateTime(dtp_assign.Text) + "'));";
                         SqlCommand cmd   = new SqlCommand(query, con);
                         cmd.ExecuteNonQuery();
                         MessageBox.Show("Congrats! Data Recorded");
                     }
                 }
             }
         }
         GroupStudent std = new GroupStudent();
         this.Hide();
         std.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection(conStr);
                con.Open();
                if (e.RowIndex > -1)
                {
                    if (e.ColumnIndex == 0)
                    {
                        EditGroup edit = new EditGroup();
                        edit.txt_groupid.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();

                        edit.com_sta.Text    = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
                        edit.dtp_assign.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();

                        edit.ShowDialog();
                    }
                    else if (e.ColumnIndex == 1)
                    {
                        DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                        string          m   = "DELETE FROM [ProjectA].[dbo].[GroupEvaluation] where GroupId = '" + row.Cells[2].Value + "';";

                        string t = "DELETE FROM GroupStudent where GroupId = '" + row.Cells[2].Value + "';";
                        string h = "DELETE FROM [ProjectA].[dbo].[Group] where Id = '" + row.Cells[2].Value + "';";

                        SqlCommand cmtt = new SqlCommand(m, con);
                        cmtt.ExecuteNonQuery();
                        SqlCommand cmt = new SqlCommand(t, con);
                        cmt.ExecuteNonQuery();
                        SqlCommand cmttt = new SqlCommand(h, con);
                        cmttt.ExecuteNonQuery();

                        MessageBox.Show("Congrats! Record Recorded");
                        SqlDataAdapter sql     = new SqlDataAdapter("SELECT * from GroupStudent;", con);
                        DataTable      datatab = new DataTable();
                        sql.Fill(datatab);
                        dataGridView1.DataSource = datatab;
                        con.Close();
                    }
                    GroupStudent std = new GroupStudent();
                    this.Hide();
                    std.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
 public EditGroup(GroupStudent std, long id)
 {
     InitializeComponent();
     this.aadv   = std;
     this.advnum = id;
 }