Generic collection of small project staff punching, set of Staff punching

Source: Internet
Author: User

Generic collection of small project staff punching, set of Staff punching

 

Project Style

Requirement Description: 1. Implement new employees

2. Use the DataGrideView space to display employee information

3. Delete employee information

4. Right-click the main form to sign in and exit from work.

5. If you select sign-in, You must retrieve the employee's punch history. If you have already signed in, you are prompted that you cannot sign in again.

6. If you select to sign back, You must retrieve the employee's logging record. If you have signed back, you are prompted that you cannot sign back.

7. Use the DataGrideView control to display employee attendance records

 

Project start:

First, set up the form to create the staff class SE punch-in time class.

Public class SE
{

Public int id {get; set;} // store employee id
Public string name {get; set;} // store employee name
Public int age {get; set;} // store employee age
Public string sex {get; set;} // store employees
Public int type; // stores the punch type 1, 2, 3
}

 

Public class Time
{
Public DateTime start {get; set;} // stores the check-in time
Public DateTime close {get; set;} // store the token return time
Public int id {get; set;} // stores the punch type 1, 2, 3
Public string name {get; set;} // store employee name

}

Create a generic set list

Public List <SE> list = new List <SE> (); // stores the set of employees.
Public static Dictionary <string, Time> dic = new Dictionary <string, Time> (); // stores Logging

 

Bind a data source when the form load time is DataGrideView

SE s1 = new SE ();
S1.id = 111;
S1.name = "Wang xiaomao ";
S1.age = 26;
S1.sex = "male ";
SE s2 = new SE ();
S2.id = 112;
S2.name = "Zhou Xinyu ";
S2.age = 22;
S2.sex = "female ";
SE s3 = new SE ();
S3.name = "Zhang Ye ";
S3.id = 113;
S3.age = 30;
S3.sex = "male ";
List. Add (s1 );
List. Add (s2 );
List. Add (s3 );
DataGridView1.DataSource = list;

Add is jump to add employee form

Click Add to save new employee information to the set

SE s = new SE ();
S. id = Convert. ToInt32 (textBox1.Text );
S. name = textBox2.Text;
S. age = Convert. ToInt32 (textBox3.Text );
S. sex = textBox4.Text;
Frm1.list. Add (s );
MessageBox. Show ("New RR added successfully! ");
Frm1.Show ();
Frm1.clear (frm1.list );
This. Close ();

Modifying employee information involves passing values in a form. This time we upload a SE object.

First, modify the employee information form to create a new SE object.

Click Modify in the main form to jump to modify the employee information form.

Form3 frm = new Form3 ();
Frm. name = maid [1]. Value. ToString ();
Foreach (SE s in list)
{
If (s. id. ToString () = maid (selectedcells [0]. Value. ToString ())
{
Frm. s = s;
Break;
}
}
Frm. f = this;
Frm. Show ();
This. Hide ();

Jump to the modify employee information form. You can edit employee information in textBox.

Click Modify to save the data.

SE s = new SE ();
S. id = Convert. ToInt32 (textBox1.Text );
S. age = Convert. ToInt32 (textBox3.Text );
S. sex = textBox4.Text;
For (int I = 0; I <f. list. Count; I ++)
{
If (f. list [I]. name = name)
{
F. list [I]. age = Convert. ToInt32 (textBox3.Text );
F. list [I]. id = Convert. ToInt32 (textBox1.Text );
F. list [I]. sex = textBox4.Text;
Break;
}
}
MessageBox. Show ("modification successful! ");
F. clear (f. list );
F. Show ();

Add ContextMenuTrip in the DataGrideView of the main form, and add sign-in and sign-off

Click sign-in and sign-out to add a data entry to the collection.

String name = maid [1]. Value. ToString ();
SE s = new SE ();
Foreach (SE se in list)
{
If (se. name = name)
{
S = se;
Break;
}
}
Num = s. type;
If (num = 0)
{
Time t = new Time ();
T. id = Convert. ToInt32 (maid [0]. Cells [0]. Value );
T. name = maid [0]. Cells [1]. Value. ToString ();
T. start = DateTime. Now;
Dic. Add (t. name, t );
S. type = 1;
MessageBox. Show ("sign-in successful ~ ");
}
Else
{
MessageBox. Show ("You have signed in ");
}

Check whether the sign-in is complete. The sign-in is the same as the sign-out.

Click the logging record to view the staff logging information.

In this way, a simple small program is finished.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.