Пример #1
0
        }//ctor

        //удаление пользователя
        private async Task RemoveUser()
        {
            try
            {
                ApiService api = new ApiService { Url = ApiService.URL_REMOVE_USER };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key", App.APP.CurrentUser.AuthKey },
                    {"id", currentUser.Id.ToString() },
                };
                api.AddParams(data);
                var res = await api.GetRequest();

                if ((bool)res["status"])
                {
                    await DisplayAlert("Success", "User was deleted", "OK");
                    await Navigation.PopModalAsync(true);
                }
                else
                {
                    await DisplayAlert("Warning", "User was not deleted", "Done");
                }

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #2
0
        }//c_tor


        //удаление 
        private async void Bt_delete_Clicked(object sender, EventArgs e)
        {
            try
            {

                if (currentPoint != null)
                {
                    ApiService api = new ApiService { Url = ApiService.URL_REMOVE_RETAIL };
                    Dictionary<string, string> data = new Dictionary<string, string>
                    {
                        {"auth_key", App.APP.CurrentUser.AuthKey },
                        {"id", currentPoint.Id.ToString() }
                    };
                    api.AddParams(data);
                    var res = await api.GetRequest();
                    if ((bool)res["status"])
                    {
                        await DisplayAlert("Success", "Network was removed", "OK");
                        await Navigation.PopModalAsync(true);
                    }
                    else
                    {
                        await DisplayAlert("Warning", "Network was not removed", "Done");
                        await Navigation.PopModalAsync(true);
                    }
                }

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #3
0
        protected async override void OnAppearing()
        {
            ai_ind.IsVisible = true;
            ai_ind.IsRunning = true;
            lv_container.IsVisible = false;
            try
            {

                ApiService api = new ApiService { Url = ApiService.URL_RETAIL_AT_USER };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key",App.APP.CurrentUser.AuthKey }
                };
                api.AddParams(data);

                var res = await api.GetRetailPoints();

                lv_container.ItemsSource = res;
                lv_container.ItemSelected += Lv_container_ItemSelected;

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
            finally
            {
                ai_ind.IsVisible = false;
                ai_ind.IsRunning = false;
                lv_container.IsVisible = true;
            }

            base.OnAppearing();
        }//OnAppearing
Пример #4
0
        private async Task GetProducts()
        {
            try
            {
                if (((CompanyData)pc_company.SelectedItem) != null)
                {
                    ApiService api = new ApiService {
                        Url = ApiService.URL_GET_PRODUCTS
                    };
                    Dictionary <string, string> data = new Dictionary <string, string>
                    {
                        { "auth_key", App.APP.CurrentUser.AuthKey },
                        { "company_id", ((CompanyData)pc_company.SelectedItem).Id.ToString() },
                    };

                    api.AddParams(data);

                    lv_bonus.ItemsSource = await api.GetProducts();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #5
0
        //удаление кампании
        private async void Bt_del_Clicked(object sender, EventArgs e)
        {
            try
            {
                ApiService api = new ApiService {
                    Url = "https://www.exsales.net/api/v1/company/remove"
                };
                Dictionary <string, string> data = new Dictionary <string, string>();
                data.Add("auth_key", user.AuthKey);
                data.Add("id", company.Id.ToString());

                api.AddParams(data);

                JObject res = await api.DelCompany();

                if ((bool)res["status"])
                {
                    await DisplayAlert("Success", "Company deleted", "OK");
                }
                else
                {
                    await DisplayAlert("Warning", "Company not deleted", "Done");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #6
0
        protected async override void OnAppearing()
        {
            ai_ind.IsRunning = true;
            ai_ind.IsVisible = true;
            lv_container.IsVisible = false;
            try
            {
                ApiService api = new ApiService {Url = ApiService.URL_GET_NOTIFICATION };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key", App.APP.CurrentUser.AuthKey },
                    {"link_id", branch.Id.ToString()},
                };
                api.AddParams(data);
                customNotes = await api.GetNotifications();
            }catch(Exception ex)
            {
                customNotes = new List<CustomNotification>();
            }
            finally
            {
                ai_ind.IsRunning = false;
                ai_ind.IsVisible = false;
                lv_container.IsVisible = true;
            }

            lv_container.ItemsSource = customNotes;

            base.OnAppearing();
        }
Пример #7
0
        //удаление подразделения
        private async void Bt_delete_Clicked(object sender, EventArgs e)
        {
            try
            {

                ApiService api = new ApiService { Url = ApiService.URL_REMOVE_SUBDIVISION };
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("auth_key", App.APP.CurrentUser.AuthKey);
                if (currentSubdivision == null) throw new Exception("Not find current subdivision");
                data.Add("id", currentSubdivision.Id.ToString());
                api.AddParams(data);

                var res = await api.GetRequest();
                if ((bool)res["status"])
                {
                    await DisplayAlert("Succees", "Subdivision was deleted", "OK");
                    await Navigation.PopModalAsync(true);
                }
                else
                {
                    await DisplayAlert("Warning", "Subdivision was not deleted", "OK");
                }

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #8
0
        protected async override void OnAppearing()
        {
            try
            {
                if (App.APP.CompanyCollection == null)
                {
                    ApiService api = new ApiService {
                        Url = ApiService.URL_GET_COMPANIES
                    };
                    Dictionary <string, string> data = new Dictionary <string, string>
                    {
                        { "auth_key", App.APP.CurrentUser.AuthKey }
                    };
                    api.AddParams(data);
                    App.APP.CompanyCollection = (await api.GetCompany()).ToList();
                }
                pc_company.ItemsSource   = App.APP.CompanyCollection;
                pc_company.SelectedIndex = 0;

                await GetProducts();
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
            base.OnAppearing();
        }
Пример #9
0
        }//t_add_Clicked

        //при старте окна
        protected async override void OnAppearing()
        {
            //получение списка пользователей
            try
            {
                ApiService api = new ApiService { Url = ApiService.URL_USERS_AT_COMPANY };
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("auth_key", App.APP.CurrentUser.AuthKey);
                data.Add("id", currentCompany.Id.ToString());
                api.AddParams(data);
                var users = await api.GetSubdivisionUsers();
                pc_user.ItemsSource = users;
                pc_user.SelectedIndex = 0;

                if(currentSubdivision!=null && currentSubdivision.User.Length > 0)
                {
                    pc_user.SelectedItem = users.Where(x => (x.Firstname + " " + x.Lastname) == currentSubdivision.User).First();
                }

            }
            catch(Exception ex)
            {
                await DisplayAlert("Warning", "Users not load", "Done");
            }
            base.OnAppearing();

        }//OnAppearing()
Пример #10
0
 //удаление записи 
 private async void Bt_delete_Clicked(object sender, EventArgs e)
 {
     try
     {
         ApiService api = new ApiService { Url = ApiService.URL_REMOVE_NOTIFICATION };
         Dictionary<string, string> data = new Dictionary<string, string>
         {
             {"id", currentNotice.Id.ToString() }
         };
         api.AddParams(data);
         var res = await api.GetRequest();
         if ((bool)res["status"])
         {
             await DisplayAlert("Success", "Notice was deleted", "OK");
             await Navigation.PopModalAsync(true);
         }
         else
         {
             await DisplayAlert("Warning", "Notice was deleted", "Done");
         }
     }catch(Exception ex)
     {
         await DisplayAlert("Error", ex.Message, "Done");
     }
 }
Пример #11
0
        //удаление картинки
        private async void bt_deleteClick(object sender, EventArgs e)
        {
            try
            {
                ApiService api = new ApiService { Url = ApiService.URL_REMOVE_MEDIA };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"id", currentNotice.Id.ToString()},
                    {"image", ((ServerImage)lv_images.Item).CustomImage }
                };

                api.AddParams(data);

                var res = await api.GetRequest();

                if ((bool)res["status"])
                {
                    await DisplayAlert("Success", "Image was deleted", "OK");
                    await Navigation.PopModalAsync(true);
                }
                else
                {
                    await DisplayAlert("Warning", "Image was not deleted", "Done");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
        }
Пример #12
0
        }//En_item_retail_Focused

        //действия при входе на страницу
        protected async override void OnAppearing()
        {
            //получаем список торговых сетей
            try
            {
                ApiService api = new ApiService { Url = ApiService.URL_COMPANY_AT_TYPE };
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("id","2");
                api.AddParams(data);
                networks = await api.GetNetworks();
                pc_item_network.ItemsSource = networks;
                pc_item_network.SelectedIndex = 0;

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }

            if (currentPoint != null)
            {
                bt_add.IsVisible = false;
                en_item_title.Text = currentPoint.Title;
                if (networks != null)
                    pc_item_network.SelectedItem = networks.Where(x => x.Id == currentPoint.DistributorId).First();
            }
            else
            {
                bt_delete.IsVisible = false;
            }


            base.OnAppearing();
        }//OnAppearing()
Пример #13
0
        }//FillData

        protected async override void OnAppearing()
        {


            if (currentNotice != null)
            {
         
                try
                {
                    //await DisplayAlert("Warning", currentNotice.Id.ToString(), "Done");
                    ApiService api = new ApiService { Url = ApiService.URL_GET_CURRENT_NOTIFICATION };
                    Dictionary<string, string> data = new Dictionary<string, string>
                    {
                        { "id", currentNotice.Id.ToString() }
                    };
                    api.AddParams(data);
                    JObject res = await api.GetRequest();
                   // await DisplayAlert("Warning", res["data"].ToString(), "Done");
                    currentNotice = CustomNotification.GetNotice(res);
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Warning", ex.Message, "Done");
                }

            }
            FillData();

            base.OnAppearing();
        }
Пример #14
0
        }//c_tor

        //обработка нажатия на кнопку отправить
        private async void Bt_send_Clicked(object sender, EventArgs e)
        {

            //activ_ind.IsRunning = true;
            //activ_ind.Color = Color.AliceBlue;
            //Thread.Sleep(3000);
            //activ_ind.IsRunning = false;
            try
            {
                //задаем url отправки
                ApiService api = new ApiService
                {
                    Url = "https://www.exsales.net/api/v1/user/registration"
                };

                //добавляем параметы к запросу
                Dictionary<string, string> data = new Dictionary<string, string>();
                //добавляем почту
                data.Add("email", ApiService.StringUrlEncode(en_email.Text));

                //добавляем роль
                // data.Add("role",role_pc.SelectedIndex.ToString());
                data.Add("role", "0");
                api.AddParams(data);

                if (!String.IsNullOrEmpty(en_email.Text) /*&& role_pc.SelectedIndex !=-1*/)
                {
                    //отправляем запрос и ждем результат
                    string res = await api.Registration();
                    await DisplayAlert("Message", res, "OK");
                }
                else
                {
                    //await DisplayAlert("Warning", LangResources.RegPageDataError, "OK");
                    await DisplayAlert("Warning", "Проверьте указанные данные и выберите роль!", "OK");
                }
              
                //выводим ответ
                
            }
            catch (Exception ex)
            {
               await DisplayAlert("Error", ex.Message, "OK");
            }

        }
Пример #15
0
        async Task GetSales()
        {
            ai_ind.IsVisible = true;
            ai_ind.IsRunning = true;
            try
            {
                ApiService api = new ApiService {
                    Url = ApiService.URL_ALL_USER_SALES
                };
                Dictionary <string, string> data = new Dictionary <string, string>
                {
                    { "auth_key", App.APP.CurrentUser.AuthKey }
                };
                api.AddParams(data);
                var sales = await api.GetOwnSales();

                lv_sales_container.ItemsSource = sales;

                int bonus = sales.Sum(x => x.Bonus);

                lb_quant_bonus.Text = bonus.ToString();

                //lv_sales_container.HasUnevenRows = true;
                //lv_sales_container.ItemTemplate = new DataTemplate(() =>
                //{
                //    OwnSaleCell customCell = new OwnSaleCell();
                //    customCell.SetBinding(OwnSaleCell.ProductProperty, "Product");
                //    Binding quantityBinding = new Binding { Path = "Quantity", StringFormat = "Quantity : {0}" };
                //    customCell.SetBinding(OwnSaleCell.QuantityProperty, quantityBinding);
                //    Binding bonusBinding = new Binding { Path = "Bonus", StringFormat = "Bonus : {0}" };
                //    customCell.SetBinding(OwnSaleCell.BonusProperty, bonusBinding);

                //    return customCell;
                //});
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }
            finally
            {
                ai_ind.IsVisible = false;
                ai_ind.IsRunning = false;
            }
        }
        }//c_tor

        protected async override void OnAppearing()
        {

            ai_ind.IsRunning = true;
            ai_ind.IsVisible = true;
            try
            {
                ApiService api = new ApiService {Url = ApiService.URL_GET_USERS };

                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key", App.APP.CurrentUser.AuthKey }
                };

                api.AddParams(data);

                var res = await api.GetUsers();
    
                lv_container.ItemsSource = res;
                lv_container.HasUnevenRows = true;
                lv_container.ItemTemplate = new DataTemplate(() =>
                {
                    UserListViewCell customCell = new UserListViewCell();
                    customCell.SetBinding(UserListViewCell.FirstNameProperty, "Firstname");
                    customCell.SetBinding(UserListViewCell.LastNameProperty, "Lastname");
                    Binding emailBinding = new Binding { Path = "Email", StringFormat = "Email : {0}" };
                    customCell.SetBinding(UserListViewCell.EmailProperty, emailBinding);
                    Binding phoneBinding = new Binding { Path = "Phone", StringFormat = "Phone : {0}" };
                    customCell.SetBinding(UserListViewCell.PhoneProperty, phoneBinding);
                    return customCell;
                });


            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
            finally
            {
                ai_ind.IsRunning = false;
                ai_ind.IsVisible = false;
            }
            base.OnAppearing();
        }
Пример #17
0
        //подгрузка данных
        protected async override void OnAppearing()
        {
            ai_ind.IsRunning = true;
            ai_ind.IsVisible = true;
            lv_container.IsVisible = false;
            try
            {
                ApiService api = new ApiService {Url = ApiService.URL_GET_BRANCH };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key", App.APP.CurrentUser.AuthKey }
                };
                api.AddParams(data);

                branchesList = await api.GetBranches();

            }catch(Exception ex)
            {
                branchesList = new List<Branch>();
            }
            finally
            {
                ai_ind.IsRunning = false;
                ai_ind.IsVisible = false;
                lv_container.IsVisible = true;
            }

            lv_container.ItemsSource = branchesList;

            lv_container.ItemTemplate = new DataTemplate(() =>
            {
                BranchListViewCell customCell = new BranchListViewCell ();
                customCell.SetBinding(BranchListViewCell.TitleProperty, "Title");
                Binding companyBinding = new Binding { Path = "Company", StringFormat = "Company : {0}" };
                customCell.SetBinding(BranchListViewCell.CompanyProperty, companyBinding);
                Binding retailerBinding = new Binding { Path = "Retailer", StringFormat = "Network : {0}" };
                customCell.SetBinding(BranchListViewCell.RetailerProperty, retailerBinding);
                return customCell;
            });

            base.OnAppearing();
        }//OnAppearing
Пример #18
0
        }//Bt_add_Clicked

        protected async override void OnAppearing()
        {
            //заполняем список компаний
            if (App.APP.CompanyCollection != null && App.APP.CompanyCollection.Count > 0)
            {
                companyData = App.APP.CompanyCollection;
            }
            else
            {
                ApiService api = new ApiService { Url = "https://www.exsales.net/api/v1/company/get" };
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("auth_key", App.APP.CurrentUser.AuthKey);
                api.AddParams(data);
                companyData = (await api.GetCompany()).ToList();
                App.APP.CompanyCollection = companyData;
            }
            pc_company.ItemsSource = companyData;
            pc_company.SelectedIndex = 0;

            //заполняем список сетей
            try
            {
                ApiService api = new ApiService { Url = ApiService.URL_RETAIL_AT_USER };
                Dictionary<string, string> data = new Dictionary<string, string>
                {
                    {"auth_key",App.APP.CurrentUser.AuthKey }
                };
                api.AddParams(data);

                var res = await api.GetRetailPoints();

                pc_network.ItemsSource = res;
                pc_network.SelectedIndex = 0;
            }
            catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }


            base.OnAppearing();
        }//OnAppearing
Пример #19
0
        //получение фокуса полес ввода города
        private async void En_city_Focused(object sender, FocusEventArgs e)
        {
            ai_city.IsRunning = true;
            en_city.IsVisible = false;
            if (cityNames == null)
            {
                ApiService api = new ApiService {
                    Url = "https://www.exsales.net/api/v1/city/cic"
                };
                Dictionary <string, string> data = new Dictionary <string, string>();

                int id = countryNames.Where(x => x.Country == en_country.Text).Select(x => x.Id).First();
                //await DisplayAlert("dwdew", id.ToString(), "OK");
                //lb_title.Text = id.ToString();
                data.Add("id", id.ToString());
                api.AddParams(data);
                cityNames = await api.GetCities();
            }

            if (cityNames != null && cityNames.Count > 0)
            {
                var cities = cityNames.Select(x => x.City).ToArray();
                var action = await DisplayActionSheet("Select city", "Cancel", null, cities);

                if (action != "Cancel")
                {
                    ((Entry)sender).Text = action;
                }

                ((Entry)sender).IsEnabled = false;
                bt_editCity.IsEnabled     = true;
            }
            else
            {
                await DisplayAlert("Warning", "С выбранной страной не связано ни одного города. Для добавления интересующего города свяжитесь с админитратором!", "OK");

                ((Entry)sender).IsEnabled = false;
            }
            ai_city.IsRunning = false;
            en_city.IsVisible = true;
        }
Пример #20
0
        //фокус на поле ввода торговой точки
        private async void En_item_retail_Focused(object sender, FocusEventArgs e)
        {
            ApiService api = new ApiService { Url = ApiService.URL_GET_RETAIL };
            Dictionary<string,string> data = new Dictionary<string, string>();
            data.Add("id", ((Network)pc_item_network.SelectedItem).Id.ToString());
            api.AddParams(data);
            retailPoints = await api.GetRetailPoints();
            string[] names = retailPoints.Select(x => (x.Title + "\n" + "Address : " + x.Address)).ToArray();
            var item = await DisplayActionSheet("Select retail point", "Cancel", null, names);

            if (item != "Cancel")
            {
                en_item_retail.Text = item;
                en_item_retail.IsEnabled = false;
            }
            else
            {
                en_item_title.Focus();
            }

        }//En_item_retail_Focused
Пример #21
0
        async Task<List<FunctionData>> GetFunctionData(int functionId)
        {
            try
            {
                //задаем url отправки
                ApiService api = new ApiService
                {
                    Url = "https://www.exsales.net/api/v1/user/functions"
                };

                //добавляем параметы к запросу
                Dictionary<string, string> data = new Dictionary<string, string>();
                //добавляем идентификатор пользователя
                data.Add("auth_key", user.AuthKey);

                //идентификатор функции
                data.Add("func", functionId.ToString());
                api.AddParams(data);

                if (!String.IsNullOrEmpty(user.AuthKey) && functionId != 0)
                {
                    //отправляем запрос и ждем результат
                    List<FunctionData> res = await api.Function();
                    return res;
                }
                else
                {
                    await DisplayAlert("Warning", "Ошибка идентификаторов", "OK");
                    return null;
                }

                //выводим ответ

            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
                return null;
            }
        }
Пример #22
0
        }//OnAppearing

        //подгрузка подразделений для компании
        async Task LoadCompanyData()
        {
            ai_ind.IsVisible = true;
            ai_ind.IsRunning = true;
            if (currentCompany != null)
            {

                ApiService api = new ApiService { Url = ApiService.URL_GET_SUBDIVISION };
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("auth_key", App.APP.CurrentUser.AuthKey);
                data.Add("id", currentCompany.Id.ToString());
                api.AddParams(data);
                subdivisionList = await api.GetSubdivisions();

                lv_subdivisions.ItemsSource = subdivisionList;


            }//if

            ai_ind.IsVisible = false;
            ai_ind.IsRunning = false;
        }//LoadCompanyData
        protected async override void OnAppearing()
        {
            ai_ind.IsVisible       = true;
            ai_ind.IsRunning       = true;
            lv_companies.IsVisible = false;

            try
            {
                ApiService api = new ApiService {
                    Url = "https://www.exsales.net/api/v1/company/get"
                };
                Dictionary <string, string> data = new Dictionary <string, string>();
                data.Add("auth_key", user.AuthKey);
                api.AddParams(data);
                companyData = await api.GetCompany();
            }
            catch (Exception ex)
            {
                companyData = new ObservableCollection <CompanyData>();
            }

            App.APP.CompanyCollection = companyData.ToList();

            try {
                lv_companies.HasUnevenRows = true;
                // Определяем источник данных
                lv_companies.ItemsSource = companyData;

                // Определяем формат отображения данных
                lv_companies.ItemTemplate = new DataTemplate(() =>
                {
                    CompanyListViewCell customCell = new CompanyListViewCell(user);
                    customCell.SetBinding(CompanyListViewCell.TitleProperty, "Title");
                    Binding typeBinding = new Binding {
                        Path = "Type", StringFormat = "Тип компании {0}"
                    };
                    customCell.SetBinding(CompanyListViewCell.TypeProperty, typeBinding);
                    Binding addressBinding = new Binding {
                        Path = "Address", StringFormat = "Адрес {0}"
                    };
                    customCell.SetBinding(CompanyListViewCell.AddressProperty, addressBinding);
                    Binding countryBinding = new Binding {
                        Path = "Country", StringFormat = "Country: {0}"
                    };
                    customCell.SetBinding(CompanyListViewCell.CountryProperty, countryBinding);

                    Binding cityBinding = new Binding {
                        Path = "City", StringFormat = "City: {0}"
                    };
                    customCell.SetBinding(CompanyListViewCell.CityProperty, cityBinding);

                    Binding dateBinding = new Binding {
                        Path = "Date", StringFormat = "Date: {0:D}"
                    };
                    customCell.SetBinding(CompanyListViewCell.DateProperty, dateBinding);


                    customCell.SetBinding(CompanyListViewCell.CurrentCompanyProperty, "Id");


                    //customCell.SetBinding(CompanyListViewCell.ImagePathProperty, "ImagePath");
                    return(customCell);
                });
            }
            catch (Exception ex)
            {
                await DisplayAlert("Warning", ex.Message, "OK");
            }
            finally
            {
                ai_ind.IsVisible       = false;
                ai_ind.IsRunning       = false;
                lv_companies.IsVisible = true;
            }
        }
Пример #24
0
        }//UpdateUser()

        protected async override void OnAppearing()
        {
            try
            {
                if (App.APP.CompanyCollection == null)
                {
                    ApiService api = new ApiService { Url = ApiService.URL_GET_COMPANIES };
                    Dictionary<string, string> data = new Dictionary<string, string>
                    {
                        {"auth_key", App.APP.CurrentUser.AuthKey }
                    };

                    api.AddParams(data);
                    App.APP.CompanyCollection = (await api.GetCompany()).ToList();
                }

                lv_functions.ItemsSource = App.APP.CompanyCollection;

            }catch(Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }

            if (currentUser != null)
            {
                try
                {
                    //ApiService api = new ApiService { Url = ApiService.URL_USER_FUNCTIONS };
                    //Dictionary<string, string> data = new Dictionary<string, string>
                    //{
                    //    {"auth_key", App.APP.CurrentUser.AuthKey},
                    //    {"user_id", currentUser.Id.ToString()}
                    //};

                    //api.AddParams(data);

                    //var res = await api.Function();


                    //                  FunctionData temp;

                    //                  //отмечаем включенные функции
                    //                  //компании
                    //                  temp = res.Where(x => x.Id == 1).FirstOrDefault();
                    ////                  await DisplayAlert("temp", temp.ToString(), "ddeded");
                    //                  chb_companyManagement.Checked = temp != null ? true : false;

                    //                  //торговые сети
                    //                  temp = res.Where(x => x.Id == 2).FirstOrDefault();
                    ////                  await DisplayAlert("temp", temp.ToString(), "ddeded");
                    //                  chb_networkManagement.Checked = temp != null ? true : false;

                    //                  //точки реализации
                    //                  temp = res.Where(x => x.Id == 3).FirstOrDefault();
                    //                  chb_retailManagement.Checked = temp != null ? true : false;

                    //                  //personnel management
                    //                  temp = res.Where(x => x.Id == 4).FirstOrDefault();
                    //                  chb_personnelManagement.Checked = temp != null ? true : false;

                    //                  //product management
                    //                  temp = res.Where(x => x.Id == 5).FirstOrDefault();
                    //                  chb_productManagement.Checked = temp != null ? true : false;

                    //                  //bonus management
                    //                  temp = res.Where(x => x.Id == 6).FirstOrDefault();
                    //                  chb_bonusManagement.Checked = temp != null ? true : false;

                    //                  //sales
                    //                  temp = res.Where(x => x.Id == 7).FirstOrDefault();
                    //                  chb_salesManagement.Checked = temp != null ? true : false;

                    //                  //sales monitoring
                    //                  temp = res.Where(x => x.Id == 8).FirstOrDefault();
                    //                  chb_salesMonitoring.Checked = temp != null ? true : false;

                    //                  //rack-jobber
                    //                  temp = res.Where(x => x.Id == 9).FirstOrDefault();
                    //                  chb_rack_jobberManagement.Checked = temp != null ? true : false;
           

                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error", ex.Message, "Done");
                }
            }
            base.OnAppearing();
        }
