public ActionResult CancelRequest(string id)
        {
            RequestDAO request = new RequestDAO();

            switch (request.CancelRequest(id, Convert.ToInt32(Session["userid"].ToString()))) //PUT LOGIN EMP_ID HERE
            {
            case ("success"):
            {
                SetFlash(Enums.FlashMessageType.Success, "Successfully Cancelled!");
                return(RedirectToAction("RequisitionList"));
            }

            case ("failed"):
            {
                SetFlash(Enums.FlashMessageType.Error, "Something went wrong! Please try again later or contact your webmaster.");
                return(RedirectToAction("RequisitionList"));
            }

            case ("unauthorized"):
            {
                SetFlash(Enums.FlashMessageType.Warning, "You cannot cancel requests which are not yours!");
                return(RedirectToAction("RequisitionList"));
            }

            case ("reviewed"):
            {
                SetFlash(Enums.FlashMessageType.Warning, "You cannot cancel requests which are already reviewed!");
                return(RedirectToAction("RequisitionList"));
            }
            }

            return(RedirectToAction("RequisitionList"));
        }
        public ActionResult RequisitionList()
        {
            RequestDAO request = new RequestDAO();

            ViewData["Requisitions"] = request.GetRequistionListByEmpId(Convert.ToInt32(Session["userid"].ToString())); //PUT LOGIN EMP_ID HERE
            return(View());
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int     id = int.Parse(dataGridView1.SelectedRows[0].Cells["requestID"].Value.ToString());
            Request re = RequestDAO.getRequestByRequestID(id);

            re.MaID      = m.MaID;
            re.DateReply = DateTime.Now.ToString();
            re.Reply     = txtReplyContent.Text;
            RequestDAO.Update(re);
            MessageBox.Show("Reply Success");
            DataTable dt     = RequestDAO.GetDataTable();
            DataView  dv     = new DataView(dt);
            string    filter = "";

            if (comboBox1.SelectedIndex == 1)
            {
                filter = "maID is not null";
            }
            if (comboBox1.SelectedIndex == 0)
            {
                filter = "maID is null";
            }
            dv.RowFilter             = filter;
            dataGridView1.DataSource = dv;
            btnSave.Enabled          = false;
            txtReplyContent.Enabled  = false;
            txtReplyContent.Text     = "";
            btnCancel.Enabled        = false;
            btnReply.Enabled         = true;
        }
Exemplo n.º 4
0
 public void DeleteRequestDetail([FromBody] RequestViewModel reqDetail)
 {
     if (reqDetail != null)
     {
         RequestDAO.DeleteRequestDetail(reqDetail);
     }
 }
Exemplo n.º 5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtRequestContent.Text))
     {
         string  content = txtRequestContent.Text;
         Request hp      = new Request(s.StuID, DateTime.Now.ToString(), content, "", "", "", 1);
         RequestDAO.Insert(hp);
         MessageBox.Show("Request Success");
         DataTable dt     = RequestDAO.GetDataTableByStuID(s.StuID);
         DataView  dv     = new DataView(dt);
         string    filter = "";
         if (comboBox1.SelectedIndex == 0)
         {
             filter = "maID is not null";
         }
         if (comboBox1.SelectedIndex == 1)
         {
             filter = "maID is null";
         }
         dv.RowFilter              = filter;
         dataGridView1.DataSource  = dv;
         btnSave.Enabled           = false;
         txtRequestContent.Enabled = false;
         txtRequestContent.Text    = "";
         btnCancel.Enabled         = false;
         btnRequest.Enabled        = true;
     }
     else
     {
         MessageBox.Show("TextFiled is not empty");
     }
 }
Exemplo n.º 6
0
        public MResponse UpdateReqStatus(RequisitionVM status)
        {
            bool      success  = new RequestDAO().UpdateStatus(status.Status, status.Id);
            MResponse response = new MResponse(success);

            return(response);
        }
        public void ProcessMailForExpenses(string subjectName)
        {
            List <MailMessage> claims = mailHelper.getStringMessages(subjectName);

            foreach (MailMessage claim in claims)
            {
                //store the request....
                RequestDAO request = new RequestDAO();
                if (request.shouldProcess(claim.id))
                {
                    Request req = request.createRequestOrGetRequest(claim.from, claim.body, DateTime.Now, claim.id);
                    //call the rest service.
                    XmlDocument xdoc              = RestHelper.callRestService(restEndPoint, claim.body);
                    ExpenseDTO  expenseDTO        = Deserialiser.deserialiseContent <ExpenseDTO>(xdoc);
                    ExpenseDAO  expenseDAO        = new ExpenseDAO();
                    Expense     expenseToValidate = expenseDAO.CreateExpense(expenseDTO, req);

                    ExpenseValidator validator = new ExpenseValidator(expenseToValidate);

                    mailHelper.sendMessage(claim.from, validator.getMessage(), claim.id, string.Format("response to claim dated {0}", claim.date));
                    //deserialise the content
                    //validate the request
                    //store - valid request or failure and respond to user
                }
            }
        }
