public SubCategoryListPage()
        {
            InitializeComponent();

            IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication();
            if (IsolatedStorageSettings.ApplicationSettings.Contains("islogin"))
            {
                if (!(Convert.ToString(IsolatedStorageSettings.ApplicationSettings["islogin"]).ToLower() == "yes"))
                {
                    NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
                }
                else
                {
                    if (ISOFile.FileExists("CurrentLoginUserDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("CurrentLoginUserDetails", FileMode.Open))
                        {
                            DataContractSerializer serializer = new DataContractSerializer(typeof(LoginViewModel));
                            var ObjUserData = (LoginViewModel)serializer.ReadObject(fileStream);
                            this.txtHeaderOrgName.Text = ObjUserData.organizationName;
                            this.txtHeaderFullName.Text = ObjUserData.firstName + " " + ObjUserData.lastName;
                            _employeeId = Convert.ToInt32(ObjUserData.employeeId);
                            _organizationId = Convert.ToInt32(ObjUserData.organizationId);
                            lstMenuItems.ItemsSource = Utilities.GetMenuItems(MenuCode.CatMngt);

                            if (Utilities.CheckInternetConnection())
                            {
                                // ----------------------------------------------------------------------
                                // "Network Status: Connected."

                                //====================================================================================================================
                                // Sub Category module Data Synchronization
                                //====================================================================================================================

                                // Show Loader
                                myIndeterminateProbar.Visibility = Visibility.Visible;
                                CategoryDataProvider _CategoryDataProvider = new CategoryDataProvider();
                                var result = _CategoryDataProvider.GetsyncedSubCategoryOfflineList("False");

                                if (result != null)
                                {
                                    if (result.Count > 0)
                                    {
                                        try
                                        {
                                            foreach (var itm in result)
                                            {
                                                // Parameters
                                                SubCategoryRequest obj = new SubCategoryRequest();
                                                obj.organizationId = _organizationId; // Logged In organizationId
                                                obj.categoryId = Convert.ToInt32(itm.categoryId);
                                                obj.categoryCode = itm.categoryCode;
                                                obj.categoryDescription = itm.categoryDescription;
                                                obj.parentCategoryId = Convert.ToInt32(itm.parentCategoryId); // 0 for category and category id for subcategory

                                                String data = string.Empty;

                                                //Initialize WebClient
                                                WebClient webClient = new WebClient();

                                                //Set Header
                                                webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                                                webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                                                webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";

                                                data = "organizationId=" + obj.organizationId + "&categoryId=" + obj.categoryId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId;
                                                webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/updateCategory/")), "POST", data);

                                                //Assign Event Handler
                                                webClient.UploadStringCompleted += wc_UploadSaveCompleted;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show("Something wrong happened.");
                                        }
                                    }
                                }

                            }
                            else
                            {
                                //====================================================================================================================
                                // Fill Category List From Offline DB
                                //====================================================================================================================

                                CategoryDataProvider _CategoryDataProvider = new CategoryDataProvider();
                                ListSubCategoryData = new List<SubCategoryOfflineViewModel>();
                                foreach (var itm in _CategoryDataProvider.GetAllSubCategoryOfflineList())
                                {
                                    var Source = "/Assets/category/icon_sub_categories.png";
                                    if (!string.IsNullOrEmpty(itm.imageName))
                                    {
                                        Source = Utilities.GetMarketplaceURL() + uploadImagePath.SUBCATEGORY + itm.imageName;
                                    }

                                    ListSubCategoryData.Add(new SubCategoryOfflineViewModel { categoryId = itm.categoryId, organizationId = itm.organizationId, categoryCode = itm.categoryCode, categoryDescription = itm.categoryDescription, imageName = itm.imageName, imagePath = itm.imagePath, active = itm.active, parentCategoryId = itm.parentCategoryId, createDt = itm.createDt, lastModifiedDt = itm.lastModifiedDt, lastModifiedBy = itm.lastModifiedBy, parentCategory = itm.parentCategory, fullImagePath = Source });
                                };
                                this.lstSubCateoryItems.ItemsSource = ListSubCategoryData;
                            }
                        }
                    }
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
        public ProductAddMasterList()
        {
            InitializeComponent();

            _isPopUpOpen = false;

            IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication();
            if (IsolatedStorageSettings.ApplicationSettings.Contains("islogin"))
            {
                if (!(Convert.ToString(IsolatedStorageSettings.ApplicationSettings["islogin"]).ToLower() == "yes"))
                {
                    NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
                }
                else
                {
                    if (ISOFile.FileExists("CurrentLoginUserDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("CurrentLoginUserDetails", FileMode.Open))
                        {
                            DataContractSerializer serializer = new DataContractSerializer(typeof(LoginViewModel));
                            var ObjUserData = (LoginViewModel)serializer.ReadObject(fileStream);
                            _employeeId = Convert.ToInt32(ObjUserData.employeeId);
                            _organizationId = Convert.ToInt32(ObjUserData.organizationId);

                            // Show Loader
                            myIndeterminateProbar.Visibility = Visibility.Visible;

                            //====================================================================================================================
                            // Fill Master Product List
                            //====================================================================================================================

                            // Parameters
                            ProductRequest obj = new ProductRequest();
                            obj.organizationId = _organizationId;
                            obj.set = 1;
                            obj.count = Utilities.GetListCount();
                            obj.isInventory = 0; //0 for product list, 1 for inventory list

                            String data = "organizationId=" + obj.organizationId + "&set=" + obj.set + "&count=" + obj.count + "&count=" + obj.count;

                            //Initialize WebClient
                            WebClient webClient = new WebClient();
                            //Set Header
                            webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                            webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                            webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";
                            webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageProduct/masterProductList/")), "POST", data);
                            //Assign Event Handler0
                            webClient.UploadStringCompleted += wc_UploadOrganizationProductCompleted;

                        }
                    }
                }

                //====================================================================================================================
                // Fill Category Dropdown Default
                //====================================================================================================================

                if (Utilities.CheckInternetConnection())
                {
                    // ----------------------------------------------------------------------
                    // "Network Status: Connected."

                    // Show Loader
                    myIndeterminateProbar.Visibility = Visibility.Visible;

                    SubCategoryRequest obj = new SubCategoryRequest();
                    obj.organizationId = _organizationId;
                    obj.set = 1;
                    obj.count = Utilities.GetListCount();
                    String data = "organizationId=" + obj.organizationId + "&set=" + obj.set + "&count=" + obj.count;

                    //Initialize WebClient
                    WebClient webClient = new WebClient();
                    //Set Header
                    webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                    webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                    webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";
                    webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/categoryListing/")), "POST", data);
                    //Assign Event Handler0
                    webClient.UploadStringCompleted += wc_UploadCategoryCompleted;
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
        public bool UpdateSubCategoryOffline(SubCategoryRequest SubCustomerOffline, string _synced)
        {
            bool result = false;
            try
            {
                using (var db = new SQLite.SQLiteConnection(_dbPath))
                {
                    var objSubCategoryOffline = db.Query<PointePayApp.Model.SubCategoryOffline>("select * from SubCategoryOffline where categoryId=" + SubCustomerOffline.categoryId).FirstOrDefault();
                    if (objSubCategoryOffline != null)
                    {
                        //objSubCategoryOffline.categoryId = Convert.ToString(SubCustomerOffline.categoryId);
                        //objSubCategoryOffline.organizationId = Convert.ToString(SubCustomerOffline.organizationId);
                        objSubCategoryOffline.categoryCode = Convert.ToString(SubCustomerOffline.categoryCode);
                        objSubCategoryOffline.categoryDescription = SubCustomerOffline.categoryDescription;
                        objSubCategoryOffline.parentCategoryId = Convert.ToString(SubCustomerOffline.parentCategoryId);
                        //objSubCategoryOffline.active = SubCustomerOffline.active;

                        objSubCategoryOffline.synced = _synced;  // i.e. Need to synced when online and Update the synced status = "True"

                        db.RunInTransaction(() =>
                        {
                            db.Update(objSubCategoryOffline);
                        });
                    }
                }

                result = true;
            }//try
            catch (Exception ex)
            {

            }//catch
            return result;
        }
        public SubCategoryAddEditPage()
        {
            InitializeComponent();

            if (IsolatedStorageSettings.ApplicationSettings.Contains("islogin"))
            {
                if (!(Convert.ToString(IsolatedStorageSettings.ApplicationSettings["islogin"]).ToLower() == "yes"))
                {
                    NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
                }
                else
                {
                    if (ISOFile.FileExists("CurrentLoginUserDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("CurrentLoginUserDetails", FileMode.Open))
                        {
                            DataContractSerializer serializer = new DataContractSerializer(typeof(LoginViewModel));
                            var ObjUserData = (LoginViewModel)serializer.ReadObject(fileStream);
                            _organizationId = Convert.ToInt32(ObjUserData.organizationId);
                        }
                    }

                    if (ISOFile.FileExists("viewSubCategoryDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewSubCategoryDetails", FileMode.Open))
                        {
                            DataContractSerializer serializer = new DataContractSerializer(typeof(SubCategoryOfflineViewModel));
                            var ObjCategoryData = (SubCategoryOfflineViewModel)serializer.ReadObject(fileStream);
                            txtsubcategoryName.Text = Convert.ToString(ObjCategoryData.categoryCode);
                            txtsubcategoryDescription.Text = Convert.ToString(ObjCategoryData.categoryDescription);
                            _categoryId = Convert.ToInt32(ObjCategoryData.categoryId);
                            _ParentCategoryID = Convert.ToInt32(ObjCategoryData.parentCategoryId);
                            _mode = ObjCategoryData.mode;

                            if (_mode == "Add")
                            {
                                btnSave.Content = "Add Sub Category";
                                lblHeader.Text = "ADD SUBCATEGORY";
                            }
                            if (_mode == "Edit")
                            {
                                btnSave.Content = "Save";
                                lblHeader.Text = "EDIT SUBCATEGORY";
                            }
                        }
                    }

                    //====================================================================================================================
                    // Fill Category Dropdown Default
                    //====================================================================================================================

                    if (Utilities.CheckInternetConnection())
                    {
                        // ----------------------------------------------------------------------
                        // "Network Status: Connected."

                        // Show Loader
                        myIndeterminateProbar.Visibility = Visibility.Visible;

                        SubCategoryRequest obj = new SubCategoryRequest();
                        obj.organizationId = _organizationId;
                        obj.set = 1;
                        obj.count = 5;
                        String data = "organizationId=" + obj.organizationId + "&set=" + obj.set + "&count=" + obj.count;

                        //Initialize WebClient
                        WebClient webClient = new WebClient();
                        //Set Header
                        webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                        webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                        webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";
                        webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/categoryListing/")), "POST", data);
                        //Assign Event Handler0
                        webClient.UploadStringCompleted += wc_UploadCategoryCompleted;
                    }
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // Parameters
            SubCategoryRequest obj = new SubCategoryRequest();
            obj.organizationId = _organizationId; // Logged In organizationId
            obj.categoryCode = txtsubcategoryName.Text;
            obj.categoryDescription = txtsubcategoryDescription.Text;

            if (Utilities.CheckInternetConnection())
            {
                // ----------------------------------------------------------------------
                // "Network Status: Connected."

                ListPickerItem selectedItemState = this.listPickerCategory.ItemContainerGenerator.ContainerFromItem(this.listPickerCategory.SelectedItem) as ListPickerItem;
                SubCategoryOfflineViewModel SelecteddataCategory = selectedItemState.DataContext as SubCategoryOfflineViewModel;
                obj.parentCategoryId = Convert.ToInt32(SelecteddataCategory.categoryId);

                String data = string.Empty;

                if (Validation() == true)
                {
                    // Show Loader
                    myIndeterminateProbar.Visibility = Visibility.Visible;

                    //Initialize WebClient
                    WebClient webClient = new WebClient();

                    //Set Header
                    webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                    webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                    webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";

                    if (_mode == "Add")
                    {
                        data = "organizationId=" + obj.organizationId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId;
                        webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/addCategory/")), "POST", data);
                    }
                    if (_mode == "Edit")
                    {
                        obj.categoryId = _categoryId;

                        data = "organizationId=" + obj.organizationId + "&categoryId=" + obj.categoryId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId;
                        webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/updateCategory/")), "POST", data);
                    }

                    //Assign Event Handler
                    webClient.UploadStringCompleted += wc_UploadSaveCompleted;
                }
            }
            else
            {
                // ----------------------------------------------------------------------
                //  "Network Status: Not Connected."

                MessageBoxResult objMessageBox = MessageBox.Show("Right now you are in offline mode. data save and will be sent to the server the next time you are online.", "Network Status !", MessageBoxButton.OKCancel);
                if (objMessageBox == MessageBoxResult.OK)
                {
                    try
                    {
                        if (Validation() == true)
                        {
                            if (_mode == "Add")
                            {
                                MessageBox.Show("You can not create a new sub category in offline mode.");
                                NavigationService.Navigate(new Uri("/Views/SubCategory/SubCategoryListPage.xaml", UriKind.Relative));
                            }

                            if (_mode == "Edit")
                            {
                                obj.categoryId = _categoryId;
                                obj.parentCategoryId = _ParentCategoryID;

                                CategoryDataProvider _CategoryDataProvider = new CategoryDataProvider();
                                var result = _CategoryDataProvider.UpdateSubCategoryOffline(obj, "False");
                                if (result == true)
                                {
                                    MessageBox.Show("successfully Updated.");
                                    NavigationService.Navigate(new Uri("/Views/SubCategory/SubCategoryListPage.xaml", UriKind.Relative));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Something wrong happened.");
                    }
                }
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // Parameters
            SubCategoryRequest obj = new SubCategoryRequest();
            obj.organizationId = _organizationId; // Logged In organizationId
            obj.categoryCode = txtsubcategoryName.Text;
            obj.categoryDescription = txtsubcategoryDescription.Text;

            ListPickerItem selectedItemState = this.listPickerCategory.ItemContainerGenerator.ContainerFromItem(this.listPickerCategory.SelectedItem) as ListPickerItem;
            SubCategoryOfflineViewModel SelecteddataCategory = selectedItemState.DataContext as SubCategoryOfflineViewModel;
            obj.parentCategoryId = Convert.ToInt32(SelecteddataCategory.categoryId);

            String data = string.Empty;

            if (Validation() == true)
            {
                // Show Loader
                myIndeterminateProbar.Visibility = Visibility.Visible;

                //Initialize WebClient
                WebClient webClient = new WebClient();

                //Set Header
                webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization();
                webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US";

                if (_mode == "Add")
                {
                    data = "organizationId=" + obj.organizationId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId;
                    webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/addCategory/")), "POST", data);
                }
                if (_mode == "Edit")
                {
                    obj.categoryId = _categoryId;

                    data = "organizationId=" + obj.organizationId + "&categoryId=" + obj.categoryId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId;
                    webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/updateCategory/")), "POST", data);
                }

                //Assign Event Handler
                webClient.UploadStringCompleted += wc_UploadSaveCompleted;
            }
        }