예제 #1
0
        private async Task GenerateMealHistory(int ID, string mealtype)
        {
            try
            {
                mstr_meal_history meal = null;
                ObservableCollection <mstr_meal_history> dataList = new ObservableCollection <mstr_meal_history>();

                string     URL        = Library.URL + "/" + Library.METHODE_SHOWPATIENTMEALDETAILSBYID + "/" + Convert.ToInt32(ID) + "/" + mealtype + "/" + Library.KEY_USER_ccode + "/" + Library.KEY_USER_regcode + "/" + Library.KEY_USER_siteid;
                var        uri        = new Uri(URL);
                HttpClient httpClient = new System.Net.Http.HttpClient();
                // HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/" + Library.METHODE_SHOWPATIENTMEALDETAILSBYID + "/" + Convert.ToInt32(ID) + "/" + mealtype + "/" + Library.KEY_USER_ccode + "/" + Library.KEY_USER_regcode + "/" + Library.KEY_USER_siteid);
                // HttpResponseMessage response = await httpClient.SendAsync(request);

                // var data = await response.Content.ReadAsStringAsync();

                var data = await httpClient.GetStringAsync(uri);

                JArray jarray = JArray.Parse(data);
                if (jarray.Count == 0)
                {
                    await PageDialog.DisplayAlertAsync("Alert!!", "There is no meal history for this patient.", "OK");

                    IsPageEnabled = false;
                    return;
                }

                for (int i = 0; i < jarray.Count; i++)
                {
                    JObject row = JObject.Parse(jarray[i].ToString());
                    meal = new mstr_meal_history
                    {
                        beveragesid  = string.IsNullOrEmpty(row["beveragesid"].ToString())? "NA": row["beveragesid"].ToString(),
                        dessertid    = string.IsNullOrEmpty(row["dessertid"].ToString()) ? "NA" : row["dessertid"].ToString(),
                        entreeid     = string.IsNullOrEmpty(row["entreeid"].ToString()) ? "NA" : row["entreeid"].ToString(),
                        juiceid      = string.IsNullOrEmpty(row["juiceid"].ToString()) ? "NA" : row["juiceid"].ToString(),
                        orderdate    = row["orderdate"].ToString(),
                        remarkid     = string.IsNullOrEmpty(row["remarkid"].ToString()) ? "NA" : row["remarkid"].ToString(),
                        soupid       = string.IsNullOrEmpty(row["soupid"].ToString()) ? "NA" : row["soupid"].ToString(),
                        status       = string.IsNullOrEmpty(row["status"].ToString()) ? "NA" : row["status"].ToString(),
                        addonid      = string.IsNullOrEmpty(row["addonid"].ToString()) ? "NA" : row["addonid"].ToString(),
                        mealoptionid = string.IsNullOrEmpty(row["mealoptionid"].ToString()) ? "NA" : row["mealoptionid"].ToString()
                    };
                    dataList.Add(meal);
                }
                PatientMealHistoryList = new List <mstr_meal_history>(dataList);
                IsPageEnabled          = false;
                await navigation.PushPopupAsync(new MealInfoPopUp(dataList, mealtype));
            }
            catch (Exception)
            {
                IsPageEnabled = false;
            }
        }
        private async Task GenerateMealHistory(int ID, string mealtype)
        {
            try
            {
                mstr_meal_history meal = null;
                ObservableCollection <mstr_meal_history> dataList = new ObservableCollection <mstr_meal_history>();
                // string p_id = library.LoadSetting(Library.KEY_PATIENT_ID_HISTORY);
                //start progessring
                //myring.IsActive = true;
                //myring.Visibility = Windows.UI.Xaml.Visibility.Visible;
                // String method = "AllergentDietList";
                HttpClient          httpClient = new System.Net.Http.HttpClient();
                HttpRequestMessage  request    = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/" + Library.METHODE_SHOWPATIENTMEALDETAILSBYID + "/" + Convert.ToInt32(ID) + "/" + mealtype + "/" + Library.KEY_USER_ccode + "/" + Library.KEY_USER_regcode + "/" + Library.KEY_USER_siteid);
                HttpResponseMessage response   = await httpClient.SendAsync(request);

                var data = await response.Content.ReadAsStringAsync();

                JArray jarray = JArray.Parse(data);
                if (jarray.Count == 0)
                {
                    await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("nomealhistrory", AppResources.Culture), "OK");

                    IsPageEnabled = false;
                    return;
                }

                for (int i = 0; i < jarray.Count; i++)
                {
                    JObject row = JObject.Parse(jarray[i].ToString());
                    meal = new mstr_meal_history
                    {
                        beveragesid = row["beveragesid"].ToString(),
                        dessertid   = row["dessertid"].ToString(),
                        entreeid    = row["entreeid"].ToString(),
                        juiceid     = row["juiceid"].ToString(),
                        orderdate   = row["orderdate"].ToString(),
                        remarkid    = row["remarkid"].ToString(),
                        soupid      = row["soupid"].ToString(),
                        status      = row["status"].ToString()
                    };
                    dataList.Add(meal);
                }
                PatientMealHistoryList = new List <mstr_meal_history>(dataList);
                IsPageEnabled          = false;
                await navigation.PushPopupAsync(new MealInfoPopUp(dataList, mealtype));
            }
            catch (Exception)
            {
                IsPageEnabled = false;
            }
        }
        private async void CancelOrder(mstr_patient_info patient, bool IsDeleted = false)
        {
            mstr_meal_history meal = null;
            ObservableCollection <mstr_meal_history> dataList = new ObservableCollection <mstr_meal_history>();

            List <mstr_meal_option> list = new List <mstr_meal_option>();
            HttpClient httpClient        = new System.Net.Http.HttpClient();
            string     ss    = Library.KEY_USER_ROLE;
            string     scode = Library.KEY_USER_SiteCode;


            DateTime date = DateTime.ParseExact(patient.meal_order_date, "dd/MM/yy", null);


            //DateTime.TryParse(patient.meal_order_date, out date);

            HttpRequestMessage request = null;

            if (ss == "Nurse")
            {
                request = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/Nurse_Cancel_order/" + patient.ID + "/" + patient.meal_order_id + "/" + date.ToString("dd-MM-yyyy") + "/" + scode);
            }
            else
            {
                request = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/FSA_Cancel_order/" + patient.ID + "/" + patient.meal_order_id + "/" + date.ToString("dd-MM-yyyy") + "/" + scode);
            }

            HttpResponseMessage response = await httpClient.SendAsync(request);

            var data = await response.Content.ReadAsStringAsync();

            JArray jarray = JArray.Parse(data);

            for (int i = 0; i < jarray.Count; i++)
            {
                JObject row = JObject.Parse(jarray[i].ToString());
                meal = new mstr_meal_history
                {
                    orderdate      = row["orderdate"].ToString(),
                    createdby      = row["createdby"].ToString(),
                    mealtimename   = row["mealtimename"].ToString(),
                    Id             = row["Id"].ToString(),
                    mealtimeid     = row["mealtimeid"].ToString(),
                    meal_detail_id = row["meal_detail_id"].ToString(),
                    Cut_Off_time   = row["Cut_Off_time"].ToString(),
                    remarks        = ""
                };
                if (!String.IsNullOrEmpty(row["orderdate"].ToString()))
                {
                    DateTime dt = SelectedDate;
                    if (dt.Date > DateTime.Now.Date)
                    {
                        dataList.Add(meal);
                    }
                    else
                    {
                        DateTime cutDate  = DateTime.ParseExact(row["Cut_Off_time"].ToString(), "HH:mm", CultureInfo.InvariantCulture).ToUniversalTime();
                        DateTime currtime = DateTime.Now.ToUniversalTime();
                        if (currtime >= cutDate)
                        {
                        }
                        else
                        {
                            dataList.Add(meal);
                        }
                    }
                }

                //dbhelper.Insert_INTO_mstr_ingredient(new mstr_ingredient(Convert.ToInt32(row["ID"].ToString()), row["ingredient_name"].ToString(), row["ingredient_description"].ToString(), Convert.ToInt32(row["status_id"].ToString()), row["site_code"].ToString()));
            }
            if (IsDeleted && dataList.Count > 0)
            {
                //   DisplayPatientListOnPatientsearch();
            }
            else if (dataList.Count == 0)
            {
                await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("nit2", AppResources.Culture), "OK");


                return;
            }
            PatientMealHistoryList = new List <mstr_meal_history>(dataList);

            //commented on 23/08/2017
            //this.clist.ItemsSource = dataList;
            // img_panels.Visibility = Visibility.Visible;



            var a  = PatientMealHistoryList;
            var ui = new CancelOrderPopup(PatientMealHistoryList, PageDialog);

            ui.Disappearing  += Ui_Disappearing;
            ui.BindingContext = patient;
            await navigation.PushPopupAsync(ui, false);
        }