public void TestBusinessLocationDecrementStock(int id, string address, string city, string zipcode, string state,
                                                       int productId, string productName, decimal productPrice, int productStock)
        {
            BusinessLocation location = new BusinessLocation();

            location.Id      = id;
            location.Address = address;
            location.City    = city;
            location.Zipcode = zipcode;
            location.State   = state;

            BusinessProduct product = new BusinessProduct()
            {
                Id    = productId,
                Name  = productName,
                Price = productPrice
            };

            location.AddProduct(product, productStock);
            int quantity = 1;

            location.DecrementStock(product, quantity);

            Assert.Equal(location.inventory[product], productStock - 1);
        }
Пример #2
0
 protected void OnBusinessLocationSelect(BusinessLocation location)
 {
     if (location.BusinessOrg == null)
     {
         SessionManager.EffLocation = location;
         //  uclSearchBar.TitleItem.Text =  "- " + location.Company.COMPANY_NAME;
         uclSearchBar.SetButtonsEnabled(false, false, false, false, false, false);
     }
     else if (location.Plant == null)
     {
         SessionManager.EffLocation = location;
         pnlSearchList.Visible      = uclBusLoc.LocationSelectPanel.Visible = false;
         divPageBody.Visible        = uclAdminTabs.BusOrgPanel.Visible = true;
         uclSearchBar.SetButtonsNotClicked();
         uclSearchBar.SetButtonsEnabled(false, false, false, false, false, true);
         SetupPage();
         tab_Click("lbBusOrgDetail_tab", "");
     }
     else
     {
         SessionManager.EffLocation = location;
         SetLocalOrg(null);
         uclSearchBar.SetButtonsNotClicked();
         uclSearchBar.SetButtonsEnabled(false, false, false, false, false, true);
         Response.Redirect("/Admin/Administrate_ViewPlant.aspx");
     }
 }
        public void TestBusinessLocationDecrementStockWhenProductNotInStock(int id, string address, string city, string zipcode, string state,
                                                                            int productId, string productName, decimal productPrice, int productStock)
        {
            BusinessLocation location = new BusinessLocation();

            location.Id      = id;
            location.Address = address;
            location.City    = city;
            location.Zipcode = zipcode;
            location.State   = state;

            BusinessProduct product = new BusinessProduct()
            {
                Id    = productId,
                Name  = productName,
                Price = productPrice
            };

            location.AddProduct(product, productStock);

            BusinessProduct productNotInStock = new BusinessProduct()
            {
                Id    = productId + 1,
                Name  = productName + "a",
                Price = productPrice + 1
            };
            int quantity = 10;

            Assert.Throws <BusinessLocationException>(() => location.DecrementStock(productNotInStock, quantity));
        }
