Exemple #1
0
        //TODO:: there is a problem accessing the values in the sql
        private void NewLec_Click(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);


                if (toolStripComboBox1.Text.Equals("") && !toolStripComboBox2.Text.Equals(""))

                {
                    str = toolStripComboBox2.Text;
                    SqlCommand cmd = new SqlCommand("UPDATE Classes_SM1 SET [" + Hour.Text + "] = 1 WHERE [date] = '" + str + "' AND [Class_Id] = '" + Class.Text + "'", sqlcon);
                    MessageBox.Show("Changed!");
                    Lecture.Visible = true;


                    SqlDataAdapter sda = new SqlDataAdapter();
                    sda.SelectCommand = cmd;
                    DataTable dbdataset = new DataTable();
                    sda.Fill(dbdataset);
                    BindingSource bsource = new BindingSource();

                    bsource.DataSource = dbdataset;
                    Lecture.DataSource = bsource;
                    sda.Update(dbdataset);
                }
                else if (toolStripComboBox2.Text.Equals("") && !toolStripComboBox1.Text.Equals(""))
                {
                    str = toolStripComboBox1.Text;
                    SqlCommand cmd = new SqlCommand("UPDATE Classes_SM2 SET [" + Hour.Text + "] = 1 WHERE [date] = '" + str + "' AND [Class_Id] = '" + Class.Text + "'", sqlcon);
                    MessageBox.Show("Changed!");
                    Lecture.Visible = true;


                    SqlDataAdapter sda = new SqlDataAdapter();
                    sda.SelectCommand = cmd;
                    DataTable dbdataset = new DataTable();
                    sda.Fill(dbdataset);
                    BindingSource bsource = new BindingSource();

                    bsource.DataSource = dbdataset;
                    Lecture.DataSource = bsource;
                    sda.Update(dbdataset);
                }
                else
                {
                    throw new ArgumentException("Error selecting dates,try again!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
                ExtraLecture form2 = new ExtraLecture();
                form2.Show();
            }
        }
Exemple #2
0
        private void Available_Classes_Button_Click(object sender, EventArgs e)
        {
            ExtraLecture lec = new ExtraLecture();

            lec.TopLevel        = false;
            lec.FormBorderStyle = FormBorderStyle.None;
            lec.WindowState     = FormWindowState.Maximized;
            panel5.Controls.Add(lec);
            panel5.Visible = true;

            lec.Show();
        }
Exemple #3
0
        private void Available_Classes_Click(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 (toolStripComboBox1.Text.Equals("") && !toolStripComboBox2.Text.Equals(""))

                {
                    str = toolStripComboBox2.Text;
                    //MessageBox.Show(str);
                    cmd             = new SqlCommand("select * from Classes_SM1 where date='" + str + "'", sqlcon);
                    Lecture.Visible = true;
                }
                else if (toolStripComboBox2.Text.Equals("") && !toolStripComboBox1.Text.Equals(""))
                {
                    str = toolStripComboBox1.Text;
                    //MessageBox.Show(str);
                    cmd             = new SqlCommand("select * from Classes_SM2 where date='" + str + "'", sqlcon);
                    Lecture.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();

                bsource.DataSource = dbdataset;
                Lecture.DataSource = bsource;
                sda.Update(dbdataset);

                Lecture.EnableHeadersVisualStyles = false;
                Lecture.GridColor = Utility.HeaderBackColor;
                Lecture.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                Lecture.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                Lecture.AutoResizeColumns();
                Lecture.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                Lecture.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;

                // this design loop for chart
                int i = 0;
                for (int j = 0; j <= 9; j++)
                {
                    // the def of this function located below
                    paintCells2(i);
                    i++;
                }

                foreach (DataGridViewRow row in Lecture.Rows)
                {
                    row.Height = 45;
                }
            }
            catch (Exception ex)
            {
                this.Close();
                MessageBox.Show(ex.Message);
                ExtraLecture form2 = new ExtraLecture();
                form2.Show();
            }
        }