private void Go_back_Click(object sender, EventArgs e) { this.Hide(); AddGroupStudent f4 = new AddGroupStudent(); f4.ShowDialog(); this.Close(); }
private void Manage_Group_Click(object sender, EventArgs e) { this.Hide(); AddGroupStudent f1 = new AddGroupStudent(); f1.ShowDialog(); this.Close(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { con1.Open(); int UP_Row = int.Parse(e.RowIndex.ToString()); int UP_RowIndex = int.Parse(e.ColumnIndex.ToString()); ID1 = Convert.ToInt32(dataGridView1.Rows[UP_Row].Cells[0].Value.ToString()); int dd = (int)dataGridView1.CurrentRow.Cells[0].Value; if (UP_RowIndex == 8) { if (UP_RowIndex == 1) { if (UP_RowIndex == 0) { MessageBox.Show("Click Again"); } } if (UP_RowIndex != 0) { var askfirst1 = MessageBox.Show("Are you sure you want to add this student?", "Add", MessageBoxButtons.YesNo); if (askfirst1 == DialogResult.Yes) { AddGroupStudent s = new AddGroupStudent(dd); ID = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()); s.textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); s.Flagg2 = 0; s.ShowDialog(); con1.Close(); this.Close(); } else { con1.Close(); this.Hide(); FromStudents f2 = new FromStudents(); f2.ShowDialog(); } } } else { MessageBox.Show("Click on add button"); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { con.Open(); int URow = int.Parse(e.RowIndex.ToString()); int URowIndex = int.Parse(e.ColumnIndex.ToString()); ID = Convert.ToInt32(dataGridView1.Rows[URow].Cells[0].Value.ToString()); ID1 = Convert.ToInt32(dataGridView1.Rows[URow].Cells[2].Value.ToString()); int dd = (int)dataGridView1.CurrentRow.Cells[0].Value; if (URowIndex == 5) { int d1 = (int)dataGridView1.CurrentRow.Cells[0].Value; if (URowIndex == 0) { MessageBox.Show("Click again"); con.Close(); } if (URowIndex != 0) { var askfirst1 = MessageBox.Show("Are you sure you want to Update this?", "Update", MessageBoxButtons.YesNo); if (askfirst1 == DialogResult.Yes) { Flagg2 = ID; comboBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); con.Close(); } else { Flagg2 = 0; con.Close(); this.Hide(); AddGroupStudent f2 = new AddGroupStudent(); f2.ShowDialog(); } } } else { Flagg2 = 0; con.Close(); } }
private void Create_Click(object sender, EventArgs e) { bool b = Empty_St(); if (b == false) { bool std = StId_Exists(Convert.ToInt32(textBox2.Text), Convert.ToInt32(comboBox1.Text)); if (std == false) { if (Flagg2 == 0) { con.Open(); string StatusId = string.Format("SELECT Id From Lookup WHERE Value = '{0}'", "Active"); SqlCommand cmd3 = new SqlCommand(StatusId, con); int s = (Int32)cmd3.ExecuteScalar(); DateTime time = DateTime.Now; cmd2 = new SqlCommand("insert into GroupStudent(GroupId, StudentId, Status, AssignmentDate) values ('" + comboBox1.Text + "','" + textBox2.Text + "','" + s + "' , @time)", con); cmd2.Parameters.AddWithValue("@time", time); int gI = Convert.ToInt32(comboBox1.Text); cmd2.ExecuteNonQuery(); MessageBox.Show("Inserted Successfully"); con.Close(); this.Hide(); AddGroupStudent f4 = new AddGroupStudent(); f4.ShowDialog(); this.Close(); } if (Flagg2 > 0) { con.Open(); string StatusId = string.Format("SELECT Id From Lookup WHERE Value = '{0}'", "Active"); SqlCommand cmd3 = new SqlCommand(StatusId, con); int s = (Int32)cmd3.ExecuteScalar(); DateTime time = DateTime.Now; cmd1 = new SqlCommand("UPDATE [GroupStudent] set GroupStudent.GroupId=@GroupId, GroupStudent.StudentId=@StudentId WHERE GroupId = @dd AND StudentId = @d1 ", con); cmd1.Parameters.AddWithValue("@dd", Flagg2); cmd1.Parameters.AddWithValue("@d1", ID1); cmd1.Parameters.AddWithValue("@GroupId", Convert.ToInt32(comboBox1.Text)); cmd1.Parameters.AddWithValue("@StudentId", Convert.ToInt32(textBox2.Text)); cmd1.ExecuteNonQuery(); string store_value = comboBox1.Text; string StatusNId = string.Format("SELECT Id From Lookup WHERE Value = '{0}'", "InActive"); SqlCommand cmdN3 = new SqlCommand(StatusNId, con); int sN = (Int32)cmdN3.ExecuteScalar(); cmd2 = new SqlCommand("UPDATE [GroupStudent] set GroupStudent.Status = @Status WHERE GroupId != @d2 AND StudentId = @d3", con); cmd2.Parameters.AddWithValue("@d3", ID1); cmd2.Parameters.AddWithValue("@d2", store_value); cmd2.Parameters.AddWithValue("@Status", 4); cmd2.ExecuteNonQuery(); MessageBox.Show("Updated Successfully"); con.Close(); this.Hide(); AddGroupStudent f4 = new AddGroupStudent(); f4.ShowDialog(); this.Close(); } } else { MessageBox.Show("This students exists in this group already"); } } else { MessageBox.Show("Select Student From Add Student"); } }