Example #1
0
            public async void SaveSelected(string POStatus, Action <int> Callback, string Remarks = "")
            {
                int NumberOfSelectedItem         = this.Where(t => t.isApproved == true).Count();
                int numberOfSuccessFullOperation = 0;
                int numberOfSaveCompleted        = 0;

                foreach (var model in this)
                {
                    if (model.isApproved == true)
                    {
                        ApprovalRepository repo = new ApprovalRepository();
                        int result = 0;

                        result = await repo.SavePOApprovalDetails(model.POID, bitopiApplication.User.UserCode,
                                                                  bitopiApplication.User.EmployeeName, POStatus,
                                                                  bitopiApplication.ApprovalType, bitopiApplication.ApprovalRoleType, Remarks);

                        numberOfSuccessFullOperation += result;
                        numberOfSaveCompleted++;
                        if (result == 1)
                        {
                            model.isDeleted = true;
                            //numberOfSuccessFullOperation++;
                        }

                        if (numberOfSaveCompleted == NumberOfSelectedItem)
                        {
                            Callback(numberOfSuccessFullOperation);
                        }
                    }
                }
            }
Example #2
0
            public void BtnNotApprove_click(object sender, EventArgs e)
            {
                ImageButton senderButton   = ((ImageButton)sender);
                string      PO             = senderButton.Tag.ToString();
                View        parentView     = (View)senderButton.Parent;
                int         ItemPostition  = (int)parentView.Tag;
                var         progressDialog = ProgressDialog.Show(_context, null, "", true);

                new Thread(new ThreadStart(() =>
                {
                    ApprovalRepository repo = new ApprovalRepository();
                    int result = 0;
                    result     = repo.SavePOApprovalDetails(PO, bitopiApplication.User.UserCode,
                                                            bitopiApplication.User.EmployeeName,
                                                            bitopiApplication.ApprovalRoleType == ApprovalRoleType.Approve ? "Rejected" : "NotRecommend",
                                                            bitopiApplication.ApprovalType, bitopiApplication.ApprovalRoleType, "").Result;
                    if (result == 1)
                    {
                        ////model.isDeleted = true;
                        //if (_approvalList.Count > 1)
                        //{
                        //    var tempModel = _approvalList.Where(er => er.POID == PO).First();
                        //    if (tempModel != null)
                        //        _approvalList.Remove(tempModel);
                        //}
                        //else
                        //    _approvalList = new ApprovalDetailList();
                        _approvalList.RemoveAt(ItemPostition);
                    }
                    //List<ApprovalDetailsModel> aprovalList = repo.GetPOApprovalDetails(bitopiApplication.User.UserCode, bitopiApplication.ApprovalRoleType,
                    //bitopiApplication.ApprovalType).Result;
                    //_approvalList.Clear();
                    //aprovalList.ForEach(s => _approvalList.Add(s));


                    _context.RunOnUiThread(() =>
                    {
                        if (result == 1 && _approvalList.Count == 0)
                        {
                            ((ApprovalDetailActivity)_context).rlMsg.Visibility            = ViewStates.Visible;
                            ((ApprovalDetailActivity)_context).rlapprovalDetail.Visibility = ViewStates.Gone;
                        }
                        NotifyDataSetChanged();
                        progressDialog.Dismiss();
                        Toast.MakeText(_context, PO + " has been " +
                                       ((bitopiApplication.ApprovalRoleType == ApprovalRoleType.Approve) ? "Rejected" : "Not Recommended")
                                       , ToastLength.Short).Show();
                    });
                })).Start();
            }