Ejemplo n.º 1
0
        public List <entCliente_Telefono> BuscaCliente(String telefono, String NumDoc)
        {
            SqlCommand cmd = null;
            List <entCliente_Telefono> Lista = null;
            SqlDataReader dr = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscaCliente", cn);
                cmd.Parameters.AddWithValue("@TELEFONO", telefono);
                cmd.Parameters.AddWithValue("@NRO_DOCUMENTO", NumDoc);

                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entCliente_Telefono>();
                while (dr.Read())
                {
                    entCliente c = new entCliente();
                    c.Cli_Id                  = Convert.ToInt32(dr["Cli_Id"]);
                    c.Cli_Codigo              = dr["Cli_Codigo"].ToString();
                    c.Cli_Nombre              = dr["Cli_Nombre"].ToString();
                    c.Cli_RazonSocial         = dr["Cli_RazonSocial"].ToString();
                    c.Cli_Numero_Documento    = dr["Cli_Numero_Documento"].ToString();
                    c.Cli_FechaNacimiento     = Convert.ToDateTime(dr["Cli_FechaNacimiento"]);
                    c.Cli_LugarNacimiento     = dr["Cli_LugarNacimiento"].ToString();
                    c.Cli_Correo              = dr["Cli_Correo"].ToString();
                    c.Cli_Telefono_Referencia = dr["Cli_Telefono_Referencia"].ToString();
                    c.Cli_Estado              = dr["Cli_Estado"].ToString();
                    c.Cli_FechaRegistro       = Convert.ToDateTime(dr["Cli_FechaRegistro"]);
                    c.Cli_FechaModificacion   = Convert.ToDateTime(dr["Cli_FechaModificacion"]);
                    entTipDoc d = new entTipDoc();
                    d.td_Descripcion = dr["td_Descripcion"].ToString();
                    c.TipDoc         = d;
                    entSegmento s = new entSegmento();
                    s.Seg_Nombre = dr["Seg_Nombre"].ToString();
                    c.Segmento   = s;
                    entTelefono t = new entTelefono();
                    t.Tel_Id        = Convert.ToInt32(dr["Tel_Id"]);
                    t.Tel_Numero    = dr["Tel_Numero"].ToString();
                    t.Tel_Producto  = dr["Tel_Producto"].ToString();
                    t.Tel_Direccion = dr["Tel_Direccion"].ToString();
                    t.Tel_FechaAlta = Convert.ToDateTime(dr["Tel_FechaAlta"]);
                    t.Tel_F1        = Convert.ToDouble(dr["Tel_F1"]);
                    t.Tel_F2        = Convert.ToDouble(dr["Tel_F2"]);
                    t.Tel_F3        = Convert.ToDouble(dr["Tel_F3"]);
                    entCliente_Telefono cl = new entCliente_Telefono();
                    cl.Cliente  = c;
                    cl.Telefono = t;
                    Lista.Add(cl);
                }
            }
            catch (Exception)
            {
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
        public List <entAsigncionLlamadas> ListaClientesAsignadosXUsuario(Int32 UsuarioId)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            List <entAsigncionLlamadas> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spListaClientesAsignadosXUsuario", cn);
                cmd.Parameters.AddWithValue("@prmtIntIdUsu", UsuarioId);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entAsigncionLlamadas>();

                while (dr.Read())
                {
                    entSegmento s = new entSegmento();
                    s.Seg_Id = Convert.ToInt32(dr["Cli_Seg_Id"]);

                    entCliente c = new entCliente();
                    c.Cli_Id            = Convert.ToInt32(dr["Cli_Id"]);
                    c.Cli_Nombre        = dr["Cli_Nombre"].ToString();
                    c.Cli_RazonSocial   = dr["Cli_RazonSocial"].ToString();
                    c.Cli_Estado        = dr["Cli_Estado"].ToString();
                    c.Cli_FechaRegistro = Convert.ToDateTime(dr["Cli_FechaRegistro"]);
                    c.Segmento          = s;

                    entTelefono t = new entTelefono();
                    t.Tel_Id        = Convert.ToInt32(dr["Tel_Id"]);
                    t.Tel_Numero    = dr["Tel_Numero"].ToString();
                    t.Tel_Producto  = dr["Tel_Producto"].ToString();
                    t.Tel_FechaAlta = Convert.ToDateTime(dr["Tel_FechaAlta"]);

                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.CliTel_Id = Convert.ToInt32(dr["CliTel_Id"]);
                    ct.Cliente   = c;
                    ct.Telefono  = t;

                    entAsigncionLlamadas al = new entAsigncionLlamadas();
                    al.Asi_Id          = Convert.ToInt32(dr["Asi_Id"]);
                    al.ClienteTelefono = ct;

                    Lista.Add(al);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(Lista);
        }
Ejemplo n.º 3
0
        public List <entPedido> ListaHistllamadas(String telefono)
        {
            SqlCommand       cmd   = null;
            SqlDataReader    dr    = null;
            List <entPedido> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spHisLlamadasPedido", cn);
                cmd.Parameters.AddWithValue("@NUM_TELEF", telefono);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entPedido>();
                while (dr.Read())
                {
                    entPedido p = new entPedido();
                    p.Respuesta         = dr["Respuesta"].ToString();
                    p.Ped_FechaRegistro = Convert.ToDateTime(dr["Ped_FechaRegistro"]);
                    p.Ped_Obser_Estados = dr["Ped_Obser_Estados"].ToString();
                    p.Ped_Observaciones = dr["Ped_Observaciones"].ToString();
                    entEstado e = new entEstado();
                    e.Est_Nombre = dr["Est_Nombre"].ToString();
                    p.Estado     = e;
                    entCliente_Telefono ct = new entCliente_Telefono();
                    entCliente          c  = new entCliente();
                    c.Cli_Nombre           = dr["Cli_Nombre"].ToString();
                    c.Cli_Numero_Documento = dr["Cli_Numero_Documento"].ToString();
                    entTelefono t = new entTelefono();
                    t.Tel_Numero      = dr["Tel_Numero"].ToString();
                    ct.Cliente        = c;
                    ct.Telefono       = t;
                    p.ClienteTelefono = ct;
                    entUsuario u  = new entUsuario();
                    entPersona pe = new entPersona();
                    pe.Per_Nombres   = dr["Per_Nombres"].ToString();
                    pe.Per_Apellidos = dr["Per_Apellidos"].ToString();
                    u.Persona        = pe;
                    p.Usuario        = u;
                    entAccionComercial ac = new entAccionComercial();
                    ac.Acc_Nombre = dr["Acc_Nombre"].ToString();
                    entProducto pro = new entProducto();
                    pro.Pro_Nombre    = dr["Pro_Nombre"].ToString();
                    p.Producto        = pro;
                    p.AccionComercial = ac;
                    Lista.Add(p);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Ejemplo n.º 4
0
        public List <entRegLamadas> ListLlamAgen(int idusuario)
        {
            SqlCommand           cmd   = null;
            SqlDataReader        dr    = null;
            List <entRegLamadas> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spListaCliAgend", cn);
                cmd.Parameters.AddWithValue("@IS_USUARIO", idusuario);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entRegLamadas>();
                while (dr.Read())
                {
                    entRegLamadas r = new entRegLamadas();
                    r.rll_id            = Convert.ToInt32(dr["rll_id"]);
                    r.rll_resultado     = dr["rll_resultado"].ToString();
                    r.rll_fechahor_reg  = Convert.ToDateTime(dr["rll_fechahor_reg"].ToString());
                    r.rll_estado        = dr["rll_estado"].ToString();
                    r.rll_observaciones = dr["rll_observaciones"].ToString();
                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.CliTel_Id = Convert.ToInt32(dr["CliTel_Id"]);
                    entCliente c = new entCliente();
                    c.Cli_Id     = Convert.ToInt32(dr["Cli_Id"]);
                    c.Cli_Nombre = dr["Cli_Nombre"].ToString();
                    ct.Cliente   = c;
                    entTelefono t = new entTelefono();
                    t.Tel_Id        = Convert.ToInt32(dr["Tel_Id"]);
                    t.Tel_Numero    = dr["Tel_Numero"].ToString();
                    ct.Telefono     = t;
                    r.cliente_telef = ct;
                    entAsigncionLlamadas al = new entAsigncionLlamadas();
                    al.Asi_Id     = Convert.ToInt32(dr["Asi_Id"]);
                    r.assllamadas = al;
                    entAccionComercial ac = new entAccionComercial();
                    ac.Acc_Nombre = dr["Acc_Nombre"].ToString();
                    entProducto p = new entProducto();
                    p.Pro_Nombre      = dr["Pro_Nombre"].ToString();
                    r.accioncomercial = ac;
                    r.producto        = p;
                    Lista.Add(r);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
        public List <entCliente_Telefono> ListaClientesParaAsignar()
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            List <entCliente_Telefono> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListaClientesParaAsignar", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entCliente_Telefono>();

                while (dr.Read())
                {
                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.CliTel_Id = Convert.ToInt32(dr["CliTel_Id"]);

                    entSegmento s = new entSegmento();
                    s.Seg_Id = Convert.ToInt32(dr["Cli_Seg_Id"]);

                    entCliente c = new entCliente();
                    c.Cli_Id            = Convert.ToInt32(dr["Cli_Id"]);
                    c.Cli_Nombre        = dr["Cli_Nombre"].ToString();
                    c.Cli_RazonSocial   = dr["Cli_RazonSocial"].ToString();
                    c.Cli_Estado        = dr["Cli_Estado"].ToString();
                    c.Cli_FechaRegistro = Convert.ToDateTime(dr["Cli_FechaRegistro"]);
                    c.Segmento          = s;

                    entTelefono t = new entTelefono();
                    t.Tel_Id        = Convert.ToInt32(dr["Tel_Id"]);
                    t.Tel_Numero    = dr["Tel_Numero"].ToString();
                    t.Tel_Producto  = dr["Tel_Producto"].ToString();
                    t.Tel_FechaAlta = Convert.ToDateTime(dr["Tel_FechaAlta"]);

                    ct.Cliente  = c;
                    ct.Telefono = t;
                    Lista.Add(ct);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(Lista);
        }
        public entAsigncionLlamadas BuscaAsiLla(Int32 UsuarioId, Int32 AsiLlaId)
        {
            SqlCommand           cmd = null;
            SqlDataReader        dr  = null;
            entAsigncionLlamadas al  = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spBuscaAsiLla", cn);
                cmd.Parameters.AddWithValue("@prmtIntIdAsiUsu", UsuarioId);
                cmd.Parameters.AddWithValue("@prmtIntIdAsiLla", AsiLlaId);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    entSegmento s = new entSegmento();
                    s.Seg_Nombre = dr["Seg_Nombre"].ToString();

                    entTipDoc td = new entTipDoc();
                    td.td_nombre = dr["td_nombre"].ToString();

                    entCliente c = new entCliente();
                    c.Cli_Id               = Convert.ToInt32(dr["Cli_Id"]);
                    c.Cli_Nombre           = dr["Cli_Nombre"].ToString();
                    c.Cli_Numero_Documento = dr["Cli_Numero_Documento"].ToString();
                    c.Cli_RazonSocial      = dr["Cli_RazonSocial"].ToString();
                    c.TipDoc               = td;
                    c.Segmento             = s;

                    entTelefono t = new entTelefono();
                    t.Tel_Id        = Convert.ToInt32(dr["Tel_Id"]);
                    t.Tel_Numero    = dr["Tel_Numero"].ToString();
                    t.Tel_Producto  = dr["Tel_Producto"].ToString();
                    t.Tel_Direccion = dr["Tel_Direccion"].ToString();
                    t.Tel_FechaAlta = Convert.ToDateTime(dr["Tel_FechaAlta"]);
                    t.Tel_F1        = Convert.ToDouble(dr["Tel_F1"]);
                    t.Tel_F2        = Convert.ToDouble(dr["Tel_F2"]);
                    t.Tel_F3        = Convert.ToDouble(dr["Tel_F3"]);

                    entUsuario u = new entUsuario();
                    u.Usu_Id = Convert.ToInt32(dr["Asi_Usu_Id"]);

                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.CliTel_Id = Convert.ToInt32(dr["CliTel_Id"]);
                    ct.Cliente   = c;
                    ct.Telefono  = t;

                    al                 = new entAsigncionLlamadas();
                    al.Asi_Id          = Convert.ToInt32(dr["Asi_Id"]);
                    al.Usuario         = u;
                    al.ClienteTelefono = ct;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(al);
        }
        public ActionResult RegistroVenta(FormCollection form)
        {
            try
            {
                entUsuario us = (entUsuario)Session["usuario"];
                if (us != null)
                {
                    entSegmento s = new entSegmento();
                    s.Seg_Id = Convert.ToInt32(form["txt_Seg"]);

                    entTipDoc td = new entTipDoc();
                    td.td_id = Convert.ToInt32(form["txt_TipDoc"]);

                    //para capturar el usuario en sesion////////////
                    entUsuario user         = (entUsuario)Session["usuario"];
                    String     userRegistro = user.Persona.NombreCompleto;
                    ///////////////////////////////////////////
                    entCliente c = new entCliente();
                    //c.Cli_Id = Convert.ToInt32(form["txtIdC"]);
                    c.Segmento = s;
                    c.TipDoc   = td;
                    if (s.Seg_Id == 1)
                    {
                        c.Cli_Nombre      = form["txt_NomCli"].ToString();
                        c.Cli_RazonSocial = "";
                    }
                    else
                    {
                        c.Cli_Nombre      = "";
                        c.Cli_RazonSocial = form["txt_NomCli"].ToString();
                    }
                    c.Cli_FechaNacimiento     = Convert.ToDateTime(form["txtFecNac"]);
                    c.Cli_LugarNacimiento     = form["txt_LugNac"].ToString();
                    c.Cli_Numero_Documento    = form["txt_NumDocumento"].ToString();
                    c.Cli_Telefono_Referencia = form["txt_TelRef"].ToString();
                    c.Cli_Correo          = form["txt_Cor"].ToString();
                    c.Cli_UsuarioRegistro = userRegistro;
                    entTelefono t = new entTelefono();
                    t.Tel_Numero    = form["txt_Telefono"].ToString();
                    t.Tel_Direccion = form["txt_Direccion"].ToString();


                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.Cliente  = c;
                    ct.Telefono = t;
                    //ct.AsiUsu = AsiUsu;
                    ct.CliTel_UsuarioRegistro = userRegistro;

                    entPedido p = new entPedido();
                    p.Ped_Cod_Experto     = form["txt_CodExperto"].ToString();
                    p.Ped_Dir_Inst        = form["txt_Direccion"].ToString();
                    p.Ped_Observaciones   = form["txtobserva"].ToString();
                    p.PedidoX             = form["txtCordenadaX"].ToString();
                    p.PedidoY             = form["txtCoordenadaY"].ToString();
                    p.Ped_UsuarioRegistro = userRegistro;

                    entUsuario ur = new entUsuario();
                    ur.Usu_Id = user.Usu_Id;

                    entAccionComercial ac = new entAccionComercial();
                    ac.Acc_Id = Convert.ToInt32(form["idAccCom"]);

                    entProducto pro = new entProducto();
                    pro.Pro_ID = Convert.ToInt32(form["Prod"]);

                    entDepartamento d = new entDepartamento();
                    d.idDepa = Convert.ToInt32(form["depto"]);

                    entProvincia prov = new entProvincia();
                    prov.idProv = Convert.ToInt32(form["provin"]);

                    entDistrito dis = new entDistrito();
                    dis.idDist = Convert.ToInt32(form["distrit"]);

                    p.Distrito        = dis;
                    p.Provincia       = prov;
                    p.Departamento    = d;
                    p.Producto        = pro;
                    p.AccionComercial = ac;
                    p.Usuario         = ur;
                    p.ClienteTelefono = ct;

                    if (p.PedidoX == "" || p.PedidoY == "" || p.PedidoX == null || p.PedidoY == null)
                    {
                        return(RedirectToAction("RegistroVenta", "AsesorVentasCampo", new { mensaje = "Debe marcar en el mapa una ubicación de referencia", identificador = 2 }));
                    }

                    int i = negPedido.Instancia.InsUpdPedidoCampo(p, 1);
                    if (i > 0)
                    {
                        return(RedirectToAction("RegistroVenta", "AsesorVentasCampo", new { mensaje = "Se Inserto Satisfactoriamente", identificador = 3 }));
                    }
                    else
                    {
                        return(RedirectToAction("RegistroVenta", "AsesorVentasCampo", new { mensaje = "Problemas al Insertar", identificador = 2 }));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            catch (ApplicationException x)
            {
                ViewBag.mensaje = x.Message;
                return(RedirectToAction("RegistroVenta", "AsesorVentasCampo", new { mensaje = x.Message, identificador = 1 }));
            }
            catch (Exception e)
            {
                return(RedirectToAction("RegistroVenta", "AsesorVentasCampo", new { mensaje = e.Message, identificador = 2 }));
            }
        }
Ejemplo n.º 8
0
        public ActionResult InsertarDataCliente(FormCollection form)
        {
            try
            {
                entUsuario us = (entUsuario)Session["usuario"];
                if (us != null)
                {
                    entSegmento s = new entSegmento();
                    s.Seg_Id = Convert.ToInt32(form["txt_Segmento"]);

                    entTipDoc td = new entTipDoc();
                    td.td_id = Convert.ToInt32(form["txt_TipDoc"]);

                    //para capturar el usuario en sesion////////////
                    entUsuario user         = (entUsuario)Session["usuario"];
                    String     userRegistro = user.Persona.NombreCompleto;
                    ///////////////////////////////////////////

                    List <entProducto> lsSVAS    = new List <entProducto>();
                    String             selectSVA = form["txt_svas"];
                    lsSVAS = (selectSVA != null) ? DividirCadenaRetornaListSVAS(selectSVA) : null;

                    entCliente c = new entCliente();
                    c.Segmento             = s;
                    c.TipDoc               = td;
                    c.Cli_Nombre           = form["txt_Nom"].ToString();
                    c.Cli_RazonSocial      = form["txt_Rs"].ToString();
                    c.Cli_Numero_Documento = form["txt_NumDocumento"].ToString();
                    c.Cli_UsuarioRegistro  = userRegistro;
                    c.SVAS = lsSVAS;

                    entTelefono t = new entTelefono();
                    t.Tel_Numero    = form["txt_Telefono"].ToString();
                    t.Tel_Producto  = form["txt_Producto"].ToString();
                    t.Tel_Direccion = form["txt_Direccion"].ToString();
                    t.Tel_FechaAlta = Convert.ToDateTime(form["txt_Fecha_Alta"]);
                    t.Tel_F1        = Convert.ToDouble(form["txt_F1"]);
                    t.Tel_F2        = Convert.ToDouble(form["txt_F2"]);
                    t.Tel_F3        = Convert.ToDouble(form["txt_F3"]);

                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.Cliente  = c;
                    ct.Telefono = t;
                    ct.CliTel_UsuarioRegistro = userRegistro;

                    int i = negCliente_Telefono.Instancia.InsUpdCliente(ct, 1);
                    if (i > 0)
                    {
                        return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Se Inserto Satisfactoriamente", identificador = 3 }));
                    }
                    else
                    {
                        return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Problemas al Insertar", identificador = 2 }));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            catch (ApplicationException x)
            {
                ViewBag.mensaje = x.Message;
                return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = x.Message, identificador = 1 }));
            }
            catch (Exception e)
            {
                return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = e.Message, identificador = 2 }));
            }
        }
Ejemplo n.º 9
0
        public ActionResult AsignaClienteUsuario(entCliente_TelefonoView model, FormCollection form)
        {
            try
            {
                entUsuario us = (entUsuario)Session["usuario"];
                if (us != null)
                {
                    List <entCliente_Telefono> Lista = model.Cliente_Telefono;
                    Int32 cantselect = 0;
                    foreach (entCliente_Telefono item in Lista)
                    {
                        if (item.IsSelected == true)
                        {
                            cantselect++;
                        }
                    }
                    if (cantselect != 0)
                    {
                        //para capturar el usuario en sesion////////////
                        entUsuario user         = (entUsuario)Session["usuario"];
                        String     userRegistro = user.Persona.NombreCompleto;
                        ///////////////////////////////////////////
                        Int32      idAsesor = Convert.ToInt32(form["txt_aseven"]);
                        entUsuario cu       = new entUsuario();
                        cu.Usu_Id = idAsesor;
                        List <entAsigncionLlamadas> lsAsiLlaCli = new List <entAsigncionLlamadas>();
                        foreach (entCliente_Telefono item in Lista)
                        {
                            if (item.IsSelected == true)
                            {
                                entAsigncionLlamadas asi = new entAsigncionLlamadas();
                                entCliente_Telefono  ct  = new entCliente_Telefono();
                                ct.CliTel_Id        = item.CliTel_Id;
                                asi.ClienteTelefono = ct;
                                entUsuario u = new entUsuario();
                                u.Usu_Id                = idAsesor;
                                asi.Usuario             = u;
                                asi.Asi_UsuarioRegistro = userRegistro;
                                lsAsiLlaCli.Add(asi);
                            }
                        }
                        cu.lsAsiLla = lsAsiLlaCli;

                        int i = negUsuario.Instancia.InsUpdDelBloActAsignacionUsuario(cu, 1);
                        if (i > 0)
                        {
                            return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Se Asigno Data Satisfactoriamente", identificador = 3 }));
                        }
                        else
                        {
                            return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Problemas al Insertar", identificador = 2 }));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Debe Seleccionar por lo menos un Cliente", identificador = 2 }));
                    }
                }
                else
                {
                    return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = "Problemas al Insertar", identificador = 2 }));
                }
            }
            catch (ApplicationException x)
            {
                ViewBag.mensaje = x.Message;
                return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = x.Message, identificador = 1 }));
            }
            catch (Exception e)
            {
                return(RedirectToAction("InsertarDataCliente", "AdministradorData", new { mensaje = e.Message, identificador = 2 }));
            }


            //return View(model);
        }
        public int InsUpdCliente(entCliente_Telefono ct, Int16 TipoEdicion)
        {
            try
            {
                List <entProducto> Svas = new List <entProducto>();
                Svas = ct.Cliente.SVAS;
                Int32 TieneSVA = 0;
                TieneSVA = (Svas != null) ? 1 : 0;

                String cadXml = "";
                cadXml += "<CliTel ";
                cadXml += "CliTel_UsuarioRegistro='" + ct.CliTel_UsuarioRegistro + "' ";
                cadXml += "TieneSVA='" + TieneSVA + "' ";
                cadXml += "TipoEdicion='" + TipoEdicion + "'>";

                cadXml += "<Cli ";
                cadXml += "Cli_TipDoc_Id='" + ct.Cliente.TipDoc.td_id + "' ";
                cadXml += "Cli_Nombre='" + ct.Cliente.Cli_Nombre + "' ";
                cadXml += "Cli_RazonSocial='" + ct.Cliente.Cli_RazonSocial + "' ";
                cadXml += "Cli_Seg_Id='" + ct.Cliente.Segmento.Seg_Id + "' ";
                cadXml += "Cli_Numero_Documento='" + ct.Cliente.Cli_Numero_Documento + "' ";
                cadXml += "Cli_UsuarioRegistro='" + ct.Cliente.Cli_UsuarioRegistro + "' ";
                cadXml += "TipoEdicion='" + TipoEdicion + "'>";

                if (TieneSVA != 0)
                {
                    foreach (entProducto p in ct.Cliente.SVAS)
                    {
                        cadXml += "<ProCon ";
                        cadXml += "ProCon_Pro_Id='" + p.Pro_ID + "' ";
                        cadXml += "ProCon_UsuarioRegistro='" + ct.CliTel_UsuarioRegistro + "'/>";
                    }
                }

                cadXml += "</Cli>";

                cadXml += "<Tel ";
                cadXml += "Tel_Numero='" + ct.Telefono.Tel_Numero + "' ";
                cadXml += "Tel_Producto='" + ct.Telefono.Tel_Producto + "' ";
                cadXml += "Tel_Direccion='" + ct.Telefono.Tel_Direccion + "' ";
                cadXml += "Tel_FechaAlta='" + ct.Telefono.Tel_FechaAlta.ToString("yyyy/MM/dd") + "' ";
                cadXml += "Tel_F1='" + ct.Telefono.Tel_F1 + "' ";
                cadXml += "Tel_F2='" + ct.Telefono.Tel_F2 + "' ";
                cadXml += "Tel_F3='" + ct.Telefono.Tel_F3 + "' ";
                cadXml += "TipoEdicion='" + TipoEdicion + "'/>";

                cadXml += "</CliTel>";
                cadXml  = "<root>" + cadXml + "</root>";

                if (TipoEdicion == 1)
                {
                    String Telefono_Ingreso = ct.Telefono.Tel_Numero.ToString();
                    int    val = datTelefono.Instancia.ValidaTelefono(Telefono_Ingreso);
                    if (val > 0)
                    {
                        throw new ApplicationException("Telefono Ya Registrado");
                    }
                }
                int i = datCliente_Telefono.Instancia.InsUpdDelBloActCliente(cadXml);
                if (TipoEdicion == 1)
                {
                    if (i <= 0)
                    {
                        throw new ApplicationException("No se Pudo Insertar a el Cliente");
                    }
                }
                if (TipoEdicion == 2)
                {
                    if (i <= 0)
                    {
                        throw new ApplicationException("No se Pudo Editar a el Cliente");
                    }
                }
                return(i);
            }
            catch (ApplicationException ae)
            {
                throw ae;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 11
0
        public ActionResult RegistroLlamada(FormCollection form)
        {
            Int32 AsiUsu = Convert.ToInt32(form["txtAsiU"]);

            try
            {
                // registrando agendamiento o rechazo
                int accion      = Convert.ToInt32(form["resultado"]);
                int tipoedicion = 0;
                if (accion != 1)
                {
                    String acc = "";
                    if (accion == 2)
                    {
                        acc = "Rechazo";
                    }
                    else
                    {
                        acc = "Pendiente";
                    }
                    entRegLamadas rll = new entRegLamadas();
                    rll.rll_id            = Convert.ToInt32(form["txtIdRegLlam"]);
                    rll.rll_resultado     = acc;
                    rll.rll_observaciones = form["Desc"];
                    entAsigncionLlamadas all = new entAsigncionLlamadas();
                    all.Asi_Id      = AsiUsu;
                    rll.assllamadas = all;
                    entCliente_Telefono ct = new entCliente_Telefono();
                    ct.CliTel_Id      = Convert.ToInt32(form["txtCli_telf_id"]);
                    rll.cliente_telef = ct;
                    entUsuario u = new entUsuario();
                    if (Session["usuario"] != null)
                    {
                        u = (entUsuario)Session["usuario"];
                    }
                    rll.usuario = u;
                    entAccionComercial ac = new entAccionComercial();
                    ac.Acc_Id           = Convert.ToInt32(form["idAccCom"]);
                    rll.accioncomercial = ac;
                    entProducto p = new entProducto();
                    p.Pro_ID     = Convert.ToInt32(form["Prod"]);
                    rll.producto = p;
                    if (rll.rll_id == 0)
                    {
                        tipoedicion = 1;
                    }
                    else
                    {
                        tipoedicion = 2;
                    }
                    int i = negPedido.Instancia.RegUpdaLlamadas(rll, tipoedicion);
                    return(RedirectToAction("RegistroLlamada", "AsesorVentasCall", new { mensaje = "Se Inserto Satisfactoriamente", identificador = 3, AsiLlaId = AsiUsu }));
                }
                else
                {
                    // borra registro de llamada agendada de bd y pasa a ser un pedido
                    if (form["txtIdRegLlam"].ToString() != "0")
                    {
                        entRegLamadas rll = new entRegLamadas();
                        rll.rll_id = Convert.ToInt32(form["txtIdRegLlam"]);
                        int i = negPedido.Instancia.EliminaRegLlamAgend(rll.rll_id);
                    }

                    entUsuario us = (entUsuario)Session["usuario"];
                    if (us != null)
                    {
                        entSegmento s = new entSegmento();
                        s.Seg_Id = Convert.ToInt32(form["txt_Seg"]);

                        entTipDoc td = new entTipDoc();
                        td.td_id = Convert.ToInt32(form["txt_TipDoc"]);

                        //para capturar el usuario en sesion////////////
                        entUsuario user         = (entUsuario)Session["usuario"];
                        String     userRegistro = user.Persona.NombreCompleto;
                        ///////////////////////////////////////////

                        entCliente c = new entCliente();
                        c.Cli_Id   = Convert.ToInt32(form["txtIdC"]);
                        c.Segmento = s;
                        c.TipDoc   = td;
                        if (s.Seg_Id == 1)
                        {
                            c.Cli_Nombre      = form["txt_NomCli"].ToString();
                            c.Cli_RazonSocial = "";
                        }
                        else
                        {
                            c.Cli_Nombre      = "";
                            c.Cli_RazonSocial = form["txt_NomCli"].ToString();
                        }
                        c.Cli_FechaNacimiento     = Convert.ToDateTime(form["txtFecNac"]);
                        c.Cli_LugarNacimiento     = form["txt_LugNac"].ToString();
                        c.Cli_Numero_Documento    = form["txt_NumDocumento"].ToString();
                        c.Cli_Telefono_Referencia = form["txt_TelRef"].ToString();
                        c.Cli_Correo          = form["txt_Cor"].ToString();
                        c.Cli_UsuarioRegistro = userRegistro;


                        entTelefono t = new entTelefono();
                        t.Tel_Numero    = form["txt_Telefono"].ToString();
                        t.Tel_Direccion = form["txt_Direccion"].ToString();


                        entCliente_Telefono ct = new entCliente_Telefono();
                        ct.Cliente  = c;
                        ct.Telefono = t;
                        ct.AsiUsu   = AsiUsu;
                        ct.CliTel_UsuarioRegistro = userRegistro;

                        entPedido p = new entPedido();
                        p.Ped_Cod_Experto     = form["txt_CodExperto"].ToString();
                        p.Ped_Dir_Inst        = form["txt_Direccion"].ToString();
                        p.Ped_Observaciones   = form["txtobserva"].ToString();
                        p.Ped_UsuarioRegistro = userRegistro;

                        entUsuario ur = new entUsuario();
                        ur.Usu_Id = user.Usu_Id;

                        entAccionComercial ac = new entAccionComercial();
                        ac.Acc_Id = Convert.ToInt32(form["idAccCom"]);

                        entProducto pro = new entProducto();
                        pro.Pro_ID = Convert.ToInt32(form["Prod"]);

                        entDepartamento d = new entDepartamento();
                        d.idDepa = Convert.ToInt32(form["depto"]);

                        entProvincia prov = new entProvincia();
                        prov.idProv = Convert.ToInt32(form["provin"]);

                        entDistrito dis = new entDistrito();
                        dis.idDist = Convert.ToInt32(form["distrit"]);

                        p.Distrito        = dis;
                        p.Provincia       = prov;
                        p.Departamento    = d;
                        p.Producto        = pro;
                        p.AccionComercial = ac;
                        p.Usuario         = ur;
                        p.ClienteTelefono = ct;



                        int i = negPedido.Instancia.InsUpdPedido(p, 1);
                        if (i > 0)
                        {
                            return(RedirectToAction("RegistroLlamada", "AsesorVentasCall", new { mensaje = "Se Inserto Satisfactoriamente", identificador = 3, AsiLlaId = AsiUsu }));
                        }
                        else
                        {
                            return(RedirectToAction("RegistroLlamada", "AsesorVentasCall", new { mensaje = "Problemas al Insertar", identificador = 2, AsiLlaId = AsiUsu }));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Inicio"));
                    }
                }
            }
            catch (ApplicationException x)
            {
                ViewBag.mensaje = x.Message;
                return(RedirectToAction("RegistroLlamada", "AsesorVentasCall", new { mensaje = x.Message, identificador = 1, AsiLlaId = AsiUsu }));
            }
            catch (Exception e)
            {
                return(RedirectToAction("RegistroLlamada", "AsesorVentasCall", new { mensaje = e.Message, identificador = 2, AsiLlaId = AsiUsu }));
            }
        }