protected void btnClockOut_Click(object sender, EventArgs e) { TimeSpan span = TimeSpan.Parse("00:00:00.0000000"); Employee emp = dde.Employees.Where(t => t.Emp_User_Name.ToUpper().Equals(Username.Text.ToUpper()) && t.Emp_Password.Equals(Password.Text)).FirstOrDefault(); if (emp != null) { Empworktime EmpChk = dde.Empworktimes.Where(t => t.Emp_ID == emp.Emp_ID && t.Clock_In != span && t.Clock_Out == span).ToList().FirstOrDefault(); if (EmpChk != null) { EmpChk.Clock_Out = DateTime.Now.TimeOfDay; EmpChk.Emp_ID = emp.Emp_ID; EmpChk.Work_Date = DateTime.Now; dde.SaveChanges(); lblError.Text = ""; } else { lblError.Text = "User has not clocked in yet."; lblError.Visible = true; } } else { lblError.Text = "Username or Password is incorrect."; lblError.Visible = true; } }
protected void btnViewTimesheet_Click(object sender, EventArgs e) { Employee emp = dde.Employees.Where(t => t.Emp_User_Name.ToUpper().Equals(Username.Text.ToUpper()) && t.Emp_Password.Equals(Password.Text)).FirstOrDefault(); if (emp != null) { Empworktime Timesheet = new Empworktime(); List <Empworktime> WorkTimes = dde.Empworktimes.Where(t => t.Emp_ID == emp.Emp_ID).ToList(); lvDisplayTimeSheet.DataSource = WorkTimes; lvDisplayTimeSheet.DataBind(); lblError.Text = ""; } else { lblError.Text = "Username or Password is incorrect."; lblError.Visible = true; } }