Пример #25
0
        protected async override void OnAppearing()
        {
            try
            {
                ApiService api = new ApiService {
                    Url = ApiService.URL_USER_FUNCTIONS
                };
                Dictionary <string, string> data = new Dictionary <string, string>
                {
                    { "auth_key", App.APP.CurrentUser.AuthKey },
                    { "user_id", CurrentUser.Id.ToString() },
                    { "company_id", CurrentCompany.Id.ToString() },
                };

                api.AddParams(data);

                var res = await api.Function();


                FunctionData temp;

                //отмечаем включенные функции
                //компании
                temp = res.Where(x => x.Id == 1).FirstOrDefault();
                //                  await DisplayAlert("temp", temp.ToString(), "ddeded");
                chb_companyManagement.Checked = temp != null ? true : false;

                //торговые сети
                temp = res.Where(x => x.Id == 2).FirstOrDefault();
                //                  await DisplayAlert("temp", temp.ToString(), "ddeded");
                chb_networkManagement.Checked = temp != null ? true : false;

                //точки реализации
                temp = res.Where(x => x.Id == 3).FirstOrDefault();
                chb_retailManagement.Checked = temp != null ? true : false;

                //personnel management
                temp = res.Where(x => x.Id == 4).FirstOrDefault();
                chb_personnelManagement.Checked = temp != null ? true : false;

                //product management
                temp = res.Where(x => x.Id == 5).FirstOrDefault();
                chb_productManagement.Checked = temp != null ? true : false;

                //bonus management
                temp = res.Where(x => x.Id == 6).FirstOrDefault();
                chb_bonusManagement.Checked = temp != null ? true : false;

                //sales
                temp = res.Where(x => x.Id == 7).FirstOrDefault();
                chb_salesManagement.Checked = temp != null ? true : false;

                //sales monitoring
                temp = res.Where(x => x.Id == 8).FirstOrDefault();
                chb_salesMonitoring.Checked = temp != null ? true : false;

                //rack-jobber
                temp = res.Where(x => x.Id == 9).FirstOrDefault();
                chb_rack_jobberManagement.Checked = temp != null ? true : false;
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "Done");
            }


            base.OnAppearing();
        }
