コード例 #1
0
        public bool AddCategoryOffline(CategoryOfflineViewModel newCategoryOffline, string _synced)
        {
            bool result = false;
            try
            {
                using (var db = new SQLite.SQLiteConnection(_dbPath))
                {
                    CategoryOffline objCategoryOffline = new CategoryOffline();

                    objCategoryOffline.categoryId = Convert.ToString(newCategoryOffline.categoryId);
                    objCategoryOffline.organizationId = Convert.ToString(newCategoryOffline.organizationId);
                    objCategoryOffline.categoryCode = Convert.ToString(newCategoryOffline.categoryCode);
                    objCategoryOffline.categoryDescription = newCategoryOffline.categoryDescription;
                    objCategoryOffline.parentCategoryId = newCategoryOffline.parentCategoryId;
                    objCategoryOffline.imageName = newCategoryOffline.imageName;
                    objCategoryOffline.active = newCategoryOffline.active;

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

                    db.RunInTransaction(() =>
                    {
                        db.Insert(objCategoryOffline);
                    });
                }

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

            }//catch
            return result;
        }
コード例 #2
0
        public CategoryDetailsPage()
        {
            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("viewCategoryDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewCategoryDetails", FileMode.Open))
                        {
                            //====================================================================================================================
                            // Read Category Details
                            //====================================================================================================================
                            ObjCategoryData = new CategoryOfflineViewModel();
                            DataContractSerializer serializer = new DataContractSerializer(typeof(CategoryOfflineViewModel));
                            ObjCategoryData = (CategoryOfflineViewModel)serializer.ReadObject(fileStream);
                            lblCategory.Text = ObjCategoryData.categoryCode;
                            lblDescription.Text = ObjCategoryData.categoryDescription;

                        }

                    }
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
コード例 #3
0
        void wc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            try
            {
                CategoryDataProvider _CategoryDataProvider = new CategoryDataProvider();

                if (e.Result.Contains("no Category found"))
                {
                    ListCategoryData = new List<CategoryOfflineViewModel>();
                    this.lstCateoryItems.ItemsSource = ListCategoryData;
                }
                else
                {
                    //Parse JSON result
                    var rootObject = JsonConvert.DeserializeObject<RootObject_Category>(e.Result);
                    if (rootObject.success == 1)
                    {
                        foreach (var itm in rootObject.response.data)
                        {
                            CategoryOfflineViewModel obj = new CategoryOfflineViewModel();
                            obj.categoryId = Convert.ToString(itm.categoryId);
                            obj.organizationId = Convert.ToString(itm.organizationId);
                            obj.categoryCode = Convert.ToString(itm.categoryCode);
                            obj.categoryDescription = itm.categoryDescription;
                            obj.parentCategoryId = itm.parentCategoryId;
                            obj.imageName = itm.imageName;
                            obj.active = itm.active;

                            _CategoryDataProvider = new CategoryDataProvider();
                            var result = _CategoryDataProvider.AddCategoryOffline(obj, "True");
                            if (result == true)
                            {
                                //MessageBox.Show("successfully registerd Customer.");
                            }
                        }

                        //====================================================================================================================
                        // Fill Category List From Offline DB
                        //====================================================================================================================

                        _CategoryDataProvider = new CategoryDataProvider();
                        ListCategoryData = new List<CategoryOfflineViewModel>();
                        foreach (var itm in _CategoryDataProvider.GetAllCategoryOfflineList())
                        {
                            var Source = "/Assets/category/category_icon.png";
                            if (!string.IsNullOrEmpty(itm.imageName))
                            {
                                Source = Utilities.GetMarketplaceURL() + uploadImagePath.CATEGORY + itm.imageName;
                            }

                            ListCategoryData.Add(new CategoryOfflineViewModel { 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, fullImagePath=Source});
                        };
                        this.lstCateoryItems.ItemsSource = ListCategoryData;

                        // hide Loader
                        myIndeterminateProbar.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        MessageBox.Show(rootObject.response.message.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something wrong happened.");
            }
            finally
            {
                // hide Loader
                myIndeterminateProbar.Visibility = Visibility.Collapsed;
            }
        }
コード例 #4
0
        private void ImgAddCateory_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //====================================================================================================================
            // Add new Cateory
            //====================================================================================================================

            CategoryOfflineViewModel _CategoryDataContext = new CategoryOfflineViewModel();
            // Set page mode for Add record of category
            _redirectMode = "Add";
            _CategoryDataContext.mode = "Add";
            if (ISOFile.FileExists("viewCategoryDetails"))
            {
                ISOFile.DeleteFile("viewCategoryDetails");
            }
            using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewCategoryDetails", FileMode.Create))
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(CategoryOfflineViewModel));
                serializer.WriteObject(fileStream, _CategoryDataContext);

                NavigationService.Navigate(new Uri("/Views/Category/CategoryAddEditPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }