Exemple #1
0
        public String crear(FacturacionBE facturacionBE)
        {
            String resultado = "success";
            SqlCommand cmd = new SqlCommand();
            SqlConnection cn = new SqlConnection(connection.getConnectionString());

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

                cmd.Parameters.Add("@paisID", SqlDbType.Int).Value = facturacionBE.PaisID;
                cmd.Parameters.Add("@campanha", SqlDbType.VarChar, 6).Value = facturacionBE.Campanha;

                cmd.Parameters.Add("@companhiaCodigo", SqlDbType.VarChar, 2).Value = facturacionBE.CompanhiaCodigo;
                cmd.Parameters.Add("@regionCodigo", SqlDbType.VarChar, 2).Value = facturacionBE.RegionCodigo;
                cmd.Parameters.Add("@zonaCodigo", SqlDbType.VarChar, 6).Value = facturacionBE.ZonaCodigo;
                cmd.Parameters.Add("@fecha", SqlDbType.SmallDateTime).Value = Convert.ToDateTime(facturacionBE.Fecha);
                cmd.Parameters.Add("@estadoActivo", SqlDbType.VarChar, 6).Value = facturacionBE.EstadoActivo;

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

            return resultado;
        }
    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;
    }
Exemple #3
0
 public String crear(FacturacionBE facturacionBE)
 {
     return dao.crear(facturacionBE);
 }