//public void AssignLeave(AssignLeaves Al) //{ // string Querry = string.Format("insert into EmployeeLeaveCountHistory (EmployeeID,LeaveTypeID,Count,Date) values('{0}','{1}','{2}','{3}')", Al.EmployeeID, Al.LeaveTypeID, Al.Count, DateTime.Now); // DataBase.ExecuteQuerry(Querry); // Al.Count += GetLeaveCount(Al); // Querry = string.Format("update EmployeeLeaveCount set Count = '{0}' where EmployeeID = '{1}'and LeaveTypeID ='{2}' " + // "if @@ROWCOUNT = 0 " + // "insert into EmployeeLeaveCount(Count,EmployeeID,LeaveTypeID) values('{0}', '{1}', '{2}')", Al.Count, Al.EmployeeID, Al.LeaveTypeID); // DataBase.ExecuteQuerry(Querry); //} public void AssignLeave(AssignLeaves al) {//this function is used by assign all or assign_all_dep or single assign employee string Querry = string.Format("insert into EmployeeLeaveCountHistory (EmployeeID,LeaveTypeID,Count,Date) values('{0}','{1}','{2}','{3}')", al.EmployeeID, al.LeaveTypeID, al.Count, DateTime.Now); DataBase.ExecuteQuerry(Querry); al.Count += GetLeaveCount(al); Querry = string.Format("update EmployeeLeaveCount set Count = '{0}' where EmployeeID = '{1}'and LeaveTypeID ='{2}' " + "if @@ROWCOUNT = 0 " + "insert into EmployeeLeaveCount(Count,EmployeeID,LeaveTypeID) values('{0}', '{1}', '{2}')", al.Count, al.EmployeeID, al.LeaveTypeID); DataBase.ExecuteQuerry(Querry); }
}/// <summary> /// Assign Leaves to all department employees /// </summary> public void AssignAllDep(AssignLeaves Al) { string Querry = string.Format("select * from Employee where DepartmentID='{0}'", Al.DepartmentID); DataSet ds = DataBase.Read(Querry); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AssignLeave(new AssignLeaves() { EmployeeID = ds.Tables[0].Rows[i][0].ToString(), LeaveTypeID = Al.LeaveTypeID, Count = Al.Count }); } }
/// <summary> /// Assign Leave to all employees /// </summary> public void AssignAll(AssignLeaves Al) { string Querry = "select EmployeeID from Employee"; DataSet ds = DataBase.Read(Querry); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AssignLeave(new AssignLeaves() { EmployeeID = ds.Tables[0].Rows[i][0].ToString(), LeaveTypeID = Al.LeaveTypeID, Count = Al.Count }); } }/// <summary>
public DataSet ShowAffectedUsers(AssignLeaves al, String Querry) {//this method store the data temporarily from incoming assign leave request for further processing and return data for users who are getting affected by this request DataSet ds = DataBase.Read(Querry); return(ds); }
/// <summary> /// It return count of employee's remaining leaves /// </summary> public double GetLeaveCount(AssignLeaves al) {//this table has employee leave balance... string Querry = string.Format("select EmployeeLeaveCount.Count from EmployeeLeaveCount where EmployeeID='{0}'and LeaveTypeID='{1}'", al.EmployeeID, al.LeaveTypeID); return(Convert.ToDouble(DataBase.ExecuteScalar(Querry))); }