Exemplo n.º 1
0
        private void button8_Click(object sender, EventArgs e)
        {
            S_Attendance_GV h = new S_Attendance_GV();

            this.Hide();
            h.Show();
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DESKTOP-OQV6IBM;Initial Catalog=ProjectB;Integrated Security=True");

            conn.Open();
            string     query         = "Insert into ClassAttendance (AttendanceDate) OUTPUT INSERTED.Id values('" + DateTime.Now + "')";
            SqlCommand command       = new SqlCommand(query, conn);
            int        attendence_id = (int)command.ExecuteScalar();

            if (comboBox1.Text != "" && comboBox2.Text != "")
            {
                if (button3.Text == "AddAttendance")
                {
                    int status = 1;
                    if (comboBox2.Text == "Absent")
                    {
                        status = 2;
                    }
                    else if (comboBox2.Text == "Late")
                    {
                        status = 4;
                    }
                    else if (comboBox2.Text == "Leave")
                    {
                        status = 3;
                    }
                    string     STDID = (comboBox1.SelectedItem as ComboboxItem).Value.ToString();
                    string     Query = "insert into StudentAttendance(StudentId, AttendanceStatus, AttendanceId) values('" + STDID + "','" + status + "','" + attendence_id + "')";
                    SqlCommand cmd   = new SqlCommand(Query, conn);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Attendance Successfully Added");
                    S_Attendance_GV f = new S_Attendance_GV();
                    f.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Please fill all the fields ");
            }
        }