コード例 #1
0
        public static void EditSelected(LIVEX.UserControls.AsistenciaMaestros am)
        {
            string              uid        = am.cmbUID.Text;
            livexEntities       context    = new livexEntities();
            asistencia_maestros teacherAtt = context.asistencia_maestros.FirstOrDefault(x => x.UID == uid);
            string              hour       = am.cmbHour.Text;
            var time = hour.Split(':');

            teacherAtt.Name = am.cmbName.Text;
            teacherAtt.hour = Int32.Parse(time[0]);
            teacherAtt.min  = Int32.Parse(time[1]);
            if (time.Count() > 2)
            {
                teacherAtt.sec = Int32.Parse(time[2]);
            }
            else
            {
                teacherAtt.sec = 0;
            }

            teacherAtt.date = Convert.ToDateTime(am.dpDate.Text);

            int result = context.SaveChanges();

            if (result >= 0)
            {
                MessageBox.Show("El registro se guardó exitosamente");
            }
            else
            {
                MessageBox.Show("El registro NO se guardó");
            }
        }
コード例 #2
0
        public static void refreshCombos(LIVEX.UserControls.AsistenciaMaestros am)
        {
            livexEntities       context = new livexEntities();
            asistencia_maestros a       = new asistencia_maestros();
            teacher             t       = new teacher();

            if (am.cmbUID.SelectedItem != null || am.cmbUID.Text != "")
            {
                string uid = am.cmbUID.SelectedItem.ToString();
                a = context.asistencia_maestros.FirstOrDefault(x => x.UID == uid);
                if (a != null)
                {
                    am.cmbName.Text          = a.Name;
                    am.cmbName.SelectedValue = a.Name;

                    //teacher teacherFound = context.teacher.FirstOrDefault(x => x.uid == a.UID);

                    //if (teacherFound != null)
                    //{
                    //    am.cmbTeacherNames.Text = teacherFound.teacher_names + " " + teacherFound.teacher_lastname;
                    //    am.cmbTeacherNames.SelectedValue = teacherFound.teacher_names + " " + teacherFound.teacher_lastname;
                    //}
                }
            }
        }
コード例 #3
0
        public static int uploadTimerFile(string path, string filename)
        {
            try
            {
                livexEntities context = new livexEntities();
                int           result  = 0;

                using (var reader = new StreamReader(path))//(@"C:\Users\Tania\Documents\NewCo\Proyectos\LIVEX\Docs\LogData\HisGLog_0001_20171201.csv"))
                {
                    int isduplicated = context.asistencia_maestros.Count(x => x.filename == filename);

                    if (isduplicated > 0)
                    {
                        MessageBox.Show("El archivo ya ha sido cargado");
                        return(0);
                    }
                    int i = 0;
                    while (!reader.EndOfStream)
                    {
                        asistencia_maestros am = new asistencia_maestros();

                        var line   = reader.ReadLine();
                        var values = line.Split('\t');

                        if (i > 0)
                        {
                            am.No       = Int32.Parse(values[0]);
                            am.DN       = Int32.Parse(values[1]);
                            am.UID      = values[2];
                            am.Name     = values[3];
                            am.Status   = values[4];
                            am.Action   = Int32.Parse(values[5]);
                            am.APB      = Int32.Parse(values[6]);
                            am.JobCode  = Int32.Parse(values[7]);
                            am.date     = Convert.ToDateTime(Convert.ToDateTime(values[8]).ToShortDateString());
                            am.hour     = Convert.ToDateTime(values[8]).Hour;
                            am.min      = Convert.ToDateTime(values[8]).Minute;
                            am.sec      = Convert.ToDateTime(values[8]).Second;
                            am.filename = filename;

                            context.asistencia_maestros.Add(am);
                        }
                        i++;
                    }
                    result = context.SaveChanges();
                }
                if (result > 0)
                {
                    MessageBox.Show("Archivo cargado exitosamente");
                    return(1);
                }
                return(0);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(0);
            }
        }
コード例 #4
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");
                }
            }
        }
コード例 #5
0
        public static void AddAttendaceRow(LIVEX.UserControls.AsistenciaMaestros am)
        {
            livexEntities       context = new livexEntities();
            asistencia_maestros newAtt  = new asistencia_maestros();
            DateTime            date    = Convert.ToDateTime(am.dpDate.Text);
            string hour = am.cmbHour.Text;
            var    time = hour.Split(':');

            newAtt.DN       = 1;
            newAtt.UID      = am.cmbUID.Text;
            newAtt.Name     = am.cmbName.Text;
            newAtt.Status   = "0";
            newAtt.Action   = 3;
            newAtt.APB      = 0;
            newAtt.JobCode  = 0;
            newAtt.date     = Convert.ToDateTime(date.ToShortDateString());
            newAtt.No       = 0;
            newAtt.filename = "LIVEX_Sys";
            newAtt.hour     = Int32.Parse(time[0]);
            newAtt.min      = Int32.Parse(time[1]);
            if (time.Count() > 2)
            {
                newAtt.sec = Int32.Parse(time[2]);
            }
            else
            {
                newAtt.sec = 0;
            }

            context.asistencia_maestros.Add(newAtt);
            int result = context.SaveChanges();

            if (result > 0)
            {
                MessageBox.Show("El registro se guardó exitosamente");
            }
            else
            {
                MessageBox.Show("El registro NO se guardó");
            }
        }