Ich entwickle ein Anwesenheitsverwaltungssystem, ich möchte, dass der Benutzer einmal pro Tag ein- und ausgeht. Was ich denke, ist es wird die employeeID und Indate, intime und out Zeit aus der Datenbank auswählen und wenn indate und intime Wert hat, wird es zeigen, einmal pro Tag obly same thigh w/timeout wählen indate, outtime usw. Hier ist meine CodeDen Benutzer einmal am Tag zur Ein-/Auszeit auffordern?
private void button1_Click(object sender, EventArgs e)
{
try
{
//VALIDATION
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = @" SELECT EmployeeID, Firstname, Lastname
FROM tblEmployee
WHERE EmployeeID = @1";
command.Parameters.AddWithValue("@1", textBox1.Text);
reader = command.ExecuteReader();
if (reader.Read())
{
dataGridView1.Rows[0].Cells[0].Value = reader[0].ToString();
dataGridView1.Rows[0].Cells[1].Value = reader[1].ToString();
dataGridView1.Rows[0].Cells[2].Value = reader[2].ToString();
dataGridView1.Rows[0].Cells[3].Value = dateTimePicker1.Value.ToString();
savetimein();
}
else
{
MessageBox.Show("No Employee ID");
}
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//SAVE TO DATABASE
private void savetimein()
{
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO [TimeinTimeout](EmployeeID, Firstname, Lastname, InDate, InTime) VALUES (@1,@2,@3,@4,@5)";
command.Parameters.Clear();
command.Parameters.AddWithValue("@1", textBox1.Text);
command.Parameters.AddWithValue("@2", dataGridView1.Rows[0].Cells[1].Value);
command.Parameters.AddWithValue("@3", dataGridView1.Rows[0].Cells[2].Value);
command.Parameters.AddWithValue("@4", DateTime.Now.ToShortDateString());
command.Parameters.AddWithValue("@5", DateTime.Now.ToLongTimeString());
command.ExecuteNonQuery();
MessageBox.Show("Data Saved!");
this.Hide();
Form1 Mm = new Form1();
Mm.ShowDialog();
}
Wo werden Sie nach der letzten Anmeldung gefragt? Du scheinst zu wissen, was du zu tun hast - was ist deine Frage? –
Ich denke über die Begrenzung der Benutzeranmeldung, aber ich möchte wissen, was ist der Code zu seterminine, wenn eine bestimmte Spalte Wert so etwas hat –
Wenn Datenbankspalte keinen Wert hat, wird es ausgeführt, aber wenn es Wert hat, wird es nicht –