Пример #4
0
        // GET api/rosterapi?businessId=1231232&startDate=12312&endDate=1232132
        public IEnumerable <RosterDTO> GetRostersForBusiness(Guid businessLocationId, string startDate, string endDate)
        {
            DateTime         sDate            = DateTime.Parse(startDate);
            DateTime         eDate            = DateTime.Parse(endDate);
            BusinessLocation businessLocation = db.BusinessLocations.Find(businessLocationId);

            if (businessLocation == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            if (ClaimsAuthorization.CheckAccess("Get", "BusinessId", businessLocation.Business.Id.ToString()))
            {
                var rosterList = db.Rosters.Where(r => r.BusinessLocation.Id == businessLocationId && r.WeekStartDate >= sDate && r.WeekStartDate <= eDate);

                if (rosterList == null)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(MapperFacade.MapperConfiguration.Map <IEnumerable <Roster>, IEnumerable <RosterDTO> >(rosterList.AsEnumerable()));
            }
            else
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
        }
Пример #5
0
        public HttpResponseMessage PostinternalLocation(Guid businesslocationId, Guid internalLocationId, InternalLocationDTO internalLocationDTO)
        {
            BusinessLocation businessLocation = db.BusinessLocations.Find(businesslocationId);

            if (businessLocation == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            if (ClaimsAuthorization.CheckAccess("Put", "BusinessLocationId", businessLocation.Id.ToString()))
            {
                if (ModelState.IsValid)
                {
                    var location = MapperFacade.MapperConfiguration.Map <InternalLocationDTO, InternalLocation>(internalLocationDTO);
                    location.Id      = Guid.NewGuid(); //Assign new ID on save.
                    location.Enabled = true;

                    //Lookup Business and attach, so that no updates or inserts are performed on BusinessType lookup table
                    location.BusinessLocation = db.BusinessLocations.SingleOrDefault(b => b.Id == businesslocationId);

                    db.InternalLocations.Add(location);
                    db.SaveChanges();

                    return(Request.CreateResponse(HttpStatusCode.Created));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            else
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
        }
Пример #6
0
        public BusinessLocation ProblemBusinessLocation()
        {
            BusinessLocation problemLocation = new BusinessLocation();

            if (this.IncidentList != null && this.IncidentList.Count > 0)
            {
                INCIDENT incident = this.IncidentList[0];
                if (incident.INCIDENT_TYPE == "QI")
                {
                    problemLocation.Company     = SQMModelMgr.LookupCompany((decimal)incident.RESP_COMPANY_ID);
                    problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.RESP_BUS_ORG_ID);
                    problemLocation.Plant       = SQMModelMgr.LookupPlant((decimal)incident.RESP_PLANT_ID);
                }
                else
                {
                    problemLocation.Company     = SQMModelMgr.LookupCompany((decimal)incident.DETECT_COMPANY_ID);
                    problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.DETECT_BUS_ORG_ID);
                    problemLocation.Plant       = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
                }
            }
            else
            {
                problemLocation.Company = this.ProbCase.COMPANY;
            }

            return(problemLocation);
        }
Пример #7
0
 public static object Map(this BusinessLocation location, long eventId)
 {
     return(new
     {
         EventId = eventId,
         BusinessLocationId = location.Id,
         location.CustomFields
     });
 }
Пример #8
0
        public ActionResult LocationTemplate(int id, BusinessLocation u, HttpPostedFileBase ImageURL = null)
        {
            string fullPath = null;

            if (ImageURL != null)
            {
                var path = System.IO.Path.GetFileName(ImageURL.FileName);
                fullPath = "/Content/images/" + MD5Hasher.Hash(DateTime.Now.ToShortTimeString() + DateTime.Now.ToShortDateString()) + path;
                fullPath = fullPath.Replace(" ", "_");
                ImageURL.SaveAs(Server.MapPath(fullPath));
            }
            int        uid;
            string     utoken;
            HttpCookie cookie = Request.Cookies["User"];

            if (cookie != null)
            {
                uid    = int.Parse(cookie["id"]);
                utoken = cookie["token"];
            }
            else
            {
                uid    = 0;
                utoken = null;
            }
            if (auth.CheckAuthStatus(uid, utoken) && auth.GetCurrentUser(cookie)["Role"] == "1")
            {
                ViewBag.RoleNum = auth.GetCurrentUser(cookie)["Role"];
                ViewBag.User    = auth.GetCurrentUser(cookie)["User"];
                ViewBag.Role    = db.Roles.Find(int.Parse(auth.GetCurrentUser(cookie)["Role"])).Name;
                if (id == 0)
                {
                    u.ImageURL = fullPath;
                    db.BusinessLocation.Add(u);
                }
                else
                {
                    db.BusinessLocation.Find(id).Name        = u.Name;
                    db.BusinessLocation.Find(id).Email       = u.Email;
                    db.BusinessLocation.Find(id).Description = u.Description;
                    db.BusinessLocation.Find(id).ImageURL    = fullPath;
                    db.BusinessLocation.Find(id).IsPartner   = u.IsPartner;
                    db.BusinessLocation.Find(id).Latitude    = u.Latitude;
                    db.BusinessLocation.Find(id).Longtitude  = u.Longtitude;
                    db.BusinessLocation.Find(id).PhoneNumber = u.PhoneNumber;
                }
                db.SaveChanges();
                return(Redirect("~/Locations"));
            }
            else
            {
                return(Redirect("~/Login"));
            }
        }
Пример #9
0
        public void BindBusinessLocation(BusinessLocation businessLocation, bool bindAll, bool allowChange, bool showLocationInputs, bool showHeader)
        {
            newLocation      = currentLocation = businessLocation;
            staticShowHeader = showHeader;

            if (allowChange)
            {
                pnlBusinessLocEdit.Visible = true;
                if (newLocation.Company != null)
                {
                    lblSelCompany.Text = newLocation.Company.COMPANY_NAME;
                }
                if (bindAll)
                {
                    if (newLocation.BusinessOrg != null)
                    {
                        lblSelBusOrg.Text = newLocation.BusinessOrg.ORG_NAME;
                    }
                    if (newLocation.Plant != null)
                    {
                        lblSelPlant.Text = newLocation.Plant.PLANT_NAME;
                    }
                }
                else
                {
                    lblSelBusOrg.Visible = lblSelPlant.Visible = false;
                }
            }
            else
            {
                pnlBusinessLoc.Visible = true;
                if (newLocation.Company != null)
                {
                    lblUserCompany.Text = newLocation.Company.COMPANY_NAME;
                }
                if (bindAll)
                {
                    if (newLocation.BusinessOrg != null)
                    {
                        lblUserBusOrg.Text = newLocation.BusinessOrg.ORG_NAME;
                    }
                    if (newLocation.Plant != null)
                    {
                        lblUserPlant.Text = newLocation.Plant.PLANT_NAME;
                    }
                }
            }

            if (showLocationInputs)
            {
                lblSelCompany.Visible = pnlLocationText.Visible = btnCancel.Visible = true;
                //btnReset.Visible = true;
            }
        }
Пример #10
0
 protected void OnBusinessLocationAdd(BusinessLocation location)
 {
     if (location.BusinessOrg != null)
     {
         SessionManager.EffLocation = location;
         SetLocalOrg(null);
         uclSearchBar.SetButtonsNotClicked();
         uclSearchBar.SetButtonsEnabled(false, false, false, false, false, true);
         Response.Redirect("/Admin/Administrate_ViewPlant.aspx");
     }
 }
Пример #11
0
        public void BindApproverListR(List <INCFORMAPPROVERLIST> ApproverItemList, BusinessLocation businessLocation, string context)
        {
            hfApproverActionContext.Value = context;
            if (context != "company")
            {
                hfApproverActionBusLoc.Value = context == "plant" ? businessLocation.Plant.PLANT_ID.ToString() : businessLocation.BusinessOrg.BUS_ORG_ID.ToString();
            }


            pnlApproverAction.Visible           = true;
            rgRegionalApproverAction.DataSource = ApproverItemList;
            rgRegionalApproverAction.DataBind();
        }
Пример #12
0
 private void ApplyWorkingLocation(BusinessLocation newLocation)
 {
     if (newLocation == null)
     {
         SessionManager.UserContext.WorkingLocation = SessionManager.UserContext.HRLocation;
     }
     else
     {
         SessionManager.UserContext.WorkingLocation = newLocation;
         uclPrefsEdit.BindUser(null, SessionManager.UserContext.HRLocation, SessionManager.UserContext.WorkingLocation);
     }
     Server.Transfer(Request.Path);
 }
Пример #13
0
        private Roster CreateRosterForWeekStarting(RosterCreateDTO rosterCreateDTO, BusinessLocation businessLocation, int weeksToAdd = 0)
        {
            var roster = MapperFacade.MapperConfiguration.Map <RosterCreateDTO, Roster>(rosterCreateDTO);

            roster.Id = Guid.NewGuid(); //Assign new ID on save.
            roster.BusinessLocation = businessLocation;
            roster.WeekStartDate    = roster.WeekStartDate.AddDays(7 * weeksToAdd);

            roster.Timesheet = new Timesheet {
                Id = Guid.NewGuid()
            };

            //Add template shifts to roster
            if (rosterCreateDTO.UseShiftTemplates)
            {
                //First set up all recurring weekly shifs
                var weeklyShiftTemplates = new List <ShiftTemplate>();
                weeklyShiftTemplates.AddRange(businessLocation.ShiftTemplates.Where(st => st.Frequency == ShiftFrequency.Weekly && st.Enabled));
                CreateShiftsFromTemplates(roster, weeklyShiftTemplates);

                //Then set up any once off shifts for this week
                var oneOffShiftTemplates = new List <ShiftTemplate>();
                oneOffShiftTemplates.AddRange(businessLocation.ShiftTemplates.Where(st => st.Frequency == ShiftFrequency.OneOff && st.WeekStarting == roster.WeekStartDate && st.Enabled));
                CreateShiftsFromTemplates(roster, oneOffShiftTemplates);


                var weekOfYear = WebUI.Common.Common.GetWeekOfYear(roster.WeekStartDate);

                //If this is an odd week in the year then apply fortnight1 (this is due to 1st week of year being off, so start year on fortnight1)
                if (weekOfYear % 2 == 1)
                {
                    var firstWeekShiftTemplates = businessLocation.ShiftTemplates.Where(st => st.Frequency == ShiftFrequency.Fortnight1 && st.Enabled).ToList();

                    CreateShiftsFromTemplates(roster, firstWeekShiftTemplates);
                }
                else //Every other week apply Fortnight2
                {
                    var secondWeekShiftTemplates = businessLocation.ShiftTemplates.Where(st => st.Frequency == ShiftFrequency.Fortnight2 && st.Enabled);

                    CreateShiftsFromTemplates(roster, secondWeekShiftTemplates);
                }

                if (weeksToAdd == 3) //If we have added at least 4 weeks (ie one month) then insert monthly template
                {
                    var monthShiftTemplates = businessLocation.ShiftTemplates.Where(st => st.Frequency == ShiftFrequency.Monthly && st.Enabled);

                    CreateShiftsFromTemplates(roster, monthShiftTemplates);
                }
            }
            return(roster);
        }
Пример #14
0
        private void SetupPage()
        {
            if (langList == null || langList.Count == 0)
            {
                langList = SQMModelMgr.SelectLanguageList(new PSsqmEntities(), true);
                uclPrefsEdit.SetLanguageList(langList);
            }

            BusinessLocation businessLocation = new BusinessLocation(); businessLocation = SessionManager.UserContext.HRLocation;

            List <decimal> respForList = new List <decimal>();

            respForList.Add(SessionManager.UserContext.Person.PERSON_ID);
            respForList.AddRange(SessionManager.UserContext.DelegateList);

            SessionManager.UserContext.TaskList.Clear();
            SessionManager.UserContext.TaskList = new List <TaskItem>();
            AccessMode accessmode;

            DateTime fromDate = DateTime.Now.AddMonths(-6);

            if ((accessmode = UserContext.RoleAccess()) > AccessMode.Limited)
            {
                SessionManager.UserContext.TaskList.AddRange(TaskMgr.ProfileInputStatus(new DateTime(fromDate.Year, fromDate.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), respForList, SessionManager.UserContext.EscalationAssignments));
                SessionManager.UserContext.TaskList.AddRange(TaskMgr.IncidentTaskStatus(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, respForList, SessionManager.UserContext.EscalationAssignments, true));
                if (accessmode == AccessMode.Admin && SessionManager.UserContext.EscalationAssignments.Count > 0)
                {
                    SessionManager.UserContext.TaskList.AddRange(TaskMgr.ProfileFinalizeStatus(new DateTime(fromDate.Year, fromDate.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), respForList, SessionManager.UserContext.EscalationAssignments, SessionManager.UserContext.Person));
                }
            }

            lblTaskCount0.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Owner).Count().ToString();
            uclTaskList0.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Owner).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());

            lblTaskCount1.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Delegate).Count().ToString();
            if (lblTaskCount1.Text != "0")
            {
                divTaskList1.Visible = pnlTaskList1.Visible = true;
                uclTaskList1.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Delegate).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());
            }

            lblTaskCount2.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Escalation).Count().ToString();
            if (lblTaskCount2.Text != "0")
            {
                divTaskList2.Visible = pnlTaskList2.Visible = true;
                uclTaskList2.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Escalation).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());
            }

            ++SessionManager.UserContext.InboxReviews;
        }
