async public void listof_datewiseRecord_ItemTapped(object sender, ItemTappedEventArgs e) { await this.Navigation.PushModalAsync(new Loading()); try { if (e == null) { return; // has been set to null, do not 'process' tapped event } ((ListView)sender).SelectedItem = null; // de-select the row var selection = e.Item as DateData; Debug.WriteLine("DDDDDDDDDDDDDDDD>>>" + selection.Is_Loc_Device_Changed.ToString()); Debug.WriteLine(selection.uid.ToString() + " " + string.Format("{0:yyyy-MM-dd HH:mm:ss}", selection._date)); get_inoutDetails obj = new get_inoutDetails(); obj.choosedDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", selection._date); obj.userid = selection.uid.ToString(); var json = JsonConvert.SerializeObject(obj); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient Client = new HttpClient(); HttpResponseMessage response = null; response = await Client.PostAsync(ColorResources.baseUrl + "get_inoutdetailsperdate", content); if (response.IsSuccessStatusCode) { Debug.WriteLine(response.StatusCode.ToString()); var content1 = await response.Content.ReadAsStringAsync(); var res = JsonConvert.DeserializeObject <inoutDetailsPerDate>(content1); if (res.inTimes.Count != 0 && res.outTimes.Count != 0) { await this.Navigation.PopModalAsync(); await this.Navigation.PushAsync(new info_ofdayPage(res, selection.totalInTime.ToString(), selection.employeeName, selection._date, selection.weekday)); } else { await this.Navigation.PopModalAsync(); await DisplayAlert(" nWorksLeaveApp", "Not Appropriate Data!", "OK"); } } } catch (Exception ex) { await this.Navigation.PopModalAsync(); await DisplayAlert(" nWorksLeaveApp", "Unable to connect server, Try again!", "OK"); Debug.WriteLine(ex.ToString()); } }
public detailsPage(string date, List <DateData> listofUser) { BackgroundColor = ColorResources.PageBackgroundColor; Title = Convert.ToDateTime(date).ToString("dd-MMM-yyyy"); var empName_header = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = 16, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, TextColor = Color.Red, Text = Convert.ToDateTime(date).ToString("dd-MMM-yyyy"), }; ListView listof_datewiseRecord = new ListView { BackgroundColor = ColorResources.PageBackgroundColor, ItemTemplate = new DataTemplate(typeof(data_cell)), ItemsSource = listofUser, RowHeight = 70, }; listof_datewiseRecord.ItemTapped += async(object sender, ItemTappedEventArgs e) => { await this.Navigation.PushModalAsync(new Loading()); try { if (e == null) { return; // has been set to null, do not 'process' tapped event } ((ListView)sender).SelectedItem = null; // de-select the row var selection = e.Item as DateData; Debug.WriteLine("DDDDDDDDDDDDDDDD>>>" + selection.Is_Loc_Device_Changed.ToString()); Debug.WriteLine(selection.uid.ToString() + " " + string.Format("{0:yyyy-MM-dd HH:mm:ss}", selection._date)); get_inoutDetails obj = new get_inoutDetails(); obj.choosedDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", selection._date); obj.userid = selection.uid.ToString(); var json = JsonConvert.SerializeObject(obj); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient Client = new HttpClient(); HttpResponseMessage response = null; response = await Client.PostAsync(ColorResources.baseUrl + "get_inoutdetailsperdate", content); if (response.IsSuccessStatusCode) { Debug.WriteLine(response.StatusCode.ToString()); var content1 = await response.Content.ReadAsStringAsync(); var res = JsonConvert.DeserializeObject <inoutDetailsPerDate>(content1); if (res.inTimes.Count != 0 && res.outTimes.Count != 0) { await this.Navigation.PushAsync(new info_ofdayPage(res, selection.totalInTime.ToString(), selection.employeeName, selection._date, selection.weekday)); } else { await DisplayAlert(" nWorksLeaveApp", "Not Appropriate Data!", "OK"); } } } catch (Exception ex) { await DisplayAlert(" nWorksLeaveApp", "Unable to connect server, Try again!", "OK"); Debug.WriteLine(ex.ToString()); } await this.Navigation.PopModalAsync(); }; var listHeader = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { Text = "Date", FontFamily = "HelveticaNeue-Medium", FontSize = 14, WidthRequest = 90, TextColor = Color.Aqua, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }, new Label { Text = "In Time", FontFamily = "HelveticaNeue-Medium", FontSize = 14, WidthRequest = 60, TextColor = Color.Aqua, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }, new Label { Text = "Out Time", FontFamily = "HelveticaNeue-Medium", FontSize = 14, WidthRequest = 60, TextColor = Color.Aqua, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }, new Label { Text = "Total", FontFamily = "HelveticaNeue-Medium", FontSize = 14, WidthRequest = 60, TextColor = Color.Aqua, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }, } }; Content = new StackLayout { Padding = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { empName_header, listHeader, listof_datewiseRecord, } }; }
public inoutDetailsPerDate get_inoutDetailsPerDate(get_inoutDetails obj) { inoutDetailsPerDate data = new inoutDetailsPerDate(); Debug.WriteLine(string.Format("{0:yyyy-MM-dd}", obj.choosedDate.ToString()) + " " + obj.userid.ToString()); Debug.WriteLine(" Universal Time :" + Convert.ToDateTime(obj.choosedDate).ToUniversalTime().ToString("yyyy-MM-dd")); string q4 = "select distinct inTime,isdevicechanged,deviceid,location,distancefromorigin from in_out where inTime != '00:00:00' and uid='" + obj.userid + "' and _date='" + Convert.ToDateTime(obj.choosedDate).ToString("yyyy-MM-dd") + "';"; string q5 = "select distinct outTime,isdevicechanged,deviceid,location,distancefromorigin from in_out where outTime != '00:00:00' and uid='" + obj.userid + "' and _date='" + Convert.ToDateTime(obj.choosedDate).ToString("yyyy-MM-dd") + "';"; MySqlCommand cmd4 = new MySqlCommand(q4, conn); MySqlCommand cmd5 = new MySqlCommand(q5, conn); List <inTimes> MYinT = new List <inTimes>(); List <outTimes> MYoutT = new List <outTimes>(); MySqlDataReader rdr4; MySqlDataReader rdr5; conn.Open(); rdr4 = cmd4.ExecuteReader(); while (rdr4.Read()) { inTimes A = new inTimes(); //MYinT.Add(getConvert(rdr4.GetString("inTime").Substring(10, 8))); //inT.Add((rdr4.getString("inTime").Substring(10,8))); A.INTIMES = getConvert(rdr4.GetString("inTime").Substring(10, 8)); A.deviceid = rdr4.GetString("deviceid"); A.location = rdr4.GetString("location"); if (rdr4.GetFloat("DistanceFromOrigin") > 100.000 || rdr4.GetInt16("IsDeviceChanged") == 1) { Debug.WriteLine(rdr4.GetFloat("DistanceFromOrigin").ToString()); A.IsDevice_or_LocationChanged = "Red"; } else { A.IsDevice_or_LocationChanged = "White"; } MYinT.Add(A); } conn.Close(); conn.Open(); rdr5 = cmd5.ExecuteReader(); while (rdr5.Read()) { outTimes B = new outTimes(); //MYoutT.Add(getConvert(rdr5.GetString("outTime").Substring(10, 8))); B.OUTTIMES = getConvert(rdr5.GetString("outTime").Substring(10, 8)); B.deviceid = rdr5.GetString("deviceid"); B.location = rdr5.GetString("location"); if (rdr5.GetFloat("DistanceFromOrigin") > 100.000 || rdr5.GetInt16("IsDeviceChanged") == 1) { Debug.WriteLine(rdr5.GetFloat("DistanceFromOrigin").ToString()); B.IsDevice_or_LocationChanged = "Red"; } else { B.IsDevice_or_LocationChanged = "White"; } MYoutT.Add(B); } conn.Close(); data.inTimes = MYinT; data.outTimes = MYoutT; return(data); }