Пример #1
0
        private static ResultadoTransaccion SaveFollowups(IList<clsClienteFollowUp> followDatabase, ClsLlamadaTelefonica ObjLlamada)
        {
            foreach (var followUp in ObjLlamada.FollowUps) {
                if (followUp.IsNew)
                    resTransaccion = Clientes.clsClienteMasterADO.AgregarFollowUpClienteMaster(followUp, transaction);
                else
                    resTransaccion = Clientes.clsClienteMasterADO.ModificarFollowUpClienteMaster(followUp, transaction);

                if (resTransaccion.Estado == Enums.EstadoTransaccion.Rechazada)
                    throw new Exception(resTransaccion.Descripcion);
            }

            if (!ObjLlamada.IsNew) {
                var newlist = ObjLlamada.FollowUps.ToList();
                foreach (var followUp in followDatabase) {
                    var encontrado = newlist.Find(foo => foo.Id32.Equals(followUp.Id32));
                    if (encontrado == null) {
                        resTransaccion = Clientes.clsClienteMasterADO.EliminarLogicoFollowUpClienteMaster(followUp, transaction);
                        if (resTransaccion.Estado == Enums.EstadoTransaccion.Rechazada)
                            throw new Exception(resTransaccion.Descripcion);
                    }
                }
            }
            return resTransaccion;
        }
Пример #2
0
        public static ResultadoTransaccion GuardaLlamada(ClsLlamadaTelefonica ObjLlamada)
        {
            var followDatabase = Clientes.clsClienteMasterADO.ObtenerFollowUpClientePorLlamada(ObjLlamada.Id32);

            resTransaccion = new ResultadoTransaccion();
            try
            {
                //Abrir Conexion
                conn = BaseDatos.Conexion();

                //Crear Transaccion
                transaction = conn.BeginTransaction();

                //Registrar Llamada Telefonica
                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_N_VENTAS_LLAMADA");
                objParams[0].Value = ObjLlamada.Codigo;
                objParams[1].Value = ObjLlamada.FechaHora  ;
                objParams[2].Value = ObjLlamada.Descripcion ;
                objParams[3].Value = ObjLlamada.ObjContacto.Id;
                objParams[4].Value = ObjLlamada.ObjUsuario.Id;
                objParams[5].Value = ObjLlamada.ObjVendedor.Id;
                objParams[6].Value = ObjLlamada.ObjCustomer.Id;
                objParams[7].Value = ObjLlamada.EntradaSalida;
                objParams[8].Value = ObjLlamada.Importancia;
                objParams[9].Value = ObjLlamada.ObjTipoProducto.Id;

                SqlCommand command = new SqlCommand("SP_N_VENTAS_LLAMADA", conn);
                command.Transaction = transaction;
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                ObjLlamada.Id32= Convert.ToInt32(command.ExecuteScalar());

                foreach (var followup in ObjLlamada.FollowUps)
                    followup.IdLlamadaTelefonica = ObjLlamada.Id32;

                resTransaccion = SaveFollowups(followDatabase, ObjLlamada);

                //Ejecutar transaccion
                transaction.Commit();
                resTransaccion.Estado = Enums.EstadoTransaccion.Aceptada;
                resTransaccion.Descripcion = "Se registró Llamada Telefónica Exitosamente";

                if (resTransaccion.Estado == Enums.EstadoTransaccion.Rechazada)
                    throw new Exception(resTransaccion.Descripcion);

            }
            catch (Exception ex)
            {
                transaction.Rollback();
                Log.EscribirLog(ex.Message);

                resTransaccion.Descripcion = ex.Message;
                resTransaccion.ArchivoError = "clsLlamadaTelefonica.cs";
                resTransaccion.MetodoError = "GuardaLlamada";
                resTransaccion.Estado = Enums.EstadoTransaccion.Rechazada ;

            }
            finally
            {

                conn.Close();

            }
            return resTransaccion;
        }
