Esempio n. 1
0
        public List <entTipDoc> ListaTipDoc()
        {
            SqlCommand       cmd   = null;
            SqlDataReader    dr    = null;
            List <entTipDoc> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListaDocumentos", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entTipDoc>();
                while (dr.Read())
                {
                    entTipDoc d = new entTipDoc();
                    d.td_id          = Convert.ToInt32(dr["td_id"]);
                    d.td_nombre      = dr["td_nombre"].ToString();
                    d.td_Descripcion = dr["td_Descripcion"].ToString();
                    Lista.Add(d);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
Esempio n. 2
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 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 }));
            }
        }
Esempio n. 5
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 }));
            }
        }
Esempio n. 6
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 }));
            }
        }