服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - ASP.NET教程 - .NET实现工资管理系统

.NET实现工资管理系统

2020-06-07 15:16Unitue_逆流 ASP.NET教程

这篇文章主要为大家详细介绍了.NET实现工资管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了.NET实现工资管理系统的具体代码,供大家参考,具体内容如下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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("|---------------------------------------------|");
      }    
    }
  }
}

运行结果:

.NET实现工资管理系统

.NET实现工资管理系统

.NET实现工资管理系统

.NET实现工资管理系统

.NET实现工资管理系统

.NET实现工资管理系统

.NET实现工资管理系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

延伸 · 阅读

精彩推荐