Exemplo n.º 8
0
 public void UpdateRequestDetails([FromBody] List <RequestViewModel> reqDetails)
 {
     if (reqDetails != null)
     {
         RequestDAO.UpdateRequestDetails(reqDetails);
     }
 }
Exemplo n.º 9
0
 public void InsertRequestDetail([FromBody] RequestViewModel reqDetail)
 {
     if (reqDetail != null)
     {
         RequestDAO.InsertRequestDetail(reqDetail);
     }
 }
        public ActionResult ApprovedRequestDetails(int id)
        {
            RequestDAO request = new RequestDAO();

            ViewData["RequestDetails"] = request.GetRequestDetail(id);

            return(View());
        }
        public ActionResult ApprovedRequests()
        {
            RequestDAO request = new RequestDAO();

            ViewData["Requests"] = request.GetApprovedRequests();

            return(View());
        }
        public ActionResult ViewPendingRequestDetails(int id)
        {
            RequestDAO requestDAO = new RequestDAO();

            ViewData["PendingRequests"] = requestDAO.ViewPendingRequestDetails(id);

            return(View());
        }
        public ActionResult RequestDetail(int id)
        {
            RequestDAO requestDAO = new RequestDAO();

            ViewData["RequestDetail"] = requestDAO.GetRequestDetail(id);

            return(View());
        }
Exemplo n.º 14
0
        /// <summary>
        /// This controller's constructor instantiates a UserDAO, a RequestDAO, and a logger. Each has parameters found in WebConfig.
        /// </summary>
        public RequestController()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["GameGroove"].ConnectionString;
            string logPath          = ConfigurationManager.AppSettings["LogPath"];

            _Logger            = new Logger(logPath);
            _RequestDataAccess = new RequestDAO(logPath, connectionString);
            _UserDataAccess    = new UserDAO(logPath, connectionString);
        }
Exemplo n.º 15
0
        public MResponse GetRequestDetail(int reqId)
        {
            RequestDAO dao = new RequestDAO();

            return(new MResponseList <MRequestItem>()
            {
                ResList = dao.GetRequestItems(reqId)
            });
        }
Exemplo n.º 16
0
        public ActionResult List()
        {
            string userId  = User.Identity.GetUserId();
            var    s1      = StaffDepartmentDAO.GetStaffByUserId(userId);
            var    reqList = RequestDAO.GetRequests(s1).ToList();

            ModelState.Clear();
            return(View(reqList));
        }
Exemplo n.º 17
0
        public MResponse GetRequestHistory(string deptId)
        {
            RequestDAO dao = new RequestDAO();

            return(new MResponseList <RequisitionVM>()
            {
                ResList = dao.GetReqListByDepartment(deptId)
            });
        }
Exemplo n.º 18
0
        public MResponse ApproveAllRequst(string deptId)
        {
            RequestDAO dao = new RequestDAO();

            return(new MResponse()
            {
                Success = dao.ApproveAllRequest(deptId)
            });
        }
        public void parseRequestID()
        {
            int         requestID    = 1284;
            RequestDAO  dao          = new RequestDAO();
            Request     req          = dao.getById(requestID);
            string      toParse      = Encoding.UTF8.GetString(req.MailContent);
            XmlDocument parsedSample = StringHelper.ParseString(toParse);

            Assert.IsTrue(!BusinessLayer.Deserialiser.deserialiseContent <ExpenseDTO>(parsedSample).isEmpty());
        }
        //******************************************//



        public ActionResult ReviewStationeryRequest()
        {
            string      username    = Session["username"].ToString();
            EmployeeDAO employeeDAO = new EmployeeDAO();
            Employee    employee    = employeeDAO.GetEmployeeByUsername(username);
            RequestDAO  reqlist     = new RequestDAO();

            ViewData["reqlist"] = reqlist.GetRequestList(employee.DepartmentId);
            return(View());
        }
Exemplo n.º 21
0
        public ActionResult Detail(int?requestId)
        {
            if (TempData.ContainsKey("ShowHistory"))
            {
                ViewBag.ShowHistory = TempData["ShowHistory"];
            }
            ViewBag.requestId = requestId;
            // Read from database
            var reqDetails = RequestDAO.GetRequestViewModelListByReqId((int)requestId);

            return(View(reqDetails));
        }
Exemplo n.º 22
0
        public ActionResult Store(string itemNo, int?requestId, string category)
        {
            ViewBag.requestId = requestId;

            ViewBag.category = category;

            ViewBag.categoryList = new SelectList(InventoryDAO.getAllCategoryId(), category);

            // Click add to cart
            if (itemNo != null)
            {
                switch (requestId)
                {
                // New request (store in session)
                case null:
                {
                    var li = Session["cartItems"] as List <string>;
                    IncreaseStringList(ref li, itemNo);
                    Session["cartItems"] = li;
                }
                break;

                // Existed request (store in database
                default:
                {
                    // insert the request detail
                    RequestViewModel rd = new RequestViewModel()
                    {
                        itemNo               = itemNo,
                        requestId            = Convert.ToInt32(requestId),
                        quantityNeed         = 1,
                        status_requestDetail = "unfulfilled"
                    };

                    int count = RequestDAO.InsertRequestDetail(rd);
                    ViewBag.RequestItemCount = count;
                }
                break;
                }
            }

            List <InventoryViewModel> items = null;

            if (!string.IsNullOrEmpty(category) && category != "0")
            {
                items = InventoryDAO.GetInventories(category);
            }
            else
            {
                items = InventoryDAO.GetInventories();
            }
            return(View(items));
        }
        public ActionResult ViewPendingRequestDetails(int id)
        {
            if (Session["delegation"].ToString() != "Yes")
            {
                return(RedirectToAction("ShowError", "Base"));
            }
            RequestDAO requestDAO = new RequestDAO();

            ViewData["PendingRequests"] = requestDAO.ViewPendingRequestDetails(id);

            return(View());
        }
