public CustomerDetails()
        {
            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("viewCustomerDetails"))//read current user login details
                    {
                        using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewCustomerDetails", FileMode.Open))
                        {
                            //====================================================================================================================
                            // Read Customer Details
                            //====================================================================================================================
                            ObjCustomerData = new CustomerOfflineViewModel();
                            DataContractSerializer serializer = new DataContractSerializer(typeof(CustomerOfflineViewModel));
                            //var ObjCustomerData = (CustomerOfflineViewModel)serializer.ReadObject(fileStream);
                            ObjCustomerData = (CustomerOfflineViewModel)serializer.ReadObject(fileStream);
                            lblName.Text = ObjCustomerData.displayFullName;
                            lblEmail.Text = ObjCustomerData.email;
                            lblPhone.Text = ObjCustomerData.displayContact;
                            lblState.Text = ObjCustomerData.stateName;
                            lblArea.Text = ObjCustomerData.areaName;
                            lblCity.Text = ObjCustomerData.cityName;
                            lblStreet.Text = ObjCustomerData.addressLine1;
                            if (!string.IsNullOrEmpty(ObjCustomerData.fullImagePath))
                            {
                                imgCustomer.ImageSource = new BitmapImage(new Uri(ObjCustomerData.fullImagePath, UriKind.RelativeOrAbsolute));
                            }
                            else
                            {
                                imgCustomer.ImageSource = new BitmapImage(new Uri("/Assets/Employee/account-circle.png", UriKind.RelativeOrAbsolute));
                            }
                        }

                    }
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
        void wc_UploadLoadCustomerCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            try
            {
                CustomerDataProvider _CustomerDataProvider = new CustomerDataProvider();
                //Parse JSON result
                var results = JsonConvert.DeserializeObject<dynamic>(e.Result);
                if (results.success == 1)
                {
                    //Parse JSON result
                    var rootObject = JsonConvert.DeserializeObject<RootObject_Customer>(e.Result);
                    foreach (var itm in rootObject.response.data)
                    {
                        CustomerOfflineViewModel obj = new CustomerOfflineViewModel();
                        obj.employeeId=_employeeId;
                        obj.organizationId=_organizationId;
                        obj.customerId=itm.customerId;
                        obj.addressLine1=itm.addressLine1;
                        obj.address_Line2=itm.address_Line2;
                        obj.firstName=itm.firstName;
                        obj.lastName=itm.lastName;
                        obj.city=itm.city;
                        obj.state=itm.state;
                        obj.area=itm.area;
                        obj.email = itm.email;
                        obj.phone=itm.phone;
                        obj.stateName=itm.stateName;
                        obj.cityName=itm.cityName;
                        obj.areaName = itm.areaName;
                        obj.imageName = itm.imageName;

                        _CustomerDataProvider = new CustomerDataProvider();
                        var result = _CustomerDataProvider.AddCustomerOffline(obj, "True");
                        if (result == true)
                        {
                            //MessageBox.Show("successfully registerd Customer.");
                        }
                    }

                    //====================================================================================================================
                    // Fill Customer List From Offline DB
                    //====================================================================================================================

                    _CustomerDataProvider = new CustomerDataProvider();
                    ListCustomerData = new List<CustomerOfflineViewModel>();
                    foreach (var itm in _CustomerDataProvider.GetAllCustomerOfflineList())
                    {
                        var Source = "/Assets/Employee/account-circle.png";
                        if (!string.IsNullOrEmpty(itm.imageName))
                        {
                            Source = Utilities.GetMarketplaceURL() + uploadImagePath.CUSTOMER + itm.imageName;
                        }

                        ListCustomerData.Add(new CustomerOfflineViewModel { displayFullName = itm.firstName + " " + itm.lastName, displayContact = itm.phone, email = itm.email, stateName = itm.stateName, areaName = itm.areaName, cityName = itm.cityName, addressLine1 = itm.addressLine1, city = itm.city, state = itm.state, area = itm.area, firstName = itm.firstName, lastName = itm.lastName, employeeId = itm.employeeId, customerId = itm.customerId,fullImagePath=Source });
                    };
                    this.lstCustomerItems.ItemsSource = ListCustomerData;

                }
                if (results.success == 0)
                {
                    MessageBox.Show(results.response.message.ToString());
                }

            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("no user found"))
                {
                }
                else { MessageBox.Show("Something wrong happened."); }
            }
            finally
            {
                // hide Loader
                myIndeterminateProbar.Visibility = Visibility.Collapsed;
            }
        }
        private void ImgAddCustomer_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //====================================================================================================================
            // Add new Customer
            //====================================================================================================================

            CustomerOfflineViewModel _CustomerDataContext = new CustomerOfflineViewModel();
            // Set page mode for Edit record of employee
            _redirectMode = "Add";
            _CustomerDataContext.mode = "Add";
            if (ISOFile.FileExists("viewCustomerDetails"))
            {
                ISOFile.DeleteFile("viewCustomerDetails");
            }
            using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewCustomerDetails", FileMode.Create))
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(CustomerOfflineViewModel));
                serializer.WriteObject(fileStream, _CustomerDataContext);

                NavigationService.Navigate(new Uri("/Views/Customer/CustomerAddEdit.xaml", UriKind.RelativeOrAbsolute));
            }
        }
