-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lista.cs
209 lines (174 loc) · 6.75 KB
/
Lista.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Microsoft.Office.Interop;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Net;
using UNOLibs.Net;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
namespace MasterCheck2._0
{
public partial class Lista : CustomForm.MyForm
{
string c = string.Format("Select idrfid, noEmp as `No Empleado`, Nombre, FechaIn as `Fecha de Ingreso`, Asistencias, Faltas, Puesto from registros");
string es = string.Format("select * from entrada");
string s = string.Format("select * from salida");
string[] lis = new string[3] {"Empleados","Salida","Entrada"};
public Lista()
{
InitializeComponent();
btnexport.Enabled = false;
// dataGridView1.DataSource = db.SelectDataTable(c);
for (int i = 0; i < lis.Length; i++)
{
cdlistas.Items.Add(lis[i]);
}
}
//iniciar servidor
TcpListener Listener = new TcpListener(65535);
TcpListener Listener1 = new TcpListener(65534);
UNOLibs.Net.ClientClass clnt = new UNOLibs.Net.ClientClass();
private UNOLibs.Net.ServerClass withEventsField_server;
public UNOLibs.Net.ServerClass server;
UNOLibs.Net.ServerClass server2;
private void Listening()
{
Listener.Start();
Listener1.Start();
}
BaseDeDatos db = new BaseDeDatos();
private void copy()
{
bunifuCustomDataGrid1.SelectAll();
DataObject dataObj = bunifuCustomDataGrid1.GetClipboardContent();
if (dataObj != null)
Clipboard.SetDataObject(dataObj);
}
private void btnExp_Click(object sender, EventArgs e)
{
}
private void ToCsV(DataGridView dGV, string filename)
{
string stOutput = "";
// Export titles:
string sHeaders = "";
for (int j = 0; j < dGV.Columns.Count; j++)
sHeaders = sHeaders.ToString() + Convert.ToString(dGV.Columns[j].HeaderText) + "\t";
stOutput += sHeaders + "\r\n";
// Export data.
for (int i = 0; i < dGV.RowCount - 1; i++)
{
string stLine = "";
for (int j = 0; j < dGV.Rows[i].Cells.Count; j++)
stLine = stLine.ToString() + Convert.ToString(dGV.Rows[i].Cells[j].Value) + "\t";
stOutput += stLine + "\r\n";
}
Encoding utf16 = Encoding.GetEncoding(1254);
byte[] output = utf16.GetBytes(stOutput);
FileStream fs = new FileStream(filename, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(output, 0, output.Length); //write the encoded file
bw.Flush();
bw.Close();
fs.Close();
}
private void btnemp_Click(object sender, EventArgs e)
{
}
private void btnhis_Click(object sender, EventArgs e)
{
}
private void tEmpleados_Click(object sender, EventArgs e)
{
}
private void tSalidas_Click(object sender, EventArgs e)
{
}
private void tentradas_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void cbcmd_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void OnDiagnosticMessage(string Args)
{
Interaction.MsgBox("La tranferencia del archivo ha finalizado correctamente!", MsgBoxStyle.Information, "Notificacion");
}
private void Lista_Load(object sender, EventArgs e)
{
Computer mycomputer = new Computer();
txtpath.Text = mycomputer.FileSystem.SpecialDirectories.MyDocuments + "\\";
server = new UNOLibs.Net.ServerClass(65534, true, txtpath.Text);
server2 = new UNOLibs.Net.ServerClass(65532, true, "C:\\");
Thread ListThread = new Thread(new ThreadStart(Listening));
//Creates the thread
ListThread.Start();
label1.Font = new Font("Paloseco", 10, FontStyle.Regular);
label2.Font = new Font("Paloseco", 10, FontStyle.Regular);
label3.Font = new Font("Paloseco", 10, FontStyle.Regular);
label4.Font = new Font("Paloseco", 10, FontStyle.Regular);
label5.Font = new Font("Paloseco", 10, FontStyle.Regular);
}
private void btnreturn_Click(object sender, EventArgs e)
{
}
private void btnregresar_Click(object sender, EventArgs e)
{
Menu f = new Menu();
f.Show();
this.Hide();
}
private void btnexport_Click(object sender, EventArgs e)
{
try
{
// string c = string.Format("Select idrfid, Nombre, FechaIn, Asistencias, Faltas, Puesto, noEmp from registros");
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Excel Documents (*.xls)|*.xls";
sfd.FileName = "export.xls";
if (sfd.ShowDialog() == DialogResult.OK)
{
//ToCsV(dataGridView1, @"c:\export.xls");
ToCsV(bunifuCustomDataGrid1, sfd.FileName); // Here dataGridview1 is your grid view name
clnt.SendFiles(this.txtip.Text, 65534, sfd.FileNames);
Interaction.MsgBox("El archivo se ha enviado con exito!", MsgBoxStyle.Information, "Notificacion");
}
}
catch(Exception ex)
{
MessageBox.Show("Hubo un error "+ ex);
}
}
private void cdlistas_SelectedIndexChanged(object sender, EventArgs e)
{
if (cdlistas.Text == "Empleados")
{
bunifuCustomDataGrid1.DataSource = db.SelectDataTable(c);
btnexport.Enabled = true;
}
else if (cdlistas.Text == "Salida")
{
bunifuCustomDataGrid1.DataSource = db.SelectDataTable(s);
btnexport.Enabled = true;
}
else if (cdlistas.Text == "Entrada")
{
bunifuCustomDataGrid1.DataSource = db.SelectDataTable(es);
btnexport.Enabled = true;
}
}
}
}