public static string loadApprovedRequests()
        {
            User user = (User)HttpContext.Current.Session["user"];
            if (user == null)
            {
                return null;
            }
            int empId = user.id;

            //--------------------------------------------------------------

            JavaScriptSerializer js = new JavaScriptSerializer();
            RequisitionController requisitionController = new RequisitionController();
            // hard coded user id = 6
               // List<Requisition> requisition_entities =requisitionController.actionGetPendingRequisitionsByUserID(6);
            List<Requisition> requisition_entities = requisitionController.actionGetApprovedRequisitionsByUserID(empId);
            List<RequisitionModel> model = new List<RequisitionModel>();
            StationeryController stationeryController = new StationeryController();
            List<StationaryRequests> stationeryRequests = new List<StationaryRequests>();
            foreach (Requisition r in requisition_entities)
            {
                StationaryRequests stationaryRequests = new StationaryRequests();
                stationaryRequests.Quantity = r.quantity;
                stationaryRequests.StrationeryName = stationeryController.actionGetStationeryByID(r.stationery).stationery_name;
                stationaryRequests.RequestedDate = r.datetime_requested.ToString("MMMM dd, yyyy");
                stationeryRequests.Add(stationaryRequests);
            }

            return js.Serialize(stationeryRequests);
        }
예제 #2
0
        public Message actionChangeAllToFulfillment()
        {
            rc = new RequisitionController();
            List <Requisition> approvedList = rc.actionGetApprovedRequisitions();

            return(proceedAll(approvedList));
        }
        public string makeRequisition(int userId, string stationeryName, int quantity)
        {
            StationeryController stController = new StationeryController();
            Requisition requisition = new Requisition();

            // System.Diagnostics.Debug.WriteLine("inside actionGetStationeryIdByName::" + name);
            string newstationeryName = stationeryName.Replace('_', ' ');
            //  System.Diagnostics.Debug.WriteLine("inside actionGetStationeryIdByName::" + newstationeryName);

            int stationeryId = Convert.ToInt32(stController.actionGetStationeryIdByName(newstationeryName));
            requisition.stationery = stationeryId;
            requisition.quantity = quantity;
            requisition.user_obj = userId;
            //hardcoded department id
            requisition.department = 8;
            requisition.user_approved_by = null;
            RequisitionController requisitionController = new RequisitionController();
            Message msg = requisitionController.actionCreateRequisition(requisition);
            if (msg.condition)
            {
                System.Diagnostics.Debug.WriteLine("success");
                return "success";
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("fail");
                return "fail";
            }
        }
예제 #4
0
        public Message actionChangeAllToFulfillmentByDepartment(int dept_id)
        {
            rc = new RequisitionController();
            List <Requisition> approvedList = rc.actionGetApprovedRequisitionsByDepartmentID(dept_id);

            return(proceedAll(approvedList));
        }