Пример #15
0
        /// <summary>
        /// Retrieves all of the locations in the database.
        /// </summary>
        /// <returns>All BusinessLocation objects in the database</returns>
        public static ICollection <BusinessLocation> GetLocations()
        {
            Log.Information($"Called the Data Access method to get the all locations");
            using var context = new TThreeTeasContext(SQLOptions.options);

            List <BusinessLocation> bLocations = new List <BusinessLocation>();

            foreach (Location location in context.Location)
            {
                BusinessLocation bLocation = GetLocationWithId(location.Id);
                bLocations.Add(bLocation);
            }
            return(bLocations);
        }
        public void BindPrivGroups(List <PRIVGROUP> privGroupList, BusinessLocation businessLocation, string context)
        {
            hfPrivGroupContext.Value = context;

            if (ddlPrivGroupStatus.Items.Count == 0)
            {
                XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "ACTIVE_STATUS", "PRIV_PRIV", "PRIV_SCOPE"
                });

                ddlPrivGroupStatus.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "ACTIVE_STATUS").ToList();
                ddlPrivGroupStatus.DataValueField = "XLAT_CODE";
                ddlPrivGroupStatus.DataTextField  = "DESCRIPTION";
                ddlPrivGroupStatus.DataBind();
            }

            if (ddlScope.Items.Count == 0)
            {
                ddlScope.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "PRIV_SCOPE").ToList();
                ddlScope.DataValueField = "XLAT_CODE";
                ddlScope.DataTextField  = "DESCRIPTION";
                ddlScope.DataBind();
            }

            if (ddlPriviledge.Items.Count == 0)
            {
                ddlPriviledge.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "PRIV_PRIV").ToList();
                ddlPriviledge.DataValueField = "XLAT_CODE";
                ddlPriviledge.DataTextField  = "DESCRIPTION";
                ddlPriviledge.DataBind();
                RadComboBoxItem item = new RadComboBoxItem("", "select a priviledge level");
                ddlPriviledge.Items.Insert(0, item);
                try
                {
                    item         = ddlPriviledge.FindItemByValue("100");
                    item.Enabled = false;
                }
                catch { }
            }

            defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", "");

            pnlPrivGroups.Visible = true;

            rgPrivGroup.DataSource = privGroupList;
            rgPrivGroup.DataBind();
        }
        public void TestBusinessLocationSettersAndGetters(int id, string address, string city, string zipcode, string state,
                                                          int expectedId, string expectedAddress, string expectedCity, string expectedZipcode, string expectedState)
        {
            BusinessLocation location = new BusinessLocation();

            location.Id      = id;
            location.Address = address;
            location.City    = city;
            location.Zipcode = zipcode;
            location.State   = state;

            Assert.Equal(expectedId, id);
            Assert.Equal(expectedAddress, address);
            Assert.Equal(expectedCity, city);
            Assert.Equal(expectedZipcode, zipcode);
            Assert.Equal(expectedState, state);
        }
