//actions to be taken before logout
        private async Task <object[]> PreLogOutActions()
        {
            object[] status = new object[2];

            string restUrl = Values.ApiRootAddress + "Notification/PostPreLogout";
            var    content = new FormUrlEncodedContent(new Dictionary <string, string>
            {
                { "CompId", new AppPreferences().GetValue(User.CompId) },
                { "EmpNo", new AppPreferences().GetValue(User.EmployeeNo) },
                { "UserId", new AppPreferences().GetValue(User.UserId) },
                { "DeviceId", FirebaseInstanceId.Instance.Token }
            });

            dynamic response = await new DataApi().PostAsync(restUrl, content);

            if (IsJsonObject(response))
            {
                AppPreferences pref = new AppPreferences();
                pref.RemoveValue(User.UserId);
                pref.RemoveValue(User.Password);
                bmp       = null;
                status[0] = true;
                status[1] = "";
            }
            else
            {
                status[0] = false;
                status[1] = (string)response;
            }

            return(status);
        }
Example #2
0
        //save user data to preference dictionary
        private bool SaveToPreferences(dynamic result, string userId, string password)
        {
            AppPreferences pref = new AppPreferences();

            //save values to collection
            pref.SaveValue(User.UserId, userId);
            pref.SaveValue(User.Password, password);
            pref.SaveValue(User.CompId, result["CompId"]);
            pref.SaveValue(User.CompName, result["CompName"]);
            pref.SaveValue(User.RoleId, result["RoleId"]);
            pref.SaveValue(User.EmployeeNo, result["EmployeeNo"].ToString());
            pref.SaveValue(User.Name, result["Name"]);
            pref.SaveValue(User.Title, result["Title"]);
            pref.SaveValue(User.DateOfBirth, result["DateOfBirth"]);
            pref.SaveValue(User.AccountNo, result["AccountNo"]);
            pref.SaveValue(User.Email, result["Email"]);
            pref.SaveValue(User.DeptCode, result["DeptCode"]);
            pref.SaveValue(User.GradeCode, result["GradeCode"]);
            pref.SaveValue(User.LicenseDate, result["LicenseDate"]);
            pref.SaveValue(User.AccountingYear, result["AccountingYear"]);
            pref.SaveValue(User.Location, result["Location"]);
            pref.SaveValue(User.Department, result["Department"]);
            pref.SaveValue(User.Designation, result["Designation"]);
            pref.SaveValue(User.Grade, result["Grade"]);
            pref.SaveValue(User.LocationCode, result["LocationCode"]);

            return(true);
        }
Example #3
0
        //store Leave values to preference dictionary for submittion access
        private void StoreToPref(dynamic response, string Where)
        {
            AppPreferences LeaveExtPref = new AppPreferences();

            for (int i = 0; i < response.Count; i++)               //start from one to ensure synchronization
            {
                LeaveExtPref.SaveValue(i + "", response[i]["CODE"].ToString());
            }
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                SetContentView(Resource.Layout.UserProfile);

                //get data from API
                AppPreferences appPref = new AppPreferences();
                string         uri     = Values.ApiRootAddress + "UserProfile/GetBasicDetails?compId=" + appPref.GetValue(User.CompId) + "&empNo=" + appPref.GetValue(User.EmployeeNo);

                Toast.MakeText(this, Values.LoadingMsg, ToastLength.Short).Show();

                dynamic json = await new DataApi().GetAsync(uri);

                if (IsJsonObject(json))
                {
                    JsonValue          basicDetailsData    = json["BasicDetails"];
                    JsonValue          qualificationsData  = json["Qualifications"];
                    JsonValue          profCredentialsData = json["ProfessionalCredentials"];
                    JsonValue          employeeTypeData    = json["EmployeeType"];
                    JsonValue          reportToData        = json["ReportTo"];
                    ExpandableListView expListView         = FindViewById <ExpandableListView>(Resource.Id.expdLstVw1);

                    //Bind list
                    List <string> parentList = GenerateParents();
                    Dictionary <string, List <string> > childDictionaryList = GenerateChildItems(parentList, basicDetailsData, qualificationsData, profCredentialsData, employeeTypeData, reportToData);
                    MyExpandableListAdapter             listAdapter         = new MyExpandableListAdapter(this, parentList, childDictionaryList);
                    expListView.SetAdapter(listAdapter);
                    expListView.ExpandGroup(0); expListView.ExpandGroup(1); expListView.ExpandGroup(2); expListView.ExpandGroup(3); expListView.ExpandGroup(4);
                }
                else
                {
                    Toast.MakeText(this, (string)json, ToastLength.Long).Show();
                }
            }
            catch (Exception ex)
            {
                ex.Log();
                Toast.MakeText(this, Values.ErrorMsg, ToastLength.Long).Show();
            }
        }
 //store Leave values to preference dictionary for submittion access
 private void StoreToPref(dynamic response, string Where)
 {
     if (Where == "Leave")
     {
         AppPreferences LeavePref = new AppPreferences();
         for (int i = 0; i < response.Count; i++)               //start from one to ensure synchronization
         {
             LeavePref.SaveValue(i + "", response[i]["CODE"]);
         }
     }
     else
     {
         AppPreferences ReliefOfficerID = new AppPreferences();
         for (int i = 0; i < response.Count; i++)               //start from one to ensure synchronization
         {
             ReliefOfficerID.SaveValue(i + "", response[i]["emplyeno"]);
         }
     }
 }
