Esempio n. 1
0
        public static ResultadoTransaccion ActualizarTipoProducto(clsClientesProductos producto, SqlTransaction transaccion, SqlConnection conection)
        {
            resTransaccion = new ResultadoTransaccion();
            try {
                objParams = SqlHelperParameterCache.GetSpParameterSet(conection, "SP_A_CLIENTES_PRODUCTO_PREFERIDO");
                objParams[0].Value = producto.Producto.Id;
                objParams[1].Value = producto.Customer.Id;
                objParams[2].Value = producto.Id;

                SqlCommand command = new SqlCommand("SP_A_CLIENTES_PRODUCTO_PREFERIDO", conection);
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                command.Transaction = transaccion;
                command.ExecuteNonQuery();

                resTransaccion.Estado = Enums.EstadoTransaccion.Aceptada;

            } catch (Exception ex) {
                Base.Log.Log.EscribirLog(ex.Message);
                resTransaccion.Descripcion = ex.Message;
                resTransaccion.MetodoError = MethodBase.GetCurrentMethod().Name;
                resTransaccion.ArchivoError = MethodBase.GetCurrentMethod().ToString();
                resTransaccion.Estado = Entidades.Enums.Enums.EstadoTransaccion.Rechazada;
            } finally {
                //conn.Close();
            }
            return resTransaccion;
        }
Esempio n. 2
0
        public static IList<clsClientesProductos> ObtenerProductosPreferidos(Int64 IdCiente)
        {
            clsClientesProductos producto = null;
            IList<clsClientesProductos> listProductos = new List<clsClientesProductos>();
            SqlDataReader dreaderProd = null;
            try {
                //Abrir Conexion
                conn = BaseDatos.NuevaConexion();

                objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_C_CLIENTES_PRODUCTOS_PREFERIDOS");
                objParams[0].Value = IdCiente;

                DataSet ds = SqlHelper.ExecuteDataset(conn, "SP_C_CLIENTES_PRODUCTOS_PREFERIDOS", objParams);
                if (ds != null) {
                    foreach (DataRow row in ds.Tables[0].Rows) {
                        producto = new clsClientesProductos();
                        producto.Producto.Id = Convert.ToInt64(row["IdTipoCarga"]);
                        producto.Producto.Nombre = row["Descripcion"].ToString();
                        producto.Producto.Activo = row["Activo"].ToString();
                        producto.Id = Convert.ToInt64(row["Id"]);

                        if (!(row["Nombres"] is DBNull)) {
                            producto.Customer.Id = Convert.ToInt64(row["IdCliente"]);
                            producto.Customer.Nombre = row["Nombres"].ToString();
                            producto.Customer.ApellidoPaterno = row["ApellidoPaterno"].ToString();
                            producto.Customer.ApellidoMaterno = row["ApellidoMaterno"].ToString();
                            producto.Customer.Email = row["Email"].ToString();
                        }

                        listProductos.Add(producto);
                    }
                }

                //SqlCommand command = new SqlCommand("SP_C_CLIENTES_PRODUCTOS_PREFERIDOS", conn);
                //command.Parameters.AddRange(objParams);
                //command.CommandType = CommandType.StoredProcedure;
                //dreaderProd = command.ExecuteReader();

                //while (dreaderProd.Read())
                //{
                //    producto = new clsClientesProductos();
                //    producto.Producto.Id = Convert.ToInt64(dreaderProd["IdTipoCarga"]);
                //    producto.Producto.Nombre = dreaderProd["Descripcion"].ToString();
                //    producto.Producto.Activo = dreaderProd["Activo"].ToString();
                //    producto.Id = Convert.ToInt64(dreaderProd["Id"]);

                //    if (!(dreaderProd["IdCustomer"] is DBNull))
                //    {
                //        producto.Customer = Usuarios.clsUsuarioADO.ObtenerUsuarioPorId(
                //                Convert.ToInt16(dreaderProd["IdCustomer"].ToString()));
                //    }

                //    listProductos.Add(producto);
                //}

            } catch (Exception ex) {
                Base.Log.Log.EscribirLog(ex.Message);
                resTransaccion.MetodoError = MethodBase.GetCurrentMethod().Name;
                resTransaccion.ArchivoError = MethodBase.GetCurrentMethod().ToString();
            } finally {
                conn.Close();
            }

            return listProductos;
        }
