public async Task <CheckListItems> UpdateItem(CheckListItems item)
        {
            using (IDbConnection conn = Connection){
                CheckListItems _item = new CheckListItems {
                    CLITEMID    = item.CLITEMID,
                    ITEMTITLE   = item.ITEMTITLE,
                    USERID      = item.USERID,
                    CHECKLISTID = item.CHECKLISTID,
                    ISCHECKED   = item.ISCHECKED
                };

                var _params = new DynamicParameters();
                _params.Add("@itemtitle", _item.ITEMTITLE);
                _params.Add("@userid", _item.USERID);
                _params.Add("@checklistid", _item.CHECKLISTID);
                _params.Add("@ischecked", _item.ISCHECKED);
                _params.Add("@clitemid", _item.CLITEMID);

                string sQuery = @"update CHECKLISTITEMS set ";
                sQuery += " ITEMTITLE=@itemtitle,";
                sQuery += " ISCHECKED=@ischecked, ";
                sQuery += " USERID=@USERID, ";
                sQuery += " CHECKLISTID=@CHECKLISTID ";
                sQuery += " where CLITEMID=@clitemid";
                var affectedRows = await conn.ExecuteAsync(sQuery, _params);

                if (affectedRows == 0)
                {
                    return(null);
                }
                return(_item);
            }
        }
        /// <summary>
        /// Populate the list of checkboxes with teams' names,
        /// And check the teams that are selected
        /// </summary>
        private void PopulateTeamsComboboxes()
        {
            CheckListItems.Clear();

            //Get all team features from the layer
            List <client.Graphic> allTeams = new List <client.Graphic>(teamFeatureLayer.Graphics);

            //Listen to the property change event of each feature. Particularly, we will listen to the "Selected" property
            foreach (client.Graphic team in allTeams)
            {
                team.PropertyChanged += team_PropertyChanged;
            }

            //Sort the names of all the teams for better presentation
            List <string> allTeamNames = allTeams.Select(t => t.Attributes[nameAttribute].ToString()).ToList();

            allTeamNames.Sort();

            //populate the check list items
            foreach (string teamName in allTeamNames)
            {
                MyCheckedListItem checkListItem = new MyCheckedListItem()
                {
                    Caption   = teamName,
                    IsChecked = recommendedTeams.Any(selectedTeam => selectedTeam.Attributes[nameAttribute].ToString() == teamName)
                };
                CheckListItems.Add(checkListItem);
            }
        }
Пример #3
0
        public async Task <ActionResult <CheckListItems> > UpdateCheckListItem([FromBody] CheckListItems model)
        {
            var _item = new CheckListItems
            {
                CLITEMID    = model.CLITEMID,
                CHECKLISTID = model.CHECKLISTID,
                ITEMTITLE   = model.ITEMTITLE,
                ISCHECKED   = model.ISCHECKED,
                USERID      = model.USERID
            };

            var result = await _lists.UpdateItem(_item);

            if (result == null)
            {
                return(BadRequest("Record is not updated 1"));
            }

            if (result.CLITEMID == -1)
            {
                return(BadRequest("Record is not updated 2"));
            }

            return(await Task.FromResult(result));
        }
Пример #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                Advice advice = e.Parameter as Advice;
                this.titlePathBox.TitlePath = advice?.Caption;
                if (advice != null)
                {
                    this._advice   = advice;
                    this.PageTitle = advice.Caption;
                    Office o = advice.Office;
                    if (o != null)
                    {
                        this._office = o;

                        TimeSpan ts = o.GetMaxOpeningToday() - DateTime.Now;
                        if (ts.TotalMinutes > 0)
                        {
                            this._progress.Maximum = ts.TotalMinutes;
                            this._progress.Value   = 10 + o.GetEstimatedWaitTimeInMinutes();
                            this.ExpectedNumber    = (o.GetCurrentWaiting()).ToString();
                            this.ExpectedTime      = DateTime.Now.AddMinutes(10 + o.GetEstimatedWaitTimeInMinutes()).ToString("h:mm tt");
                        }
                        else
                        {
                            this._progress.Maximum    = 100;
                            this._progress.Value      = 100;
                            this._progress.Foreground = new SolidColorBrush(Colors.DarkRed);
                            this.ExpectedNumber       = "Closed";
                        }
                    }
                    foreach (CheckListItem item in advice.CheckListItems)
                    {
                        this.CheckListItems.Add(item);
                    }

                    bool allChecked = CheckListItems.All(checkListItem => checkListItem.IsChecked);

                    if (!allChecked)
                    {
                        this._officeGrid.Visibility = Visibility.Visible;
                        this._itemGrid.Visibility   = Visibility.Collapsed;
                        this._lineGrid.Visibility   = Visibility.Collapsed;
                    }
                    else
                    {
                        this._officeGrid.Visibility   = Visibility.Collapsed;
                        this._itemGrid.Visibility     = Visibility.Visible;
                        this._lineGrid.Visibility     = Visibility.Collapsed;
                        this.EnableQueueNumberService = true;
                        if (o != null)
                        {
                            this._ticket = o.GetTicketForAdviceIfExists(DataService.Instance.CurrentAccount);
                            LoadTicket();
                        }
                    }
                }
            }
        }
 /// <summary>
 /// When user selects/unselects a team feature on map, check/uncheck the corresponding check box on the team assignment page
 /// </summary>
 void team_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Selected")
     {
         client.Graphic    team          = sender as client.Graphic;
         MyCheckedListItem checkListItem = CheckListItems.FirstOrDefault(item => item.Caption == team.Attributes[nameAttribute].ToString());
         checkListItem.IsChecked = team.Selected;
     }
 }
