-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshareman.cs
More file actions
166 lines (139 loc) · 5.25 KB
/
shareman.cs
File metadata and controls
166 lines (139 loc) · 5.25 KB
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
using System;
using System.Collections.Generic;
namespace Ap_Project_Clinic_
{
public class shareman : Ipay
{
public string name { get; set; }
public string familyname { get; set; }
public double salary { get; set; }//percent of share
public string idnumber { get; set; }
public string account { get; set; }
public string phone { get; set; }
public Double lastcash { get; set; }
public DateTime datecheck { get; set; }
public List<shareman> share = new List<shareman>();
string path = rateform.getpath() + @"\shareman.txt";
string pathckeck = rateform.getpath() + "\\checkoutemployee.txt";
public shareman(string idnumber)//read from file
{
//string[] allinform1 = System.IO.File.ReadAllLines(path);
//for (int i = 0; i < allinform1.Length; i++)
//{
// string[] personinform = allinform1[i].Split('*');
// if (personinform[4] == idnumber)
// {
// name = personinform[0];
// familyname = personinform[1];
// salary = Convert.ToDouble(personinform[2]);
// idnumber = personinform[4];
// account = personinform[5];
// lastcash = Convert.ToDouble(personinform[6]);
// this.idnumber = personinform[4];
// }
//}
share = readandwritesha.set();
for (int i = 0; i < share.Count; i++)
{
if(share[i].idnumber==idnumber)
{
name = share[i].name;
familyname = share[i].familyname;
salary = share[i].salary;
idnumber = share[i].idnumber;
account = share[i].account;
lastcash = share[i].lastcash;
this.idnumber = share[i].idnumber;
}
}
}
public shareman(string name, string familyname, string accountin, double lastcash, DateTime date)
{
this.name = name;
this.familyname = familyname;
this.account = accountin;
this.lastcash = lastcash;
datecheck = date;
}
public shareman(string name, string familyname, string accountin, double lastcash,double salary,string idnumber)
{
this.name = name;
this.familyname = familyname;
this.account = accountin;
this.lastcash = lastcash;
this.salary = salary;
this.idnumber = idnumber;
}
public string checkout()
{
double allprofit = finantial.finalcheckout1();
salary = (salary * allprofit) / 100;
string ret = "";
lastcash += salary;
string check = "name:" + name + "*" + "familyname:" + familyname + "*" + "salary:" + salary + "*" + "account:" + account + "*" + "Date:" + DateTime.Now + "*" + "shareman" + "lastcash" + lastcash + "\n";
System.IO.File.AppendAllText(pathckeck, check);
ret += check + "\n";
return ret;
}
}
public static class readandwritesha
{
static string path = rateform.getpath() + @"\shareman.txt";
static List<shareman> share = new List<shareman>();
static List<Ipay> shaipay = new List<Ipay>();
public static void writeinlist(List<Ipay> sha)
{
System.IO.File.Delete(path);
string information = "";
for (int i = 0; i < sha.Count; i++)
{
if (sha[i] is shareman share)
information += share.name + '*' + share.familyname + '*' + share.salary + '*' + share.salary + '*' + share.idnumber + '*' + share.account + '*' + share.lastcash + "\n";
}
System.IO.File.AppendAllText(path, information);
}
public static List<shareman> set()
{
share.Clear();
shaipay.Clear();
if (!System.IO.File.Exists(path))
{
System.IO.File.Create(path);
}
string[] allinform1;
try
{
allinform1 = System.IO.File.ReadAllLines(path);
for (int i = 0; i < allinform1.Length; i++)
{
string[] personinform = allinform1[i].Split('*');
share.Add(new shareman(personinform[0], personinform[1], personinform[5], Convert.ToDouble(personinform[6]), Convert.ToDouble(personinform[2]), personinform[4]));
}
return share;
}
catch
{
return share;
}
}
public static shareman search(shareman sha)
{
set();
for (int i = 0; i < share.Count; i++)
{
if (share[i].idnumber == sha.idnumber)
return sha;
}
return null;
}
public static List<Ipay>get()
{
set();
for (int i = 0; i < share.Count; i++)
{
shaipay.Add(share[i]);
}
return shaipay;
}
}
}