Esempio n. 3
0
        private static clsClientesProductos GetProducto(IDataReader dataReader)
        {
            try {
                var row = dataReader;
                if ((row["IdTipoCarga"] is DBNull))
                    return null;

                var producto = new clsClientesProductos();
                producto.Producto.Id = Convert.ToInt64(row["IdTipoCarga"]);
                producto.Producto.Nombre = row["Descripcion"].ToString();
                producto.Producto.Activo = row["Activo"].ToString();
                producto.Id = Convert.ToInt64(row["Id"]);

                if (!(row["u_Nombres"] is DBNull)) {
                    producto.Customer.Id = Convert.ToInt64(row["IdCliente"]);
                    producto.Customer.Nombre = row["u_Nombres"].ToString();
                    producto.Customer.ApellidoPaterno = row["u_ApellidoPaterno"].ToString();
                    producto.Customer.ApellidoMaterno = row["u_ApellidoMaterno"].ToString();
                    producto.Customer.Email = row["Email"].ToString();
                }

                return producto;
            } catch (Exception e) {
                Console.Write(e.Message);
                return null;
            }
        }
Esempio n. 4
0
        private void VistaADominioPaso3()
        {
            //Paso 3
                    foreach (clsTipoProducto producto in lstProductos.CheckedItems)
                    {
                        clsClientesProductos productoMaster = new clsClientesProductos();
                        productoMaster.Customer.Id = -1;
                        productoMaster.Producto = producto;
                        TargetAccount.ClienteMaster.ProductosPreferidos = new List<clsClientesProductos>();
                        TargetAccount.ClienteMaster.ProductosPreferidos.Add(productoMaster);
                    }

                    TargetAccount.ServiciosComplementarios = new List<clsTipoServicioComplementario>();
                    foreach (clsTipoServicioComplementario servicio in lstServiciosComplementarios.CheckedItems)
                    {
                        TargetAccount.ServiciosComplementarios.Add(servicio);
                    }

                    TargetAccount.Objeciones = new List<clsTipoObjeciones>();
                    foreach (clsTipoObjeciones objecion in lstObjeciones.CheckedItems)
                    {
                        TargetAccount.Objeciones.Add(objecion);
                    }

                    TargetAccount.AccionTomar = new clsTipoAccionesTomar();

                    TargetAccount.AccionTomar.IdTargetAccount = TargetAccount.Id;
                        TargetAccount.AccionTomar.QueNecesita = txtQueNecesita.Text.Trim();

                        if (txtProximaOrgen.Text.Trim().Length.Equals(0))
                            TargetAccount.AccionTomar.ProximaOrden = new DateTime(9999,1,1);
                        else
                            TargetAccount.AccionTomar.ProximaOrden = txtProximaOrgen.DateTime;

                        TargetAccount.AccionTomar.ComoComunicara = txtComoComunicara.Text.Trim();

                    //foreach (clsTipoAccionesTomar accion in lstAccionesATomar.CheckedItems)
                    //{
                    //    TargetAccount.AccionesTomar.Add(accion);
                    //}

                    TargetAccount.ObservacionVisita = txtObservacionVisita.Text;

                        TargetAccount.Estado = Enums.EstadosMetas.Visita;
        }
