private void btnAtAdEndTime_Click(object sender, EventArgs e) { try { Buisness_Logic.empAttendence em1 = new Buisness_Logic.empAttendence(); em1.empID = int.Parse(txtEmpIDatte.Text); em1.theDay = txtempAT_theday.Text; em1.startTime = txtStartTime.Text; em1.endTime = textAtEndTime.Text; Buisness_Logic.empAttendence_repository emprep1 = new Buisness_Logic.empAttendence_repository(); if (emprep1.addEndTime(em1)) { MessageBox.Show("Success", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Information); textAtTotalHr.Text = em1.hoursWorked.ToString(); } else { MessageBox.Show("Failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ew) { throw; } }
private void btnAtAdStrtTime_Click(object sender, EventArgs e) { try { Buisness_Logic.empAttendence em = new Buisness_Logic.empAttendence(); em.empID = int.Parse(txtEmpIDatte.Text); em.theDay = txtempAT_theday.Text; em.startTime = txtStartTime.Text; Buisness_Logic.empAttendence_repository emprep = new Buisness_Logic.empAttendence_repository(); if (emprep.addStartTime(em)) { MessageBox.Show("Success", "Start time and day are added to the database.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ew) { throw; } }
private void btncalculate_Hours_Click(object sender, EventArgs e) { Buisness_Logic.empAttendence em1 = new Buisness_Logic.empAttendence(); em1.startTime = txtStartTime.Text; em1.endTime = textAtEndTime.Text; // Buisness_Logic.empAttendence_repository emprep1 = new Buisness_Logic.empAttendence_repository(); //DateTime st= DateTime.ParseExact(" "+em1.startTime, " h:mm tt", CultureInfo.InvariantCulture); // DateTime et = DateTime.ParseExact(" " + em1.endTime, " h:mm tt", CultureInfo.InvariantCulture); // TimeSpan dif = et - st; // string y = dif.ToString(@"hh\:mm"); textAtTotalHr.Text = em1.hoursWorked.ToString(); textAtExtraHr.Text = em1.extraHours.ToString(); }
private void btnAtSerchM_Click(object sender, EventArgs e) { try { Buisness_Logic.empAttendence ea1 = new Buisness_Logic.empAttendence(); ea1.empID = int.Parse(txtEmpIDatte.Text); ea1.theDay = DateTime.Today.ToShortDateString(); Buisness_Logic.empAttendence_repository emarep2 = new Buisness_Logic.empAttendence_repository(); if (emarep2.searchMemAt(ea1)) { MessageBox.Show("Employee attendence record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txtStartTime.Text = ea1.startTime; txtempAT_theday.Text = ea1.theDay; if (string.IsNullOrWhiteSpace(ea1.endTime)) { } else { textAtEndTime.Text = ea1.endTime; textAtTotalHr.Text = ea1.hoursWorked.ToString(); textAtExtraHr.Text = ea1.extraHours.ToString(); } } else { MessageBox.Show("No record found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } transport1 = ea1; } catch (Exception es) { throw; } }
public bool addEndTime(Buisness_Logic.empAttendence eat) { bool temp3 = false; try { DataLayer.dbConnect con3 = new DataLayer.dbConnect(); con3.openConnection(); string q3 = "UPDATE tbl_emp_attendence SET end_time=@et, hours_worked=@hw ,extra_hours=@eh where theDay=@day and empid=@eid"; SqlCommand cmd3 = new SqlCommand(q3, con3.getConnection()); cmd3.Parameters.AddWithValue("@day", eat.theDay); cmd3.Parameters.AddWithValue("@eid", eat.empID); cmd3.Parameters.AddWithValue("@et", eat.endTime); cmd3.Parameters.AddWithValue("@hw", eat.hoursWorked); cmd3.Parameters.AddWithValue("@eh", eat.extraHours); cmd3.ExecuteNonQuery(); temp3 = true; } catch (Exception euid) { throw; } if (temp3 == true) { return(true); } else { return(false); } }
public bool addStartTime(Buisness_Logic.empAttendence eat) { bool temp1 = false; try { DataLayer.dbConnect con1 = new DataLayer.dbConnect(); con1.openConnection(); string q1 = "INSERT INTO tbl_emp_attendence (theDay,empid,start_time) values (@day, @empid, @st)"; SqlCommand cmd1 = new SqlCommand(q1, con1.getConnection()); cmd1.Parameters.AddWithValue("@day", eat.theDay); cmd1.Parameters.AddWithValue("@empid", eat.empID); cmd1.Parameters.AddWithValue("@st", eat.startTime); cmd1.ExecuteNonQuery(); temp1 = true; } catch (Exception eui) { throw; } if (temp1 == true) { return(true); } else { return(false); } }
public bool searchMemAt(Buisness_Logic.empAttendence eat1) { bool tempx = false; try { DataLayer.dbConnect con2 = new DataLayer.dbConnect(); con2.openConnection(); string q2 = "SELECT * FROM tbl_emp_attendence WHERE empid=@emp AND theDay=@day"; SqlCommand cmd2 = new SqlCommand(q2, con2.getConnection()); cmd2.Parameters.AddWithValue("@day", eat1.theDay); cmd2.Parameters.AddWithValue("@emp", eat1.empID); DataTable dt1 = new DataTable(); SqlDataAdapter da1 = new SqlDataAdapter(cmd2); da1.Fill(dt1); if (dt1.Rows.Count > 0) { eat1.startTime = dt1.Rows[0]["start_time"].ToString(); eat1.theDay = dt1.Rows[0]["theDay"].ToString(); eat1.endTime = dt1.Rows[0]["end_time"].ToString(); if (!DBNull.Value.Equals(dt1.Rows[0]["end_time"])) { eat1.endTime = dt1.Rows[0]["end_time"].ToString(); } else { } if (!DBNull.Value.Equals(dt1.Rows[0]["hours_worked"])) { eat1.hoursWorked = (double)dt1.Rows[0]["hours_worked"]; } else { } if (!DBNull.Value.Equals(dt1.Rows[0]["extra_hours"])) { eat1.extraHours = (double)dt1.Rows[0]["extra_hours"]; } else { } tempx = true; } } catch (Exception exw) { throw; } if (tempx == true) { return(true); } else { return(false); } }