Exemplo n.º 1
0
        protected void discrepancyListView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            discrepancyListView.PageIndex = e.NewPageIndex;

            User user = (User)Session["user"];

            if (user == null || user.user_type != 5 && user.user_type != 6)
            {
                Response.Redirect("~/Login.aspx");
            }
            id = user.user_type;

            if (id == 5)
            {
                discrepencies = discrepancyController.actionGetDiscrepanciesForStoreSupervisor();
                discrepancyListView.DataSource = discrepencies;
                discrepancyListView.DataBind();
            }
            else if (id == 6)
            {
                discrepencies = discrepancyController.actionGetDiscrepanciesForStoreManager();
                discrepancyListView.DataSource = discrepencies;
                discrepancyListView.DataBind();
            }

            //discrepancyListView.DataSource = discrepencies;
            //discrepancyListView.DataBind();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            discrepancyController = new DiscrepencyController();
            if (!Page.IsPostBack)
            {
                User user = (User)Session["user"];
                if (user == null || user.user_type != 5 && user.user_type != 6)
                {
                    Response.Redirect("~/Login.aspx");
                }
                id = user.user_type;

                if (id == 5)
                {
                    discrepencies = discrepancyController.actionGetDiscrepanciesForStoreSupervisor();
                    discrepancyListView.DataSource = discrepencies;
                    discrepancyListView.DataBind();
                }
                else if (id == 6)
                {
                    discrepencies = discrepancyController.actionGetDiscrepanciesForStoreManager();
                    discrepancyListView.DataSource = discrepencies;
                    discrepancyListView.DataBind();
                }
            }
            //discrepancyListView.DataBind();
        }
        public void get_descrepencies(HttpContext context)
        {
            User user = getUserByAccessToken(context.Request.Form["access_token"]);

            if (user == null)
            {
                return;
            }
            List <Supervisor_Discrepancy_View> ds       = new List <Supervisor_Discrepancy_View>();
            DiscrepencyController discripencyController = new DiscrepencyController();

            switch (user.user_type)
            {
            case 5:
                ds = discripencyController.actionGetDiscrepanciesForStoreSupervisor();
                break;

            case 6:
                ds = discripencyController.actionGetDiscrepanciesForStoreManager();
                break;

            default:
                break;
            }
            List <DiscrepencyViewModel> dvs = new List <DiscrepencyViewModel>();

            foreach (Supervisor_Discrepancy_View d in ds)
            {
                DiscrepencyViewModel vm = new DiscrepencyViewModel();
                vm.id                = d.id;
                vm.stationery_id     = d.stationery;
                vm.stationery_name   = d.stationery_name;
                vm.quantity          = d.quantity;
                vm.price             = d.price;
                vm.totalprice        = d.totalprice;
                vm.datetime_reported = ((DateTime)d.datetime_reported).ToString(" dd/ MM/ yyyy");
                vm.remark            = d.remark;
                dvs.Add(vm);
            }

            context.Response.Write(JsonConvert.SerializeObject(dvs));
        }