private void All_Person_Button_Click_1(object sender, EventArgs e) { this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False"; this.sqlcon = new SqlConnection(connetionString); try { SqlCommand cmd = new SqlCommand("select Email, Password, Permission from person", sqlcon); StudentsReport.Visible = true; SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bsource = new BindingSource(); //Paint headers StudentsReport.EnableHeadersVisualStyles = false; StudentsReport.GridColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; StudentsReport.AutoResizeColumns(); StudentsReport.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; bsource.DataSource = dbdataset; StudentsReport.DataSource = bsource; sda.Update(dbdataset); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Load_table_Click_1(object sender, EventArgs e) { this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False"; this.sqlcon = new SqlConnection(connetionString); SqlCommand cmd = new SqlCommand("declare @results varchar(50) select @results = convert(varchar(50),Course_id) from Teaching_Stuff WHERE Teaching_Stuff.ID = '" + Utility.User.ID + "' SELECT Person.F_name,Person.L_name,Teaching_Stuff.ID,Teaching_Stuff.Course_id,Teaching_Stuff.office,Person.Email FROM Teaching_Stuff JOIN Person on Person.ID=Teaching_Stuff.ID WHERE Course_id = @results AND Teaching_Stuff.ID != '" + Utility.User.ID + "'", sqlcon); try { SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bsource = new BindingSource(); //Paint headers StudentsReport.EnableHeadersVisualStyles = false; StudentsReport.GridColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; StudentsReport.AutoResizeColumns(); StudentsReport.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; bsource.DataSource = dbdataset; StudentsReport.DataSource = bsource; sda.Update(dbdataset); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); Reports form2 = new Reports(); form2.StartPosition = FormStartPosition.Manual; form2.SetDesktopBounds(218, 46, 1520, 820); form2.ShowDialog(); } this.sqlcon.Close(); //this.Close(); }
private void Failing_Students_Click(object sender, EventArgs e) { this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False"; this.sqlcon = new SqlConnection(connetionString); try { SqlCommand cmd = new SqlCommand("select stud_Id, final_grade from Student_Courses where final_grade <= 56 and course_id='" + CourseID.Text + "'", sqlcon); StudentsReport.Visible = true; SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bsource = new BindingSource(); //Paint headers StudentsReport.EnableHeadersVisualStyles = false; StudentsReport.GridColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; StudentsReport.AutoResizeColumns(); StudentsReport.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; bsource.DataSource = dbdataset; StudentsReport.DataSource = bsource; sda.Update(dbdataset); } catch (SqlException ex) { //this.Close(); CourseID.Text = ""; MessageBox.Show("Error selecting course id, try again!\n" + ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click_1(object sender, EventArgs e) { this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False; MultipleActiveResultSets=true"; this.sqlcon = new SqlConnection(connetionString); StudentsReport.Visible = true; try { SqlCommand cmd = new SqlCommand("select Student_Courses.stud_Id,Student_Courses.course_id FROM Student_Courses LEFT join Teaching_Stuff on Student_Courses.course_id=Teaching_Stuff.Course_ID where ID='" + Utility.User.ID + "' and Type = 1", sqlcon); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bsource = new BindingSource(); //Paint headers StudentsReport.EnableHeadersVisualStyles = false; StudentsReport.GridColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; StudentsReport.AutoResizeColumns(); StudentsReport.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; bsource.DataSource = dbdataset; StudentsReport.DataSource = bsource; sda.Update(dbdataset); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); Reports form2 = new Reports(); form2.StartPosition = FormStartPosition.Manual; form2.SetDesktopBounds(218, 46, 1520, 820); form2.ShowDialog(); } }
private void button3_Click_1(object sender, EventArgs e) { string str = null; try { this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False"; this.sqlcon = new SqlConnection(connetionString); SqlCommand cmd = new SqlCommand("select * from Classes_SM1 where date='" + "1990-01-01" + "'", sqlcon); if (toolStripComboBox3.Text.Equals("") && !toolStripComboBox4.Text.Equals("")) { str = toolStripComboBox4.Text; //MessageBox.Show(str); cmd = new SqlCommand("select * from Classes_SM1 where date='" + str + "'", sqlcon); StudentsReport.Visible = true; } else if (toolStripComboBox4.Text.Equals("") && !toolStripComboBox3.Text.Equals("")) { str = toolStripComboBox3.Text; //MessageBox.Show(str); cmd = new SqlCommand("select * from Classes_SM2 where date='" + str + "'", sqlcon); StudentsReport.Visible = true; } else { throw new ArgumentException("Error selecting dates,try again!"); } SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bsource = new BindingSource(); //Paint headers StudentsReport.EnableHeadersVisualStyles = false; StudentsReport.GridColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor; StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; StudentsReport.AutoResizeColumns(); StudentsReport.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; bsource.DataSource = dbdataset; StudentsReport.DataSource = bsource; sda.Update(dbdataset); int i = 0; for (int j = 0; j <= 9; j++) { paintCells2(i); i++; } } catch (Exception ex) { MessageBox.Show(ex.Message); toolStripComboBox3.Text = ""; toolStripComboBox4.Text = ""; } Print.Visible = true; Application.DoEvents(); }