java员工签到与签退_员工签到签退

employee.cs:

using System;

using System.Collections.Generic;

using System.Linq; using System.Text;

namespace ConsoleApplication21

{

class employee

{

private string name;

public string Name

{

get { return name; }

set { name = value; }

}

private int id;

public int Id

{

get { return id; }

set { id = value; }

}

}

}

Program.cs:

using System;

using System.Collections.Generic;

using System.Linq; using System.Text;

using System.Collections;

namespace ConsoleApplication21

{

class Program

{

static void Main(string[] args)

{

employee em = new employee();

begin:

record re = new record();

Console.WriteLine("=======================");

Console.WriteLine("1.签到,2.签退,3.退出");

Console.WriteLine("=======================");

Console.WriteLine("请选择服务项目");

int value = Convert.ToInt32(Console.ReadLine());

switch (value )

{

case 1:

re.insign();

goto begin;

case 2:

re.signout();

goto begin;

case 3:

goto begin;

default :

Console.WriteLine("输入错误,请重新输入");

goto begin;

}

}     } }

record.cs:

using System;

using System.Collections.Generic;

using System.Linq; using System.Text;

namespace ConsoleApplication21

{

class record

{

employee e = new employee();

private DateTime signintime;

public DateTime Signintime

{

get { return signintime; }

set { signintime = value; }

}

private DateTime signouttime;

public DateTime Signouttime

{

get { return signouttime; }

set { signouttime = value; }

}

public record()

{

init();

}

Dictionary em = new Dictionary();

public void init()

{

employee em1 = new employee();

em1.Name  = "小熊";

em1.Id  = 1;

employee em2 = new employee();

em2.Name  = "小智";

em2.Id  = 2;

em.Add(em1.Id , em1);

em.Add(em2.Id , em2);

}

DateTime dt = DateTime.Now;

int d = DateTime.Now.Hour;

bool isadd = false;

public void insign()

{

begin:

Console.WriteLine("请输入你的员工工号");

int value = Convert.ToInt32(Console.ReadLine ());

if (d > 15)

{

Console.WriteLine("请在8点前签到,现在时间为{0}",dt );

}

else

{

foreach (employee emp in em.Values)

{

if (emp.Id.Equals ( value))

{

if (isadd)

{

Console.WriteLine("今天员工已签到,不能重复签到");

}

else

{

Console.WriteLine("签到成功");

showtime();

signintime = dt;

isadd = true;

}

break;

}

else

{

Console.WriteLine("不存在该员工");

goto begin;

}

}

}

}

public void signout()

{

begin:

Console.WriteLine("请输入你的员工工号");

int value = Convert.ToInt32(Console.ReadLine());

foreach (employee eml in em.Values)

{

if (value.Equals (eml.Id))

{

bool isadd = true;

if (d < 10)

{

Console.WriteLine("请在17点之后签到,现在时间为{0}", dt);

}

else

{

if (isadd)

{

end:

Console.WriteLine("是否确认签退,1-确认,2-退出");

int a = Convert.ToInt32(Console.ReadLine());

switch (a)

{

case 1:

Console.WriteLine("签退成功");

showtime();

signouttime = dt;

continue;

case 2:

break;

default:

Console.WriteLine("输入错误,请重新输入");

goto end;

}

}

else

{

Console.WriteLine("还没签到,不能签退");

}

}

break;

}

else

{

Console.WriteLine("该员工不存在,请重新输入");

goto begin;

}

}

}

public void showtime()

{

DateTime dt = DateTime.Now;

Console.WriteLine(string .Format ("{0:yyyy-mm-dd  hh:mm:ss}",dt ));

}

} }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值