예제 #4
0
        void wc_UploadLoadCustomerCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            try
            {
                CustomerDataProvider _CustomerDataProvider = new CustomerDataProvider();
                //Parse JSON result
                var results = JsonConvert.DeserializeObject<dynamic>(e.Result);
                if (results.success == 1)
                {
                    //Parse JSON result
                    var rootObject = JsonConvert.DeserializeObject<RootObject_Customer>(e.Result);
                    foreach (var itm in rootObject.response.data)
                    {
                        CustomerOfflineViewModel obj = new CustomerOfflineViewModel();
                        obj.employeeId = _employeeId;
                        obj.organizationId = _organizationId;
                        obj.customerId = itm.customerId;
                        obj.addressLine1 = itm.addressLine1;
                        obj.address_Line2 = itm.address_Line2;
                        obj.firstName = itm.firstName;
                        obj.lastName = itm.lastName;
                        obj.city = itm.city;
                        obj.state = itm.state;
                        obj.area = itm.area;
                        obj.email = itm.email;
                        obj.phone = itm.phone;
                        obj.stateName = itm.stateName;
                        obj.cityName = itm.cityName;
                        obj.areaName = itm.areaName;
                        obj.imageName = itm.imageName;

                        _CustomerDataProvider = new CustomerDataProvider();
                        var result = _CustomerDataProvider.AddCustomerOffline(obj, "True");
                        if (result == true)
                        {
                            //MessageBox.Show("successfully registerd Customer.");
                        }
                    }

                }
                if (results.success == 0)
                {
                    MessageBox.Show(results.response.message.ToString());
                }

            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("no user found"))
                {
                }
                else { MessageBox.Show("Something wrong happened."); }
            }
            finally
            {
                // hide Loader
                myIndeterminateProbar.Visibility = Visibility.Collapsed;
            }
        }
        private void ImgAddCustomer_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (Utilities.CheckInternetConnection())
            {
                // ----------------------------------------------------------------------
                // "Network Status: Connected."

                //====================================================================================================================
                // Add new Customer
                //====================================================================================================================

                CustomerOfflineViewModel _CustomerDataContext = new CustomerOfflineViewModel();
                // Set page mode for Edit record of employee
                _redirectMode = "Add";
                _CustomerDataContext.mode = "Add";
                if (ISOFile.FileExists("viewCustomerDetails"))
                {
                    ISOFile.DeleteFile("viewCustomerDetails");
                }
                using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewCustomerDetails", FileMode.Create))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(CustomerOfflineViewModel));
                    serializer.WriteObject(fileStream, _CustomerDataContext);

                    NavigationService.Navigate(new Uri("/Views/Customer/CustomerAddEdit.xaml", UriKind.RelativeOrAbsolute));
                }
            }
            else
            {
                // ----------------------------------------------------------------------
                //  "Network Status: Not Connected."

                MessageBox.Show("You can not create a new customer in offline mode.");
            }
        }