Beispiel #1
0
        public String crear(GerenteZonaBE gerenteZonaBE)
        {
            String resultado = "success";
            SqlCommand cmd = new SqlCommand();
            SqlConnection cn = new SqlConnection(connection.getConnectionString());

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

                cmd.Parameters.Add("@paisID", SqlDbType.Int).Value = gerenteZonaBE.paisID;
                cmd.Parameters.Add("@regionCodigo", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.regionCodigo != null) ? gerenteZonaBE.regionCodigo : "";
                cmd.Parameters.Add("@zonaCodigo", SqlDbType.VarChar, 6).Value = (gerenteZonaBE.zonaCodigo != null) ? gerenteZonaBE.zonaCodigo : "";
                cmd.Parameters.Add("@seccionCodigo", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.seccionCodigo != null) ? gerenteZonaBE.seccionCodigo : "";
                cmd.Parameters.Add("@territorioCodigo", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.territorioCodigo != null) ? gerenteZonaBE.territorioCodigo : "";
                cmd.Parameters.Add("@companhiaCodigo", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.companiaCodigo != null) ? gerenteZonaBE.companiaCodigo : "";
                cmd.Parameters.Add("@consultoraCodigo", SqlDbType.VarChar, 15).Value = (gerenteZonaBE.consultoraCodigo != null) ? gerenteZonaBE.consultoraCodigo : "";
                cmd.Parameters.Add("@pasarped", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.pasarped != null) ? gerenteZonaBE.pasarped : "";
                cmd.Parameters.Add("@motivoRetiro", SqlDbType.VarChar, 2).Value = (gerenteZonaBE.motivoRetiro != null) ? gerenteZonaBE.motivoRetiro : "";
                cmd.Parameters.Add("@apellidoPaterno", SqlDbType.VarChar, 30).Value = (gerenteZonaBE.apellidoPaterno != null) ? gerenteZonaBE.apellidoPaterno : "";
                cmd.Parameters.Add("@apellidoMaterno", SqlDbType.VarChar, 30).Value = (gerenteZonaBE.apellidoMaterno != null) ? gerenteZonaBE.apellidoMaterno : "";
                cmd.Parameters.Add("@nombres", SqlDbType.VarChar, 30).Value = (gerenteZonaBE.nombres != null) ? gerenteZonaBE.nombres : "";
                cmd.Parameters.Add("@documentoNumero", SqlDbType.VarChar, 18).Value = (gerenteZonaBE.numeroDocumento != null) ? gerenteZonaBE.numeroDocumento : "";
                cmd.Parameters.Add("@telefono", SqlDbType.VarChar, 15).Value = (gerenteZonaBE.telefono != null) ? gerenteZonaBE.telefono : "";
                cmd.Parameters.Add("@email", SqlDbType.VarChar, 40).Value = (gerenteZonaBE.email != null) ? gerenteZonaBE.email : "";
                cmd.Parameters.Add("@pin", SqlDbType.VarChar, 20).Value = (gerenteZonaBE.pin != null) ? gerenteZonaBE.pin : "";
                cmd.Parameters.Add("@imsi", SqlDbType.VarChar, 20).Value = (gerenteZonaBE.imsi != null) ? gerenteZonaBE.imsi : "";
                cmd.Parameters.Add("@estadoActivo", SqlDbType.Bit).Value = gerenteZonaBE.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;
    }
Beispiel #4
0
 public String crear(GerenteZonaBE gerenteZonaBE)
 {
     return dao.crear(gerenteZonaBE);
 }