14 Scala 实现客户信息管理系统

客户信息管理系统

1. AppStart

package com.guli.chapter15.app

import com.guli.chapter15.customerView.CustomerView

object AppStart {
  def main(args: Array[String]): Unit = {
    (new CustomerView).meau()
  }
}

2. CustomerView

package com.guli.chapter15.customerView

import com.guli.chapter15.customerService.CustomerService

import scala.io.StdIn

class CustomerView {
  var customerService = new CustomerService()

  def meau(): Unit = {
    var flag = true
    do {
      println("-----------------客户信息管理软件-----------------")
      println("                  1 添 加 客 户                  ")
      println("                  2 修 改 客 户                  ")
      println("                  3 删 除 客 户                  ")
      println("                  4 客 户 列 表                  ")
      println("                  5 查 询 客 户                   ")
      println("                  6 退      出                  ")
      println("请选择(1-6):                  ")

      var num = StdIn.readInt()

      num match {
        case 1 => addClient()
        case 2 => updateCli()
        case 3 => deleteCli()
        case 4 => showList()
        case 5 => searchCli()
        case 6 => exitApp()
      }
    } while (flag)

    // 退出程序
    def exitApp(): Unit = {
      print("确认是否退出Y/N:")
      val r = StdIn.readLine()
      if (r.equals("Y") || r.equals("y")) {
        flag = false
        println("成功退出程序!Bye~~")
      }
    }
  }

  // 显示客户列表
  def showList(): Unit = {
    println("编号\t\t" + "姓名\t\t" + "性别\t\t" + "年龄\t\t" + "电话\t\t" + "邮箱")
    customerService.showList(customerService.customers)
  }

  // 添加客户
  def addClient(): Unit = {
    customerService.addClient()
  }

  // 删除客户
  def deleteCli() {
    print("请输入要删除的客户编号(-1退出):")
    val id = StdIn.readInt()
    if (id == -1) {
      return
    }
    val index = customerService.findIndexById(id)
    if (index != -1) {
      print("确认是否删除Y/N:")
      val r = StdIn.readLine()
      if (r.equals("Y") || r.equals("y")) {
        customerService.deleteCli(index)
        println("删除成功!")
        return
      }
    }
    println("删除失败!")
  }

  // 修改客户信息
  def updateCli(): Unit = {
    print("请输入要修改的客户的编号:")
    val id = StdIn.readInt()
    val index = customerService.findIndexById(id)
    if (index == -1) {
      print("查无此人!")
      return
    }
    customerService.updateCli(index)
  }

  // 查询客户
  def searchCli(): Unit = {
    print("请选择查询方式(1:根据id , 2:根据名字)")
    val way = StdIn.readInt()
    customerService.serchCli(way)
  }

}

3. CustomerService

package com.guli.chapter15.customerService

import com.guli.chapter15.customer.Customer

import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

class CustomerService {
  var customers = new ListBuffer[Customer]()
  var id = 0
  // customers.append(new Customer(1,"zgl",'男',23,"180","zgl@163.com"))

  // 显示客户列表
  def showList(customers: ListBuffer[Customer]): Unit = {
    for (item <- customers) {
      println(item)
    }
  }

  // 添加客户
  def addClient(): Unit = {
    id += 1
    print("请输入客户姓名:")
    val name = StdIn.readLine()
    print("请输入客户性别:")
    val sex = StdIn.readChar()
    print("请输入客户年龄:")
    val age = StdIn.readShort()
    print("请输入客户电话:")
    val tel = StdIn.readLine()
    print("请输入客户邮箱:")
    val mail = StdIn.readLine()
    customers.append(new Customer(id, name, sex, age, tel, mail))
  }

  // 查找客户
  def findIndexById(id: Int): Int = {
    var index = 0
    for (item <- customers) {
      if (item.id == id) return index
    }
    -1
  }

  // 删除客户
  def deleteCli(index: Int): Unit = {
    customers.remove(index)
  }