Пример #18
0
        public void BindUser(PERSON person, BusinessLocation HRLocation, BusinessLocation workingLocation)
        {
            ToggleVisible(pnlUserPrefEdit);
            PERSON user = person;

            if (user == null)
            {
                user = SessionManager.UserContext.Person;
            }

            tbUserPhone.Text = user.PHONE;

            if (HRLocation != null)
            {
                uclHRLoc.BindBusinessLocation(HRLocation, true, false, true, false);
            }
        }
Пример #19
0
        private void SetupPage()
        {
            if (langList == null || langList.Count == 0)
            {
                langList = SQMModelMgr.SelectLanguageList(new PSsqmEntities(), true);
                uclPrefsEdit.SetLanguageList(langList);
            }

            BusinessLocation businessLocation = new BusinessLocation(); businessLocation = SessionManager.UserContext.HRLocation;

            uclPrefsEdit.BindUser(null, SessionManager.UserContext.HRLocation, SessionManager.UserContext.WorkingLocation);

            if (UserContext.CheckAccess("CQM", "home", "92") == AccessMode.None)
            {
                uclPrefsEdit.DelegateList.Attributes.Add("disabled", "true");
            }

            // quality tasks
            if (uclTaskList.TaskListRepeater.Items.Count < 1)
            {
                bool            hasDelegates;
                List <TaskItem> taskList = new List <TaskItem>();
                // taskList = QualityIssue.IncidentTaskList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, SessionManager.UserContext.Person.PERSON_ID, false, out hasDelegates);

                // EHS inputs
                if (UserContext.CheckAccess("EHS", "input", "301") > AccessMode.View)
                {
                    if (respForList == null || respForList.Count == 0)
                    {
                        respForList = SQMModelMgr.SelectDelegateList(SessionManager.UserContext.Person.PERSON_ID);
                        respForList.Insert(0, SessionManager.UserContext.Person);
                    }
                    decimal[] pids = respForList.Select(l => l.PERSON_ID).ToArray();
                    taskList.AddRange(EHSModel.ProfileTaskList(EHSModel.GetIncompleteInputs(pids, DateTime.Now.AddMonths(-12))));
                }
                // Problem cases
                if (UserContext.CheckAccess("CQM", "prob", "151") > AccessMode.View)
                {
                    taskList.AddRange(ProblemCase.CaseTaskList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, SessionManager.UserContext.Person.PERSON_ID, false, out hasDelegates));
                }

                // taskList = taskList.OrderBy(l => l.RecordType).ThenBy(l => l.RecordID).ToList();
                uclTaskList.BindTaskList(taskList);
            }
        }
