diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb
index 507d7bc15..e8509be9f 100644
--- a/App_Code/ClsPaginas.vb
+++ b/App_Code/ClsPaginas.vb
@@ -7475,11 +7475,11 @@ Public Class ClsPaginas
' nombreautorizo = "Lic. LUIS JORGE CONTRERAS LANDGRAVE"
'End If
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\OC.rdlc", EmpresaActual.Ruta))
- If Not Archivo.Exists OrElse EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 122, 126) Then
+ If Not Archivo.Exists OrElse EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 122, 126, 158) Then
params.Add(New ReportParameter("Descuento", DtDetalle.SUM("Descuento").ToString.FormatoNumero(2)))
End If
'DATOS PARA DESCUENTO
- If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 119, 122, 126) Then 'EMPRESAS QUE YA TIENEN EL AJUSTE EN EL FORMATO
+ If EmpresaActual.CveEmpresa.Contiene(4, 145, 7, 11, 12, 13, 72, 80, 83, 119, 122, 126, 158) Then 'EMPRESAS QUE YA TIENEN EL AJUSTE EN EL FORMATO
params.Add(New ReportParameter("SubTotal", ObjOC.SubTotal.ToString))
params.Add(New ReportParameter("SubTotal2", DtDetalle.SUM("Total").ToString))
Else
diff --git a/CRM/CatEmpresasCRM.aspx b/CRM/CatEmpresasCRM.aspx
index 4d47b17ab..1e7e82f94 100644
--- a/CRM/CatEmpresasCRM.aspx
+++ b/CRM/CatEmpresasCRM.aspx
@@ -13,11 +13,14 @@
Agregar
+
+ Cargar Prospectos
+
-
+
@@ -47,9 +50,9 @@
-
+
-
+
@@ -59,7 +62,7 @@
-
+
@@ -72,21 +75,21 @@
-
+
-
-
+
+
-
-
+
+
-
+
@@ -95,14 +98,49 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CRM/CatEmpresasCRM.aspx.cs b/CRM/CatEmpresasCRM.aspx.cs
index 9f8de821c..7a539f16b 100644
--- a/CRM/CatEmpresasCRM.aspx.cs
+++ b/CRM/CatEmpresasCRM.aspx.cs
@@ -1,11 +1,12 @@
using System;
+using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
-
+using GemBox.Spreadsheet;
using Extensiones;
public partial class CRM_CatEmpresasCRM : ClsPaginas
@@ -124,4 +125,172 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
CargaMediosCaptacion();
UPFiltros.Update();
}
+
+ protected void LnkCargaProspectos_Click(object sender, EventArgs e)
+ {
+ RegistraScript(String.Format("$('#{0}').modal();", "DivCargasMasivas"));
+ }
+
+ protected void BtnDescargar_Click(object sender, EventArgs e)
+ {
+ string Directorio = ModExtensiones.DirectorioBaseEmpresas + "Empresas\\Grales\\Formatos\\FormatoDeProspectos.xlsx";
+ FileInfo Archivo = new FileInfo(Directorio);
+ Response.Clear();
+ Response.ClearHeaders();
+ Response.ClearContent();
+ Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name);
+ Response.AddHeader("Content-Length", Archivo.Length.ToString());
+ Response.ContentType = "text/plain";
+ Response.Flush();
+ Response.TransmitFile(Archivo.FullName);
+ Response.End();
+ }
+
+ protected void BtnAgregarProspectos_Click(object sender, EventArgs e)
+ {
+ if( TxtExcel.getfiles().Archivos.Count > 0 )
+ {
+ Archivo file = TxtExcel.getfiles().Archivos[0];
+ string Directorio = Server.MapPath("~") + file.patch;
+
+ DataTable dt = ReadExcelFile(Directorio + file.filename, true);
+ DataRowCollection Rows = dt.Rows;
+ ClsCRM ObjCRM = new ClsCRM();
+ ObjCRM.IniciaTransacSQL();
+ bool TieneError = false;
+
+ foreach (DataRow row in Rows)
+ {
+ string Proceso = row["Proceso"].ToString();
+ string NombreEmpresa = row["Nombre de la empresa"].ToString();
+ string RFC = row["RFC"].ToString();
+ string Mail = row["Mail"].ToString();
+ string MedioCaptacion = row["Medio de Captación"].ToString();
+ string Agente = row["Agente"].ToString();
+ string Sucursal = row["Sucursal"].ToString();
+ string Giro = row["Giro"].ToString();
+ string ContactoPrincipal = row["Contacto Principal"].ToString();
+ string TelOficina = row["Teléfono de Oficina"].ToString();
+ string Celular = row["Celular"].ToString();
+ string Correo = row["Correo"].ToString();
+
+ int CveMedioCaptacion = -1;
+ if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa))
+ {
+ DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion));
+ if(MediosCaptacion != null)
+ {
+ CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero();
+ }else
+ {
+ Alert(String.Format("El medio de captación '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia);
+ TieneError = true;
+ break;
+ }
+ }
+
+ int CveVendedor = -1;
+ DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Vendedor = '{0}'",Agente));
+ if (Vendedor != null)
+ {
+ CveVendedor = Vendedor["CveVendedor"].ToString().ToEntero();
+ }else
+ {
+ Alert(String.Format("El vendedor '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia);
+ TieneError = true;
+ break;
+ }
+
+ int CveSubProyecto = -1;
+ DataRow SubProyecto = get_GlobalDTSubProyectos(-1,CveEmpresa:UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("SubProyecto = '{0}'",Sucursal));
+ if(SubProyecto != null)
+ {
+ CveSubProyecto = SubProyecto["CveSubProyecto"].ToString().ToEntero();
+ }else
+ {
+ Alert(String.Format("El SubProyecto '{0}'", Sucursal), ModExtensiones.TipoMensaje.MsgAdvertencia);
+ TieneError = true;
+ break;
+ }
+
+ int CveGiro = -1;
+ DataRow GiroDt = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("ClienteClasificacion = '{0}'", Giro));
+ if (GiroDt != null)
+ {
+ CveGiro = GiroDt["CveClienteClasificacion"].ToString().ToEntero();
+ }
+ else
+ {
+ Alert(String.Format("El Giro de Empresa '{0}'", Giro), ModExtensiones.TipoMensaje.MsgAdvertencia);
+ TieneError = true;
+ break;
+ }
+
+ TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0));
+
+ }
+
+ if (TieneError)
+ {
+ ObjCRM.RollBack();
+ }else
+ {
+ ObjCRM.Commit();
+ Alert("Prospectos agregados correctamente");
+ TxtExcel.Text = "";
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DivCargasMasivas"));
+ }
+
+ ObjCRM.Dispose();
+ }
+
+ }
+
+ private DataTable ReadExcelFile(string flatFilePath, bool firstRowHasHeaders)
+ {
+ SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet());
+ ExcelFile excelFile = ExcelFile.Load(flatFilePath);
+
+ int unnamed = 0;
+ int cols;
+ string[] columns;
+ int curRow = 0;
+ int curCol = 0;
+ DataTable dataTable = new DataTable();
+ ExcelWorksheet worksheet = excelFile.Worksheets[0];
+
+ for (cols = 0; cols <= worksheet.Rows[0].AllocatedCells.Count - 1; cols++)
+ {
+ if (firstRowHasHeaders)
+ {
+ if (worksheet.Rows[0].Cells[cols].Value != null)
+ dataTable.Columns.Add(worksheet.Rows[0].Cells[cols].Value.ToString().Trim());
+ else
+ dataTable.Columns.Add("Unnamed Column " + (System.Threading.Interlocked.Increment(ref unnamed)));
+
+ curRow = 1;
+ }
+ else
+ dataTable.Columns.Add("Column " + (cols + 1));
+ }
+
+ while (curRow < worksheet.Rows.Count)
+ {
+ columns = new string[cols - 1 + 1];
+
+ for (curCol = 0; curCol <= cols - 1; curCol++)
+ {
+ if (worksheet.Rows[curRow].Cells[curCol].Value == null)
+ columns[curCol] = "";
+ else
+ columns[curCol] = worksheet.Rows[curRow].Cells[curCol].Value.ToString();
+ }
+
+ dataTable.Rows.Add(columns);
+ curRow += 1;
+ }
+
+ return dataTable;
+ }
+
}
\ No newline at end of file
diff --git a/CRM/EmpresaCRM.aspx.cs b/CRM/EmpresaCRM.aspx.cs
index abb4a55a9..7fdf33a49 100644
--- a/CRM/EmpresaCRM.aspx.cs
+++ b/CRM/EmpresaCRM.aspx.cs
@@ -252,6 +252,8 @@ public partial class CRM_EmpresaCRM : ClsPaginas
VerificaPermisos();
CargaClasificaciones();
DdlPS.setEsWebService(true);
+ DdlPS.SelectedText = "Seleccione";
+ DdlPS.SelectedValue = "-1";
}
}
@@ -1516,6 +1518,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas
if ((UsuarioActual.CveVendedor != CveVendedor))
{
BtnGuardarEmpresa.Visible = false;
+ BtnEliminarEmpresa.Visible = false;
BtnAgregarContacto.Visible = false;
//LnkAgregarAcercamiento.Visible = false;
DivAccionesBitacora.Visible = false;