Example #6
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            //get the selected name from shared preference
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
            var Name = prefs.GetString("SelectedName", "");

            var      view         = Activity.LayoutInflater.Inflate(Resource.Layout.TrainingNominateDialog, null);
            TextView tvMessage    = view.FindViewById <TextView>(Resource.Id.textView2);
            TextView tvwResultMsg = Activity.FindViewById <TextView>(Resource.Id.tvwMsgTrnReq);

            AlertDialog.Builder alert = new AlertDialog.Builder(Activity);
            alert.SetTitle("Confirm selection");

            string Message = "are you nominating " + Name + " for the training?";

            //alert.SetMessage(Message);
            tvMessage.Text = Message;

            string uri = Values.ApiRootAddress + "training/SaveNominee";

            alert.SetPositiveButton("Nominate", async(senderAlert, args) =>
            {
                AppPreferences appPrefs = new AppPreferences();
                var NominateUser        = new FormUrlEncodedContent(new Dictionary <string, string>
                {
                    { "CompanyCode", appPrefs.GetValue(User.CompId) },                  // "CO000001",
                    { "TrainingCode", prefs.GetString("TrainingCode", "") },
                    { "TrainingSerialNo", prefs.GetInt("TrainingSerialNo", 0) + "" },   // 1,
                    { "NomineeEmployeeNo", prefs.GetInt("NomineeEmployeeNo", 0) + "" }, //43,
                    { "ReqEmployeeNo", appPrefs.GetValue(User.EmployeeNo) },            // 694,
                    { "Reason", view.FindViewById <EditText>(Resource.Id.edtTxtReason).Text },
                    { "Username", appPrefs.GetValue(User.UserId) }
                });

                tvwResultMsg.Text = Values.WaitingMsg;
                dynamic json      = await new DataApi().PostAsync(uri, NominateUser);
                tvwResultMsg.Text = "";
                if (DataApi.IsJsonObject(json))
                {
                    if (json != null)
                    {
                        if (json["status"] == 0)
                        {
                            DialogClosed?.Invoke(this, true);
                            tvwResultMsg.SuccessMsg((string)json["message"]);
                        }
                        else
                        {
                            tvwResultMsg.ErrorMsg((string)json["message"]);
                        }
                        //Toast.MakeText(new Activity(), json["message"].ToString(), ToastLength.Short).Show();
                    }
                }
                else
                {
                    tvwResultMsg.ErrorMsg((string)json);
                }
                Dismiss();
            });

            alert.SetNegativeButton("Cancel", (senderAlert, args) =>
            {
                Dismiss();
                //Toast.MakeText(Activity, "Cancelled!", ToastLength.Short).Show();
            });

            alert.SetView(view);
            return(alert.Create());
        }
