.NET实现工资管理系统
程序员文章站
2024-01-02 16:26:22
本文实例为大家分享了.net实现工资管理系统的具体代码,供大家参考,具体内容如下
using system;
using system.collection...
本文实例为大家分享了.net实现工资管理系统的具体代码,供大家参考,具体内容如下
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace gongzi { class program { static bool flag = true; //工人数 const int num = 3; //定义二维数组 static string[,] gong = new string[num, 5]; static void main(string[] args) { console.title = "工资管理系统"; jiemian(); //菜单界面 login(); //登录界面 while (flag) { caidan(); //菜单界面 } } static void jiemian() { console.clear(); console.writeline("------工资管理系统------"); console.writeline("-----@lijia---2018-4-4-----------"); console.readkey(); } static void login() //登录界面 { console.writeline("请输入用户名:"); string username = console.readline(); console.writeline("请输入密码:"); string password = console.readline(); if (username == "lijia" && password == "123456") { flag = true;//进入菜单界面 } else { console.writeline("对不起,你输入的用户名或者密码错误!请重新输入!"); flag = false; } } static void caidan() { console.clear(); console.writeline("工资管理系统"); console.writeline("1.工资录入"); console.writeline("2.工资查询"); console.writeline("3.工资修改"); console.writeline("4.工资统计"); console.writeline("0.退出系统"); console.writeline("请输入0-3数字:"); string choice = console.readline(); switch (choice) { case "1": console.writeline("工资录入"); inputgongzi(gong,num); console.readkey(); break; case "2": console.writeline("工资查询"); outputgongzi(gong, num); console.readkey(); break; case "3": console.writeline("请输入你需要选择的哪种工资的修改:(1基本工资2奖金)"); string temp = string.empty; int t = convert.toint32(console.readline()); switch (t) { case 1: console.writeline("输入您要修改基本工资在二维数组中所在行数(0-2):"); int t1 = convert.toint32(console.readline()); temp = gong[t1, 2]; gong[t1, 2] = console.readline(); sfgz(); break; case 2: console.writeline("输入您要修改的奖金在二维数组中所在行数(0-2):"); int t2 = convert.toint32(console.readline()); temp = gong[t2, 3]; gong[t2, 3] = console.readline(); sfgz(); break; } break; case "4": double a = convert.todouble(gong[0, 4]); double b = convert.todouble(gong[1, 4]); double c = convert.todouble(gong[2, 4]); if (a > b) { if (a > c) { console.writeline("最高工资:{0}", a); if (b > c) { console.writeline("最低工资:{0}", c); } else { console.writeline("最低工资:{0}", b); } } else { console.writeline("最高工资:{0}", c); } } else {//a<b if (b > c) { console.writeline("最高工资:{0}", b); if (a > c) { console.writeline("最低工资:{0}", c); } else { console.writeline("最低工资:{0}", a); } } else//b<c { console.writeline("最高工资:{0}", c); console.writeline("最低工资:{0}", a); } } double pjzhi = (a + b + c) / 3; console.writeline("工资平均值:{0}", pjzhi); console.readkey(); break; case "0": flag = false; break; } } static void inputgongzi(string[,] gong,int num) { string yuangong = string.empty; string[] tmp; for (int i = 0; i < num; i++) { console.writeline("请输入第{0}个工人的工号、姓名、基本工资、奖金(以空格分割):", i + 1); yuangong = console.readline(); //分割工人信息 tmp = yuangong.split(' '); for (int j = 0; j < tmp.length; j++) { gong[i, j] = tmp[j]; } //计算实发工资 double sodeshui = 0; double sfgz; double jbgz = convert.todouble(gong[i, 2]); double jj = convert.todouble(gong[i, 3]); if ((jbgz + jj) < 5000) { sfgz = jbgz + jj - sodeshui; gong[i, 4] = convert.tostring(sfgz); } else if ((jbgz + jj) < 8000) { sodeshui = jbgz * 0.03; } else if ((jbgz + jj) < 20000) { sodeshui = 3000 * 0.03 + (jbgz - 8000) * 0.15; } else if ((jbgz + jj) > 20000) { sodeshui = 3000 * 0.03 + 2000 * 0.15 + (jbgz - 20000) * 0.25; } //计算实发工资 sfgz = jbgz + jj - sodeshui; gong[i, 4] = convert.tostring(sfgz); } } static void sfgz() { double sodeshui = 0; double sfgz; int i = 0; double jbgz = convert.todouble(gong[i, 2]); double jiangjin = convert.todouble(gong[i, 3]); if ((jbgz + jiangjin) < 5000) { sfgz = jbgz + jiangjin - sodeshui; gong[i, 4] = convert.tostring(sfgz); } else if ((jbgz + jiangjin) < 8000) { sodeshui = jbgz * 0.03; } else if ((jbgz + jiangjin) < 20000) { sodeshui = 3000 * 0.03 + (jbgz - 8000) * 0.15; } else if ((jbgz + jiangjin) > 20000) { sodeshui = 3000 * 0.03 + 2000 * 0.15 + (jbgz - 20000) * 0.25; } //计算实发工资 sfgz = jbgz + jiangjin - sodeshui; gong[i, 4] = convert.tostring(sfgz); } static void outputgongzi(string[,] gong, int num) { console.writeline("-----------工人工资单-------------"); console.writeline("|----------------------------------|"); console.writeline("|工 号|姓 名|基本工资|奖 金|实发工资|"); console.writeline("-----------------------------------|"); for (int i = 0; i < num; i++) { console.writeline("|{0,5}|{1,8}|{2,8:f2}|{3,8:f2}|{4:8,f2}|", gong[i, 0], gong[i, 1], gong[i, 2], gong[i, 3], gong[i, 4]); console.writeline("|---------------------------------------------|"); } } } }
运行结果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
-
基于CakePHP实现的简单博客系统实例_PHP
-
使用C# (.NET Core) 实现状态设计模式 (State Pattern)
-
【lrzsz】安装lrzsz工具实现Linux和Windows系统之间文件便捷上传与下载
-
Asp.net MVC3实现JSONP
-
PHP工资管理系统、考勤管理系统、薪资管理系统
-
BAT批处理提取系统时间的实现代码(bug修复)
-
详解如何在ASP.Net Core中实现健康检查
-
ASP.NET Core Middleware的实现方法详解
-
.NET实现工资管理系统
-
.NET Core类库System.Reflection.DispatchProxy实现简易Aop的方法