Exemplo n.º 1
0
        private void btnDiscard_Click(object sender, EventArgs e)
        {
            frmAttendenceDetail attendDetail = new frmAttendenceDetail();

            attendDetail.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            frmAttendenceDetail ad = new frmAttendenceDetail();

            ad.Show();
            this.Hide();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Save Data into Database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveData();
            MessageBox.Show("Data has been updated");
            frmAttendenceDetail ad = new frmAttendenceDetail();

            ad.Show();
            this.Hide();
        }
Exemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            String        conURL1 = "Data Source = DESKTOP-RPO4Q5R\\PARVEEN; Initial Catalog = ProjectB ; User ID = mohsin; Password = mohsin123; MultipleActiveResultSets = True";
            SqlConnection conn1   = new SqlConnection(conURL1);

            conn1.Open();

            for (int i = 0; i < (dgvAttendence.Rows.Count - 1); i++)
            {
                string att = (string)dgvAttendence.Rows[i].Cells[2].Value;
                MyClass.regno = (int)dgvAttendence.Rows[i].Cells[0].Value;
                int j = 0;
                if (att == "Present")
                {
                    j = 1;
                }
                else if (att == "Absent")
                {
                    j = 2;
                }
                else if (att == "Leave")
                {
                    j = 3;
                }
                else
                {
                    j = 4;
                }

                /// Attendence Id
                String cmd1 = "SELECT TOP 1 Id FROM ClassAttendance ORDER BY Id DESC";
                //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn);
                SqlCommand    cmd = new SqlCommand(cmd1, conn1);
                SqlDataReader myReader;
                myReader = cmd.ExecuteReader();
                if (!myReader.Read())
                {
                    MessageBox.Show("NewValue is not found");
                    return;
                }


                try
                {
                    MyClass.attd = myReader.GetValue(0).ToString();
                    cmd.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                /// Student Id
                String cmd2 = "Select Student.Id as StudentId From Student  Where Student.Id =" + MyClass.regno;
                //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn);
                SqlCommand    cmd02 = new SqlCommand(cmd2, conn1);
                SqlDataReader myReader1;
                myReader1 = cmd02.ExecuteReader();
                if (!myReader1.Read())
                {
                    MessageBox.Show("NewValue is not found");
                    return;
                }


                try
                {
                    MyClass.std = myReader1.GetValue(0).ToString();
                    cmd02.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }



                String     cmd3  = "SET IDENTITY_INSERT StudentAttendance ON insert into StudentAttendance( AttendanceId ,  StudentId , AttendanceStatus) Values ('" + Convert.ToInt32(MyClass.attd) + "' , '" + Convert.ToInt32(MyClass.std) + "' ,'" + j + "' ) SET IDENTITY_INSERT StudentAttendance OFF";
                SqlCommand cmd03 = new SqlCommand(cmd3, conn1);
                int        n     = cmd03.ExecuteNonQuery();



                /*  String cmd2 = "insert into StudentAttendance StudentId Select Student ('" + Convert.ToDateTime(dateTimePicker1.Text) + "')";
                 * SqlCommand cmd02 = new SqlCommand(cmd2, conn1);
                 * cmd02.ExecuteNonQuery();*/
            }
            MessageBox.Show("Data has been Saved");
            conn1.Close();

            frmAttendenceDetail attenDetail = new frmAttendenceDetail();

            attenDetail.Show();
            this.Hide();
        }