Exemplo n.º 24
0
        public List <RequestViewModel> ReadRequest()
        {
            var   userId = User.Identity.GetUserId();
            Staff s1     = StaffDepartmentDAO.GetStaffByUserId(userId);

            var reqList = new List <RequestViewModel>();

            if (s1 != null)
            {
                reqList = RequestDAO.GetRequests(s1);
            }
            return(reqList);
        }
        public ActionResult ApproveRejectRequest(string status, int reqId)
        {
            RequestDAO chngStatus = new RequestDAO();

            chngStatus.UpdateStatus(status, reqId);
            EmailDAO emailDAO = new EmailDAO();
            Employee employee = emailDAO.EmailRequestStatus(reqId);
            string   sender   = Session["username"].ToString();
            Email    email    = new Email();

            email.SendEmail(employee.Email, "Requesation Status", "Dear" + employee.Name + ",   \n Please check for Requestsation status. Regards,\n" + sender);
            return(RedirectToAction("ReviewStationeryRequest", "DepartmentHead"));
        }
Exemplo n.º 26
0
        public ActionResult Delete(int requestId)
        {
            string userId = User.Identity.GetUserId();
            var    s1     = StaffDepartmentDAO.GetStaffByUserId(userId);

            if (s1 != null)
            {
                // Delete the request
                RequestDAO.DeleteRequest(s1.staffId, requestId);
            }

            return(RedirectToAction("List"));
        }
Exemplo n.º 27
0
 public void updateApproveRejectStatus([FromBody] RequestViewModel request)
 {
     if (request != null && request.requestId != null && request.status_request != null)
     {
         if (request.status_request.ToUpper() == "APPROVED")
         {
             RequestDAO.ApproveRequest(request.requestId, request.remark);
         }
         else if (request.status_request.ToUpper() == "REJECTED")
         {
             RequestDAO.RejectRequest(request.requestId, request.remark);
         }
     }
 }
        public ActionResult ApproveAllRequests(string id)
        {
            RequestDAO requestDAO = new RequestDAO();

            if (!requestDAO.ApproveAllRequests(id))
            {
                SetFlash(Enums.FlashMessageType.Error, "Something went wrong!");

                return(RedirectToAction("ReviewStationeryRequest", "DepartmentHead"));
            }
            SetFlash(Enums.FlashMessageType.Success, "Great! You've successfully approved all requests");

            return(RedirectToAction("ReviewStationeryRequest", "DepartmentHead"));
        }
Exemplo n.º 29
0
        public List <RequestViewModel> ListRequestsByDepartmentId()
        {
            string userId = User.Identity.GetUserId();
            Staff  s1     = StaffDepartmentDAO.GetStaffByUserId(userId);

            if (s1 == null)
            {
                return(null);
            }

            List <RequestViewModel> reqList = RequestDAO.GetPendingRequestsInDepartment(s1);

            return(reqList);
        }
        public List <int> ExtractSalesReports( )
        {
            int year = DateTime.Now.Year;

            EmployeeDAO employeeDAO = new EmployeeDAO();

            RequestDAO requestDAO = new RequestDAO();

            DepartmentDAO departmentDAO = new DepartmentDAO();

            List <Department> departments = departmentDAO.GetDepartments();

            List <int> monthlySales = new List <int>(); //{paper,pen,stapler}

            foreach (Department d in departments)
            {
                List <RequestReport> requestReports = requestDAO.GetRequestsByDepartment(d.Id);

                if (requestReports != null)
                {
                    int[] sales = new int[3];

                    foreach (RequestReport request in requestReports)
                    {
                        if (request.ReqYear == year)     //DateTime.Today.year)
                        {
                            if (request.CategoryID == 1) //paper
                            {
                                sales[0] += request.Qty;
                            }
                            else if (request.CategoryID == 2) //pen
                            {
                                sales[1] += request.Qty;
                            }
                            else //stapler
                            {
                                sales[2] += request.Qty;
                            }
                        }
                    }
                    //monthlySales.Add(DateTime.Today.Month);
                    monthlySales.Add(sales[0]);
                    monthlySales.Add(sales[1]);
                    monthlySales.Add(sales[2]);
                }
            }
            System.Diagnostics.Debug.WriteLine(monthlySales);
            return(monthlySales);
        }