Пример #6
0
        /// <summary>
        /// Open the form and get a return value.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            // Title for the complete form
            string dialogCaption = String.IsNullOrEmpty(DialogCaption.Get(context)) ? " " : DialogCaption.Get(context);

            // Inputs for the Radio Group box
            string        radioGroupTitle = String.IsNullOrEmpty(RadioGroupTitle.Get(context)) ? " " : RadioGroupTitle.Get(context);
            List <string> radioGroupItems = RadioGroupItems.Get(context);
            int           rgIndex         = RadioGroupIndex.Expression != null?RadioGroupIndex.Get(context) : -1;

            // Inputs for the Check list box
            string        checkListTitle = String.IsNullOrEmpty(CheckListTitle.Get(context)) ? " " : CheckListTitle.Get(context);
            List <string> checkListItems = CheckListItems.Get(context);

            var form = new RadioGroupWithCheckListForm
            {
                RadioGroupItems   = radioGroupItems,
                Text              = dialogCaption,
                RadioGroupMessage = radioGroupTitle,
                DefaultIndex      = rgIndex,
                CheckListMessage  = checkListTitle,
                CheckListItems    = checkListItems
            };

            // Default to -1 for the Radio Group index and set all to False for the Check List
            RadioGroupResult.Set(context, -1);
            if (checkListItems != null)
            {
                List <bool> tempList = new List <bool>();
                for (int i = 0; i < checkListItems.Count; i++)
                {
                    tempList.Add(false);
                }
                CheckListResult.Set(context, tempList);
            }

            // Do not show the dialog if no items to show
            if ((radioGroupItems == null) && (checkListItems == null))
            {
                return;
            }

            DialogResult result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                RadioGroupResult.Set(context, form.SelectedIndex);
                CheckListResult.Set(context, form.CheckListBoxResult);
            }
            DialogResult.Set(context, result);
        }
        /// <summary>
        /// When user clicks the button, check if there's any selected team and the message to send is empty
        /// If there is/are selected team(s) and the message is not empty, send the SMS
        /// </summary>
        private void btnAssign_Click(object sender, RoutedEventArgs e)
        {
            #region Error checking: no team selected or empty message
            if (CheckListItems.Any(i => i.IsChecked) == false || string.IsNullOrEmpty(txtMessage.Text))
            {
                MessageBox.Show("Make sure one or more team is selected, and the message is not empty");
                return;
            }
            #endregion

            try
            {
                #region Get the selected teams and check if they have already been assigned to the designated area
                //1. Get the captions of the checked list items
                var checkedItemCaptions = from item in CheckListItems
                                          where item.IsChecked == true
                                          select item.Caption;

                //2. Fom the caption, get the actual team items that are now checked
                seletcedTeams = teamFeatureLayer.Graphics.Where(team => checkedItemCaptions.Contains(team.Attributes[nameAttribute].ToString())).ToList();

                //3. Check if the same teams have already been assigned. Do not allow assignment if all selected teams have been assiged to that area
                if (seletcedTeams.Any(team => team.Attributes[areaAttribute].ToString() != searchAreaName) == false)
                {
                    MessageBox.Show("Teams have been assigned to the designated area already", "Teams Assigned ");
                    return;
                }
                #endregion

                #region Update team assignment
                //Assign teams by updating their SearchAreaName attributes
                foreach (client.Graphic team in seletcedTeams)
                {
                    team.Attributes[areaAttribute] = searchAreaName;
                }

                //Save the edits
                commitEditCount = 0;
                teamFeatureLayer.EndSaveEdits += teamFeatureLayer_EndSaveEdits;
                teamFeatureLayer.SaveEdits();
                #endregion
            }
            catch (Exception)
            {
                MessageBox.Show("Error sending message");
                this.Close();
            }
        }
        public async Task <CheckListItems> AddItem(CheckListItems item)
        {
            using (IDbConnection conn = Connection){
                CheckListItems _item = new CheckListItems {
                    CLITEMID    = -1,
                    ITEMTITLE   = item.ITEMTITLE,
                    USERID      = item.USERID,
                    CHECKLISTID = item.CHECKLISTID,
                    ISCHECKED   = item.ISCHECKED
                };

                var _params = new DynamicParameters();
                _params.Add("@itemtitle", _item.ITEMTITLE);
                _params.Add("@userid", _item.USERID);
                _params.Add("@checklistid", _item.CHECKLISTID);
                _params.Add("@ischecked", _item.ISCHECKED);
                _params.Add(name: "@v_clitemid", value: _item.CLITEMID, dbType: DbType.Int64,
                            direction: ParameterDirection.InputOutput);

                string sQuery = @" begin ";
                sQuery += " insert into CHECKLISTITEMS(ITEMTITLE,ISCHECKED,CHECKLISTID,USERID)";
                sQuery += " values (@ITEMTITLE,@ISCHECKED,@CHECKLISTID,@USERID) ";
                sQuery += " set @v_clitemid=SCOPE_IDENTITY()";
                sQuery += " end ";
                //try{
                var affectedRows = await conn.ExecuteAsync(sQuery, _params);

                if (affectedRows > 0)
                {
                    Int64 newListId = _params.Get <Int64>("@v_clitemid");
                    _item.CLITEMID = newListId;
                }

//                }catch(Exception ex){
//                  return null;
//            }

                return(_item);
            }
        }
Пример #9
0
        private void OnCheckListTapped(object sender, TappedRoutedEventArgs e)
        {
            bool allChecked = CheckListItems.All(checkListItem => checkListItem.IsChecked);

            this.EnableQueueNumberService = allChecked;
        }