Exemple #1
0
        protected async override void OnStart()
        {
            bitopiApplication.CurrentActivity = "Approval Detail Activity";
            base.OnStart();
            var progressDialog = ProgressDialog.Show(this, null, "Please wait...", true);

            repo = new TNARepository();

            List <MyTaskDBModel> mytaskList = null;

            if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
            {
                mytaskList = await repo.GetMyTask(bitopiApplication.User.UserCode);
            }
            if (bitopiApplication.MyTaskType == MyTaskType.SEEN)
            {
                mytaskList = await repo.GetMyTask(bitopiApplication.User.UserCode, "SEEN");
            }
            if (bitopiApplication.MyTaskType == MyTaskType.COMPLETED)
            {
                mytaskList = await repo.GetMyTask(bitopiApplication.User.UserCode, "COMPLETE");
            }
            if (mytaskList.Count == 0)
            {
                tvMsg.Visibility = ViewStates.Visible;
            }
            mytaskList.ForEach(s => _MyTaskList.Add(s));
            _TNAMyTaskListAdapter = new TNAMyTaskListAdapter(_MyTaskList, lvMyTask, this, () => { tvMsg.Visibility = ViewStates.Visible; });
            lvMyTask.SetAdapter(_TNAMyTaskListAdapter);
            _TNAMyTaskListAdapter.NotifyDataSetChanged();
            lvMyTask.SetGroupIndicator(null);
            progressDialog.Dismiss();
        }
Exemple #2
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.refresh:
                var progressDialog = ProgressDialog.Show(this, null, "", true);
                new Thread(new ThreadStart(() =>
                {
                    repo = new TNARepository();

                    List <MyTaskDBModel> mytaskList = null;
                    if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                    {
                        mytaskList = repo.GetMyTask(bitopiApplication.User.UserCode).Result;
                    }
                    if (bitopiApplication.MyTaskType == MyTaskType.SEEN)
                    {
                        mytaskList = repo.GetMyTask(bitopiApplication.User.UserCode, "SEEN").Result;
                    }
                    if (bitopiApplication.MyTaskType == MyTaskType.COMPLETED)
                    {
                        mytaskList = repo.GetMyTask(bitopiApplication.User.UserCode, "COMPLETE").Result;
                    }
                    if (mytaskList.Count == 0)
                    {
                        tvMsg.Visibility = ViewStates.Visible;
                    }

                    _MyTaskList.Clear();
                    mytaskList.ForEach(s => _MyTaskList.Add(s));


                    RunOnUiThread(() =>
                    {
                        TNAMyTaskListAdapter _adapter
                            = new TNAMyTaskListAdapter(_MyTaskList, lvMyTask, this, () => { tvMsg.Visibility = ViewStates.Visible; });
                        lvMyTask.SetAdapter(_adapter);
                        _adapter.NotifyDataSetChanged();


                        progressDialog.Dismiss();
                    });
                })).Start();
                return(true);

            case Resource.Id.about:
                bitopiApplication.ShowAboutDialog(this);
                return(true);
            }
            return(base.OnOptionsItemSelected(item));
        }
        protected async override void OnStart()
        {
            base.OnStart();
            TNARepository repo = new TNARepository();

            MyTaskCountDBModel mytaskList = null;

            mytaskList = await repo.GetTaskCount(bitopiApplication.User.UserCode);

            if (mytaskList != null)
            {
                if (mytaskList.TotalUnSeenTask != "0")
                {
                    numberUnseen.Text       = mytaskList.TotalUnSeenTask;
                    numberUnseen.Visibility = ViewStates.Visible;
                }
                else
                {
                    numberUnseen.Visibility = ViewStates.Gone;
                }
                if (mytaskList.TotalSeenTask != "0")
                {
                    numberSeen.Text       = mytaskList.TotalSeenTask;
                    numberSeen.Visibility = ViewStates.Visible;
                }
                else
                {
                    numberSeen.Visibility = ViewStates.Gone;
                }
                if (mytaskList.TotalCompleteTask != "0")
                {
                    numberCompleted.Text       = mytaskList.TotalCompleteTask;
                    numberCompleted.Visibility = ViewStates.Visible;
                }
                else
                {
                    numberCompleted.Visibility = ViewStates.Gone;
                }
            }
        }
