Пример #1
0
        public string SubmitCreateFuelData(FuelData FuelData)
        {
            var                       User     = System.Web.HttpContext.Current.User.Identity.Name;
            FormsIdentity             id       = (FormsIdentity)HttpContext.Current.User.Identity;
            FormsAuthenticationTicket ticket   = id.Ticket;
            string                    userData = ticket.UserData;

            string[]  roles     = userData.Split(',');
            string    userRole  = roles[0];
            UserOpMap userOpMap = new UserOpMap();

            BAL.BAL_Common bAL_Common = new BAL.BAL_Common();
            userOpMap = bAL_Common.GetUserOperationMapping(HttpContext.Current.User.Identity.Name, userRole);

            EntitySubmittedResponse entitySubmittedResponse = new EntitySubmittedResponse();

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            try
            {
                BAL.BAL_Fuel bAL_Fuel = new BAL.BAL_Fuel();
                long         fuelID   = bAL_Fuel.CreateFuel(FuelData, userOpMap);
                entitySubmittedResponse.submited = true;
                entitySubmittedResponse.message  = "Fuel submitted!";
                return(js.Serialize("Fuel Created"));
            }
            catch (Exception ex)
            {
                entitySubmittedResponse.submited = false;
                entitySubmittedResponse.message  = string.Format("Error occured while generating Bill with message:{0}", ex.Message);
                //return js.Serialize(entitySubmittedResponse);
                return(js.Serialize(string.Format("Error occured while generating Bill with message:{0}", ex.Message)));
            }
        }
Пример #2
0
        public string SubmitEditTankerData(TankerData TankerData)
        {
            var                       User     = System.Web.HttpContext.Current.User.Identity.Name;
            FormsIdentity             id       = (FormsIdentity)HttpContext.Current.User.Identity;
            FormsAuthenticationTicket ticket   = id.Ticket;
            string                    userData = ticket.UserData;

            string[]  roles     = userData.Split(',');
            string    userRole  = roles[0];
            UserOpMap userOpMap = new UserOpMap();

            BAL.BAL_Common bAL_Common = new BAL.BAL_Common();
            userOpMap = bAL_Common.GetUserOperationMapping(HttpContext.Current.User.Identity.Name, userRole);

            EntitySubmittedResponse entitySubmittedResponse = new EntitySubmittedResponse();

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            try
            {
                BAL.BAL_Tanker bAL_Tanker = new BAL.BAL_Tanker();
                long           tankerID   = bAL_Tanker.UpdateTanker(TankerData, userOpMap);
                entitySubmittedResponse.submited = true;
                entitySubmittedResponse.message  = "Tanker Data Updated Successfully!";
                //return js.Serialize(entitySubmittedResponse);
                return(js.Serialize("Tanker Data Updated Successfully!"));
            }
            catch (Exception ex)
            {
                entitySubmittedResponse.submited = false;
                entitySubmittedResponse.message  = string.Format("Error occured while updating tanker data with message:{0}", ex.Message);
                return(js.Serialize(string.Format("Error occured while updating tanker data with message:{0}", ex.Message)));
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User != null)
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (HttpContext.Current.User.Identity is FormsIdentity)
                    {
                        HideControls();
                        FormsIdentity             id     = (FormsIdentity)HttpContext.Current.User.Identity;
                        FormsAuthenticationTicket ticket = id.Ticket;
                        string   userData = ticket.UserData;
                        string[] roles    = userData.Split(',');
                        HttpContext.Current.User = new GenericPrincipal(id, roles);
                        string         userRole   = roles[0];
                        UserOpMap      userOpMap  = new UserOpMap();
                        BAL.BAL_Common bAL_Common = new BAL.BAL_Common();
                        userOpMap = bAL_Common.GetUserOperationMapping(HttpContext.Current.User.Identity.Name, userRole);
                        foreach (Operations op in userOpMap.OperationsList)
                        {
                            var ctrl = this.FindControl(op.OperationName);
                            switch (ctrl.ID)
                            {
                            case "Dashboard":
                                Dashboard.Attributes.Add("style", "display:block");
                                break;

                            case "ManageCustomer":
                                ManageCustomer.Attributes.Add("style", "display:block");
                                break;

                            case "ManageTanks":
                                ManageTanks.Attributes.Add("style", "display:block");
                                break;

                            case "ManageFuel":
                                ManageFuel.Attributes.Add("style", "display:block");
                                break;

                            case "CreateSale":
                                CreateSale.Attributes.Add("style", "display:block");
                                break;

                            case "ViewSalesReports":
                                ViewSalesReports.Attributes.Add("style", "display:block");
                                break;

                            case "ViewInventoryReports":
                                ViewInventoryReports.Attributes.Add("style", "display:block");
                                break;

                            default:
                                ShowAllControls();
                                break;
                            }
                        }

                        string pageName = GetCurrentPageName();
                        switch (pageName)
                        {
                        case "Dashboard":
                            Dashboard.Attributes.Add("class", "active");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes["class"].Replace("active", "dropdown");
                            break;

                        case "ManageCustomer":
                            ManageCustomer.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes.Add("class", "dropdown active");
                            break;

                        case "ManageTanks":
                            ManageTanks.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes.Add("class", "dropdown active");
                            break;

                        case "ManageFuel":
                            ManageFuel.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes.Add("class", "dropdown active");
                            break;

                        case "CreateSale":
                            CreateSale.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes.Add("class", "dropdown active");
                            break;

                        case "InventoryReport":
                            ViewInventoryReports.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes.Add("class", "dropdown active");
                            servicesMainLi.Attributes["class"].Replace("active", "dropdown");
                            break;

                        case "SalesReport":
                            ViewSalesReports.Attributes.Add("class", "active");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes.Add("class", "dropdown active");
                            servicesMainLi.Attributes["class"].Replace("active", "dropdown");
                            break;

                        case "Sale":
                            CreateSale.Attributes.Add("class", "active");
                            Dashboard.Attributes["class"].Replace("active", "");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes.Add("class", "dropdown active");
                            break;

                        default:
                            Dashboard.Attributes.Add("class", "active");
                            ManageCustomer.Attributes["class"].Replace("active", "");
                            ManageTanks.Attributes["class"].Replace("active", "");
                            ManageFuel.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewInventoryReports.Attributes["class"].Replace("active", "");
                            CreateSale.Attributes["class"].Replace("active", "");
                            ViewSalesReports.Attributes["class"].Replace("active", "");
                            reportMainLi.Attributes["class"].Replace("active", "dropdown");
                            servicesMainLi.Attributes["class"].Replace("active", "dropdown");
                            break;
                        }
                    }
                }
                else
                {
                    FormsAuthentication.SignOut();
                    Response.Redirect("~/Login.aspx");
                }
            }
        }