Пример #26
0
        }//c_tor

        //обработка нажатия на кнопку входа
        private async void Bt_sign_in_Clicked(object sender, EventArgs e)
        {
            
            try
            {
                ai_ind.IsVisible = true;
                bt_sign_in.IsVisible = false;
                bt_register.IsVisible = false;
                //задаем url отправки
                ApiService api = new ApiService
                {
                    Url = "https://www.exsales.net/api/v1/user/auth"
                };

                //добавляем параметы к запросу
                Dictionary<string, string> data = new Dictionary<string, string>();
                //добавляем почту
                data.Add("email", ApiService.StringUrlEncode(en_login.Text));

                //добавляем роль
                data.Add("password", en_password.Text);
                api.AddParams(data);

                if (!String.IsNullOrEmpty(en_login.Text) && !String.IsNullOrEmpty(en_password.Text))
                {
                    //отправляем запрос и ждем результат
                    JObject res = await api.Auth();
              //      await DisplayAlert("Message", res/*bool.Parse(res["status"].ToString()).ToString()*/, "OK");
               //     получаем ключ авторизации пользователя
                    if (bool.Parse(res["status"].ToString()))
                    {
                        auth_key = res["auth_key"].ToString();
                        //await DisplayAlert("Message", auth_key, "OK");
                        await Navigation.PushModalAsync(new AccountPage(res), true);
                    }
                    else
                    {
#if (DEBUG)
                        await DisplayAlert("Warning", "Ошибка авторизации. Проверьте указанные данные!", "OK");

#else
                        await DisplayAlert("Warning", LangResources.StartPageEnterMessageWarning, "OK"); 
#endif
                    }
                }
                else
                {
                    await DisplayAlert("Warning", "Проверьте указанные данные!", "OK");
                }

                //выводим ответ

            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
            finally
            {
                ai_ind.IsVisible = false;
                bt_sign_in.IsVisible = true;
                bt_register.IsVisible = true;
            }
        }