Beispiel #1
0
        public ActionResult Select(sLeaveModel SL, string submit)
        {
            string queryString = "";
            int    lid;

            int.TryParse(SL.leaveID, out lid);
            switch (submit)
            {
            case "Approve":
                queryString = "UPDATE dbo.Leave SET Status = '1', " +
                              "LM_Comment = '" + SL.lmComment + "' " +
                              "WHERE dbo.Leave.Leave_Application_ID = '" + lid + "' ";
                break;

            case "Reject":
                queryString = "UPDATE dbo.Leave SET Status = '3', " +
                              "LM_Comment = '" + SL.lmComment + "' " +
                              "WHERE dbo.Leave.Leave_Application_ID = '" + lid + "' ";
                break;
            }
            var connectionString =
                ConfigurationManager.ConnectionStrings["DefaultConnection"].
                ConnectionString;

            using (var connection = new SqlConnection(connectionString))
            {
                var command = new SqlCommand(queryString, connection);
                connection.Open();
                using (var reader = command.ExecuteReader())
                    connection.Close();
            }


            /*Construct an e-mail and send it.*/
            string temp_email = TempData["EmployeeEmail"] as string;

            MailMessage message = new MailMessage();

            message.From = new MailAddress("*****@*****.**", "GIMEL LMS");



            message.To.Add(new MailAddress(temp_email));

            message.Subject = "Leave Application Update";
            string body = "";

            body = body + "You application has been fully approved.";

            message.Body = body;
            SmtpClient client = new SmtpClient();

            client.EnableSsl = true;

            client.Credentials = new NetworkCredential("*****@*****.**", "ict@333");
            client.Send(message);


            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Select(string Id)
        {
            List <sLeaveModel> passedApplications = TempData["RetrievedApplications"] as List <sLeaveModel>;
            sLeaveModel        passingLeave       = passedApplications.First(leave => leave.leaveID.Equals(Id));
            List <string>      balanceStrings     = new List <string>();
            var connectionString =
                ConfigurationManager.ConnectionStrings["DefaultConnection"].
                ConnectionString;
            string queryString = "SELECT * FROM dbo.Leave_Balance, dbo.Employee " +
                                 "WHERE dbo.Leave_Balance.Employee_ID = '" + passingLeave.employeeID + "' " +
                                 "AND dbo.Employee.Employee_ID = '" + passingLeave.employeeID + "' ";

            using (var connection = new SqlConnection(connectionString))
            {
                var command = new SqlCommand(queryString, connection);
                connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            string balanceType = GetLeaveType((int)reader["Leave_ID"]);
                            int    balance     = (int)reader["Balance"];
                            string empGender   = (string)reader["Gender"];
                            if (empGender.Equals("M") && balanceType.Equals("Maternity"))
                            {
                                continue;
                            }
                            string email = (string)reader["Email"];
                            TempData["EmployeeEmail"] = email;
                            string balanceString = balanceType + ": " + balance.ToString();
                            balanceStrings.Add(balanceString);
                        }
                    }
                }
                connection.Close();
            }

            ViewData["BalanceStrings"] = balanceStrings;
            return(View(passingLeave));
        }
Beispiel #3
0
 public ActionResult Index(sLeaveModel SL)
 {
     return(Index());
 }