示例#1
0
        public ActionResult LeaveTaken(LeaveTaken allocateClassroom)
        {
            if (vManager.IsLeaveTaken(allocateClassroom))
            {
                ViewBag.Msg        = "Date Overlapping Problem.";
                ViewBag.Employees  = eManager.EmployeeList();
                ViewBag.LeaveTypes = eManager.LeaveTypes();
            }
            else
            {
                allocateClassroom.EntryDate = DateTime.Now;
                ViewBag.Msg        = eManager.LeaveTaken(allocateClassroom);
                ViewBag.Employees  = eManager.EmployeeList();
                ViewBag.LeaveTypes = eManager.LeaveTypes();
            }

            return(View());
        }
        public string LeaveTaken(LeaveTaken taken)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    com = new SqlCommand(@"INSERT INTO [dbo].[LeaveTaken]
           ([EmployeeId]
           ,[LeaveTypeId]
           ,[StartDate]
           ,[EndDate]
           ,[EntryDate]
           ,[NoOfLeaveTaken])
     VALUES
           ( '" + taken.EmployeeId + "' , '" + taken.LeaveTypeId + "'  , '" + taken.StartDate + "'  , '" + taken.EndDate + "'  , '" + taken.EntryDate + "' , '" + taken.NoOfLeaveTaken + "')", con);

            con.Open();
            int number = com.ExecuteNonQuery();

            con.Close();
            if (number > 0)
            {
                return("Employee Taken Leave Info Save Successfully!");
            }
            return("Employee Taken Leave Info Save Failed, Please Try Again!!!");
        }
示例#3
0
        public bool IsLeaveTaken(LeaveTaken leaveTaken)
        {
            // string Query = "SELECT * FROM LeaveTaken WHERE (StartDate BETWEEN @StartDate AND @EndDate) AND (EndDate BETWEEN @StartDate AND @EndDate) AND (EmployeeId = @EmployeeId)";
            string        Query      = "SELECT * FROM LeaveTaken WHERE (StartDate <= @EndDate AND EndDate >= @StartDate AND EmployeeId = @EmployeeId)";
            SqlConnection Connection = new SqlConnection(connectionString);
            SqlCommand    Command    = new SqlCommand(Query, Connection);

            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("StartDate", SqlDbType.Date);
            Command.Parameters["StartDate"].Value = leaveTaken.StartDate;
            Command.Parameters.Add("EndDate", SqlDbType.Date);
            Command.Parameters["EndDate"].Value = leaveTaken.EndDate;
            Command.Parameters.Add("EmployeeId", SqlDbType.Int);
            Command.Parameters["EmployeeId"].Value = leaveTaken.EmployeeId;
            SqlDataReader Reader = Command.ExecuteReader();

            Reader.Read();
            bool isExist = Reader.HasRows;

            Reader.Close();
            Connection.Close();
            return(isExist);
        }
 public bool IsLeaveTaken(LeaveTaken leaveTaken)
 {
     return(vGateway.IsLeaveTaken(leaveTaken));
 }
 public string LeaveTaken(LeaveTaken taken)
 {
     return(eGateway.LeaveTaken(taken));
 }