  // 修改客户信息
  def updateCli(index: Int) {

    val cus = customers(index)
    print(s"姓名(${cus.name}):")
    val name = StdIn.readLine()
    if (name != "") cus.name = name

    print(s"性别(${cus.sex}):")
    val sex = StdIn.readLine()
    if (sex != "") cus.sex = sex.toCharArray()(0)

    print(s"年龄(${cus.age}):")
    val age = StdIn.readLine()
    if (age != "") cus.age = age.toShort

    print(s"电话(${cus.tel}):")
    val tel = StdIn.readLine()
    if (tel != "") cus.tel = tel

    print(s"邮箱(${cus.mail}):")
    val mail = StdIn.readLine()
    if (mail != "") cus.mail = mail

    customers.update(index, cus)
    println("修改成功!")
  }

  // 查询客户
  def serchCli(way: Int) {
    // 根据id查询
    if (way == 1) {
      print("请输入id:")
      val id = StdIn.readInt()
      for (item <- customers) {
        if (item.id == id) {
          println("编号\t\t" + "姓名\t\t" + "性别\t\t" + "年龄\t\t" + "电话\t\t" + "邮箱")
          println(item)
        }
      }
    } else if (way == 2) {
      // 根据姓名查询
      print("请输入名字:")
      val name = StdIn.readLine()
      for (item <- customers) {
        if (item.name.contains(name)) {
          println("编号\t\t" + "姓名\t\t" + "性别\t\t" + "年龄\t\t" + "电话\t\t" + "邮箱")
          println(item)
        }
      }
    }
    else {
      println("输入有误!")
    }

  }
}

4. Customer

package com.guli.chapter15.customer

class Customer {
  var id: Int = _
  var name: String = _
  var sex: Char = _
  var age: Short = _
  var tel: String = _
  var mail: String = _

  def this(id: Int, name: String, sex: Char, age: Short, tel: String, mail: String) {
    this
    this.id = id
    this.name = name
    this.sex = sex
    this.age = age
    this.tel = tel
    this.mail = mail
  }

  override def toString: String = {
    this.id + "\t\t" + this.name + "\t\t" + this.sex + "\t\t" + this.age + "\t\t" + this.tel + "\t\t" + this.mail
  }

}
源海客户信息管理软件(Yuanhi CIM)是源海客户关系管理系统简易篇,适用于个人用户及各类小型企业业主及营销人员使用,属于CRM、营销、办公管理类软件。 软件主要特点: 1、电脑记录并管理电话、传真、邮件、互联网络等现代网络营销手段;分类记录各项目客户沟通的记录数据。 2、方便灵活的查询、索引、数据过滤及导入数据到EXCEL,输入数据重复时自动提示所有相同信息资料。 3、三重数据安全处理,设计了权限管理、数据备份、数据加密功能,使数据得到了有效的保密和预防丢失。 4、多功能群发邮件及退订邮件功能,对正式邮件、临时邮件、导入邮件地址进行有针对性多功能分类邮件群发。 5、客户计划、事件提醒功能,可同时进行音乐和文字提醒。 6、免费在线软件自动下载升级包升级。 软件分为五大部分:系统管理、基础数据、客户信息管理、客户沟通管理、辅助功能 系统管理:主要使用对象为系统管理员;主要功能模块:软件注册,软件升级,权限分配,数据备份、修复、邮箱配置、系统选项配置等; 基础数据:主要使用对象为产品管理人员、业务员等;主要功能模块:客户基础资料、客户接触方式、公司信息、员工信息等 客户信息管理:客户信息输入、删除、修改、查询、打印、过滤、数据导入到EXCEL及简便客户邮件等 客户沟通管理:主要功能模块:客户需求、客户投诉、客户联系、客户联系、客户定单记录、邮件群发及邮件退订等; 辅助功能:主要使用对象为本软件的使用人员,它包括工具和帮助两部分,功能是方便使用人员计算、事务音乐提醒,帮助使用人员充分掌握和运用本软件的所有功能。 服务:sale@yuanhi.net
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值