Example #1
0
        public String crear(ConsultoraBE consultoraBE)
        {
            String resultado = "success";
            SqlCommand cmd = new SqlCommand();
            SqlConnection cn = new SqlConnection(connection.getConnectionString());

            try
            {
                cn.Open();
                cmd = new SqlCommand("usp_bel_consultora_crear", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Transaction = cn.BeginTransaction();

                cmd.Parameters.Add("@paisID", SqlDbType.Int).Value = consultoraBE.paisID;
                cmd.Parameters.Add("@campanhaInscripcion", SqlDbType.VarChar, 6).Value = (consultoraBE.campanhaInscripcion != null) ? consultoraBE.campanhaInscripcion : "";
                cmd.Parameters.Add("@campanhaPrimeraCompra", SqlDbType.VarChar, 6).Value = (consultoraBE.campanhaPrico != null) ? consultoraBE.campanhaPrico : "";
                cmd.Parameters.Add("@regionCodigo", SqlDbType.VarChar, 2).Value = (consultoraBE.regionCodigo != null) ? consultoraBE.regionCodigo : "";
                cmd.Parameters.Add("@zonaCodigo", SqlDbType.VarChar, 6).Value = (consultoraBE.zonaCodigo != null) ? consultoraBE.zonaCodigo : "";
                cmd.Parameters.Add("@seccionCodigo", SqlDbType.VarChar, 2).Value = (consultoraBE.seccionCodigo != null) ? consultoraBE.seccionCodigo : "";
                cmd.Parameters.Add("@territorioCodigo", SqlDbType.VarChar, 2).Value = (consultoraBE.territorioCodigo != null) ? consultoraBE.territorioCodigo : "";
                cmd.Parameters.Add("@companhiaCodigo", SqlDbType.VarChar, 2).Value = (consultoraBE.companiaCodigo != null) ? consultoraBE.companiaCodigo : "";
                cmd.Parameters.Add("@pasarped", SqlDbType.VarChar, 2).Value = (consultoraBE.pasarped != null) ? consultoraBE.pasarped : "";
                cmd.Parameters.Add("@motivoRetiro", SqlDbType.VarChar, 2).Value = (consultoraBE.motivoRetiro != null) ? consultoraBE.motivoRetiro : "";
                cmd.Parameters.Add("@codigo", SqlDbType.VarChar, 15).Value = (consultoraBE.codigo != null) ? consultoraBE.codigo : "";
                cmd.Parameters.Add("@apellidoPaterno", SqlDbType.VarChar, 30).Value = (consultoraBE.apellidoPaterno != null) ? consultoraBE.apellidoPaterno : "";
                cmd.Parameters.Add("@apellidoMaterno", SqlDbType.VarChar, 30).Value = (consultoraBE.apellidoMaterno != null) ? consultoraBE.apellidoMaterno : "";
                cmd.Parameters.Add("@nombres", SqlDbType.VarChar, 30).Value = (consultoraBE.nombres != null) ? consultoraBE.nombres : "";
                cmd.Parameters.Add("@numeroDocumento", SqlDbType.VarChar, 18).Value = (consultoraBE.numeroDocumento != null) ? consultoraBE.numeroDocumento : "";
                cmd.Parameters.Add("@telefono1", SqlDbType.VarChar, 15).Value = (consultoraBE.telefono1 != null) ? consultoraBE.telefono1 : "";
                cmd.Parameters.Add("@telefono2", SqlDbType.VarChar, 15).Value = (consultoraBE.telefono2 != null) ? consultoraBE.telefono2 : "";
                cmd.Parameters.Add("@email", SqlDbType.VarChar, 40).Value = (consultoraBE.email != null) ? consultoraBE.email : "";
                cmd.Parameters.Add("@estadoActivo", SqlDbType.Bit).Value = consultoraBE.estadoActivo;

                cmd.ExecuteNonQuery();
                cmd.Transaction.Commit();
            }
            catch (Exception ex)
            {
                resultado = ex.Message;
                cmd.Transaction.Rollback();
            }
            finally
            {
                cn.Close();
                cmd.Dispose();
                cn.Dispose();
            }

            return resultado;
        }
 public ConsultoraIncorporacionGerenteZonaBE()
 {
     _consultora = new ConsultoraBE();
     _incorporacion = new IncorporacionBE();
     _gerenteZona = new GerenteZonaBE();
 }
    private String procesaUpload(FileUpload fileUpload, int tipoProceso)
    {
        int fileLen = fileUpload.PostedFile.ContentLength;
        System.Text.Encoding encoding = System.Text.Encoding.ASCII;
        String strContenido = "";
        String[] strListado;
        String result = "";
        int cuenta = 0;
        try
        {
            byte[] input = fileUpload.FileBytes;
            strContenido = Convert.ToString(encoding.GetString(input));
            strListado = Regex.Split(strContenido, "\r\n");

            // Consultora
            if (tipoProceso == MakipurayConstant.PROCESS_TYPE_CONSULTANT)
            {
                cuenta = 0;
                foreach (String lista in strListado)
                {
                    cuenta++;
                    try
                    {
                        ConsultoraBE c = new ConsultoraBE();
                        String[] strValues = lista.Split(',');

                        c.paisID = StringFormatter.convertCountryIsoToNumber(StringFormatter.removeFirstAndLastCharacter(strValues[0]));
                        c.companiaCodigo = (isAnEmptyChain(strValues[1])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[1]); ;
                        c.codigo = (isAnEmptyChain(strValues[2])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[2]);
                        c.numeroDocumento = (isAnEmptyChain(strValues[3])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[3]);

                        c.apellidoPaterno = (isAnEmptyChain(strValues[4])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[4]);
                        c.apellidoMaterno = (isAnEmptyChain(strValues[5])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[5]);
                        c.nombres = (isAnEmptyChain(strValues[6])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[6]);

                        c.telefono1 = (isAnEmptyChain(strValues[7])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[7]);
                        c.telefono2 = (isAnEmptyChain(strValues[8])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[8]);
                        c.email = (isAnEmptyChain(strValues[9])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[9]);
                        c.pasarped = (isAnEmptyChain(strValues[10])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[10]);
                        c.motivoRetiro = (isAnEmptyChain(strValues[11])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[11]);
                        c.regionCodigo = (isAnEmptyChain(strValues[12])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[12]);
                        c.zonaCodigo = (isAnEmptyChain(strValues[13])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[13]);
                        c.seccionCodigo = (isAnEmptyChain(strValues[14])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[14]);
                        c.territorioCodigo = (isAnEmptyChain(strValues[15])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[15]);
                        c.campanhaInscripcion = (isAnEmptyChain(strValues[16])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[16]);
                        c.campanhaPrico = (isAnEmptyChain(strValues[17])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[17]);
                        c.estadoActivo = (isAnEmptyChain(strValues[18])) ? false : Convert.ToBoolean(Convert.ToInt32(StringFormatter.removeFirstAndLastCharacter(strValues[18])));

                        String message = consultoraBL.crear(c);
                        if (message != "success")
                        {
                            result = result + "<br>" + "Regitro no procesado(" + cuenta.ToString() + ") : " + message;
                        }
                    }
                    catch (Exception ex) {
                        result = result + "<br>" + "Regitro no procesado(" + cuenta.ToString() + ")";
                        Log.lanzarError(ex);
                    }
                }
            }

            // Gerente de Zona
            if (tipoProceso == MakipurayConstant.PROCESS_TYPE_ZONE_MANAGER)
            {
                cuenta = 1;
                foreach (String c in strListado)
                {
                    cuenta++;
                    try
                    {
                        GerenteZonaBE gz = new GerenteZonaBE();
                        String[] strValues = c.Split(',');

                        gz.paisID = StringFormatter.convertCountryIsoToNumber(StringFormatter.removeFirstAndLastCharacter(strValues[0]));
                        gz.companiaCodigo = (isAnEmptyChain(strValues[1])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[1]);
                        gz.consultoraCodigo = (isAnEmptyChain(strValues[2])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[2]);
                        gz.numeroDocumento = (isAnEmptyChain(strValues[3])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[3]);
                        gz.nombres = (isAnEmptyChain(strValues[4])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[4]);
                        gz.regionCodigo = (isAnEmptyChain(strValues[5])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[5]);
                        gz.zonaCodigo = (isAnEmptyChain(strValues[6])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[6]);
                        gz.seccionCodigo = (isAnEmptyChain(strValues[7])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[7]);
                        gz.territorioCodigo = (isAnEmptyChain(strValues[8])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[8]);
                        gz.telefono = (isAnEmptyChain(strValues[9])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[9]);
                        gz.email = (isAnEmptyChain(strValues[10])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[10]);
                        gz.pasarped = (isAnEmptyChain(strValues[11])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[11]);
                        gz.motivoRetiro = (isAnEmptyChain(strValues[12])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[12]);
                        gz.estadoActivo = (isAnEmptyChain(strValues[13])) ? false : Convert.ToBoolean(Convert.ToInt32(StringFormatter.removeFirstAndLastCharacter(strValues[13])));

                        String message = gerenteZonaBL.crear(gz);
                        if (message != "success")
                        {
                            result = result + "<br>" + "Regitro no procesado(" + cuenta.ToString() + ") : " + message;
                        }
                    }
                    catch (Exception ex)
                    {
                        result = result + "<br>" + "Regitro no procesado(" + cuenta.ToString() + ")";
                        Log.lanzarError(ex);
                    }

                }
            }

            // Campaña
            if (tipoProceso == MakipurayConstant.PROCESS_TYPE_CAMPAIGN)
            {
                foreach (String lista in strListado)
                {

                }
            }

            // Campaña de Facturación
            if (tipoProceso == MakipurayConstant.PROCESS_TYPE_BILLING_SCHEDULE)
            {
                foreach (String lista in strListado)
                {
                    FacturacionBE f = new FacturacionBE();
                    String[] strValues = lista.Split(',');

                    f.PaisID = StringFormatter.convertCountryIsoToNumber(StringFormatter.removeFirstAndLastCharacter(strValues[0]));
                    f.CompanhiaCodigo = (isAnEmptyChain(strValues[1])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[1]);
                    f.Campanha = (isAnEmptyChain(strValues[2])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[2]);
                    f.RegionCodigo = (isAnEmptyChain(strValues[3])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[3]);
                    f.ZonaCodigo = (isAnEmptyChain(strValues[4])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[4]);
                    f.Fecha = (isAnEmptyChain(strValues[5])) ? null : DateFormatter.getStringDate(StringFormatter.removeFirstAndLastCharacter(strValues[5]));
                    f.EstadoActivo = true;

                    String message = facturacionBL.crear(f);
                    if (message != "success")
                    {
                        result = result + "<br> Campaña de facturación>: " + message;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            String message = ex.Message;
            result = result + "<br> Excepción general ( fila " + Convert.ToString(cuenta) + " del archivo) : " + message ;
            //System.Windows.Forms.MessageBox.Show(ex.Message);
        }
        return result;
    }
Example #4
0
 public String crear(ConsultoraBE consultoraBE)
 {
     return dao.crear(consultoraBE);
 }
Example #5
0
    private String procesaUpload(FileUpload fileUpload, int tipoProceso)
    {
        int fileLen = fileUpload.PostedFile.ContentLength;

        System.Text.Encoding encoding = System.Text.Encoding.ASCII;
        String strContenido = "";
        String[] strListado;
        String result = "";
        int cuenta = 0;
        try
        {
            byte[] input = fileUpload.FileBytes;
            strContenido = Convert.ToString(encoding.GetString(input));
            strListado = Regex.Split(strContenido, "\r\n");

            // Consultora
            if (tipoProceso == MakipurayConstant.PROCESS_TYPE_CONSULTANT)
            {

                foreach (String lista in strListado)
                {
                    cuenta++;
                    ConsultoraBE c = new ConsultoraBE();
                    IncorporacionBL incorporacionBL = new IncorporacionBL();
                    String[] strValues = lista.Split('|');
                    string resultado = "";

                    /*
                    c.paisID = StringFormatter.convertCountryIsoToNumber(StringFormatter.removeFirstAndLastCharacter(strValues[0]));
                    c.companiaCodigo = (isAnEmptyChain(strValues[1])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[1]);
                    c.codigo = (isAnEmptyChain(strValues[2])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[2]);
                    c.numeroDocumento = (isAnEmptyChain(strValues[3])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[3]);
                    */

                    IncorporacionBE iBE = new IncorporacionBE();
                    String APPID = (isAnEmptyChain(strValues[0])) ? null : StringFormatter.removeFirstAndLastCharacter(strValues[0]);
                    iBE.paisID = Convert.ToInt32(strValues[1]);

                    iBE.Pin = strValues[2];
                    iBE.Imsi = strValues[3];
                    iBE.ZonaCodigo = strValues[4];
                    iBE.CampanhaInscripcion = strValues[5];
                    iBE.fechaRegistro = strValues[6];
                    iBE.ModoGrabacionInt = Convert.ToInt32(strValues[7]);

                    iBE.territorioCodigo = strValues[8];
                    iBE.tablaContactoID = (isAnEmptyChain(strValues[9])) ? 0 : Convert.ToInt32(strValues[9]);
                    iBE.consultoraRecomendadoraCodigo = strValues[10];

                    iBE.apellidoPaterno = strValues[11];
                    iBE.apellidoMaterno = strValues[12];
                    iBE.PrimerNombre = strValues[13];
                    iBE.SegundoNombre = strValues[14];

                    iBE.fechaNacimiento = strValues[15];
                    //En iBE no hay tipo de documento
                    iBE.numeroDocumento = strValues[17];
                    iBE.telefonoCasa = strValues[18];
                    iBE.telefonoCelular = strValues[19];
                    iBE.email = strValues[20];
                    //En iBE no hay flag tiene documento
                    iBE.solicitudDireccion = strValues[22];
                    iBE.solicitudReferencia = strValues[23];
                    iBE.solicitudCodigoPostal = strValues[24];

                    iBE.solicitudDivisionPolitica1 = strValues[25] + " " + strValues[26];
                    iBE.solicitudDivisionPolitica2 = strValues[27] + " " + strValues[28] + " " + strValues[29];

                    iBE.tablaEstadoCivilID = (isAnEmptyChain(strValues[30])) ? 0 : Convert.ToInt32(strValues[30]);
                    iBE.tablaNivelEducativoID = (isAnEmptyChain(strValues[31])) ? 0 : Convert.ToInt32(strValues[31]);
                    iBE.tablaOtraMarcaID = (isAnEmptyChain(strValues[32])) ? 0 : Convert.ToInt64(strValues[32]);

                    iBE.referenciaFamiliarNombres = strValues[33];
                    iBE.referenciaFamiliarApellidoPaterno = strValues[34];
                    iBE.referenciaFamiliarApellidoMaterno = strValues[35];
                    iBE.referenciaFamiliarDireccion = strValues[36];
                    iBE.referenciaFamiliarTelefono = strValues[37];
                    iBE.referenciaFamiliarCelular = strValues[38];
                    iBE.tablaReferenciaFamiliarTipoVinculoID = (isAnEmptyChain(strValues[39])) ? 0 : Convert.ToInt32(strValues[39]);

                    iBE.referenciaNoFamiliarNombres = strValues[40];
                    iBE.referenciaNoFamiliarApellidoPaterno = strValues[41];
                    iBE.referenciaNoFamiliarApellidoMaterno = strValues[42];
                    iBE.referenciaNoFamiliarDireccion = strValues[43];
                    iBE.referenciaNoFamiliarTelefono = strValues[44];
                    iBE.referenciaNoFamiliarCelular = strValues[45];
                    iBE.tablaReferenciaNoFamiliarTipoVinculoID = (isAnEmptyChain(strValues[46])) ? 0 : Convert.ToInt32(strValues[46]);

                    iBE.entregaDireccion = strValues[47];
                    iBE.entregaDivisionPolitica = strValues[48];
                    iBE.entregaCodigoPostal = strValues[49];
                    //
                    iBE.entregaReferencia = strValues[51];
                    iBE.adicionalLugarTrabajo = strValues[52];
                    iBE.adicionalHoraVisita = strValues[53];
                    iBE.adicionalProfesion = "";
                    iBE.adicionalTelefonoTrabajo = "";
                    iBE.adicionalNumeroHijos = (isAnEmptyChain(strValues[48])) ? 0 : Convert.ToInt32(strValues[54]);
                    iBE.adicionalNumeroInfantes = (isAnEmptyChain(strValues[49])) ? 0 : Convert.ToInt32(strValues[55]);
                    iBE.adicionalNumeroEscolares = (isAnEmptyChain(strValues[50])) ? 0 : Convert.ToInt32(strValues[56]);
                    iBE.adicionalNumeroNivelSuperior = (isAnEmptyChain(strValues[51])) ? 0 : Convert.ToInt32(strValues[57]);
                    iBE.adicionalNumeroAdultos = (isAnEmptyChain(strValues[52])) ? 0 : Convert.ToInt32(strValues[58]);

                    iBE.recFechaVisita = strValues[59];
                    iBE.recObservacion = strValues[60];
                    iBE.recPin = strValues[61];
                    iBE.recIMSI = strValues[62];
                    iBE.recLongitud = strValues[63];
                    iBE.recLatitud = strValues[64];
                    iBE.recMargen = strValues[66];
                    iBE.recNumeroSatelites = (isAnEmptyChain(strValues[66])) ? 0 : Convert.ToInt32(strValues[66]);

                    /*
                    iBE.adicionalTelefonoTrabajo = strValues[46];
                    iBE.modoGrabacion = Convert.ToBoolean( (isAnEmptyChain(strValues[61])) ? 0 : Convert.ToInt32(strValues[61]) );
                    */
                    resultado = incorporacionBL.ws_registroIncorporacion(iBE, APPID);

                    if (resultado.Split('|')[0] == "0")
                    {
                        //divMensaje.InnerHtml = "<div id=\"error\">" + resultado.Split('|')[1] + "</div>";
                        divMensaje.InnerHtml = "<div id=\"error\"> Error en el formato de carga de Incorporación. </div>";
                    }
                    else {
                        divMensaje.InnerHtml = "<div id=\"info\"> Se cargó registro de incorporación</div>";
                    }

                    try
                    {
                        enviaCorreo();
                    }
                    catch (Exception ex)
                    {
                        Log.lanzarError(ex);
                    }

                }
            }
        }
        catch (Exception ex)
        {
            Log.lanzarError(ex);
        }
        return result;
    }