Пример #20
0
        public BusinessLocationDTO GetBusinessLocation(Guid businesslocationid)
        {
            BusinessLocation businessLocation = db.BusinessLocations.Find(businesslocationid);

            if (businessLocation == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            if (ClaimsAuthorization.CheckAccess("Get", "BusinessId", businessLocation.Business.Id.ToString()))
            {
                return(MapperFacade.MapperConfiguration.Map <BusinessLocation, BusinessLocationDTO>(businessLocation));
            }
            else
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
        }
Пример #21
0
        public void BindNotfyPlan(List <NOTIFYACTION> notifyItemList, BusinessLocation businessLocation, string context)
        {
            XLATList = SQMBasePage.SelectXLATList(new string[4] {
                "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS", "NOTIFY_TIMING"
            });

            hfNotifyActionContext.Value = context;
            hfNotifyActionBusLoc.Value  = context == "plant" ? businessLocation.Plant.PLANT_ID.ToString() : businessLocation.BusinessOrg.BUS_ORG_ID.ToString();

            ddlNotifyScope.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE").ToList();
            ddlNotifyScope.DataValueField = "XLAT_CODE";
            ddlNotifyScope.DataTextField  = "DESCRIPTION";
            ddlNotifyScope.DataBind();

            ddlScopeTask.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK").ToList();
            ddlScopeTask.DataValueField = "XLAT_CODE";
            ddlScopeTask.DataTextField  = "DESCRIPTION";
            ddlScopeTask.DataBind();

            ddlScopeStatus.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TASK_STATUS").ToList();
            ddlScopeStatus.DataValueField = "XLAT_CODE";
            ddlScopeStatus.DataTextField  = "DESCRIPTION";
            ddlScopeStatus.DataBind();

            ddlScopeTiming.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TIMING").ToList();
            ddlScopeTiming.DataValueField = "XLAT_CODE";
            ddlScopeTiming.DataTextField  = "DESCRIPTION";
            ddlScopeTiming.DataBind();

            foreach (PRIVGROUP pg in SQMModelMgr.SelectPrivGroupList(new SysPriv[2] {
                SysPriv.admin, SysPriv.notify
            }, SysScope.incident, "A").ToList())
            {
                ddlNotifyPrivGroup.Items.Add(new RadComboBoxItem(SQMModelMgr.FormatPrivGroup(pg), pg.PRIV_GROUP));
            }

            pnlNotifyAction.Visible = true;

            hfNotifyActionContext.Value = context;

            rgNotifyAction.DataSource = notifyItemList;
            rgNotifyAction.DataBind();
        }
Пример #22
0
        public ActionResult LocationTemplate(int id)
        {
            int        uid;
            string     utoken;
            HttpCookie cookie = Request.Cookies["User"];

            if (cookie != null)
            {
                uid    = int.Parse(cookie["id"]);
                utoken = cookie["token"];
            }
            else
            {
                uid    = 0;
                utoken = null;
            }

            if (auth.CheckAuthStatus(uid, utoken) && auth.GetCurrentUser(cookie)["Role"] == "1")
            {
                ViewBag.RoleNum   = auth.GetCurrentUser(cookie)["Role"];
                ViewBag.User      = auth.GetCurrentUser(cookie)["User"];
                ViewBag.Role      = db.Roles.Find(int.Parse(auth.GetCurrentUser(cookie)["Role"])).Name;
                ViewBag.UID       = id;
                ViewBag.Roles     = db.Roles;
                ViewBag.Companies = db.Company.OrderBy(a => a.Name);
                ViewBag.Part      = "Locations";
                if (id == 0)
                {
                    return(View(new BusinessLocation {
                    }));
                }
                else
                {
                    BusinessLocation a = db.BusinessLocation.Find(id);
                    return(View(a));
                }
            }
            else
            {
                return(Redirect("~/Login"));
            }
        }
Пример #23
0
        protected void btnListCompanies_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            pnlSelectCompany.Visible = true;
            switch (btn.CommandArgument)
            {
            case "prime":
                SelectCompany(SessionManager.UserContext.HRLocation.Company.COMPANY_ID);
                return;

                break;

            case "cust":
                uclCompanyList.BindCompanyList(SQMModelMgr.SelectCompanyList(new PSsqmEntities(), true, false, false));
                btnCancel.Enabled = true;
                break;

            case "supp":
                uclCompanyList.BindCompanyList(SQMModelMgr.SelectCompanyList(new PSsqmEntities(), false, true, false));
                btnCancel.Enabled = true;
                break;

            case "reset":
                pnlSelectCompany.Visible = btnCancel.Enabled = false;
                newLocation        = null;
                lblSelCompany.Text = lblSelBusOrg.Text = lblSelPlant.Text = "";
                break;

            default:        // cancel
                pnlSelectCompany.Visible = btnCancel.Enabled = false;
                BindBusinessLocation(currentLocation, true, true, true, false);
                if (OnBusinessLocationChange != null)
                {
                    OnBusinessLocationChange(currentLocation);
                }
                break;
            }
            uclCompanyList.CloseCompanyListButton.Visible = false;
            btn.Focus();
        }