Пример #3
0
        public static ResultadoTransaccion ListarLlamadas(DateTime FechaInicio, DateTime FechaTermino, long IdContacto, long IdClienteMaster, long IdUsuario, int TipoSelect)
        {
            string[] l = null;
            if (System.Configuration.ConfigurationSettings.AppSettings.Get("Administrador") != null)
                l = System.Configuration.ConfigurationSettings.AppSettings.Get("Administrador").Split(',');

            ResultadoTransaccion res = new ResultadoTransaccion();
            IList<ClsLlamadaTelefonica> ListaLlamadas = new List<ClsLlamadaTelefonica>();
            try
            {
                //Abrir Conexion
                conn = BaseDatos.Conexion();

                //Consultar Asuntos x Tipo Actividad
                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "sp_c_ventas_llamadas_telefonicas");
                objParams[0].Value = FechaInicio;
                objParams[1].Value = FechaTermino;
                objParams[2].Value = IdContacto;
                objParams[3].Value = IdClienteMaster;
                objParams[4].Value = IdUsuario;
                objParams[5].Value = TipoSelect;

                SqlCommand command = new SqlCommand("sp_c_ventas_llamadas_telefonicas", conn);

                command.Transaction = transaction;
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                dreader = command.ExecuteReader();

                while (dreader.Read())
                {
                    ClsLlamadaTelefonica ObjLlamadaTelefonica = new ClsLlamadaTelefonica();

                    ObjLlamadaTelefonica.Id = Convert.ToInt32(dreader[0]);
                    ObjLlamadaTelefonica.Codigo = dreader[1].ToString();
                    ObjLlamadaTelefonica.FechaHora = Convert.ToDateTime(dreader[2]);
                    ObjLlamadaTelefonica.Descripcion = dreader[3].ToString();

                    ObjLlamadaTelefonica.ObjContacto = new clsContacto();

                    ObjLlamadaTelefonica.ObjContacto.Id = Convert.ToInt16(dreader[4]);
                    ObjLlamadaTelefonica.ObjContacto.Nombre = dreader[5].ToString();

                    ObjLlamadaTelefonica.ObjContacto.ClienteMaster = new clsClienteMaster(true);
                    ObjLlamadaTelefonica.ObjContacto.ClienteMaster.Id = Convert.ToInt16(dreader[7]);
                    ObjLlamadaTelefonica.ObjContacto.ClienteMaster.Nombres = dreader[6].ToString();

                    ObjLlamadaTelefonica.ObjUsuario = new clsUsuario();

                    ObjLlamadaTelefonica.ObjUsuario.Nombre = dreader[10].ToString();
                    ObjLlamadaTelefonica.ObjUsuario.Id = Convert.ToInt16(dreader[11]);

                    ObjLlamadaTelefonica.ObjVendedor = new clsUsuario();

                    ObjLlamadaTelefonica.ObjVendedor.Nombre = dreader[8].ToString();
                    if (dreader[12] != null && dreader[12].ToString() != "")
                    {
                        ObjLlamadaTelefonica.ObjVendedor.Id = Convert.ToInt16(dreader[12]);
                    }
                    else
                    {
                        ObjLlamadaTelefonica.ObjVendedor.Id = 0;
                    }

                    ObjLlamadaTelefonica.ObjCustomer = new clsUsuario();

                    ObjLlamadaTelefonica.ObjCustomer.Nombre = dreader[9].ToString();
                    if (dreader[13] != null && dreader[13].ToString() != "")
                    {
                        ObjLlamadaTelefonica.ObjCustomer.Id = Convert.ToInt16(dreader[13]);
                    }
                    else
                    {
                        ObjLlamadaTelefonica.ObjCustomer.Id = 0;
                    }
                    ObjLlamadaTelefonica.EntradaSalida = dreader[14].ToString();
                    ObjLlamadaTelefonica.Importancia = dreader[15].ToString();

                    if (dreader[16] != null && dreader[16].ToString() != "")
                    {
                        ObjLlamadaTelefonica.ObjTipoProducto = new clsTipoProducto();
                        ObjLlamadaTelefonica.ObjTipoProducto.Id = Convert.ToInt32(dreader[16]);
                        ObjLlamadaTelefonica.ObjTipoProducto.Nombre = dreader[17].ToString();
                    }

            if (l != null)
            {
                var super = l.Select(s => Convert.ToInt64(s)).ToList();

                    if (ObjLlamadaTelefonica.ObjUsuario.Id.Equals(Base.Usuario.UsuarioConectado.Usuario.Id)
                        || ObjLlamadaTelefonica.ObjVendedor.Id.Equals(Base.Usuario.UsuarioConectado.Usuario.Id)
                        || super.Contains(Base.Usuario.UsuarioConectado.Usuario.Id))
                    {
                        ListaLlamadas.Add(ObjLlamadaTelefonica);
                    }
                    else
                    {
                        ObjLlamadaTelefonica.Descripcion = "";
                        ListaLlamadas.Add(ObjLlamadaTelefonica);
                    }
                }
                res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar;
                res.ObjetoTransaccion = ListaLlamadas;
                }
            }
            catch (Exception ex)
            {
                Log.EscribirLog(ex.Message);

                res.Descripcion = ex.Message;
                res.ArchivoError = "clsLlamadaTelefonicaAdo.cs";
                res.MetodoError = "Listar Llamadas";
            }
            finally
            {
                conn.Close();
            }
            return res;
        }
