zoukankan      html  css  js  c++  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<int, employee> em = new Dictionary<int, employee>();  

           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 ));     

        }           

          } }

  • 相关阅读:
    C#将DataTable按固定个数拆分成多个表
    IDataRowPersistable
    使用临时表的示例
    2011 11 28 sql语句学习
    2010 11 30 DrawCurve GDI绘制曲线
    如何查看viewstate的内容
    const 和 readonly 的区别
    access insert 语法错误
    asp.net下载文件的常用方法大全
    【转】JS超强判断电话号码
  • 原文地址:https://www.cnblogs.com/xiaomayizoe/p/5046817.html
Copyright © 2011-2022 走看看