public async void GetWorkDays() { TextView tvwMsg = FindViewById <TextView>(Resource.Id.tvwMsgLeaveRecall); EditText edtRecallDt = FindViewById <EditText>(Resource.Id.edtRecallDt); TextView tvwStDateRec = FindViewById <TextView>(Resource.Id.tvwStDateRec); //Call getworking Days if (tvwStDateRec.Text != "" && edtRecallDt.Text != "" && tvwStDateRec.Text != edtRecallDt.Text) { DateTime?StDate = new CommonMethodsClass().ConvertStringToDate(tvwStDateRec.Text); DateTime?EndDt = new CommonMethodsClass().ConvertStringToDate(edtRecallDt.Text); if (EndDt > StDate) { string restUrl1 = Values.ApiRootAddress + "LeaveRecall/GetWorkDays/?strFromDate=" + tvwStDateRec.Text + "&strToDate=" + edtRecallDt.Text + "&compId=" + new AppPreferences().GetValue(User.CompId); tvwMsg.BasicMsg(Values.WaitingMsg); dynamic response = await new DataApi().GetAsync(restUrl1); tvwMsg.Text = ""; if (IsJsonObject(response)) { SpentDays = (int)response + ""; } else { tvwMsg.ErrorMsg((string)response); } } } }
private async void BtnSubmitMedReq_Click(object sender, EventArgs e) { TextView tvwMsg = FindViewById <TextView>(Resource.Id.tvwMsgMedReq); string dateStr = FindViewById <EditText>(Resource.Id.edtDateMedReq).Text; try { DateTime?date = new CommonMethodsClass().ConvertStringToDate(dateStr); string reason = FindViewById <EditText>(Resource.Id.edtReasonMedReq).Text; int selection = (int)FindViewById <Spinner>(Resource.Id.spnHospitalMedReq).SelectedItemId; if (date != null && date > DateTime.Now && selection > 0 && reason.Length > 0) { string restUrl = Values.ApiRootAddress + "MedicalRequest"; var content = new FormUrlEncodedContent(new Dictionary <string, string> { { "EmployeeNo", new AppPreferences().GetValue(User.EmployeeNo) }, { "HospitalId", spinnerHospCode[selection] }, { "DateStr", dateStr }, { "Reason", reason }, { "UserId", new AppPreferences().GetValue(User.UserId) }, { "CompId", new AppPreferences().GetValue(User.CompId) } }); (sender as Button).Enabled = false; tvwMsg.BasicMsg(Values.WaitingMsg); dynamic response = await new DataApi().PostAsync(restUrl, content); tvwMsg.Text = ""; (sender as Button).Enabled = true; bool success = DataApi.IsJsonObject(response); if (success) { if (response["Error"] == "") //success { FindViewById <EditText>(Resource.Id.edtDateMedReq).Text = ""; FindViewById <EditText>(Resource.Id.edtReasonMedReq).Text = ""; FindViewById <Spinner>(Resource.Id.spnHospitalMedReq).SetSelection(0); tvwMsg.SuccessMsg("Record Saved Successfully"); } else { tvwMsg.ErrorMsg((string)response["Error"]); } } else { tvwMsg.ErrorMsg((string)response); } } else { if (date == null) { tvwMsg.ErrorMsg("Please select a leave date"); } else if (date <= DateTime.Now) { tvwMsg.ErrorMsg("Please select a future date"); } else if (selection == 0) { tvwMsg.ErrorMsg("Please select a hospital"); } else { tvwMsg.ErrorMsg("Please enter your reason"); } } } catch (Exception ex) { ex.Log(); tvwMsg.ErrorMsg(Values.ErrorMsg); } }
////Used to get the Working Days based on the Dates selected //private async void GetWorkingDays() //{ // TextView tvwMsg = FindViewById<TextView>(Resource.Id.tvwMsgLeaveReq); // TextView tvwDurationExt = FindViewById<TextView>(Resource.Id.tvwDurationExt); // EditText edtStartDate = FindViewById<EditText>(Resource.Id.edtStartDate); // EditText edtEndDate = FindViewById<EditText>(Resource.Id.edtExtendTo); // string RemainingDays = FindViewById<TextView>(Resource.Id.tvwRemainDaysExt).Text; // tvwMsg.Text = ""; // //Call getworking Days // if (edtStartDate.Text != "" && edtEndDate.Text != "") // { // int StartDt = Convert.ToInt32(edtStartDate.Text.Replace("/", "")); // int EndDt = Convert.ToInt32(edtEndDate.Text.Replace("/", "")); // if (EndDt > StartDt) // { // string restUrl4 = Values.ApiRootAddress + "LeaveExtension/GetWorkDays/?strFromDate=" + edtStartDate.Text + "&strToDate=" + edtEndDate.Text + "&compId=" + new AppPreferences().GetValue(User.CompId); // dynamic response = await new DataApi().GetAsync(restUrl4); // int Days = (int)response; // if (int.Parse(RemainingDays) >= Days) // { // tvwDurationExt.Text = (int)response + ""; // } // else // { // tvwDurationExt.Text = ""; // tvwMsg.Text = "Day Applied For Cannot Be Greater Than Remaining Days"; // } // } // } //} //Used To Do variuos checks And To save the records private async void btnSubmitLeaveExt_Click(object sender, EventArgs e) { TextView tvwMsg = FindViewById <TextView>(Resource.Id.tvwMsgLeaveExt); tvwMsg.Text = ""; string resumeDatestr = FindViewById <TextView>(Resource.Id.tvwResumeDtExt).Text; DateTime?resumeDate = new CommonMethodsClass().ConvertStringToDate(resumeDatestr); string ExtendTo = FindViewById <EditText>(Resource.Id.edtExtendTo).Text; //Get End Date DateTime?date = new CommonMethodsClass().ConvertStringToDate(ExtendTo); string RemainingDays = FindViewById <TextView>(Resource.Id.tvwRemainDaysExt).Text; string Duration = FindViewById <TextView>(Resource.Id.tvwDurationExt).Text; string reason = FindViewById <EditText>(Resource.Id.edtReasonExt).Text; int selection = (int)FindViewById <Spinner>(Resource.Id.spnLeaveExt).SelectedItemId; //Get Seklected ID for the Leave if (date != null && date > resumeDate && selection > 0) { if (int.Parse(RemainingDays) >= int.Parse(Duration)) { try { string restUrl = Values.ApiRootAddress + "LeaveExtension"; var contentLeave = new FormUrlEncodedContent(new Dictionary <string, string> { { "ReqNo", RqstNo }, { "EmployeeNo", new AppPreferences().GetValue(User.EmployeeNo) }, { "AccountingYear", new AppPreferences().GetValue(User.AccountingYear) }, { "LeaveGrp", LvGrp }, { "LvCode", LevCode }, { "RemainingDays", RemainingDays }, { "Duration", Duration }, { "ToDate", ExtendTo }, { "Reason", reason }, { "UserId", new AppPreferences().GetValue(User.UserId) }, { "CompId", new AppPreferences().GetValue(User.CompId) }, { "RelOfficerId", (int)double.Parse(RelOfficerId) + "" }, { "PrevReqId", (int)double.Parse(PrevReqId) + "" } }); (sender as Button).Enabled = false; tvwMsg.BasicMsg(Values.WaitingMsg); dynamic response = await new DataApi().PostAsync(restUrl, contentLeave); tvwMsg.Text = ""; (sender as Button).Enabled = true; bool success = IsJsonObject(response); if (success) { if (response["Error"] == "") //success { FindViewById <TextView>(Resource.Id.tvwStrDtExt).Text = ""; FindViewById <TextView>(Resource.Id.tvwResumeDtExt).Text = ""; FindViewById <TextView>(Resource.Id.tvwDurationExt).Text = ""; FindViewById <TextView>(Resource.Id.tvwRemainDaysExt).Text = ""; FindViewById <EditText>(Resource.Id.edtExtendTo).Text = ""; FindViewById <TextView>(Resource.Id.edtReasonExt).Text = ""; FindViewById <Spinner>(Resource.Id.spnLeaveExt).SetSelection(0); tvwMsg.SuccessMsg("Records Saved Successfully"); } else { tvwMsg.ErrorMsg((string)response["Error"]); } } else { tvwMsg.ErrorMsg((string)response); } } catch (Exception ex) { ex.Log(); tvwMsg.ErrorMsg(Values.ErrorMsg); } } else { tvwMsg.ErrorMsg("Day Applied For Cannot Be Greater Than Remaining Days"); } } else { if (date == null) { tvwMsg.ErrorMsg("Please choose a valid Resumption Date"); } else if (date <= resumeDate) { tvwMsg.ErrorMsg("Extension date must be greater than previous resumption date"); } else if (selection <= 0) { tvwMsg.ErrorMsg("Please select a Leave Type"); } } }