示例#1
0
        public static List <TeacherAttendanceView> initTable()
        {
            List <TeacherAttendanceView> lstTAttendance = new List <TeacherAttendanceView>();
            livexEntities context = new livexEntities();
            string        today   = DateTime.Now.ToString("yyyy-MM-dd");
            DateTime      todayIS = Convert.ToDateTime(today);

            List <asistencia_maestros> lstAM = context.asistencia_maestros.Where(x => x.date >= todayIS).ToList();

            foreach (asistencia_maestros am in lstAM)
            {
                teacher t = context.teacher.FirstOrDefault(x => x.uid == am.UID);
                TeacherAttendanceView tav = new TeacherAttendanceView();
                DateTime shortdate        = Convert.ToDateTime(am.date.ToString());

                tav.UID  = am.UID;
                tav.Name = am.Name;
                tav.Date = shortdate.ToShortDateString();
                tav.Time = am.hour + ":" + am.min + ":" + am.sec;
                tav.id   = am.asistencia_maestrosID;
                if (t != null)
                {
                    tav.TeacherName = t.teacher_names + " " + t.teacher_lastname;
                }
                else
                {
                    tav.TeacherName = "";
                }

                lstTAttendance.Add(tav);
            }

            return(lstTAttendance);
        }
示例#2
0
        public static List <TeacherAttendanceView> FilterTable(DateTime from, DateTime until)
        {
            livexEntities context = new livexEntities();
            List <TeacherAttendanceView> lstTAttendance = new List <TeacherAttendanceView>();
            List <asistencia_maestros>   lstAm          = context.asistencia_maestros.Where(x => x.date >= from && x.date <= until).ToList();

            foreach (asistencia_maestros am in lstAm)
            {
                teacher t = context.teacher.FirstOrDefault(x => x.uid == am.UID);
                TeacherAttendanceView tav = new TeacherAttendanceView();
                DateTime shortdate        = Convert.ToDateTime(am.date.ToString());

                tav.UID  = am.UID;
                tav.Name = am.Name;
                tav.Date = shortdate.ToShortDateString();
                tav.Time = am.hour + ":" + am.min + ":" + am.sec;
                tav.id   = am.asistencia_maestrosID;
                if (t != null)
                {
                    tav.TeacherName = t.teacher_names + " " + t.teacher_lastname;
                }
                else
                {
                    tav.TeacherName = "";
                }

                lstTAttendance.Add(tav);
            }

            return(lstTAttendance);
        }
示例#3
0
        public static void DeleteRow(LIVEX.UserControls.AsistenciaMaestros am, object attRow)
        {
            TeacherAttendanceView row           = (TeacherAttendanceView)attRow;
            livexEntities         context       = new livexEntities();
            asistencia_maestros   teacherDelete = context.asistencia_maestros.FirstOrDefault(x => x.asistencia_maestrosID == row.id);

            if (teacherDelete != null)
            {
                context.asistencia_maestros.Remove(teacherDelete);
                int result = context.SaveChanges();
                if (result > 0)
                {
                    MessageBox.Show("El registro se borró exitosamente");
                }
                else
                {
                    MessageBox.Show("Error al borrar el registro");
                }
            }
        }
示例#4
0
        public static void EditRow(LIVEX.UserControls.AsistenciaMaestros am, object attRow)
        {
            TeacherAttendanceView atteToEdit = (TeacherAttendanceView)attRow;

            am.cmbUID.IsEnabled  = true;
            am.cmbName.IsEnabled = true;
            //am.cmbTeacherNames.IsEnabled = true;
            am.cmbHour.IsEnabled          = true;
            am.dpDate.IsEnabled           = true;
            am.btnCheckBlueEdit.IsEnabled = true;

            am.cmbUID.Text  = atteToEdit.UID;
            am.cmbName.Text = atteToEdit.Name;
            //am.cmbTeacherNames.Text = atteToEdit.TeacherName;
            am.dpDate.Text  = atteToEdit.Date;
            am.cmbHour.Text = atteToEdit.Time;

            am.btnCheckBlue.Visibility     = Visibility.Collapsed;
            am.btnCheckBlueEdit.Visibility = Visibility.Visible;
        }