예제 #5
0
        public Message actionChangeAllToFulfillmentByDepartmentAndStationeryAndTime(int dept_id, int stationeryId, DateTime dateTime)
        {
            rc = new RequisitionController();
            List <Requisition> approvedList = rc.actionGetApprovedRequisitionsByDepartmentAndStationeryAndDateTime(dept_id, stationeryId, dateTime);

            return(proceedAll(approvedList));
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            User sUser = (User)Session["user"];
            if (sUser == null || sUser.user_type != 1)
            {
                Response.Redirect("~/m/Login.aspx");
            }

            User dUser = new UserController().actionGetUserByID(sUser.id);

            RequisitionController requisitionController = new RequisitionController();
            ApplicationLayer.Requisition requisition = new ApplicationLayer.Requisition();
            requisition.user_obj = dUser.id;
            requisition.stationery = Convert.ToInt32(ui_id_hidden.Value);
            requisition.quantity = Convert.ToInt32(ui_quantity.Text);
            requisition.department = Convert.ToInt32(dUser.department);
            Message message = requisitionController.actionCreateRequisition(requisition);

            if (message.condition)
            {
                Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Requested.") { Path = "/" });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" });
                Response.Redirect("~/m/DepartmentEmployee/Stationeries.aspx");
            }
            else {
                Response.Cookies.Add(new HttpCookie("flash_message", "Requisition Fail. <br />" + message.message) { Path = "/" });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" });
                return;
            }
        }
        public Message actionChangeAllToFulfillmentByDepartmentAndStationeryAndTime(int dept_id, int stationeryId, DateTime dateTime)
        {
            rc = new RequisitionController();
            List<Requisition> approvedList = rc.actionGetApprovedRequisitionsByDepartmentAndStationeryAndDateTime(dept_id, stationeryId, dateTime);

            return proceedAll(approvedList);
        }
        public Message actionChangeAllToFulfillmentByDepartment(int dept_id)
        {
            rc = new RequisitionController();
            List<Requisition> approvedList = rc.actionGetApprovedRequisitionsByDepartmentID(dept_id);

            return proceedAll(approvedList);
        }
        public Message actionChangeAllToFulfillment()
        {
            rc = new RequisitionController();
            List<Requisition> approvedList = rc.actionGetApprovedRequisitions();

            return proceedAll(approvedList);
        }
 public string approveRequisition(string accessToken, int reqId)
 {
     try
     {
         OAuthController oAuth = new OAuthController();
         User user = oAuth.actionGetUserByToken(accessToken);
         //get userId
         RequisitionController requisitionController = new RequisitionController();
         requisitionController.actionRequisitionStatusChangeToApproved(reqId, user.id);
         return "success";
     }
     catch (Exception e)
     {
         return "fail";
     }
 }
 public string approveAllRequisitions(string accessToken, List<RequisitionId> requisitionsIds)
 {
     OAuthController oAuth = new OAuthController();
     User user = oAuth.actionGetUserByToken(accessToken);
     RequisitionController requisitionController = new RequisitionController();
     try
     {
         for (int i = 0; i < requisitionsIds.Count(); i++)
         {
             RequisitionId requisitionId = requisitionsIds[i];
             requisitionController.actionRequisitionStatusChangeToApproved(requisitionId.reqId, user.id);
         }
         return "success";
     }
     catch (Exception e)
     {
         return "fail";
     }
 }
 public string loadAllApprovedRequisitions(String accessToken)
 {
     OAuthController oAuth = new OAuthController();
     User user = oAuth.actionGetUserByToken(accessToken);
     RequisitionController requisitionController = new RequisitionController();
     List<Requisition> requisition_entities = requisitionController.actionGetApprovedRequisitionsByUserID(user.id);
     List<RequisitionModel> model = new List<RequisitionModel>();
     StationeryController stationeryController = new StationeryController();
     List<StationaryRequests> stationeryRequests = new List<StationaryRequests>();
     foreach (Requisition r in requisition_entities)
     {
         StationaryRequests stationaryRequests = new StationaryRequests();
         stationaryRequests.Quantity = r.quantity;
         stationaryRequests.StationaryName = stationeryController.actionGetStationeryByID(r.stationery).stationery_name;
         stationaryRequests.RequestedDate = r.datetime_requested.ToString();
         stationeryRequests.Add(stationaryRequests);
     }
     return JsonConvert.SerializeObject(stationeryRequests);
 }
        public static void approveRequisitions(List<RequisitionID> jsonParam)
        {
            User sUser = (User)HttpContext.Current.Session["user"];
            if (sUser == null)
            {
                return;
            }

            UserController userController = new UserController();
            User dUser = userController.actionGetUserByID(sUser.id);

            JavaScriptSerializer js = new JavaScriptSerializer();
            // System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + js.Serialize(jsonParam));
            System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + jsonParam.Count());

            //actionRequisitionStatusChangeToApproved(int requisition_id)
            RequisitionController requisitionController = new RequisitionController();

            foreach (RequisitionID requisitionId in jsonParam)
            {
                System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ param:" + requisitionId.Id);
                requisitionController.actionRequisitionStatusChangeToApproved(Convert.ToInt32(requisitionId.Id), dUser.id);
            }
        }
        public static string LoadAllApprovedRequests()
        {
            User sUser = (User)HttpContext.Current.Session["user"];
            if (sUser == null)
            {
                return null;
            }

            UserController userController = new UserController();
            User dUser = userController.actionGetUserByID(sUser.id);

            RequisitionController requisitionController = new RequisitionController();
            JavaScriptSerializer js = new JavaScriptSerializer();
            List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetApprovedRequisitionViewsByDepartmentID(Convert.ToInt32(dUser.department));
            System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ requisitions by department wise:" + requisitionDepartmentWise.Count());
            List<UserRequisition> userRequisitionsList = new List<UserRequisition>();
            foreach (RequisitionView r in requisitionDepartmentWise)
            {
                if (userRequisitionsList.Count == 0)
                {
                    UserRequisition userRequisition = new UserRequisition();
                    //Since there are no requisitions made so no question of grouping based on user id
                    userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                    userRequisition.UserId = r.user_obj;
                    Requisition requisition = new Requisition();
                    requisition.ReqId = r.requisition_id;
                    requisition.Quantity = r.quantity;
                    requisition.StationaryName = r.stationery_name;
                    // requisition.RequisitionDate = r.r
                    userRequisition.UserRequisitions.Add(requisition);
                    userRequisitionsList.Add(userRequisition);
                }
                else
                {
                    bool found = false;
                    //check if requisition from the same user is pending, if yes group the requisition based on that user id
                    foreach (UserRequisition uR in userRequisitionsList)
                    {
                        if (r.user_obj == uR.UserId)
                        {
                            found = true;
                            Requisition requisition = new Requisition();
                            requisition.ReqId = r.requisition_id;
                            requisition.Quantity = r.quantity;
                            requisition.StationaryName = r.stationery_name;
                            // requisition.RequisitionDate = r.r
                            uR.UserRequisitions.Add(requisition);
                            break;
                        }

                    }//foreach
                    //else simply add the userrequisition to the list, grouping not required
                    if (!found)
                    {
                        UserRequisition userRequisition = new UserRequisition();
                        userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                        userRequisition.UserId = r.user_obj;

                        Requisition requisition = new Requisition();
                        requisition.ReqId = r.requisition_id;
                        requisition.Quantity = r.quantity;
                        requisition.StationaryName = r.stationery_name;
                        userRequisition.UserRequisitions.Add(requisition);
                        userRequisitionsList.Add(userRequisition);
                    }
                }
            }
            System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ loadAllPendingRequests:" + js.Serialize(userRequisitionsList));
            return js.Serialize(userRequisitionsList);
        }
        public string showAllRejectedRequisitions(string accessToken)
        {
            OAuthController oAuth = new OAuthController();
            User user = oAuth.actionGetUserByToken(accessToken);
            RequisitionController requisitionController = new RequisitionController();

            List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetRejectedRequisitionViewsByDepartmentID(Convert.ToInt32(user.department));

            List<Requisition> requisitions = new List<Requisition>();
            foreach (RequisitionView rView in requisitionDepartmentWise)
            {
                Requisition requisition = new Requisition();
                requisition.EmployeeName = rView.firstname + " " + rView.lastname;
                requisition.Quantity = rView.quantity;
                requisition.RequisitionDate = rView.datetime_requested;
                requisition.ReqDate = rView.datetime_requested.ToString("MMMM dd, yyyy");
                requisition.StationaryName = rView.stationery_name;
                requisitions.Add(requisition);
            }
            return JsonConvert.SerializeObject(requisitions);
        }
        public string showAllPendingRequisition(string accessToken)
        {
            RequisitionController requisitionController = new RequisitionController();
            JavaScriptSerializer js = new JavaScriptSerializer();
            OAuthController oAuth = new OAuthController();
            User user = oAuth.actionGetUserByToken(accessToken);
            // int userId = user.id;
            List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetPendingRequisitionViewsByDepartmentID(Convert.ToInt32(user.department));
            List<UserRequisition> userRequisitionsList = new List<UserRequisition>();
            foreach (RequisitionView r in requisitionDepartmentWise)
            {
                if (userRequisitionsList.Count == 0)
                {
                    UserRequisition userRequisition = new UserRequisition();
                    userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                    userRequisition.UserId = r.user_obj;
                    Requisition requisition = new Requisition();
                    requisition.ReqId = r.requisition_id;
                    requisition.Quantity = r.quantity;
                    requisition.StationaryName = r.stationery_name;
                    userRequisition.UserRequisitions.Add(requisition);
                    userRequisitionsList.Add(userRequisition);
                }
                else
                {
                    bool found = false;
                    //check if requisition from the same user is pending, if yes group the requisition based on that user id
                    foreach (UserRequisition uR in userRequisitionsList)
                    {
                        if (r.user_obj == uR.UserId)
                        {
                            found = true;
                            Requisition requisition = new Requisition();
                            requisition.ReqId = r.requisition_id;
                            requisition.Quantity = r.quantity;
                            requisition.StationaryName = r.stationery_name;
                            requisition.RequisitionDate = r.datetime_requested;
                            uR.UserRequisitions.Add(requisition);
                            break;
                        }

                    }//foreach
                    //else simply add the userrequisition to the list, grouping not required
                    if (!found)
                    {
                        UserRequisition userRequisition = new UserRequisition();
                        userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                        userRequisition.UserId = r.user_obj;
                        Requisition requisition = new Requisition();
                        requisition.ReqId = r.requisition_id;
                        requisition.Quantity = r.quantity;
                        requisition.StationaryName = r.stationery_name;
                        userRequisition.UserRequisitions.Add(requisition);
                        userRequisitionsList.Add(userRequisition);
                    }//if
                }//else
            }//forEach

            System.Diagnostics.Debug.WriteLine("json serialized:" + JsonConvert.SerializeObject(userRequisitionsList));
            return JsonConvert.SerializeObject(userRequisitionsList);
            /// return js.Serialize(userRequisitionsList);
        }
 public string rejectRequisition(string accessToken, int reqId, string reason)
 {
     System.Diagnostics.Debug.WriteLine("inside rejectRequisition: accessToken" + accessToken + " ,reqId:" + reqId + "  ,reason:" + reason);
     try
     {
         OAuthController oAuth = new OAuthController();
         User user = oAuth.actionGetUserByToken(accessToken);
         //get userId
         RequisitionController requisitionController = new RequisitionController();
         //  requisitionController.actionRequisitionStatusChangeToRejected(reqId);
         requisitionController.actionRequisitionStatusChangeToRejectedWithRemarkAndRejectedBy(reqId, reason, user.id);
         return "success";
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("Exception occured in rejectRequisition.." + e.Message);
         return "fail";
     }
 }
        public static string MakeRequisition(object jsonParam)
        {
            User user = (User)HttpContext.Current.Session["user"];
            if (user == null)
            {
                return null;
            }
            int empId = user.id;

            String valueString = jsonParam.ToString();
            string[] values = valueString.Split('.');
               int stId= Convert.ToInt16(values[0]);
            int qty= Convert.ToInt16(values[1]);

            int depId = Convert.ToInt32(user.department);
            Requisition requisition = new Requisition();
            requisition.stationery = stId;
            requisition.quantity = qty;
            requisition.user_obj = empId;
            requisition.department = depId;
            requisition.user_approved_by = null;
            RequisitionController requisitionController = new RequisitionController();
               Message msg= requisitionController.actionCreateRequisition(requisition);
               if (msg.condition)
               {
               //return msg.message;
               return "success";
               }
               else
               {
               //return msg.message;
               return "fail";
               }

              // System.Diagnostics.Debug.WriteLine(" inside MakeRequisition " + msg);
               // return "Hi this is response from MakeRequisition";
        }
        public static void rejectRequisitions(List<RequisitionID> jsonParam, string reason)
        {
            System.Diagnostics.Debug.WriteLine("REASON FOR REJECTION:" + reason);
            User sUser = (User)HttpContext.Current.Session["user"];
            if (sUser == null)
            {
                return;
            }

            JavaScriptSerializer js = new JavaScriptSerializer();
            // System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + js.Serialize(jsonParam));
            //  System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + jsonParam.Count());

            //actionRequisitionStatusChangeToApproved(int requisition_id)
            RequisitionController requisitionController = new RequisitionController();

            foreach (RequisitionID requisitionId in jsonParam)
            {
                // System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ param:" + requisitionId.Id);
                // requisitionController.actionRequisitionStatusChangeToRejected(Convert.ToInt32(requisitionId.Id));
                requisitionController.actionRequisitionStatusChangeToRejectedWithRemarkAndRejectedBy(Convert.ToInt32(requisitionId.Id), reason, sUser.id);
            }
        }