Exemple #4
0
            public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
            {
                MyTaskDBModel model  = MatchItems[groupPosition];
                View          view   = convertView;
                Holder        holder = null;

                //if (convertView == null)
                // {
                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                {
                    view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskUnSeenRow, parent, false);
                }
                if (bitopiApplication.MyTaskType == MyTaskType.SEEN)
                {
                    view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskSeenRow, parent, false);
                }
                if (bitopiApplication.MyTaskType == MyTaskType.COMPLETED)
                {
                    view = LayoutInflater.From(_context).Inflate(Resource.Layout.MyTaskCompletedRow, parent, false);
                }

                //  visiblePosArray[position%visiblePosArray.length]=position;
                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                {
                    holder = new Holder();
                }
                else
                {
                    holder = new Holder2();
                }
                if (holder is Holder2)
                {
                    ((Holder2)holder).remarks      = view.FindViewById <TextView>(Resource.Id.etRemarks);
                    ((Holder2)holder).commitedDate = view.FindViewById <TextView>(Resource.Id.etCommitedDate);
                }
                else
                {
                    holder.remarks      = view.FindViewById <EditText>(Resource.Id.etRemarks);
                    holder.commitedDate = view.FindViewById <EditText>(Resource.Id.etCommitedDate);
                }
                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN || bitopiApplication.MyTaskType == MyTaskType.SEEN)
                {
                    holder.ckbox = view.FindViewById <CheckBox>(Resource.Id.chckApprove);
                }
                //}
                //else
                //{
                //    holder = convertView.Tag as Holder;
                //    if (!(holder is Holder2))
                //    {
                //        holder.ckbox.SetOnClickListener(null);
                //        holder.ckbox.Checked = false;
                //        holder.commitedDate.Click += null;
                //        holder.remarks.KeyPress += null;
                //    }
                //}
                if (model.IsDisabled)
                {
                    holder.ckbox.Enabled = false;
                    if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                    {
                        holder.commitedDate.Enabled = holder.remarks.Enabled = false;
                    }
                }
                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN || bitopiApplication.MyTaskType == MyTaskType.SEEN)
                {
                    holder.ckbox.Click += (sender, e) =>
                    {
                        var builder = new Android.App.AlertDialog.Builder(_context);
                        builder.SetMessage("Are you sure to seen this task?");
                        if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                        {
                            model.Remarks = holder.remarks.Text;//etUserName.SetBackgroundResource(Resource.Drawable.rounded_textview_error);
                            if (holder.commitedDate.Text == "")
                            {
                                holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview_error);
                                ((CheckBox)sender).Checked = false;
                                return;
                            }
                            else
                            {
                                holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview);
                            }
                        }
                        builder.SetPositiveButton("OK", (s, ev) =>
                        {
                            CheckBox senderCheckBox = ((CheckBox)sender);

                            View parentView = (View)senderCheckBox.Parent;
                            Holder holder1  = parentView.Tag as Holder;
                            ;
                            var progressDialog = ProgressDialog.Show(_context, null, "Please wait...", true);
                            new Thread(new ThreadStart(() =>
                            {
                                TNARepository repo = new TNARepository();
                                int result         = 0;
                                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                                {
                                    result = repo.SetTaskUnSeentoSeen(_MyTaskList[holder.GroupPostiion], bitopiApplication.User.UserCode).Result;
                                }
                                if (bitopiApplication.MyTaskType == MyTaskType.SEEN)
                                {
                                    result = repo.SetTaskSeenToComplete(_MyTaskList[holder.GroupPostiion], bitopiApplication.User.UserCode).Result;
                                }
                                if (result == 1)
                                {
                                    _MyTaskList[holder1.GroupPostiion].IsDisabled = true;
                                }
                                _context.RunOnUiThread(() =>
                                {
                                    if (result == 1)
                                    {
                                        //ListViewAnimationHelper helper = new ListViewAnimationHelper(adapter, lvMyTask, MatchItems);
                                        //helper.animateRemoval(lvMyTask, parentView);
                                        int position = lvMyTask.GetPositionForView(parentView);
                                        MatchItems.RemoveAt(position);
                                        NotifyDataSetChanged();
                                        if (MatchItems.Count == 0 && calback != null)
                                        {
                                            calback();
                                        }
                                        progressDialog.Dismiss();
                                        Toast.MakeText(_context, "Has been seen", ToastLength.Short).Show();
                                    }
                                    else
                                    {
                                        ((CheckBox)sender).Checked = false;
                                        Toast.MakeText(_context, "Data Save Failed. Please Try Later", ToastLength.Short).Show();
                                    }
                                });
                            })).Start();
                        });
                        builder.SetNegativeButton("CANCEL", (s, ev) =>
                        {
                            ((CheckBox)sender).Checked = false;
                        });
                        builder.Create().Show();
                    };
                }

                if (holder is Holder2)
                {
                    ((Holder2)holder).remarks.Text      = model.Remarks;
                    ((Holder2)holder).commitedDate.Text = model.CommittedDate;
                }
                else
                {
                    (holder).remarks.Text    = model.Remarks;
                    holder.commitedDate.Text = model.PlannedDate;
                }
                (view.FindViewById <TextView>(Resource.Id.tvTask)).Text         = model.Task;
                (view.FindViewById <TextView>(Resource.Id.tvShimpentDate)).Text = model.ShipmentDate;

                if (bitopiApplication.MyTaskType == MyTaskType.UNSEEN)
                {
                    holder.commitedDate.Click += (s, e) =>
                    {
                        DateTime SetDate;
                        if (holder.commitedDate.Text == "")
                        {
                            SetDate = DateTime.Today;
                            //model.ActualDate= holder.commitedDate.Text = SetDate.Date.ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            //DateTime.TryParseExact(holder.commitedDate.Text, "dd/MM/yyyy", new CultureInfo("en-US"),
                            //DateTimeStyles.None,
                            //out SetDate);
                            SetDate = Convert.ToDateTime(holder.commitedDate.Text);
                        }

                        DatePickerDialog dialog = new DatePickerDialog(_context, (sender, evnt) =>
                        {
                            model.PlannedDate = model.CommittedDate = holder.commitedDate.Text = evnt.Date.ToString("dd/MM/yyyy");
                            holder.commitedDate.SetBackgroundResource(Resource.Drawable.rounded_textview);
                        }, SetDate.Year, SetDate.Month - 1, SetDate.Day);
                        dialog.DatePicker.MinDate = SetDate.Millisecond;
                        dialog.Show();
                    };

                    holder.remarks.TextChanged += (s, e) =>
                    {
                        model.Remarks = holder.remarks.Text;
                    };
                    if (currentlyFocusedRow == groupPosition)
                    {
                        holder.remarks.RequestFocus();
                    }
                    (view.FindViewById <EditText>(Resource.Id.etCommitedDate)).FocusableInTouchMode = false;
                    //(view.FindViewById<EditText>(Resource.Id.etRemarks)).FocusableInTouchMode = true;
                    holder.remarks.OnFocusChangeListener = new CustomOnFocusChangeListener(this, groupPosition, lvMyTask);
                }


                //(view.FindViewById<EditText>(Resource.Id.etCommitedDate)).Click += (s, e) =>
                //{
                //    sender = s;
                //    _context.ShowDialog();
                //};

                //view.Tag = groupPosition;
                holder.GroupPostiion = groupPosition;

                view.Tag = holder;
                return(view);
            }