修改员工信息

作者:李坤凤
本次任务完成时间:2019年6月16日
开发工具与关键技术:开发工具:VS 关键技术: 修改员工信息

一、 修改存储过程语句
1、 修改存储语句,编写存储语句,修改一条数据信息;
在这里插入图片描述
2、定义传递参数,传递参数的类型,在存储过程中就定义好了,给参数类型赋值,
3、在服务端写服务契约,然后执行服务端,到客户端引用服务或者更新服务;
在这里插入图片描述
4、在客户端这边写修改保存按钮的功能,获取页面一条数据点击修改按钮,数据回填到修改页面,修改数据,如已有的账号不能重复,否则会账号重复,不能修改,账号不重复,则修改成功,使用if…else语句判断修改信息数据没有填写完整点击保存,则会显示数据没有填写完整,需要填写完整才可以保存,

private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //1、判断页面数据 if (cbo_Name.SelectedValue.ToString() != "" && txt_Account.Text.Trim() != "" && PB_Password.Password.Trim() != "")
                {
                    //获取页面数据是否为空
                    //获取页面数据
                    int intID = Convert.ToInt32(cbo_Name.SelectedValue);//员工ID
                    string strAccounts = txt_Account.Text.Trim();
                    string strPassword = PB_Password.Password.Trim();
                    bool blEffective = (bool)chk_Effect.IsChecked;
                    string strNote = txt_Note.Text.Trim();
                    int intOperatorId = Convert.ToInt32(DRV.Row["operator_id"]);//操作ID
                    //3、执行新增
                    int intCount = myClient.btn_Save_Click_UpdateStaffAccountManage(intID, strAccounts, strPassword, blEffective, strNote, intOperatorId);
                  if (intCount > 0) //4、提示
                    {
                        MessageBoxResult dr = MessageBox.Show("账号修改成功!", "系统提示", MessageBoxButton.OKCancel,
                            MessageBoxImage.Asterisk);//弹出确定对话框
                        if (dr == MessageBoxResult.OK)//如果点了确定按钮
                        {//关闭窗口
                            this.Close();
                        }
                    }
                    else if (intCount == -1)
                    {
                        MessageBox.Show("账号重复,不能修改!", "系统提示", MessageBoxButton.OKCancel,
                            MessageBoxImage.Exclamation);//弹出确定对话框
                    }
                }
                else
                {
                    MessageBox.Show("请把页面数据填写完整!", "系统提示", MessageBoxButton.OK,
                        MessageBoxImage.Warning);//弹出确定对话框
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个修改员工信息的Java示例代码: ```java import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Employee { private String name; private String address; private int age; private double salary; public Employee(String name, String address, int age, double salary) { this.name = name; this.address = address; this.age = age; this.salary = salary; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } public String toString() { return "Name: " + name + ", Address: " + address + ", Age: " + age + ", Salary: " + salary; } public static void main(String[] args) { List<Employee> employees = new ArrayList<>(); employees.add(new Employee("John Doe", "123 Main St.", 35, 50000)); employees.add(new Employee("Jane Smith", "456 Oak St.", 28, 40000)); Scanner input = new Scanner(System.in); System.out.print("Enter the name of the employee you want to modify: "); String name = input.nextLine(); for (Employee employee : employees) { if (employee.getName().equalsIgnoreCase(name)) { System.out.println("Current information: " + employee.toString()); System.out.print("Enter the new address: "); String address = input.nextLine(); employee.setAddress(address); System.out.print("Enter the new age: "); int age = input.nextInt(); employee.setAge(age); System.out.print("Enter the new salary: "); double salary = input.nextDouble(); employee.setSalary(salary); System.out.println("Updated information: " + employee.toString()); } } } } ``` 这个示例代码创建了一个 `Employee` 类来表示员工信息。在 `main` 方法中,它首先创建了两个初始员工,然后要求用户输入要修改员工的姓名。然后,它遍历员工列表,找到匹配的员工,并要求用户输入新的地址、年龄和薪水。最后,它打印出更新后的员工信息

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值