Пример #24
0
 protected void SelectCompany(decimal companyID)
 {
     if (companyID > 0)
     {
         newLocation         = new BusinessLocation();
         newLocation.Company = (COMPANY)SQMModelMgr.LookupCompany(companyID);
         lblSelBusOrg.Text   = lblSelPlant.Text = "";
         if (staticShowHeader)
         {
             uclItemHdr.DisplayCompanyData(newLocation.Company, SQMModelMgr.PersonCount(companyID));
         }
         uclCompanyList.BindOrgListRepeater(SQMModelMgr.SearchBusOrgList(new PSsqmEntities(), companyID, "", false).OrderBy(l => l.BUS_ORG_ID).ToList());
         if (OnCompanyChange != null)
         {
             OnCompanyChange(newLocation);
         }
     }
     else
     {
         pnlSelectCompany.Visible = false;
     }
 }
Пример #25
0
        public ActionResult SearchByLocation(float latitude, float longitude, int tipo_comercio)
        {
            List <UserInformation> BusinessLocation;

            try
            {
                using (var db = _context)
                {
                    BusinessLocation = db.UserInformation.FromSql("SELECT * FROM UserInformation WHERE dbo.DistanceBetween({0}, {1}, Latitude, Longitude) < 5", latitude, longitude).ToList();
                    // return BusinessLocation.AsQueryable();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            var jsonBusiness = from business in BusinessLocation.AsEnumerable()
                               select JsonComercioFromComercio(business);

            return(Json(jsonBusiness.ToList()));
            //return View();
        }
Пример #26
0
        /// <summary>
        /// Retrieves the BusinessOrder with the given order id
        /// </summary>
        /// <param name="orderId">The id of the order</param>
        /// <returns>The BusinessOrder object with the given order id</returns>
        public static BusinessOrder GetOrderWithId(int orderId)
        {
            Log.Information($"Called the Data Access method to get the order with order id {orderId}");
            using var context = new TThreeTeasContext(SQLOptions.options);

            Orders order = context.Orders.FirstOrDefault(o => o.Id == orderId);

            if (order is null)
            {
                return(null);
            }

            BusinessLocation bLocation = LocationData.GetLocationWithId(order.LocationId);
            BusinessCustomer bCustomer = CustomerData.GetCustomerWithId(order.CustomerId);
            BusinessOrder    bOrder    = new BusinessOrder
            {
                Id            = order.Id,
                StoreLocation = bLocation,
                Customer      = bCustomer,
                OrderTime     = order.OrderTime
            };

            Dictionary <BusinessProduct, int> lineItems = new Dictionary <BusinessProduct, int>();

            foreach (LineItem item in context.LineItem.Where(l => l.OrdersId == order.Id).ToList())
            {
                Product         product  = context.Product.Where(p => p.Id == item.ProductId).FirstOrDefault();
                BusinessProduct bProduct = new BusinessProduct()
                {
                    Id    = product.Id,
                    Name  = product.Name,
                    Price = product.Price
                };
                lineItems.Add(bProduct, item.Quantity);
            }
            bOrder.AddLineItems(lineItems);

            return(bOrder);
        }
        public void TestBusinessLocationAddProduct(int id, string address, string city, string zipcode, string state,
                                                   int productId, string productName, decimal productPrice, int productStock)
        {
            BusinessLocation location = new BusinessLocation();

            location.Id      = id;
            location.Address = address;
            location.City    = city;
            location.Zipcode = zipcode;
            location.State   = state;

            BusinessProduct product = new BusinessProduct()
            {
                Id    = productId,
                Name  = productName,
                Price = productPrice
            };

            location.AddProduct(product, productStock);

            Assert.True(location.inventory.ContainsKey(product));
            Assert.Equal(location.inventory[product], productStock);
        }
Пример #28
0
        /// <summary>
        /// Retrieves the location with the given location id.
        /// </summary>
        /// <param name="locationId">The id of the location</param>
        /// <returns>
        /// The BusinessLocation object that maps to the location with the given location id
        /// </returns>
        public static BusinessLocation GetLocationWithId(int locationId)
        {
            Log.Information($"Called the Data Access method to get the location with location id {locationId}");
            using var context = new TThreeTeasContext(SQLOptions.options);

            Location location = context.Location.Where(l => l.Id == locationId).FirstOrDefault();

            if (location is null)
            {
                return(null);
            }

            BusinessLocation bLocation = new BusinessLocation()
            {
                Id      = location.Id,
                Address = location.Address,
                City    = location.City,
                Zipcode = location.Zipcode,
                State   = location.State
            };

            List <Inventory> inventories = context.Inventory.Where(i => i.LocationId == location.Id).ToList();

            foreach (Inventory inventory in inventories)
            {
                Product         product  = context.Product.Where(p => p.Id == inventory.ProductId).FirstOrDefault();
                BusinessProduct bProduct = new BusinessProduct()
                {
                    Id    = product.Id,
                    Name  = product.Name,
                    Price = product.Price
                };
                bLocation.AddProduct(bProduct, inventory.Stock);
            }

            return(bLocation);
        }
Пример #29
0
        public static RadComboBoxItem SetLocationItem(BusinessLocation loc, bool formal)
        {
            RadComboBoxItem item = null;

            if (loc != null)
            {
                if (formal)
                {
                    item = new RadComboBoxItem(loc.Company.COMPANY_NAME + ", " + loc.Plant.PLANT_NAME, loc.Plant.PLANT_ID.ToString());
                }
                else
                {
                    item = new RadComboBoxItem(loc.Plant.PLANT_NAME, loc.Plant.PLANT_ID.ToString());
                }

                ADDRESS address = loc.Plant.ADDRESS.FirstOrDefault();
                if (address != null)
                {
                    item.ToolTip = address.STREET1 + " " + address.CITY;
                }
            }

            return(item);
        }
Пример #30
0
 public void RefreshOrgList(BusinessLocation location)
 {
     pnlSelectCompany.Visible = true;
     SelectCompany(location.Company.COMPANY_ID);
 }
Пример #31
0
        /// <summary>
        /// Adds a new location to a player
        /// </summary>
        /// <param name="player"></param>
        public void AddNewLocation(GamePlayer player)
        {
            BusinessLocation location = new BusinessLocation();
            LocationStorage storage = new LocationStorage();
            storage.Items = new Dictionary<BuildableItemEnum, ItemQuantity>();
            location.Storage = storage;
            player.Locations.Add(location);

            AddItem(player,
                0, new ItemQuantity 
                { 
                    ItemCode = BuildableItemEnum.Dry_Goods_Delivery_Truck, 
                    UnStoredQuantity = 1, 
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Vegetable_Farm_Delivery_Truck,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Restaurant_Storage,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Table,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Dishes,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Floor,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });
        }