Esempio n. 5
0
        private void LlenarEntidadTarget()
        {
            clsTarget Target = this.TargetActual;

            try
            {
                Target.Id = this.IdTarget;
                //Target.ClienteMaster = new clsClienteMaster();
                Target.ClienteMaster.Id = this.IdMaster;
                Target.ClienteMaster.NombreCompañia= this.txtNombreCompañia.Text.Trim();
                Target.ClienteMaster.Nombres = this.txtNombres.Text.Trim();
                Target.ClienteMaster.ApellidoPaterno = this.txtApellidoPat.Text.Trim();
                Target.ClienteMaster.ApellidoMaterno = this.txtApellidoMat.Text.Trim();
                Target.ClienteMaster.RUT = this.txtRUT.Text.Trim();

                if(Target.ClienteMaster.DireccionInfo != null)
                    if(Target.ClienteMaster.DireccionInfo.Items.Count == 0)
                        Target.ClienteMaster.DireccionInfo = null;

                Target.ClienteMaster.Tipo = Enums.TipoPersona.Target;

                if (cboTipoSaludo.SelectedIndex == 0)
                    Target.TipoSaludo = null;
                else
                    Target.TipoSaludo = (clsItemParametro)this.cboTipoSaludo.SelectedItem;

                Target.Cargo = this.txtCargo.Text.Trim();

                Target.VendedorAsignado = (Entidades.Usuarios.clsUsuario)this.cboVendedores.SelectedItem;

                Target.Telefono = this.txtTelefono.Text.Trim();
                Target.CuentaSkype = this.txtCuentaSkype.Text.Trim();
                Target.SitioWeb = this.txtSitioWeb.Text.Trim();
                Target.Email = this.txtEmail.Text.Trim();
                Target.Estado = Enums.EstadoTarget.Habilitado;
                Target.Observacion = this.txtObservacion.Text.Trim();

                if (cboSecetorEconomico.SelectedIndex == 0)
                    Target.SectorEconomico = null;
                else
                    Target.SectorEconomico =(clsItemParametro)this.cboSecetorEconomico.SelectedItem;

                if (cboMonedaVtaEst.SelectedIndex == 0)
                    Target.TipoMonedaVtaEstimada = null;
                else
                    Target.TipoMonedaVtaEstimada = (Entidades.Tarifado.clsTipoMoneda) this.cboMonedaVtaEst.SelectedItem;

                if(txtMontoVtaEst.Text == "")
                    Target.MontoVentaEstimada = 0;
                else
                    Target.MontoVentaEstimada = Convert.ToDecimal(this.txtMontoVtaEst.Text.Replace(".",""));

                if (txtNumEmpleados.Text == "")
                    Target.NumEmpleados = 0;
                else
                    Target.NumEmpleados = Convert.ToInt64(this.txtNumEmpleados.Text.Replace(".",""));

                if (cboOrigenCliente.SelectedIndex == 0)
                    Target.OrigenCliente = null;
                else
                    Target.OrigenCliente =(clsItemParametro)cboOrigenCliente.SelectedItem;

                if (cboMotivoInteres.SelectedIndex == 0)
                    Target.MotivoInteres = null;
                else
                    Target.MotivoInteres = (clsItemParametro)this.cboMotivoInteres.SelectedItem;

                if (cboNivelInteres.SelectedIndex == 0)
                    Target.NivelInteres = null;
                else
                    Target.NivelInteres = (clsItemParametro) this.cboNivelInteres.SelectedItem;

                if(txtEmpresaTrabaja.Text.Trim() == "")
                {
                    Target.EmpresaConQueTrabaja = null;
                }
                else
                {
                    for (int i = 0; i < cboEmpresaTrabaja.Properties.Items.Count; i++)
                    {
                        if (cboEmpresaTrabaja.Properties.Items[i].ToString() == txtEmpresaTrabaja.Text)
                            cboEmpresaTrabaja.SelectedIndex = i;
                    }

                    if (cboEmpresaTrabaja.SelectedIndex == 0)
                    {
                        Target.EmpresaConQueTrabaja = new clsEmpresaCompetencia(0, txtEmpresaTrabaja.Text);
                    }
                    else
                        Target.EmpresaConQueTrabaja = (clsEmpresaCompetencia)this.cboEmpresaTrabaja.SelectedItem;
                }

                if(txtOrigenCarga.Text.Trim() == "")
                {
                    Target.OrigenCarga = null;
                }
                else
                {
                    for (int i = 0; i < cboOrigenCarga.Properties.Items.Count; i++)
                    {
                        if (cboOrigenCarga.Properties.Items[i].ToString() == txtOrigenCarga.Text)
                            cboOrigenCarga.SelectedIndex = i;
                    }
                    if (cboOrigenCarga.SelectedIndex == 0)
                    {
                        Target.OrigenCarga = new clsOrigenCarga(0, txtOrigenCarga.Text);
                    }
                    else
                        Target.OrigenCarga = (clsOrigenCarga)this.cboOrigenCarga.SelectedItem;
                }

                if (cboFormaContactoPref.SelectedIndex == 0)
                    Target.FormaContactoPreferida = null;
                else
                    Target.FormaContactoPreferida = (clsItemParametro) cboFormaContactoPref.SelectedItem;

                if (this.rgTelefonoOficina.SelectedIndex == 0)
                    Target.PermiteTelOficina = false;
                else
                    Target.PermiteTelOficina = true;

                if(this.rgTelefonoParticular.SelectedIndex == 0)
                    Target.PermiteTelParticular = false;
                else
                    Target.PermiteTelParticular = true;

                if (this.rgTelefonoMovil.SelectedIndex == 0)
                    Target.PermiteTelCelular = false;
                else
                    Target.PermiteTelCelular = true;

                if (rgCuentaSkype.SelectedIndex == 0)
                    Target.PermiteSkype = false;
                else
                    Target.PermiteSkype = true;

                if(this.rgEmail.SelectedIndex == 0)
                    Target.PermiteEmail = false;
                else
                    Target.PermiteEmail = true;

                if (this.rgEmailMasivo.SelectedIndex == 0)
                    Target.PermiteEmailMasivo = false;
                else
                    Target.PermiteEmailMasivo = true;

                if (cboDiaPreferido.SelectedIndex == 0)
                    Target.DiaPreferido = null;
                else
                    Target.DiaPreferido = (clsItemParametro)cboDiaPreferido.SelectedItem;

                if (cboJornadaPreferida.SelectedIndex == 0)
                    Target.JornadaPreferida = null;
                else
                    Target.JornadaPreferida = (clsItemParametro) cboJornadaPreferida.SelectedItem;

                Target.FechaCreacion = DateTime.Now;

                Target.ClienteMaster.ProductosPreferidos = new List<clsClientesProductos>();
                foreach (clsTipoProducto item in lstProductoPreferido.CheckedItems)
                {
                    clsClientesProductos itemCP = new clsClientesProductos();
                    itemCP.Producto = item;
                    Target.ClienteMaster.ProductosPreferidos.Add(itemCP);
                }

                Target.ClienteMaster.TiposRelaciones = new List<clsItemParametro>();
                foreach (clsItemParametro tipo in lstTipoRelacion.CheckedItems)
                {
                    Target.ClienteMaster.TiposRelaciones.Add(tipo);
                }

                this.TargetActual = Target;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Target", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        private void btnAgregarProducto_Click(object sender, EventArgs e)
        {
            dxErrorProvider1.ClearErrors();
                if(cboProductoPreferido.SelectedIndex <= 0)
                {
                    dxErrorProvider1.SetError(cboProductoPreferido, "Seleccione un producto", ErrorType.Critical);
                    return;
                }

                if(txtCustomer.Text == "")
                {
                    dxErrorProvider1.SetError(txtCustomer, "Debe ingresar un customer valido", ErrorType.Critical);
                    return;
                }
                else
                {
                    for (int i = 0; i < cboCustomers.Properties.Items.Count; i++)
                    {
                        if (cboCustomers.Properties.Items[i].ToString().Trim().ToUpper() == txtCustomer.Text.Trim().ToUpper())
                        {
                            cboCustomers.SelectedIndex = i;
                            break;
                        }
                    }

                    if (cboCustomers.SelectedIndex == 0)
                    {
                        return;
                    }
                }

                if(txtIdProductoCust.Text != "0")
                {
                    foreach (var item in CuentaActual.ClienteMaster.ProductosPreferidos)
                    {
                        if(item.Id.ToString() == txtIdProductoCust.Text)
                        {
                            item.Customer = (clsUsuario)cboCustomers.SelectedItem;
                            item.Producto = (clsTipoProducto)cboProductoPreferido.SelectedItem;
                        }
                    }
                }
                else
                {
                    foreach (var item in CuentaActual.ClienteMaster.ProductosPreferidos)
                    {
                        if (item.Producto.Id == ((clsTipoProducto)cboProductoPreferido.SelectedItem).Id && !item.IsDeleted)
                        {
                            dxErrorProvider1.SetError(cboProductoPreferido, "El producto ya existe", ErrorType.Critical);
                            return;
                        }
                    }

                    clsClientesProductos producto = new clsClientesProductos();
                    producto.Customer = (clsUsuario)cboCustomers.SelectedItem;
                    producto.Producto = (clsTipoProducto)cboProductoPreferido.SelectedItem;
                    producto.Id = Convert.ToInt64(txtIdProductoCust.Text);
                    CuentaActual.ClienteMaster.ProductosPreferidos.Add(producto);
                }

                grdProductosPreferidos.DataSource = ProductosCustomerActivos();
                grdProductosPreferidos.RefreshDataSource();

                txtIdProductoCust.Text = "0";
                txtCustomer.Text = "";
                cboCustomers.SelectedIndex = 0;
                cboProductoPreferido.SelectedIndex = 0;
        }