Example #7
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TrainingRequestLayout);

            try
            {
                TextView tvwResultMsg = FindViewById <TextView>(Resource.Id.tvwMsgTrnReq);
                string   url          = Values.ApiRootAddress + "training/getTrainings?compId=" + new AppPreferences().GetValue(User.CompId);

                tvwResultMsg.BasicMsg(Values.LoadingMsg);
                dynamic json = await new DataApi().GetAsync(url);
                tvwResultMsg.Text = "";
                if (IsJsonObject(json))
                {
                    JsonValue TrainingResults = json["Training"];

                    List <string> lstTrainingCode = new List <string>();
                    lstTrainingCode.Add("Nothing");
                    List <string> lstTrainingDesc = new List <string>();
                    lstTrainingDesc.Add("Please Select");

                    for (int i = 0; i < TrainingResults.Count; i++)
                    {
                        lstTrainingCode.Add(TrainingResults[i]["TRAININGCODE"]);
                        lstTrainingDesc.Add(TrainingResults[i]["DESCRIPTION"]);

                        SelectedTraining obj = new SelectedTraining();

                        obj.TrainingCode     = TrainingResults[i]["TRAININGCODE"];
                        obj.Description      = TrainingResults[i]["DESCRIPTION"];
                        obj.Duration         = TrainingResults[i]["DURATION"];
                        obj.Type             = TrainingResults[i]["TYPE"];
                        obj.TrainingSerialNo = TrainingResults[i]["TRNSNO"];
                        obj.Venue            = TrainingResults[i]["VENUE"];

                        selectedTraining.Add(obj);
                    }
                    ;

                    Spinner spnrTrainings = FindViewById <Spinner>(Resource.Id.spnrTrainingCode);

                    ArrayAdapter <string> spinnerArrayAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, lstTrainingDesc);
                    //Use the ArrayAdapter you've set up to populate your spinner
                    spnrTrainings.Adapter = spinnerArrayAdapter;
                    //optionally pre-set spinner to an index
                    spnrTrainings.SetSelection(0);

                    spnrTrainings.ItemSelected += async(sender, e) =>
                    {
                        Spinner spinner = (Spinner)sender;

                        //save the CODE and SERIALNO of training selected
                        ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                        ISharedPreferencesEditor editor = prefs.Edit();
                        editor.PutString("TrainingCode", lstTrainingCode[e.Position]);

                        //var position = e.Position.Equals(0) ? 0 : e.Position - 1;
                        if (e.Position > 0)
                        {
                            editor.PutInt("TrainingSerialNo", selectedTraining[e.Position - 1].TrainingSerialNo);
                            editor.Apply();
                        }

                        if (mDatasource.Count > 0)
                        {
                            mDatasource.Clear();
                        }

                        AppPreferences appPrefs = new AppPreferences();
                        tvwResultMsg.BasicMsg(Values.LoadingMsg);
                        mDatasource = await Nominees(lstTrainingCode[e.Position], appPrefs.GetValue(User.EmployeeNo), appPrefs.GetValue(User.CompId));

                        tvwResultMsg.Text = "";
                        //mDatasource = await new GetNominees().Nominees(spinner.GetItemAtPosition(e.Position).ToString());
                        if (mDatasource.Count == 0 && spnrTrainings.SelectedItemPosition != 0)
                        {
                            tvwResultMsg.ErrorMsg("No Employee To Nominate");
                        }
                        else
                        {
                            tvwResultMsg.Text = "";
                        }

                        mAdapter            = new EmpDetailsAdapter(mDatasource);
                        mAdapter.ItemClick += (s, args) =>
                        {
                            //Toast.MakeText(this, "who's the BOSS now!", ToastLength.Short).Show();
                            //Toast.MakeText(this, "who's the BOSS now!" + mDatasource[position].name, ToastLength.Short).Show();

                            editor.PutString("SelectedName", mDatasource[args].name);
                            editor.PutInt("NomineeEmployeeNo", mDatasource[args].number);
                            editor.Apply();

                            FragmentTransaction transcation    = FragmentManager.BeginTransaction();
                            Dialogclass         ConfirmNominee = new Dialogclass();
                            ConfirmNominee.DialogClosed += (dlgSender, dlgEvent) =>
                            {
                                if (dlgEvent)
                                {
                                    mAdapter.empList.RemoveAt(args);
                                    mAdapter.NotifyItemRemoved(args);
                                }
                            };
                            ConfirmNominee.Show(transcation, "Dialog Fragment");
                        };

                        mRecyclerView  = (RecyclerView)FindViewById(Resource.Id.recyclerView1);
                        mLayoutManager = new LinearLayoutManager(this);
                        mRecyclerView.SetLayoutManager(mLayoutManager);
                        mRecyclerView.SetAdapter(mAdapter);

                        if (e.Position > 0)
                        {
                            Toast.MakeText(this, "Training Venue: " + selectedTraining[e.Position - 1].Venue + "\r\n" + "Training Duration: " + selectedTraining[e.Position - 1].Duration, ToastLength.Short).Show();
                        }
                    };
                }
                else
                {
                    tvwResultMsg.ErrorMsg((string)json);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
        }