Пример #4
0
        public static ResultadoTransaccion ListarLlamadasRecientes(long IdCliente)
        {
            ResultadoTransaccion res = new ResultadoTransaccion();
            IList<ClsLlamadaTelefonica> ListaLlamadas = new List<ClsLlamadaTelefonica>();
            try
            {
                //Abrir Conexion
                conn = BaseDatos.Conexion();

                //Consultar Asuntos x Tipo Actividad
                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "sp_c_ventas_llamadas_telefonicas_recientes");
                objParams[0].Value = IdCliente;

                SqlCommand command = new SqlCommand("sp_c_ventas_llamadas_telefonicas_recientes", conn);

                command.Transaction = transaction;
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                dreader = command.ExecuteReader();

                while (dreader.Read())
                {
                    ClsLlamadaTelefonica ObjLlamadaTelefonica = new ClsLlamadaTelefonica();

                    ObjLlamadaTelefonica.FechaHora = Convert.ToDateTime(dreader[0]);
                    ObjLlamadaTelefonica.Descripcion = dreader[1].ToString();

                    ObjLlamadaTelefonica.ObjContacto = new clsContacto();

                    ObjLlamadaTelefonica.ObjContacto.Nombre = dreader[2].ToString();

                    ObjLlamadaTelefonica.ObjUsuario = new clsUsuario();

                    ObjLlamadaTelefonica.ObjUsuario.Nombre = dreader[3].ToString();

                    ListaLlamadas.Add(ObjLlamadaTelefonica);
                }
                res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar;
                res.ObjetoTransaccion = ListaLlamadas;
            }
            catch (Exception ex)
            {
                Log.EscribirLog(ex.Message);

                res.Descripcion = ex.Message;
                res.ArchivoError = "clsLlamadaTelefonicaAdo.cs";
                res.MetodoError = "Listar Llamadas Recientes";
            }
            finally
            {
                conn.Close();
            }
            return res;
        }
Пример #5
0
 private void MenuSalir_Click(object sender, EventArgs e)
 {
     ObjLlamadaTelefonica = null;
     Instancia = null;
     this.Close();
 }
Пример #6
0
        private ClsLlamadaTelefonica LlenarEntidadLlamada()
        {
            string TextoCliente = "";
            string TextoContacto = "";
            string TextoTipoProducto = "";

            ClsLlamadaTelefonica ObjLlamada = new ClsLlamadaTelefonica();
            ObjLlamada.ObjVendedor = new clsUsuario();
            ObjLlamada.ObjUsuario = new clsUsuario();
            ObjLlamada.ObjCustomer = new clsUsuario();
            ObjLlamada.ObjTipoProducto = new clsTipoProducto();

            if (ObjLlamadaTelefonica != null)
            {
                ObjLlamada.Id = ObjLlamadaTelefonica.Id;
                ObjLlamada.Codigo = ObjLlamadaTelefonica.Codigo;
            }
            else
            {
                ObjLlamada.Id = 0;
                ObjLlamada.Codigo = "CodPrueba";
            }

            ObjLlamada.Descripcion = this.TxtDescription.Text;
            ObjLlamada.FechaHora = this.DtFechaHora.DateTime;
            //TextoContacto = this.CboContactos.Text;
            //Utils.Utils.SincronizaComboGlosa(CboContactos, TextoContacto);
            ObjLlamada.ObjContacto = (clsContacto)CboContactos.SelectedItem;
            TextoTipoProducto = this.comboBoxTipoProducto.Text;
            if (TextoTipoProducto.Trim() != "" && comboBoxTipoProducto.SelectedIndex > 0)
            {
                //Utils.Utils.SincronizaComboGlosa(this.comboBoxTipoProducto, TextoTipoProducto);
                ObjLlamada.ObjTipoProducto = (clsTipoProducto)comboBoxTipoProducto.SelectedItem;
            }
            else
            {
                ObjLlamada.ObjTipoProducto.Id = -1;
            }
            ObjLlamada.ObjVendedor.Id = 1;
            ObjLlamada.ObjUsuario.Id = IdUsuario;
            ObjLlamada.ObjCustomer.Id = 1;

            if (this.radioButtonEntrante.Checked == true)
            {
                ObjLlamada.EntradaSalida = "E";
            }
            else
            {
                ObjLlamada.EntradaSalida = "S";
            }

            if ((this.checkBoxImportancia.CheckState == CheckState.Checked))
            {
                ObjLlamada.Importancia = "A";
            }
            else
            {
                ObjLlamada.Importancia = "B";
            }

            ObjLlamada.FollowUps = ObtieneFollowUpsDesdeGrilla();

            foreach (var followup in ObjLlamada.FollowUps)
            {
                followup.IdInformeVisita = followup.IdTarget = -1;
                followup.IdLlamadaTelefonica = ObjLlamada.Id;
                followup.FechaCreacion = DateTime.Now;
                followup.Usuario = Base.Usuario.UsuarioConectado.Usuario;
                followup.Cliente = ObjLlamada.ObjContacto.ClienteMaster;
            }
            return ObjLlamada;
        }
Пример #7
0
 private void FrmLlamadaTelefonica_FormClosed(object sender, FormClosedEventArgs e)
 {
     ObjLlamadaTelefonica = null;
     Instancia = null;
 }
Пример #8
0
 public static ResultadoTransaccion ModificarLlamadaTelefonica(ClsLlamadaTelefonica ObjLlamada)
 {
     return clsLlamadaTelefonicaAdo.ModificarLlamada(ObjLlamada);
 }
Пример #9
0
 public static ResultadoTransaccion GuardaLlamadaTelefonica(ClsLlamadaTelefonica ObjLlamada)
 {
     return clsLlamadaTelefonicaAdo.GuardaLlamada(ObjLlamada);
 }