public static int Consultar(PAModel[] models, SessionDB sesion)
        {
            EliminaDetallesConflicto(sesion.pkUser.ToString());

            int           agregados = 0;
            List <string> listIDSIU = new List <string>();

            if (models.Length > 0)
            {
                bool TMP = true;
                foreach (PAModel model in models)
                {
                    if (model.IDSIU == "00260600")
                    {
                        model.IDSIU = model.IDSIU;
                    }
                    model.sesion = sesion;

                    IPersona persona = model as IPersona;
                    persona.findPersona();
                    model.PERSONA_REGISTRADA = model.PK_PERSONA != -1 ? "1" : "0";

                    if (listIDSIU.Contains(model.IDSIU) || persona.addPersona(TMP))
                    {
                        IPA pa = model as IPA;
                        pa.findPA();
                        model.PA_REGISTRADA = model.PK_PA != -1 ? "1" : "0";

                        if (pa.addPA(TMP))
                        {
                            agregados++;
                            listIDSIU.Add(model.IDSIU);
                            continue;
                        }
                        else
                        {
                            InsertaDetallesConflicto("PA_TMP", model.IDSIU, model.NOMBRES + " " + model.APELLIDOS, model.xQuery, model.xErrMsg, sesion.pkUser.ToString(), sesion.nickName);
                            Console.WriteLine("Este IDSIU es el del problema: " + model.IDSIU + " (revisar)");
                        }
                    }
                    else
                    {
                        InsertaDetallesConflicto("PERSONAS_TMP", model.IDSIU, model.NOMBRES + " " + model.APELLIDOS, model.xQuery, model.xErrMsg, sesion.pkUser.ToString(), sesion.nickName);
                        Console.WriteLine("Este IDSIU es el del problema: " + model.IDSIU + " (revisar)");
                    }
                }
            }
            return(agregados);
        }
Beispiel #2
0
        public static int Consultar(ActualizacionPAModel[] models, SessionDB sesion)
        {
            int           agregados = 0;
            List <string> listIDSIU = new List <string>();

            if (models.Length > 0)
            {
                bool TMP = true;
                foreach (ActualizacionPAModel model in models)
                {
                    if (model.IDSIU == "00260600")
                    {
                        model.IDSIU = model.IDSIU;
                    }
                    model.sesion = sesion;

                    IPersona persona = model as IPersona;
                    persona.findPersona();
                    model.PERSONA_REGISTRADA = model.PK_PERSONA != -1 ? "1" : "0";

                    if (listIDSIU.Contains(model.IDSIU) || persona.addPersona(TMP))
                    {
                        IPA pa = model as IPA;
                        pa.findPA();
                        model.PA_REGISTRADA = model.PK_PA != -1 ? "1" : "0";

                        if (pa.addPA(TMP))
                        {
                            agregados++;
                            listIDSIU.Add(model.IDSIU);
                            continue;
                        }
                    }
                    break;
                }
            }
            return(agregados);
        }
Beispiel #3
0
        public bool Generar(string data, out int totalPA, out int registradosPA, out int registradosPersonas)
        {
            string[] arrChecked = data.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            totalPA             = arrChecked.Length;
            registradosPA       = 0;
            registradosPersonas = 0;
            bool all_result = true;

            bool TMP       = true;
            int  NOT_FOUND = -1;

            List <string> listIDSIU = new List <string>();

            foreach (string itemChecked in arrChecked)
            {
                long.TryParse(itemChecked, out PK_PA);

                bool ok;
                bool personaActualizada;

                IPersona persona = this as IPersona;
                IPA      PA      = this as IPA;

                if (PA.editPA(TMP))
                {
                    personaActualizada = listIDSIU.Contains(IDSIU);

                    if (personaActualizada || persona.editPersona(TMP))
                    {
                        if (personaActualizada)
                        {
                            ok = true;
                        }
                        else
                        {
                            if (persona.findPersona() == NOT_FOUND)
                            {
                                ok = persona.addPersona();
                            }
                            else
                            {
                                ok = persona.savePersona();
                            }
                            registradosPersonas++;
                        }

                        if (ok)
                        {
                            if (PA.findPA() == NOT_FOUND)
                            {
                                ok = PA.addPA();
                            }
                            else
                            {
                                ok = PA.savePA();
                            }

                            if (ok)
                            {
                                markPersona();
                                markPA();
                                registradosPA++;

                                if (personaActualizada == false)
                                {
                                    listIDSIU.Add(IDSIU);
                                }
                                continue;
                            }
                        }
                    }
                }
                all_result = false;
                break;
            }

            return(all_result);
        }