private void ShowMessage(string title, string message, string[] buttonTitles, Action<int> callBack) { try { //var d1 = new AlertDialog.Builder(Forms.Context); //d1.SetPositiveButton("One", (sender, e) => { }); //d1.SetNeutralButton("Two", (sender, e) => { }); //d1.SetNegativeButton("Three", (sender, e) => { }); //d1.Create().Show(); var d = new AlertDialog.Builder(Forms.Context).Create(); d.SetTitle(title); d.SetMessage(message); if (buttonTitles.Length > 2) { d.SetButton(buttonTitles[0], (e, a) => { callBack?.Invoke(0); }); d.SetButton2(buttonTitles[1], (e, a) => { callBack?.Invoke(1); }); d.SetButton3(buttonTitles[2], (e, a) => { callBack?.Invoke(2); }); } else { d.SetButton(buttonTitles[0], (e, a) => { callBack?.Invoke(0); }); d.SetButton2(buttonTitles[1], (e, a) => { callBack?.Invoke(1); }); } d.Show(); } catch (System.Exception ex) { #if DEBUG Console.WriteLine(ex.Message); #endif } }
public void ShowAlertDroid(string title, string body, string acceptbtn = null, string rejectbtn = null, string cancelbtn = null) { var dlgAlert = new AlertDialog.Builder(MainApplication.ActivityContext).Create(); dlgAlert.SetMessage(body); dlgAlert.SetTitle(title); dlgAlert.SetButton(acceptbtn, handllerNotingButton); dlgAlert.SetButton2(rejectbtn, handllerNotingButton); dlgAlert.SetButton3(cancelbtn, handllerNotingButton); dlgAlert.Show(); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.WorkListLayout); if (!User.IsValidUser()) { StartActivity(typeof(MainActivity)); return; } TextView tvwMainMsg = FindViewById <TextView>(Resource.Id.tvwWkvMsg); (GetSystemService(NotificationService) as NotificationManager).Cancel(0); //cancel all related notifications try { string restUrl = Values.ApiRootAddress + "Approval?compId=" + new AppPreferences().GetValue(User.CompId) + "&empNo=" + new AppPreferences().GetValue(User.EmployeeNo); tvwMainMsg.BasicMsg(Values.LoadingMsg); dynamic response = await new DataApi().GetAsync(restUrl); tvwMainMsg.Text = ""; bool success = DataApi.IsJsonObject(response); if (success) { if (response["Error"] == "") { response = response["Values"]; List <object> appraisees = new List <object>(); for (int i = 0; i < response.Count; i++) { Appraisee appraisee = new Appraisee(); appraisee.SerialNo = i + 1; appraisee.Message = response[i]["Description"]; appraisee.ApprovalType = response[i]["Approval_Type"]; appraisee.SentBy = response[i]["Created By"]; appraisee.DateSent = response[i]["Date"]; appraisee.Alertid = response[i]["Alert_Id"]; appraisee.RequestId = response[i]["REQUEST"] ?? 0; appraisees.Add(appraisee); } tvwMainMsg.SuccessMsg("Outstanding Approvals: " + appraisees.Count); adapter = new ApprovalAdapter(appraisees); adapter.ItemClick += async(sender, position) => { try { Appraisee appraisee = (Appraisee)adapter[position]; //check for internet access object[] networkStatus = await DataApi.NetworkAccessStatus(); if (!(bool)networkStatus[0]) { tvwMainMsg.ErrorMsg((string)networkStatus[1]); return; } if (appraisee.ApprovalType == "Medical") { restUrl = Values.ApiRootAddress + "Approval/GetMedicalRequest?compId=" + new AppPreferences().GetValue(User.CompId) + "&empNo=" + new AppPreferences().GetValue(User.EmployeeNo) + "&accYear=" + new AppPreferences().GetValue(User.AccountingYear) + "&reqId=" + appraisee.RequestId; response = await new DataApi().GetAsync(restUrl); if (response["Error"] == "") { response = response["Values"]; var view = LayoutInflater.Inflate(Resource.Layout.MedApprovalDialogLayout, null); AlertDialog dialog = new AlertDialog.Builder(this).Create(); dialog.SetTitle("MEDICAL APPROVAL"); view.FindViewById <TextView>(Resource.Id.tvwMedEmpName).Text = response[0]["HEMP_EMPLYE_NAME"]; view.FindViewById <TextView>(Resource.Id.tvwMedReqDate).Text = response[0]["Date"]; view.FindViewById <TextView>(Resource.Id.tvwMedHospital).Text = response[0]["HOSP_NAME"]; view.FindViewById <TextView>(Resource.Id.tvwMedLimBal).Text = response[0]["LIMITBAL"]; view.FindViewById <TextView>(Resource.Id.tvwMedUsed).Text = response[0]["USED"]; view.FindViewById <TextView>(Resource.Id.tvwMedReason).Text = response[0]["REQ_REASON"]; dialog.SetView(view); dialog.SetButton("Approve", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtMedComment).Text; string status = await PostMedical(appraisee, response, "A", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton2("Reject", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtMedComment).Text; string status = await PostMedical(appraisee, response, "D", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton3("Cancel", (s, e) => { dialog.Dismiss(); tvwMainMsg.SuccessMsg("Outstanding Approvals: " + adapter.ItemCount); }); dialog.Show(); } else { tvwMainMsg.ErrorMsg((string)response["Error"]); } } else if (appraisee.ApprovalType == "Leave") { restUrl = Values.ApiRootAddress + "Approval/GetLeaveRequest?compId=" + new AppPreferences().GetValue(User.CompId) + "&empNo=" + new AppPreferences().GetValue(User.EmployeeNo) + "&reqId=" + appraisee.RequestId; tvwMainMsg.BasicMsg(Values.WaitingMsg); response = await new DataApi().GetAsync(restUrl); tvwMainMsg.Text = ""; if (response["Error"] == "") { response = response["Values"]; var view = LayoutInflater.Inflate(Resource.Layout.LvlApprovalDialogLayout, null); AlertDialog dialog = new AlertDialog.Builder(this).Create(); dialog.SetTitle("LEAVE APPROVAL"); view.FindViewById <TextView>(Resource.Id.tvwLvlEmpName).Text = response[0]["EmpName"]; view.FindViewById <TextView>(Resource.Id.tvwLvlEmpNo).Text = (int)response[0]["EmpNo"] + ""; view.FindViewById <TextView>(Resource.Id.tvwLvlDesc).Text = response[0]["LvDesc"]; view.FindViewById <TextView>(Resource.Id.tvwLvlStartDate).Text = response[0]["StrtDt"]; view.FindViewById <TextView>(Resource.Id.tvwLvlEndDate).Text = response[0]["EndDt"]; view.FindViewById <TextView>(Resource.Id.tvwLvlNoOfDays).Text = (int)response[0]["NoOfDays"] + ""; view.FindViewById <TextView>(Resource.Id.tvwLvlReason).Text = response[0]["Reason"]; dialog.SetView(view); dialog.SetButton("Approve", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtLvlComment).Text; string status = await PostLeave(appraisee, response, "A", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton2("Reject", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtLvlComment).Text; string status = await PostLeave(appraisee, response, "D", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton3("Cancel", (s, e) => { dialog.Dismiss(); tvwMainMsg.SuccessMsg("Outstanding Approvals: " + adapter.ItemCount); }); dialog.Show(); } else { tvwMainMsg.ErrorMsg((string)response["Error"]); } } else if (appraisee.ApprovalType == "Training") { restUrl = Values.ApiRootAddress + "Approval/GetTrainingRequest?compId=" + new AppPreferences().GetValue(User.CompId) + "&empNo=" + new AppPreferences().GetValue(User.EmployeeNo) + "&reqId=" + appraisee.RequestId; tvwMainMsg.BasicMsg(Values.WaitingMsg); response = await new DataApi().GetAsync(restUrl); tvwMainMsg.Text = ""; if (response["Error"] == "") { response = response["Values"]; var view = LayoutInflater.Inflate(Resource.Layout.TrnApprovalDialogLayout, null); AlertDialog dialog = new AlertDialog.Builder(this).Create(); dialog.SetTitle("TRAINING APPROVAL"); view.FindViewById <TextView>(Resource.Id.tvwTrnEmpName).Text = response[0]["Employee Name"]; view.FindViewById <TextView>(Resource.Id.tvwTrnDesc).Text = response[0]["Training Description"]; view.FindViewById <TextView>(Resource.Id.tvwTrnReason).Text = response[0]["Reason"]; view.FindViewById <TextView>(Resource.Id.tvwTrnNomBy).Text = response[0]["Nominating Emp Name"]; dialog.SetView(view); dialog.SetButton("Approve", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtTrnComment).Text; string status = await PostTraining(appraisee, response, "A", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton2("Reject", async(s, e) => { try { string comment = view.FindViewById <EditText>(Resource.Id.edtTrnComment).Text; string status = await PostTraining(appraisee, response, "D", comment); CompleteTask(status, adapter, position, dialog, tvwMainMsg); } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }); dialog.SetButton3("Cancel", (s, e) => { dialog.Dismiss(); tvwMainMsg.SuccessMsg("Outstanding Approvals: " + adapter.ItemCount); }); dialog.Show(); } else { tvwMainMsg.ErrorMsg((string)response["Error"]); } } else { tvwMainMsg.ErrorMsg("Request type not provisioned"); //should not happen for mobile (handles only 3 approvals) } } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }; RecyclerView recyclerView = (RecyclerView)FindViewById(Resource.Id.rvwWorkListViewer); recyclerView.SetLayoutManager(new LinearLayoutManager(this)); recyclerView.SetAdapter(adapter); } else { tvwMainMsg.ErrorMsg((string)response["Error"]); } } else { tvwMainMsg.ErrorMsg((string)response); } } catch (Exception ex) { ex.Log(); tvwMainMsg.ErrorMsg(Values.ErrorMsg); } }