예제 #1
0
        public async void btnAppeal_Clicked(object sender, EventArgs e)
        {
            try
            {
                string strSub          = "UpdateAppeal";
                string companyId       = (string)ContentGlobal.allldata["info"]["company"]["id"];
                string appealId        = Application.Current.Properties["NumberId"].ToString();
                int    state           = 4;
                string conform_content = "Người dùng Khiếu nại";

                var    dataEE      = ContentGlobal.allldata["appeals"][year.ToString()][month.ToString()][Application.Current.Properties["NumberId"].ToString()];
                double timepreview = (double)dataEE["send_date"];

                string strParam = @"{""companyId"":""" + companyId + @""",""appealId"":""" + appealId + @""",""state"":" + state + @",""conform_content"":""" + conform_content + @""",""send_date"":" + timepreview + @"}";

                Debug.WriteLine("strParam-----------------------------" + strParam);
                var data = await ContentGlobal.FirebasePUTFunctions(strSub, strParam);

                if ((string)data["return"] == "OK")
                {
                    Application.Current.Properties["baseAppeal"] = lbNumberId.Text.ToString();
                    await Navigation.PushAsync(new Appeal.NewAppealPage());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        private async Task btnAcceptAllClicked(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                var answer = await DisplayAlert("Phiếu chấm công", "Bạn xác nhận duyệt tất cả các phiếu chấm công", "Yes", "No");

                if (answer == true)
                {
                    try
                    {
                        int sl = 0;
                        for (int i = 0; i < listTimeSheets.Count; i++)
                        {
                            IitemTimesheets it = listTimeSheets[i];

                            if (it.State == 0)
                            {
                                string strSub = "UpdateTimeSheets";

                                string uid = Application.Current.Properties["uId"].ToString();

                                string timesheets_id = it.TimesheetsID;
                                Debug.WriteLine("timesheets_id--------------------------------------------" + timesheets_id);

                                Debug.WriteLine("year--------------------------------------------" + year);

                                int period = selectedIndexMonth + 1;
                                Debug.WriteLine("period--------------------------------------------" + period);


                                string strParam = @"{""uid"":""" + uid + @""",""timesheets_id"":""" + timesheets_id + @""",""year"":" + year + @",""period"":" + period + @",""state"": 2}";

                                Debug.WriteLine("strParam-------------------------" + strParam);

                                var data = await ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                                sl++;
                            }
                        }

                        await DisplayAlert("Hoàn thành", sl + "/" + listTimeSheets.Count + " phiếu chấm công đã được duyệt", "OK");

                        listTimeSheets = loadTimeSheet();
                        loadPeople(selectedPeople + 1);

                        await Navigation.PopAsync();
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                        Debug.WriteLine("Err PreviewTimeKeeping All---------------------------------------" + ex);
                    }
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #3
0
        async void OnRefresh(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                try
                {
                    ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                    //ContentGlobal.loadListRequest();
                    var list = (ListView)sender;
                    //put your refreshing logic here
                    Iitem.Clear();
                    Iitem = loadNotification();
                    lvNotifications.ItemsSource = Iitem;
                    list.IsRefreshing           = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                    Debug.WriteLine("Er PersionPage Sync---------------------------------------" + ex);
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #4
0
        protected override void OnDisappearing()
        {
            if (ContentGlobal.saveSetting == true)
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        var data = ContentGlobal.allldata["setting"];
                        Debug.WriteLine("date save---------------" + data);

                        string strSub   = "UpdateSetting";
                        string strParam = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""content"":" + data + @"}";

                        Debug.WriteLine("strParam-------------------------------------------------" + strParam);

                        var dataEE = ContentGlobal.FirebasePUTFunctions(strSub, strParam);

                        Debug.WriteLine("dataEE----------------------------------" + dataEE);

                        ContentGlobal.saveSetting = false;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Er-------Setting Page" + ex);
                    }
                }
            }
        }
예제 #5
0
        public async Task btnChangedPassword_Click(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") == true)
            {
                try
                {
                    if (entOldPassword.Text.ToString().Length > 6 && entOldPassword.IsEnabled == true && entNewPassword.Text.ToString().Length > 6 && entNewPassword.IsEnabled == true && entReNewPassword.Text.ToString().Length > 6 && entReNewPassword.IsEnabled == true && entNewPassword.Text.ToString().Equals(entReNewPassword.Text.ToString()) && btnChange.IsEnabled == true)
                    {
                        //entOldPassword.IsEnabled = false;
                        //entNewPassword.IsEnabled = false;
                        //entReNewPassword.IsEnabled = false;
                        stkLoad.IsVisible = true;

                        string strSub   = "resetPassword";
                        string strParam = @"{""newPassword"": """ + entNewPassword.Text.ToString() + @""", ""oldPassword"": """ + entOldPassword.Text.ToString() + @""", ""email"": """ + ContentGlobal.allldata["info"]["email"] + @""" }";

                        Debug.WriteLine("param------------------" + strParam);
                        JContainer data = await ContentGlobal.PostAllFirebase_Auth(strSub, strParam);

                        Debug.WriteLine("----datattttttttttttttttttttt--------------" + data["email"]);

                        if ((string)data["email"] == (string)ContentGlobal.allldata["info"]["email"])
                        {
                            string strSubFB   = "PasswordSafety";
                            string strParamFB = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""password_safety"":1}";

                            Debug.WriteLine("--------------param--------------" + strParamFB);
                            Debug.WriteLine("---------------111111111111111111111----------------------");
                            var dataFB = await ContentGlobal.FirebasePUTFunctions(strSubFB, strParamFB);

                            Debug.WriteLine("---------------22222222222222222222222222----------------------" + dataFB["return"]);
                            if ((string)dataFB["return"] == "OK")
                            {
                                Application.Current.Properties["TokenFB"] = "";
                                Page page = new SignIn_Page();
                                NavigationPage.SetHasNavigationBar(page, false);
                                App.Current.MainPage = new NavigationPage(page);
                            }
                        }
                        else
                        {
                            entOldPassword.Text = entNewPassword.Text = entReNewPassword.Text = "";
                            stkLoad.IsVisible   = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Lỗi", "Có vấn dề đã sảy ra, thử lại sau !", "OK");

                    Debug.WriteLine("Error--ChangedPassword--------------------------------", ex);
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo mạng", "Bạn hãy kết nối mạng để thực hiện tác vụ này !", "OK");
            }
        }
예제 #6
0
        public async void SendRequest(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                if (edtCause.Text.ToString().Length > 0)
                {
                    string strSub          = "UpdateOdooRequest";
                    string appealId        = Application.Current.Properties["NumberId"].ToString();
                    int    state           = (int)Application.Current.Properties["TypeApprove"];
                    string conform_content = Regex.Replace(edtCause.Text.ToString(), @"\s+", " ");

                    /*DateTime date = DateTime.Now;
                     * var month = (int)date.Month;
                     * var year = date.Year;*/

                    /* year = (int)ContentGlobal.allldata["timeoff"]["year"];
                     * month = (int)ContentGlobal.allldata["timeoff"]["period"];
                     *
                     * var dataEE = ContentGlobal.allldata["requests_receive"][year.ToString()][month.ToString()][Application.Current.Properties["NumberId"].ToString()];
                     * double timepreview = (double)dataEE["send_date"];*/

                    string strParam = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""request_id"":""" + appealId + @""",""action"":" + state + @",""comment"":""" + conform_content + @"""}";

                    Debug.WriteLine("strParam---------------------------------" + strParam);

                    var data = await ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                    if ((string)data["return"] == "OK")
                    {
                        var page = new MainPage();
                        NavigationPage.SetHasNavigationBar(page, false);
                        App.Current.MainPage = new NavigationPage(page);
                    }
                    else
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau", "OK");
                    }
                }
                else
                {
                    await DisplayAlert("Warring", "Hay nhập xác nhận của bạn!", "OK");

                    edtCause.Text = "";
                    edtCause.Focus();
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #7
0
        protected async override void OnAppearing()
        {
            ContentGlobal.loadListRequest();
            var dataEEProgess = ContentGlobal.allldata["timeoff"]["timeoff"];

            if (dataEEProgess != null)
            {
                Debug.WriteLine("dataEE-------------------------------------------------------------" + dataEEProgess);

                if ((float)dataEEProgess["dayoff"]["total"] > 0.0)
                {
                    float dateoff = (float)dataEEProgess["dayoff"]["timecout"] / (float)dataEEProgess["dayoff"]["total"];
                    await progessPer.ProgressTo(dateoff, 250, Easing.Linear);
                }

                lbDateoff.Text      = (string)dataEEProgess["dayoff"]["timecout"];
                lbTotalDateoff.Text = "(Tiêu chuẩn: " + (string)dataEEProgess["dayoff"]["total"] + " ngày)";
                lboffPertotal.Text  = (string)dataEEProgess["dayoff"]["timecout"] + " /" + (string)dataEEProgess["dayoff"]["total"] + "n";
            }



            /*string companyId = (string)ContentGlobal.allldata["info"]["company"]["id"];
             * string strParam = @"{""companyId"":""" + companyId + @""",""type"":1}";
             * Debug.WriteLine("strParam---------------------" + strParam);
             *
             * var getid = await ContentGlobal.FirebasePOSTFunctions("GetIdLetter", strParam);
             * Debug.WriteLine("getid---------------------" + getid);
             *
             * string id = (string)getid["ID"];
             * //lbNumberId.Text = "LR" + id;
             *
             *
             * string People_AssignName = "";
             * var dataEE = ContentGlobal.allldata["info"]["managed"];
             *
             * Debug.WriteLine("dataEE-----------------------------" + dataEE);
             *
             * var dict = JsonConvert.DeserializeObject<Dictionary<string, JContainer>>(dataEE.ToString());
             * foreach (var kv in dict)
             * {
             *  Debug.WriteLine("key :--------" + kv.Key + "value-----------------" + kv.Value);
             *  if ((int)kv.Value["state"] == 1)
             *  {
             *      //People_AssignId = kv.Key;
             *      People_AssignName = (string)kv.Value["name"];
             *  }
             * }
             *
             * //lbPeopleAssign.Text = People_AssignName;*/
        }
예제 #8
0
        public async void SendRequest(object sender, EventArgs e)
        {
            var answer = await DisplayAlert("Phiếu Xin nghỉ", "Bạn có thực sự muốn gửi phiếu nghỉ này", "Yes", "No");

            if (answer == true)
            {
                try
                {
                    string strSub    = "CreateAppeal";
                    string companyId = (string)ContentGlobal.allldata["info"]["company"]["id"];

                    int typeAppeal = selectedIndexTypeAppeal;
                    Debug.WriteLine("typeAppeal-------------------------" + typeAppeal);

                    string appealId = lbNumberId.Text.ToString();
                    Debug.WriteLine("appealId-------------------------" + appealId);

                    string people_send = Application.Current.Properties["uId"].ToString();
                    Debug.WriteLine("people_send-------------------------" + people_send);

                    string people_assign = People_AssignId;
                    Debug.WriteLine("people_assign-------------------------" + people_assign);

                    string base_on = lbBase_NumberId.Text.ToString();
                    Debug.WriteLine("base_on-------------------------" + base_on);

                    string content = edtCause.Text.ToString();
                    Debug.WriteLine("content-------------------------" + content);

                    string strParam = @"{""companyId"":""" + companyId + @""",""typeAppeal"":" + typeAppeal + @",
	""appealId"":"""     + appealId + @""",""people_send"":""" + people_send + @""",""people_assign"":""" + people_assign + @""",
    ""base_on"":""" + base_on + @""",""content"":""" + content + @"""}";

                    Debug.WriteLine("strParam-------------------------" + strParam);

                    var data = ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                    //await Navigation.PopAsync();
                    Page page = new MainPage();
                    NavigationPage.SetHasNavigationBar(page, false);
                    App.Current.MainPage = new NavigationPage(page);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #9
0
        private async void ButtonGetGPS_Clicked(object sender, EventArgs e)
        {
            PopUpDialog.IsVisible = false;
            PopUpDialog.ShowDialog();
            try
            {
                var hasPermission = await Utils.CheckPermissions(Permission.Location);

                if (!hasPermission)
                {
                    return;
                }

                ButtonGetGPS.IsEnabled = false;

                /* var locator =  CrossGeolocator.Current;
                 * locator.DesiredAccuracy = 50;
                 * lbData.Text = "Getting gps...";
                 */
                var position = await ContentGlobal.getLocation();

                if (position == null)
                {
                    lbData.Text = "null gps :(";
                    return;
                }


                Debug.WriteLine("Position Status: Latitude ------------------------------------------" + position.Latitude);
                Debug.WriteLine("Position Status: Longitude ------------------------------------------" + position.Longitude);

                lbData.Text = string.Format("Time: {0} \nLat: {1} \nLong: {2} \nAltitude: {3} \nAltitude Accuracy: {4} \nAccuracy: {5} \nHeading: {6} \nSpeed: {7}",
                                            position.Timestamp, position.Latitude, position.Longitude,
                                            position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed);
            }
            catch (Exception ex)
            {
                await DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured for analysis! Thanks.", "OK");

                Debug.WriteLine("Er------------------------" + ex);
            }
            finally
            {
                ButtonGetGPS.IsEnabled = true;
            }
        }
예제 #10
0
        private async Task btnAcceptClicked(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                var answer = await DisplayAlert("Phiếu chấm công", "Bạn xác nhận duyệt phiếu chấm công này", "Yes", "No");

                if (answer == true)
                {
                    try
                    {
                        string strSub = "UpdateTimeSheets";

                        string uid = Application.Current.Properties["uId"].ToString();

                        string timesheets_id = listTimeSheets[selectedPeople].TimesheetsID;
                        Debug.WriteLine("timesheets_id--------------------------------------------" + timesheets_id);

                        Debug.WriteLine("year--------------------------------------------" + year);

                        int period = selectedIndexMonth + 1;
                        Debug.WriteLine("period--------------------------------------------" + period);


                        string strParam = @"{""uid"":""" + uid + @""",""timesheets_id"":""" + timesheets_id + @""",""year"":" + year + @",""period"":" + period + @",""state"": 2}";

                        Debug.WriteLine("strParam-------------------------" + strParam);

                        var data = await ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                        listTimeSheets = loadTimeSheet();
                        loadPeople(selectedPeople + 1);
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                        Debug.WriteLine("Er PreviewTimekeeping---------------------------------------" + ex);
                    }
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #11
0
        async void OnRefresh(object sender, EventArgs e)
        {
            ObservableCollection <LVsearItem> items = new ObservableCollection <LVsearItem>();

            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                try
                {
                    var data = await ContentGlobal.peopleWorkingAsync();

                    if (data != null)
                    {
                        var dict = JsonConvert.DeserializeObject <Dictionary <string, JContainer> >(data.ToString());
                        foreach (var kv in dict)
                        {
                            string Name    = ContentGlobal.allldata["info"]["managed"][kv.Key.ToString()]["name"].ToString();
                            string time_in = kv.Value["time_in"].ToString();
                            items.Add(new LVsearItem()
                            {
                                IconSource = "checked.png",
                                TextColor  = "#57cf85",
                                Name       = Name,
                                TimeIn     = time_in,
                            });
                        }
                    }
                    Iitem.Clear();
                    Iitem = items;
                    lbCountPeople.Text   = Iitem.Count.ToString() + " người đang làm việc";
                    lvSearch.ItemsSource = Iitem;

                    lvSearch.IsRefreshing = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                    Debug.WriteLine("Er PersionPage Sync---------------------------------------" + ex);
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #12
0
        public async void btnCancel_Clicked(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") == false)
            {
                await DisplayAlert("Cảnh báo mạng", "Bạn hãy kết nối mạng để thực hiện tác vụ này !", "OK");
            }
            else
            {
                var answer = await DisplayAlert("Hủy yêu cầu", "Bạn có thực sự muốn hủy đơn nghỉ này", "Yes", "No");

                if (answer == true)
                {
                    try
                    {
                        //await Navigation.PopAsync();
                        string strSub          = "UpdateOdooRequest";
                        string appealId        = Application.Current.Properties["NumberId"].ToString();
                        int    state           = 3;
                        string conform_content = "Người dùng hủy";

                        string strParam = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""request_id"":""" + appealId + @""",""action"":" + state + @",""comment"":""" + conform_content + @"""}";

                        Debug.WriteLine("strParam---------------------------------" + strParam);
                        var data = await ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                        if ((string)data["return"] == "OK")
                        {
                            var page = new MainPage();
                            NavigationPage.SetHasNavigationBar(page, false);
                            App.Current.MainPage = new NavigationPage(page);
                        }
                        else
                        {
                            await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau", "OK");
                        }
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Lỗi", "Có vấn dề đã sảy ra, thử lại sau !", "OK");

                        Debug.WriteLine("Error--ChangedPassword--------------------------------", ex);
                    }
                }
            }
        }
예제 #13
0
        public async void btnAppeal_Clicked(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") == false)
            {
                await DisplayAlert("Cảnh báo mạng", "Bạn hãy kết nối mạng để thực hiện tác vụ này !", "OK");
            }
            else
            {
                try
                {
                    string strSub          = "UpdateOdooRequest";
                    string appealId        = Application.Current.Properties["NumberId"].ToString();
                    int    state           = 4;
                    string conform_content = "Người dùng Khiếu nại";

                    var    dataEE      = ContentGlobal.allldata["requests"][year.ToString()][month.ToString()][Application.Current.Properties["NumberId"].ToString()];
                    double timepreview = (double)dataEE["send_date"];

                    string strParam = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""request_id"":""" + appealId + @""",""action"":" + state + @",""comment"":""" + conform_content + @"""}";

                    Debug.WriteLine("strParam---------------------------------" + strParam);
                    var data = await ContentGlobal.FirebasePOSTFunctions(strSub, strParam);

                    if ((string)data["return"] == "OK")
                    {
                        //await Navigation.PopAsync();
                        Application.Current.Properties["baseAppeal"] = lbNumberId.Text.ToString();
                        //await Navigation.PushAsync(new Requests.NewRequestPage());
                        App.Current.MainPage = new Requests.NewRequestPage();
                    }
                    else
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau", "OK");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Lỗi", "Có vấn dề đã sảy ra, thử lại sau !", "OK");

                    Debug.WriteLine("Error--ChangedPassword--------------------------------", ex);
                }
            }
        }
예제 #14
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            var data = ContentGlobal.allldata["info"];

            lbPersionalName.Text   = (string)data["name"];
            lbOdooPersionalId.Text = (string)data["id"];
            lbEmail.Text           = lbPersionalEmail.Text = (string)data["email"];
            string image_data = (string)data["image_data"];

            imgAvatar.Source = ImageSource.FromStream(() => new MemoryStream(ContentGlobal.GetImageStreamAsBytes(ContentGlobal.StringFromBase64Stream(image_data))));
            if (ContentGlobal.Userroot == true)
            {
                lbActed.Text = "Quản lý";
            }
            else
            {
                lbActed.Text = "Không";
            }
        }
예제 #15
0
        protected override void OnAppearing()
        {
            lbLastSync.Text = "Lần gần nhất:  " + Application.Current.Properties["date_clone"].ToString();
            var data = ContentGlobal.allldata["info"];

            lbPersionalName.Text  = lbEdit_PersionalName.Text = (string)data["name"];
            lbPersionalEmail.Text = (string)data["email"];
            string image_data = (string)data["image_data"];

            imgAvatar.Source = ImageSource.FromStream(() => new MemoryStream(ContentGlobal.GetImageStreamAsBytes(ContentGlobal.StringFromBase64Stream(image_data))));

            /* if (ContentGlobal.Userroot == false)
             * {
             *   stkAssign.IsVisible = false;
             * }
             * else
             * {
             *   stkAssign.IsVisible = true;
             * }*/
        }
예제 #16
0
        async void OnRefresh(object sender, EventArgs e)
        {
            ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

            ContentGlobal.loadListRequest();
            var list = (ListView)sender;

            //put your refreshing logic here

            /*var itemList = Iitem.Reverse().ToList();
             * Iitem.Clear();
             * foreach (var s in itemList)
             * {
             *  Iitem.Add(s);
             * }*/
            Iitem.Clear();
            Iitem = loadAppeal();
            lvSearch.ItemsSource = Iitem;
            //make sure to end the refresh state
            list.IsRefreshing = false;
        }
예제 #17
0
        async void OnRefresh(object sender, EventArgs e)
        {
            if (ContentGlobal.statusNetwork().Equals("Connected") != false)
            {
                try
                {
                    ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                    ContentGlobal.loadListRequest();

                    var list = (ListView)sender;
                    //put your refreshing logic here

                    /*var itemList = Iitem.Reverse().ToList();
                     * Iitem.Clear();
                     * foreach (var s in itemList)
                     * {
                     *  Iitem.Add(s);
                     * }*/
                    Iitem.Clear();
                    Iitem = loadRequests();
                    lvSearch.ItemsSource = Iitem;
                    //make sure to end the refresh state
                    list.IsRefreshing = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                    Debug.WriteLine("Er PersionPage Sync---------------------------------------" + ex);
                }
            }
            else
            {
                await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
            }
        }
예제 #18
0
        protected async override void OnAppearing()
        {
            string companyId = (string)ContentGlobal.allldata["info"]["company"]["id"];
            string strParam  = @"{""companyId"":""" + companyId + @""",""type"":2}";

            Debug.WriteLine("strParam---------------------" + strParam);

            var getid = await ContentGlobal.FirebasePOSTFunctions("GetIdLetter", strParam);

            Debug.WriteLine("getid---------------------" + getid);

            string id = (string)getid["ID"];

            lbNumberId.Text = "BS" + id;

            lbBase_NumberId.Text = Application.Current.Properties["baseAppeal"].ToString();

            string People_AssignName = "";
            var    dataEE            = ContentGlobal.allldata["info"]["managed"];

            Debug.WriteLine("dataEE-----------------------------" + dataEE);

            var dict = JsonConvert.DeserializeObject <Dictionary <string, JContainer> >(dataEE.ToString());

            foreach (var kv in dict)
            {
                Debug.WriteLine("key :--------" + kv.Key + "value-----------------" + kv.Value);
                if ((int)kv.Value["state"] == 1)
                {
                    People_AssignId   = kv.Key;
                    People_AssignName = (string)kv.Value["name"];
                }
            }

            lbPeopleAssign.Text = People_AssignName;
        }
예제 #19
0
        public async void btnCancel_Clicked(object sender, EventArgs e)
        {
            var answer = await DisplayAlert("Hủy yêu cầu", "Bạn có thực sự muốn hủy đơn khiếu nại này", "Yes", "No");

            if (answer == true)
            {
                try
                {
                    string strSub          = "UpdateAppeal";
                    string companyId       = (string)ContentGlobal.allldata["info"]["company"]["id"];
                    string appealId        = Application.Current.Properties["NumberId"].ToString();
                    int    state           = 3;
                    string conform_content = "Người dùng hủy";

                    var    dataEE      = ContentGlobal.allldata["appeals"][year.ToString()][month.ToString()][Application.Current.Properties["NumberId"].ToString()];
                    double timepreview = (double)dataEE["send_date"];

                    string strParam = @"{""companyId"":""" + companyId + @""",""appealId"":""" + appealId + @""",""state"":" + state + @",""conform_content"":""" + conform_content + @""",""send_date"":" + timepreview + @"}";

                    Debug.WriteLine("strParam-----------------------------" + strParam);
                    var data = await ContentGlobal.FirebasePUTFunctions(strSub, strParam);

                    if ((string)data["return"] == "OK")
                    {
                        //await Navigation.PopAsync();
                        Page page = new MainPage();
                        NavigationPage.SetHasNavigationBar(page, false);
                        App.Current.MainPage = new NavigationPage(page);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #20
0
        public async void SendRequest(object sender, EventArgs e)
        {
            if (edtCause.Text.ToString().Length > 0)
            {
                string strSub          = "UpdateAppeal";
                string companyId       = (string)ContentGlobal.allldata["info"]["company"]["id"];
                string appealId        = Application.Current.Properties["NumberId"].ToString();
                int    state           = (int)Application.Current.Properties["TypeApprove"];
                string conform_content = edtCause.Text.ToString();

                year  = (int)ContentGlobal.allldata["timeoff"]["year"];
                month = (int)ContentGlobal.allldata["timeoff"]["period"];

                var    dataEE      = ContentGlobal.allldata["appeals_receive"][year.ToString()][month.ToString()][Application.Current.Properties["NumberId"].ToString()];
                double timepreview = (double)dataEE["send_date"];

                string strParam = @"{""companyId"":""" + companyId + @""",""appealId"":""" + appealId + @""",""state"":" + state + @",""conform_content"":""" + conform_content + @""",""send_date"":" + timepreview + @"}";

                Debug.WriteLine("strParam--------------------------------" + strParam);
                var data = await ContentGlobal.FirebasePUTFunctions(strSub, strParam);

                if ((string)data["return"] == "OK")
                {
                    var page = new MainPage();
                    NavigationPage.SetHasNavigationBar(page, false);
                    App.Current.MainPage = new NavigationPage(page);
                }
            }
            else
            {
                await DisplayAlert("Warring", "Hay điền đủ lý do", "OK");

                edtCause.Text = "";
                edtCause.Focus();
            }
        }
예제 #21
0
        protected override void OnDisappearing()
        {
            Debug.WriteLine("close Notification-----------------------------------------------------------");

            var month = (int)ContentGlobal.allldata["timeoff"]["period"];

            ContentGlobal.INTcountNotiUnread = ContentGlobal.CountNotiUnread("individualistic", month) + ContentGlobal.CountNotiUnread("public", month);
            CrossBadge.Current.SetBadge(ContentGlobal.INTcountNotiUnread);

            if (saveNoti == true)
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        var data = ContentGlobal.allldata["notificaton"];
                        Debug.WriteLine("date save---------------" + data);

                        string strSub   = "UpdateNotification";
                        string strParam = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""content"":" + data + @"}";

                        Debug.WriteLine("strParam-------------------------------------------------" + strParam);

                        var dataEE = ContentGlobal.FirebasePUTFunctions(strSub, strParam);

                        Debug.WriteLine("dataEE----------------------------------" + dataEE);

                        ContentGlobal.saveSetting = false;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Err Notifiaction----------------------------------------" + ex);
                    }
                }
            }
        }
예제 #22
0
        public async void SendRequest(object sender, EventArgs e)
        {
            if (selectedIndexTypeRequest >= 0 && selectedIndexSubTypeRequest >= 0 && edtCause != null && edtCause.Text.ToString().Trim().Length > 0)
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    var answer = await DisplayAlert("Phiếu Xin nghỉ", "Bạn có thực sự muốn gửi phiếu nghỉ này", "Yes", "No");

                    if (answer == true)
                    {
                        try
                        {
                            string strSub = "CreateOdooRequest";

                            string subTypeRequest = sub_type_rq;
                            Debug.WriteLine("subTypeRequest---------------------" + sub_type_rq);

                            string people_send = Application.Current.Properties["uId"].ToString();
                            Debug.WriteLine("people_send-------------------------" + people_send);

                            // string people_assign = People_AssignId;
                            // Debug.WriteLine("people_assign-------------------------" + people_assign);

                            // string requestId = lbNumberId.Text.ToString();
                            //Debug.WriteLine("requestId-------------------------" + requestId);

                            string content = edtCause.Text.ToString().Trim();
                            Debug.WriteLine("content-------------------------" + content);

                            long DatetimeMinTimeTicks = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Ticks;

                            long startdate = (long)((pkFromDate.Date.Add(pkFromTime.Time).ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000);
                            Debug.WriteLine("startdate-------------------------" + startdate);

                            long enddate = (long)((pkToDate.Date.Add(pkToTime.Time).ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000);
                            Debug.WriteLine("enddate-------------------------" + enddate);

                            string strParam = @"{ ""uid"":""" + people_send + @""",""sub_type_rq"":""" + subTypeRequest + @""",""rq_comment"":""" + content + @""",""from_date"":""" + startdate + @""",""to_date"":""" + enddate + @"""}";

                            Debug.WriteLine("strParam-------------------------" + strParam);

                            var data = ContentGlobal.FirebasePOSTFunctions(strSub, strParam);
                            Debug.WriteLine("data-------------------------------------" + data);
                            await Navigation.PopAsync();
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
                }
            }
            else
            {
                await DisplayAlert("Thông báo", "Bạn phải nhập đủ các trường thông tin !", "OK");
            }
        }
예제 #23
0
        public PersonalPage()
        {
            InitializeComponent();
            //this.BackgroundColor = Color.FromHex("#F0EFF5");
            this.BackgroundImage = "background.jpg";

            var tapAccount = new TapGestureRecognizer();

            tapAccount.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new AccountPage());
            };

            imgToAccount.GestureRecognizers.Add(tapAccount);

            var tapSetting = new TapGestureRecognizer();

            tapSetting.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Setting.SettingPage());
            };

            imgToSetting.GestureRecognizers.Add(tapSetting);


            var tapTurn = new TapGestureRecognizer();

            tapTurn.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Personal.AssignPage());
            };
            imgToTurn.GestureRecognizers.Add(tapTurn);

            var tapLogout = new TapGestureRecognizer();

            tapLogout.Tapped += async(s, e) =>
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        string strSubFirebase = "ClearRegis";
                        string strParam       = @"{ ""uid"" : """ + Application.Current.Properties["uId"].ToString() + @"""} ";
                        var    data           = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);

                        Application.Current.Properties["uId"] = "";
                        var page = new SignIn_Page();
                        NavigationPage.SetHasNavigationBar(page, false);
                        App.Current.MainPage = new NavigationPage(page);

                        /*if ((string)data["return"] == "OK")
                         * {
                         *  Application.Current.Properties["uId"] = "";
                         *  var page = new SignIn_Page();
                         *  NavigationPage.SetHasNavigationBar(page, false);
                         *  App.Current.MainPage = new NavigationPage(page);
                         * }
                         * else
                         * {
                         *  await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");
                         * }*/
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                        Debug.WriteLine("Er Account Page--------------------------------------" + ex);
                    }
                }
                else
                {
                    await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau!", "OK");
                }
            };
            stkLogout.GestureRecognizers.Add(tapLogout);

            var tapSync = new TapGestureRecognizer();

            tapSync.Tapped += async(s, e) =>
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        NavigationPage.SetHasNavigationBar(this, false);
                        await imgSync.RotateTo(-360, 2000);

                        imgSync.Rotation = 0;

                        ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                        //ContentGlobal.loadListRequest();
                        lbLastSync.Text = "Lần gần nhất:  " + Application.Current.Properties["date_clone"].ToString();
                        NavigationPage.SetHasNavigationBar(this, true);
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                        Debug.WriteLine("Er PersionPage Sync---------------------------------------" + ex);
                    }
                }
                else
                {
                    await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau", "OK");
                }
            };
            grdSync.GestureRecognizers.Add(tapSync);

            var tapAvatar = new TapGestureRecognizer();

            tapAvatar.Tapped += async(s, e) =>
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");

                    return;
                }
                var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });


                if (file == null)
                {
                    return;
                }

                var stream = file.GetStream();

                string Subs = ContentGlobal.StreamToBase64String(stream);

                Debug.WriteLine("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa===================================== :    " + Subs);

                string NameAPI = "pushImage";
                string pram    = @"{""uid"" : """ + Application.Current.Properties["uId"].ToString() + @""", ""image_data"" : """ + Subs + @"""}";

                Debug.WriteLine("Param------------------------------" + pram);

                var dataEE = await ContentGlobal.FirebasePOSTFunctions(NameAPI, pram);

                var byte002 = ContentGlobal.StringFromBase64Stream(Subs);

                imgAvatar.Source = ImageSource.FromStream(() => new MemoryStream(ContentGlobal.GetImageStreamAsBytes(byte002)));

                /*{
                 *  var stream = file.GetStream();
                 *
                 *  StreamReader reader = new StreamReader(stream);
                 *  string text = stream.ToString();
                 *
                 *  Debug.WriteLine("aaaaaaaaaaaaaaaaaaaa-----------------------------------" + text);
                 *
                 *  file.Dispose();
                 *  return stream;
                 * });*/
            };

            imgAvatar.GestureRecognizers.Add(tapAvatar);
        }
예제 #24
0
        //Page pagePersion = new Personal.PersonalPage();

        public NotificationPage()
        {
            var stkPrivate = new StackLayout();
            var stkPublic  = new StackLayout();

            InitializeComponent();
            this.BackgroundColor = Color.FromHex("#F0EFF5");


            List <String> months = ContentGlobal.ListMonth;

            foreach (String nn in months)
            {
                pickerMonth.Items.Add(nn);
            }

            month = (int)ContentGlobal.allldata["timeoff"]["period"];
            selectedIndexMonth = month - 1;

            pickerMonth.SelectedIndex = selectedIndexMonth;

            pickerMonth.SelectedIndexChanged += (sender, e) =>
            {
                Debug.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++++++changed month");
                selectedIndexMonth = pickerMonth.SelectedIndex;
                int tong = ContentGlobal.INTcountNotiUnread = ContentGlobal.CountNotiUnread("individualistic", selectedIndexMonth + 1) + ContentGlobal.CountNotiUnread("public", selectedIndexMonth + 1);
                if (tong > 0)
                {
                    DisplayAlert("Thông báo", string.Format("Tháng {0} bạn có {1} thông báo chưa đọc!", selectedIndexMonth + 1, tong), "OK");
                }
                Iitem.Clear();
                Iitem = loadNotification();
                lvNotifications.ItemsSource = Iitem;
            };

            //stkContent.Children.Add(stkPrivate);


            var tapPrivate = new TapGestureRecognizer();

            tapPrivate.Tapped += (s, e) =>
            {
                if (boolPrivate == false)
                {
                    bvPrivate.BackgroundColor = Color.FromHex("#157EFB");
                    lbPrivate.FontAttributes  = FontAttributes.Bold;
                    lbPrivate.TextColor       = Color.White;

                    bvPublic.BackgroundColor = Color.White;
                    lbPublic.TextColor       = Color.FromHex("#157EFB");
                    lbPublic.FontAttributes  = FontAttributes.None;

                    boolPrivate = true;
                    boolPublic  = false;

                    Iitem.Clear();
                    Iitem = loadNotification();
                    lvNotifications.ItemsSource = Iitem;
                }
            };
            lbPrivate.GestureRecognizers.Add(tapPrivate);

            var tapPublic = new TapGestureRecognizer();

            tapPublic.Tapped += (s, e) =>
            {
                if (boolPublic == false)
                {
                    bvPublic.BackgroundColor = Color.FromHex("#157EFB");
                    lbPublic.FontAttributes  = FontAttributes.Bold;
                    lbPublic.TextColor       = Color.White;

                    bvPrivate.BackgroundColor = Color.White;
                    lbPrivate.FontAttributes  = FontAttributes.None;
                    lbPrivate.TextColor       = Color.FromHex("#157EFB");

                    boolPublic  = true;
                    boolPrivate = false;

                    Iitem.Clear();
                    Iitem = loadNotification();
                    lvNotifications.ItemsSource = Iitem;
                }
            };
            lbPublic.GestureRecognizers.Add(tapPublic);
        }
예제 #25
0
        public async void SignInButtonClicked(object sender, EventArgs e)
        {
            stkMain.IsVisible = false;
            stkLoad.IsVisible = true;

            if (ContentGlobal.statusNetwork().Equals("Connected") == false)
            {
                stkMain.IsVisible = true;
                stkLoad.IsVisible = false;

                //await DisplayAlert("thong bao mang", ContentGlobal.statusNetwork(), "OK");
            }
            else
            {
                try
                {
                    if (EntryUserName.Text.ToString().Length > 0 &&
                        EntryPassword.Text.ToString().Length > 0)
                    {
                        stkMain.IsVisible = false;
                        stkLoad.IsVisible = true;

                        string strSubFirebase = "verifyPassword";
                        string strParam       = @"{ ""email"" : """ + EntryUserName.Text.ToString().ToLower() +
                                                @""",""password"" : """ + EntryPassword.Text.ToString() +
                                                @""",""returnSecureToken"" : ""true"" } ";
                        Debug.WriteLine("PARAM---------------------------------------------------------------" + strParam);
                        var rtFB = await ContentGlobal.PostAllFirebase_Auth(strSubFirebase, strParam);

                        Debug.WriteLine("rtFB-------------------" + rtFB);

                        string dataFB = (string)rtFB["idToken"];

                        Debug.WriteLine("idToken---------------------------" + dataFB);

                        if (dataFB != null)
                        {
                            Application.Current.Properties["uId"] = (string)rtFB["localId"];

                            ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                            ContentGlobal.loadListRequest();

                            Debug.WriteLine("allldata---------------------------" + ContentGlobal.allldata);

                            if ((int)ContentGlobal.allldata["info"]["active"] == 0)
                            {
                                App.Current.MainPage = new Account.NoAcctivePage();
                            }
                            else
                            {
                                if (ContentGlobal.registrationId.Length > 0)
                                {
                                    var registrationId = ContentGlobal.allldata["info"]["registrationId"];

                                    if (registrationId != null)
                                    {
                                        if (registrationId.ToString().Equals(ContentGlobal.registrationId) == false)
                                        {
                                            strSubFirebase = "pushData";
                                            strParam       = @"{""uid"" : """ + Application.Current.Properties["uId"].ToString() + @""", ""registrationId"" :""" + ContentGlobal.registrationId + @""" }";

                                            Debug.WriteLine("strParam-----------------------------------------------------" + strParam);

                                            var rt = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);
                                        }
                                    }
                                    else
                                    {
                                        strSubFirebase = "pushData";
                                        strParam       = @"{""uid"" : """ + Application.Current.Properties["uId"].ToString() + @""", ""registrationId"" :""" + ContentGlobal.registrationId + @""" }";

                                        Debug.WriteLine("strParam-----------------------------------------------------" + strParam);

                                        var rt = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);
                                    }
                                }


                                if ((int)ContentGlobal.allldata["info"]["acted"] == 1)
                                {
                                    ContentGlobal.PeopleWorking = await ContentGlobal.peopleWorkingAsync();

                                    ContentGlobal.Userroot = true;
                                }
                                else
                                {
                                    ContentGlobal.Userroot = false;
                                }

                                ContentGlobal.email = EntryUserName.Text.ToString().ToLower();

                                if ((int)ContentGlobal.allldata["info"]["password_safety"] == 0)
                                {
                                    //await DisplayAlert("Warring", "Bạn cần thay đổi mật khẩu hiện tại", "OK");
                                    App.Current.MainPage = new Account.FistLoginPage();
                                }
                                else
                                {
                                    var month = (int)ContentGlobal.allldata["timeoff"]["period"];

                                    ContentGlobal.INTcountNotiUnread = ContentGlobal.CountNotiUnread("individualistic", month) + ContentGlobal.CountNotiUnread("public", month);
                                    Debug.WriteLine("INTcountNotiUnread--------------------------------------------------" + ContentGlobal.INTcountNotiUnread);
                                    CrossBadge.Current.SetBadge(ContentGlobal.INTcountNotiUnread);

                                    Device.StartTimer(TimeSpan.FromMinutes(5), () => {
                                        Task.Factory.StartNew(async() =>
                                        {
                                            try
                                            {
                                                ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();
                                                ContentGlobal.loadListRequest();
                                            }
                                            catch (Exception el)
                                            {
                                                Debug.WriteLine("erorr refesh data" + el.ToString());
                                            }
                                        });

                                        return(true);
                                    });

                                    var page = new MainPage();
                                    NavigationPage.SetHasNavigationBar(page, false);
                                    App.Current.MainPage = new NavigationPage(page);
                                }
                            }
                        }
                        else
                        {
                            stkMain.IsVisible = true;
                            stkLoad.IsVisible = false;
                            if ((string)rtFB["error"]["message"] == "INVALID_PASSWORD")
                            {
                                EntryPassword.Text = "";
                                await DisplayAlert("Lỗi", "Mật khẩu bạn vừa nhập không đúng, nhập và thử lại!", "OK");
                            }
                            else if ((string)rtFB["error"]["message"] == "EMAIL_NOT_FOUND")
                            {
                                EntryUserName.Text = "";
                                EntryPassword.Text = "";
                                await DisplayAlert("Lỗi", "Tài khoản đăng nhập không đúng, nhập lại email và password!", "OK");
                            }
                            else
                            {
                                await DisplayAlert("Lỗi", (string)rtFB["error"]["message"], "OK");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    stkMain.IsVisible = true;
                    stkLoad.IsVisible = false;

                    await DisplayAlert("Lỗi", "Có vấn dề đã sảy ra, thử lại sau !", "OK");

                    Debug.WriteLine("Error SignInButtonClicked--------------------------------", ex);
                    // throw ex;
                }
            }
        }
예제 #26
0
        /* Page pagePersion = new Personal.PersonalPage();
         * Page pageTotalFinger = new Timekeeping.AllTimekeepingPage();
         * Page pageWhoWorking = new Timekeeping.WhoWorkingPage();
         * Page pageOneFinger = new Timekeeping.OneTimekeepingPage();*/
        public OverviewPage()
        {
            InitializeComponent();

            if ((int)Application.Current.Properties["from_noti"] == 1)
            {
                Debug.WriteLine("from_noti---------------------------------------");
                DisplayAlert(Application.Current.Properties["title_noti"].ToString(), Application.Current.Properties["content_noti"].ToString(), "OK");
            }

            this.BackgroundColor = Color.FromHex("#F0EFF5");

            if (Device.RuntimePlatform == Device.iOS)
            {
                stkHeader.Margin = new Thickness(0, 20, 0, 0);
            }

            if (ContentGlobal.Userroot == false)
            {
                stkWorking.IsVisible = false;
                stkAccept.IsVisible  = false;
            }
            else
            {
                stkWorking.IsVisible = true;
                stkAccept.IsVisible  = true;
            }

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Timekeeping.AllTimekeepingPage());
            };
            toTotalFinger.GestureRecognizers.Add(tapGestureRecognizer);

            var tapimgWhoWorking = new TapGestureRecognizer();

            tapimgWhoWorking.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Timekeeping.WhoWorkingPage());
            };
            stkWorking.GestureRecognizers.Add(tapimgWhoWorking);

            var tapAccept = new TapGestureRecognizer();

            tapAccept.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Timekeeping.PreviewTimeKeepingPage());
            };
            stkAccept.GestureRecognizers.Add(tapAccept);

            var tapGestureRecognizer1 = new TapGestureRecognizer();

            tapGestureRecognizer1.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Timekeeping.OneTimekeepingPage());
            };
            toOneFinger.GestureRecognizers.Add(tapGestureRecognizer1);

            var tapPersion = new TapGestureRecognizer();

            tapPersion.Tapped += (s, e) =>
            {
                stkHeader.IsVisible = false;
                Navigation.PushAsync(new Personal.PersonalPage());
            };
            imgtoPersion.GestureRecognizers.Add(tapPersion);

            var tapimgtoNotification = new TapGestureRecognizer();

            tapimgtoNotification.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new NotificationPage());
            };
            //imgtoNotification.GestureRecognizers.Add(tapimgtoNotification);
            grdNoti.GestureRecognizers.Add(tapimgtoNotification);


            var tapImgCircle = new TapGestureRecognizer();

            tapImgCircle.Tapped += async(s, e) =>
            {
                if (boolAnimation == false)
                {
                    // await DisplayAlert("Info", await takeImageAsync(), "OK");

                    // if (await takeImageAsync() == "1")
                    // {

                    var answer = await DisplayAlert("Checkin", "Bạn có muốn bắt đầu ca làm việc ngay lúc này!", "Yes", "No");

                    if (answer == true)
                    {
                        PopUpDialog.ShowDialog();
                        PopUpDialog.IsVisible = true;

                        try
                        {
                            var hasPermission = await Utils.CheckPermissions(Permission.Location);

                            if (!hasPermission)
                            {
                                Debug.WriteLine("hasPermission---------------------------------------------");
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;
                                return;
                            }

                            var position = await ContentGlobal.getLocation();

                            if (position == null)
                            {
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;
                                await DisplayAlert("Thông báo", "Không thể xác định vị trí lúc này, thử lại sau!", "OK");

                                return;
                            }

                            Debug.WriteLine("Position Status: Latitude ------------------------------------------" + position.Latitude);
                            Debug.WriteLine("Position Status: Longitude ------------------------------------------" + position.Longitude);

                            //await DisplayAlert("Location", string.Format("Latitude :{0} \nLongitude:{1}", position.Latitude, position.Longitude), "OK");

                            var    strLatitude    = position.Latitude.ToString().Replace(",", ".");
                            var    strLongitude   = position.Longitude.ToString().Replace(",", ".");
                            var    device_id      = CrossDeviceInfo.Current.Id;
                            string strSubFirebase = "CheckOdooByApp";
                            string strParam       = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""location"":""" + strLatitude + @"," + strLongitude + @""",""device_id"":""" + device_id + @"""}";

                            Debug.WriteLine("strParam CheckOdooByApp-------------------------------------------------- " + strParam);

                            var data = await ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);

                            if ((string)data["return"] == "OK")
                            {
                                ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                                OnAppearing();

                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                await DisplayAlert("Thông báo", "Bạn đã bắt đầu ca làm việc", "OK");

                                /*boolAnimation = true;
                                 * int totalminute = 12 * 60;
                                 * await imgRound.RotateTo(360 * totalminute, (uint)totalminute * 36000);*/
                            }
                            else
                            {
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                await DisplayAlert("Thông báo", "Không thể thực hiện tác vụ này, xin thử lại sau!", "OK");
                            }
                        }
                        catch (Exception ex)
                        {
                            PopUpDialog.HideDialog();
                            PopUpDialog.IsVisible = false;

                            Debug.WriteLine("Error start Circle" + ex.ToString());
                            await DisplayAlert("Thông báo", "Có lỗi sảy ra, kiểm tra lại kết nối mạng hoặc cài đặt vị trí của bạn và thử lại sau !", "OK");
                        }
                    }
                    //}
                }
                else
                {
                    //await DisplayAlert("Info", await takeImageAsync(), "OK");

                    var answer = await DisplayAlert("Checkout", "Bạn có muốn kết thúc làm việc ngay lúc này!", "Yes", "No");

                    if (answer == true)
                    {
                        try
                        {
                            PopUpDialog.ShowDialog();
                            PopUpDialog.IsVisible = true;

                            var hasPermission = await Utils.CheckPermissions(Permission.Location);

                            if (!hasPermission)
                            {
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                Debug.WriteLine("hasPermission---------------------------------------------");
                                return;
                            }

                            var position = await ContentGlobal.getLocation();

                            if (position == null)
                            {
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                await DisplayAlert("Thông báo", "Không thể xác định vị trí lúc này, thử lại sau!", "OK");

                                return;
                            }

                            Debug.WriteLine("Position Status: Latitude ------------------------------------------" + position.Latitude);
                            Debug.WriteLine("Position Status: Longitude ------------------------------------------" + position.Longitude);

                            //await DisplayAlert("Location", string.Format("Latitude :{0} \n Longitude:{1}", position.Latitude, position.Longitude), "OK");
                            var strLatitude  = position.Latitude.ToString().Replace(",", ".");
                            var strLongitude = position.Longitude.ToString().Replace(",", ".");
                            var device_id    = CrossDeviceInfo.Current.Id;

                            string strSubFirebase = "CheckOdooByApp";
                            string strParam       = @"{""uid"":""" + Application.Current.Properties["uId"].ToString() + @""",""location"":""" + strLatitude + @"," + strLongitude + @""",""device_id"":""" + device_id + @"""}";

                            Debug.WriteLine("strParam CheckOdooByApp-------------------------------------------------- " + strParam);

                            var data = await ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);

                            if ((string)data["return"] == "OK")
                            {
                                ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                                OnAppearing();

                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                await DisplayAlert("Thông báo", "Bạn đã kết thúc ca làm việc", "OK");

                                /*ViewExtensions.CancelAnimations(imgRound);
                                 * boolAnimation = false;*/
                            }
                            else
                            {
                                PopUpDialog.HideDialog();
                                PopUpDialog.IsVisible = false;

                                await DisplayAlert("Thông báo", "Không thể thực hiện tác vụ này, xin thử lại sau!", "OK");
                            }
                        }
                        catch (Exception ex)
                        {
                            PopUpDialog.HideDialog();
                            PopUpDialog.IsVisible = false;

                            Debug.WriteLine("Error stop Circle" + ex.ToString());
                            await DisplayAlert("Thông báo", "Có lỗi sảy ra, kiểm tra lại kết nối mạng hoặc cài đặt vị trí của bạn và thử lại sau !", "OK");
                        }
                    }
                }
            };
            imgCircle.GestureRecognizers.Add(tapImgCircle);
            //lbDateOfToday.GestureRecognizers.Add(tapImgCircle);
            //lbTimeIn.GestureRecognizers.Add(tapImgCircle);
            imgRound.GestureRecognizers.Add(tapImgCircle);
            lbTimeIn.GestureRecognizers.Add(tapImgCircle);
            lbTimework.GestureRecognizers.Add(tapImgCircle);
            stkTimeIn.GestureRecognizers.Add(tapImgCircle);
            stkTimework.GestureRecognizers.Add(tapImgCircle);
        }
예제 #27
0
        public AccountPage()
        {
            InitializeComponent();
            //this.BackgroundColor = Color.FromHex("#F0EFF5");
            this.BackgroundImage = "background.jpg";

            var tapLogout = new TapGestureRecognizer();

            tapLogout.Tapped += async(s, e) =>
            {
                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        string strSubFirebase = "ClearRegis";
                        string strParam       = @"{ ""uid"" : """ + Application.Current.Properties["uId"].ToString() + @"""} ";
                        var    data           = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);

                        Application.Current.Properties["uId"] = "";
                        var page = new SignIn_Page();
                        NavigationPage.SetHasNavigationBar(page, false);
                        App.Current.MainPage = new NavigationPage(page);

                        /*if ((string)data["return"] == "OK")
                         * {
                         *  Application.Current.Properties["uId"] = "";
                         *  var page = new SignIn_Page();
                         *  NavigationPage.SetHasNavigationBar(page, false);
                         *  App.Current.MainPage = new NavigationPage(page);
                         * }
                         * else
                         * {
                         *  await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");
                         * }*/
                    }
                    catch (Exception ex)
                    {
                        await DisplayAlert("Thông báo", "Có lỗi đã sảy ra, thử lại sau!", "OK");

                        Debug.WriteLine("Er Account Page--------------------------------------" + ex);
                    }
                }
                else
                {
                    await DisplayAlert("Cảnh báo", "Kiểm tra lại kết nối mạng của bạn và thử lại sau!", "OK");
                }
            };

            stkLogout.GestureRecognizers.Add(tapLogout);

            var tapChangedPassword = new TapGestureRecognizer();

            tapChangedPassword.Tapped += (s, e) =>
            {
                Navigation.PushAsync(new Setting.ChangedPasswordPage());
            };
            stkChangedPassword.GestureRecognizers.Add(tapChangedPassword);


            var tapAvatar = new TapGestureRecognizer();

            tapAvatar.Tapped += async(s, e) =>
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");

                    return;
                }
                var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });


                if (file == null)
                {
                    return;
                }


                var stream = file.GetStream();

                string Subs = ContentGlobal.StreamToBase64String(stream);

                Debug.WriteLine("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa===================================== :    " + Subs);

                string NameAPI = "pushImage";
                string pram    = @"{""uid"" : """ + Application.Current.Properties["uId"].ToString() + @""", ""image_data"" : """ + Subs + @"""}";

                Debug.WriteLine("Param------------------------------" + pram);

                var dataEE = await ContentGlobal.FirebasePOSTFunctions(NameAPI, pram);

                //var byte002 = ContentGlobal.StringFromBase64Stream(Subs);

                //imgAvatar.Source = ImageSource.FromStream(() => new MemoryStream(ContentGlobal.GetImageStreamAsBytes(byte002)));

                imgAvatar.Source = ImageSource.FromStream(() =>
                {
                    //var stream = file.GetStream();
                    file.Dispose();
                    return(stream);
                });
            };

            imgAvatar.GestureRecognizers.Add(tapAvatar);
        }
예제 #28
0
        protected async override void OnAppearing()
        {
            var properties = Xamarin.Forms.Application.Current.Properties;

            if (properties.ContainsKey("uId") && properties["uId"].ToString().Length > 0)
            {
                Debug.WriteLine("uId------------------------------------" + properties["uId"].ToString());
                stkMain.IsVisible = false;
                stkLoad.IsVisible = true;

                if (ContentGlobal.statusNetwork().Equals("Connected") != false)
                {
                    try
                    {
                        ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();

                        if ((int)ContentGlobal.allldata["info"]["active"] == 0)
                        {
                            App.Current.MainPage = new Account.NoAcctivePage();
                        }
                        else
                        {
                            ContentGlobal.loadListRequest();

                            if (ContentGlobal.registrationId.Length > 0)
                            {
                                var registrationId = ContentGlobal.allldata["info"]["registrationId"];

                                if (registrationId != null)
                                {
                                    if (registrationId.ToString().Equals(ContentGlobal.registrationId) == false)
                                    {
                                        string strSubFirebase = "pushData";
                                        string strParam       = @"{""uid"" : """ + properties["uId"].ToString() + @""", ""registrationId"" :""" + ContentGlobal.registrationId + @""" }";

                                        Debug.WriteLine("strParam-----------------------------------------------------" + strParam);

                                        var rt = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);
                                    }
                                }
                                else
                                {
                                    string strSubFirebase = "pushData";
                                    string strParam       = @"{""uid"" : """ + properties["uId"].ToString() + @""", ""registrationId"" :""" + ContentGlobal.registrationId + @""" }";

                                    Debug.WriteLine("strParam-----------------------------------------------------" + strParam);

                                    var rt = ContentGlobal.FirebasePOSTFunctions(strSubFirebase, strParam);
                                }
                            }

                            if ((int)ContentGlobal.allldata["info"]["acted"] == 1)
                            {
                                ContentGlobal.PeopleWorking = await ContentGlobal.peopleWorkingAsync();

                                ContentGlobal.Userroot = true;
                            }
                            else
                            {
                                ContentGlobal.Userroot = false;
                            }

                            var month = (int)ContentGlobal.allldata["timeoff"]["period"];

                            ContentGlobal.INTcountNotiUnread = ContentGlobal.CountNotiUnread("individualistic", month) + ContentGlobal.CountNotiUnread("public", month);
                            Debug.WriteLine("INTcountNotiUnread--------------------------------------------------" + ContentGlobal.INTcountNotiUnread);

                            CrossBadge.Current.SetBadge(ContentGlobal.INTcountNotiUnread);

                            var list_request = ContentGlobal.allldata["info"]["company_rules"]["list_request"];

                            ContentGlobal.loadListRequest();


                            Device.StartTimer(TimeSpan.FromMinutes(5), () => {
                                Task.Factory.StartNew(async() =>
                                {
                                    try
                                    {
                                        ContentGlobal.allldata = await ContentGlobal.GetAllOfPersonal();
                                        ContentGlobal.loadListRequest();
                                    }
                                    catch (Exception el)
                                    {
                                        Debug.WriteLine("erorr refesh data" + el.ToString());
                                    }
                                });

                                return(true);
                            });

                            Page page = new MainPage();
                            NavigationPage.SetHasNavigationBar(page, false);
                            App.Current.MainPage = new NavigationPage(page);
                        }
                    }
                    catch (Exception ex)
                    {
                        stkMain.IsVisible = true;
                        stkLoad.IsVisible = false;

                        await DisplayAlert("Lỗi", "Có vấn dề đã sảy ra, thử lại sau !", "OK");

                        Debug.WriteLine("Error OnAppearing--------------------------------", ex);
                    }
                }
                else
                {
                    stkMain.IsVisible = true;
                    stkLoad.IsVisible = false;

                    //await DisplayAlert("thong bao mang", ContentGlobal.statusNetwork(), "OK");
                }
            }
            else
            {
                stkLoad.IsVisible = false;
                stkMain.IsVisible = true;

                /*Page page = new SignIn_Page();
                 * NavigationPage.SetHasNavigationBar(page, false);
                 * App.Current.MainPage = new NavigationPage(page);*/
            }
        }