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); // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; //==================================================================================================================== // Fill Category List //==================================================================================================================== // Parameters EmployeeRequest obj = new EmployeeRequest(); 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/subCategoryListing/")), "POST", data); //Assign Event Handler0 webClient.UploadStringCompleted += wc_UploadStringCompleted; } } } } else { NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute)); } }
// Insert the newEmployeeOffline. public bool AddEmployeeOffline(EmployeeRequest newEmployeeOffline,string _synced) { bool result = false; try { using (var db = new SQLite.SQLiteConnection(_dbPath)) { EmployeeOffline objEmployeeOffline = new EmployeeOffline(); objEmployeeOffline.staffEmployeeId = Convert.ToString(newEmployeeOffline.staffEmployeeId); objEmployeeOffline.employeeId = Convert.ToString(newEmployeeOffline.employeeId); objEmployeeOffline.organizationId = Convert.ToString(newEmployeeOffline.organizationId); objEmployeeOffline.firstName = newEmployeeOffline.firstName; objEmployeeOffline.lastName = newEmployeeOffline.lastName; objEmployeeOffline.email = newEmployeeOffline.email; objEmployeeOffline.businessPhoneCode = newEmployeeOffline.businessPhoneCode; objEmployeeOffline.businessPhone = newEmployeeOffline.businessPhone; objEmployeeOffline.designation = newEmployeeOffline.designation; objEmployeeOffline.state = Convert.ToString(newEmployeeOffline.state); objEmployeeOffline.city = Convert.ToString(newEmployeeOffline.city); objEmployeeOffline.area = Convert.ToString(newEmployeeOffline.area); objEmployeeOffline.stateName = newEmployeeOffline.stateName; objEmployeeOffline.areaName = newEmployeeOffline.areaName; objEmployeeOffline.cityName = newEmployeeOffline.cityName; objEmployeeOffline.addressLine1 = newEmployeeOffline.addressLine1; objEmployeeOffline.salary = newEmployeeOffline.salary; objEmployeeOffline.userName = newEmployeeOffline.userName; objEmployeeOffline.role = newEmployeeOffline.empRoleArray; objEmployeeOffline.active = newEmployeeOffline.active; objEmployeeOffline.synced = _synced; // i.e. Need to synced when online and Update the synced status = "True" db.RunInTransaction(() => { db.Insert(objEmployeeOffline); }); } result = true; }//try catch (Exception ex) { }//catch return result; }
void wc_UploadLoadEmployeeCompleted(object sender, UploadStringCompletedEventArgs e) { EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); try { if (e.Result.Contains("no employee found")) { MessageBox.Show("No employee found"); } else { //Parse JSON result var rootObject = JsonConvert.DeserializeObject<RootObject_Employee>(e.Result); if (rootObject.success == 1) { foreach (var itm in rootObject.response.data) { EmployeeRequest obj = new EmployeeRequest(); obj.employeeId = Convert.ToInt32(_employeeId); obj.organizationId = Convert.ToInt32(itm.organizationId); obj.staffEmployeeId = Convert.ToInt32(itm.employeeId); obj.firstName = itm.firstName; obj.lastName = itm.lastName; obj.email = itm.email; obj.businessPhoneCode = itm.businessPhoneCode; obj.businessPhone = itm.businessPhone; obj.addressLine1 = itm.addressLine1; obj.salary = itm.salary; obj.userName = itm.userName; obj.state = Convert.ToInt32(itm.state); obj.area = Convert.ToInt32(itm.area); obj.city = Convert.ToInt32(itm.city); // here zipId is cityID obj.empRoleArray = itm.empRoleList; obj.designation = itm.designation; obj.active = itm.active; obj.areaName = itm.areaName; obj.cityName = itm.cityName; obj.stateName = itm.stateName; obj.imageName = itm.imageName; _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.AddEmployeeOffline(obj, "True"); if (result == true) { //MessageBox.Show("successfully registerd employee."); } } //==================================================================================================================== // Fill Employee List From Offline DB //==================================================================================================================== _EmployeeDataProvider = new Provider.EmployeeDataProvider(); ListEmployeeData = new List<EmployeeViwModel>(); foreach (var itm in _EmployeeDataProvider.GetAllEmployeeOfflineList()) { string _blockUnblockIconSrc = "/Assets/Employee/bullet_red.png"; if (itm.active == "1") { // Inactive - already block _blockUnblockIconSrc = "/Assets/Employee/bullet_green.png"; } var Source = "/Assets/Employee/account-circle.png"; if (!string.IsNullOrEmpty(itm.imageName)) { Source = Utilities.GetMarketplaceURL() + uploadImagePath.EMPLOYEE + itm.imageName; } ListEmployeeData.Add(new EmployeeViwModel { displayFullName = itm.firstName + " " + itm.lastName, displayContact = itm.businessPhoneCode + " " + itm.businessPhone, email = itm.email, salary = itm.salary, stateName = itm.stateName, areaName = itm.areaName, cityName = itm.cityName, addressLine1 = itm.addressLine1, active = itm.active, city = itm.city, state = itm.state, area = itm.area, empRoleList = itm.role, firstName = itm.firstName, lastName = itm.lastName, employeeId = itm.employeeId, staffEmployeeId = itm.staffEmployeeId, businessPhone = itm.businessPhone, userName = itm.userName, blockUnblockIconSrc = _blockUnblockIconSrc, designation = itm.designation, fullImagePath = Source }); }; this.lstEmployeeItems.ItemsSource = ListEmployeeData; } else { MessageBox.Show(rootObject.response.message.ToString()); } } } catch (Exception ex) { if (ex.Message.Contains("no employee found")) { } else { MessageBox.Show("Something wrong happened."); } } finally { // hide Loader myIndeterminateProbar.Visibility = Visibility.Collapsed; } }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { if (Utilities.CheckInternetConnection()) { // ---------------------------------------------------------------------- // "Network Status: Connected." // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; //==================================================================================================================== // Clear offline Employee table //==================================================================================================================== EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.DeleteAllEmployeeOffline(); if (result == true) { // Success } //==================================================================================================================== // Fill Employee List //==================================================================================================================== // Parameters EmployeeRequest obj = new EmployeeRequest(); 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("manageEmployee/employeeList/")), "POST", data); //Assign Event Handler webClient.UploadStringCompleted += wc_UploadLoadEmployeeCompleted; } }
public EmployeeListPage() { 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.EmpMgnt); if (Utilities.CheckInternetConnection()) { // ---------------------------------------------------------------------- // "Network Status: Connected." //==================================================================================================================== // Employee module Data Synchronization //==================================================================================================================== // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.GetsyncedEmployeeOfflineList("False"); if (result != null) { if (result.Count > 0) { try { foreach (var itm in result) { EmployeeRequest obj = new EmployeeRequest(); obj.employeeId = Convert.ToInt32(itm.employeeId); obj.organizationId = Convert.ToInt32(itm.organizationId); _staffEmployeeId = Convert.ToInt32(itm.staffEmployeeId); obj.firstName = itm.firstName; obj.lastName = itm.lastName; obj.email = itm.email; obj.businessPhoneCode = itm.businessPhoneCode; // hardcoded now obj.businessPhone = itm.businessPhone; obj.addressLine1 = itm.addressLine1; obj.salary = itm.salary; obj.userName = itm.userName; obj.designation = itm.designation; obj.empRoleArray = itm.role; string[] dataarry = new string[] { obj.empRoleArray }; // Serialise the data we are sending in to JSON string serialisedDataempRoleArray = JsonConvert.SerializeObject(dataarry); 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 = "designation=" + obj.designation + "&staffEmployeeId=" + _staffEmployeeId + "&employeeId=" + obj.employeeId + "&organizationId=" + obj.organizationId + "&firstName=" + obj.firstName + "&lastName=" + obj.lastName + "&email=" + obj.email + "&businessPhoneCode=" + obj.businessPhoneCode + "&businessPhone=" + obj.businessPhone + "&state=" + obj.state + "&area=" + obj.area + "&city=" + obj.city + "&addressLine1=" + obj.addressLine1 + "&salary=" + obj.salary + "&userName="******"&role=" + serialisedDataempRoleArray; webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageEmployee/updateEmployee")), "POST", data); //Assign Event Handler webClient.UploadStringCompleted += wc_UploadSycnedOfflineCompleted; } } catch (Exception ex) { MessageBox.Show("Something wrong happened."); } } } } else { // ---------------------------------------------------------------------- // "Network Status: Not Connected." EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); ListEmployeeData = new List<EmployeeViwModel>(); foreach (var itm in _EmployeeDataProvider.GetAllEmployeeOfflineList()) { string _blockUnblockIconSrc = "/Assets/Employee/bullet_red.png"; if (itm.active == "0") { // Inactive - already block _blockUnblockIconSrc = "/Assets/Employee/bullet_green.png"; } ListEmployeeData.Add(new EmployeeViwModel { displayFullName = itm.firstName + " " + itm.lastName, displayContact = itm.businessPhoneCode + " " + itm.businessPhone, email = itm.email, salary = itm.salary, stateName = itm.stateName, areaName = itm.areaName, cityName = itm.cityName, addressLine1 = itm.addressLine1, active = itm.active, city = itm.city, state = itm.state, area = itm.area, empRoleList = itm.empRoleList, firstName = itm.firstName, lastName = itm.lastName, employeeId = itm.employeeId, staffEmployeeId = itm.staffEmployeeId, businessPhone = itm.businessPhone, userName = itm.userName, blockUnblockIconSrc = _blockUnblockIconSrc }); }; this.lstEmployeeItems.ItemsSource = ListEmployeeData; // hide Loader myIndeterminateProbar.Visibility = Visibility.Collapsed; } } } } } else { NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute)); } }
private void ImgEditBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var _EmployeeDataContext = (EmployeeViwModel)(sender as Image).DataContext; Popup popup = new Popup(); popup.VerticalOffset = 80; PopUpUserControl control = new PopUpUserControl(); control.HorizontalAlignment = HorizontalAlignment.Center; if (_EmployeeDataContext.active == "1") { control.btnblock.Content = "Block"; } else { control.btnblock.Content = "Unblock"; } popup.Child = control; popup.IsOpen = true; grdGrayBackground.Visibility = Visibility.Visible; _redirectMode = "Default"; control.btnEdit.Click += (s, args) => { //==================================================================================================================== // PopUp Edit button //==================================================================================================================== popup.IsOpen = false; // Set page mode for Edit record of employee _redirectMode = "Edit"; _EmployeeDataContext.mode = "Edit"; if (ISOFile.FileExists("viewEmployeeDetails")) { ISOFile.DeleteFile("viewEmployeeDetails"); } using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("viewEmployeeDetails", FileMode.Create)) { DataContractSerializer serializer = new DataContractSerializer(typeof(EmployeeViwModel)); serializer.WriteObject(fileStream, _EmployeeDataContext); NavigationService.Navigate(new Uri("/Views/Employee/EmployeeAddEdit.xaml", UriKind.RelativeOrAbsolute)); } }; control.btnblock.Click += (s, args) => { //==================================================================================================================== // PopUp block Unblock Button //==================================================================================================================== int active = 1; if (_EmployeeDataContext.active == "1") { active = 0; } // Parameters EmployeeRequest obj = new EmployeeRequest(); obj.organizationId = _organizationId; obj.employeeId = _employeeId; obj.staffEmployeeId = Convert.ToInt32(_EmployeeDataContext.staffEmployeeId); obj.blockStatus = active; String data = "organizationId=" + obj.organizationId + "&employeeId=" + obj.employeeId + "&staffEmployeeId=" + obj.staffEmployeeId + "&blockStatus=" + obj.blockStatus; //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("manageEmployee/blockUnblockEmployee/")), "POST", data); //Assign Event Handler webClient.UploadStringCompleted += wc_UploadBlockCompleted; popup.IsOpen = false; grdGrayBackground.Visibility = Visibility.Collapsed; }; control.btnclose.Tap += (s, args) => { //==================================================================================================================== // PopUp cancel Button //==================================================================================================================== popup.IsOpen = false; grdGrayBackground.Visibility = Visibility.Collapsed; }; }
void wc_UploadLoadEmployeeCompleted(object sender, UploadStringCompletedEventArgs e) { try { if (e.Result.Contains("no employee found")) { } else { //Parse JSON result var rootObject = JsonConvert.DeserializeObject<RootObject_Employee>(e.Result); if (rootObject.success == 1) { ListEmployeeData = new List<EmployeeViwModel>(); foreach (var itm in rootObject.response.data) { EmployeeRequest obj = new EmployeeRequest(); obj.employeeId = Convert.ToInt32(_employeeId); obj.organizationId = Convert.ToInt32(itm.organizationId); obj.staffEmployeeId = Convert.ToInt32(itm.employeeId); obj.firstName = itm.firstName; obj.lastName = itm.lastName; obj.email = itm.email; obj.businessPhoneCode = itm.businessPhoneCode; obj.businessPhone = itm.businessPhone; obj.addressLine1 = itm.addressLine1; obj.salary = itm.salary; obj.userName = itm.userName; obj.state = Convert.ToInt32(itm.state); obj.area = Convert.ToInt32(itm.area); obj.city = Convert.ToInt32(itm.city); // here zipId is cityID obj.empRoleArray = itm.empRoleList; obj.designation = itm.designation; obj.active = itm.active; obj.areaName = itm.areaName; obj.cityName = itm.cityName; obj.stateName = itm.stateName; obj.imageName = itm.imageName; EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.AddEmployeeOffline(obj, "True"); if (result == true) { //MessageBox.Show("successfully registerd employee."); } }; } else { MessageBox.Show(rootObject.response.message.ToString()); } } } catch (Exception ex) { if (ex.Message.Contains("no employee found")) { } else { MessageBox.Show("Something wrong happened."); } } finally { // hide Loader myIndeterminateProbar.Visibility = Visibility.Collapsed; } }
public HomePage() { InitializeComponent(); // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; 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.Home); if (Utilities.CheckInternetConnection()) { // ---------------------------------------------------------------------- // "Network Status: Connected." //==================================================================================================================== // Employee module Data Synchronization //==================================================================================================================== EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.GetsyncedEmployeeOfflineList("False"); if (result != null) { if (result.Count > 0) { try { foreach (var itm in result) { EmployeeRequest obj = new EmployeeRequest(); obj.employeeId = Convert.ToInt32(itm.employeeId); obj.organizationId = Convert.ToInt32(itm.organizationId); _staffEmployeeId = Convert.ToInt32(itm.staffEmployeeId); obj.firstName = itm.firstName; obj.lastName = itm.lastName; obj.email = itm.email; obj.businessPhoneCode = itm.businessPhoneCode; // hardcoded now obj.businessPhone = itm.businessPhone; obj.addressLine1 = itm.addressLine1; obj.salary = itm.salary; obj.userName = itm.userName; obj.designation = itm.designation; obj.empRoleArray = itm.role; 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 = "designation=" + "" + "&staffEmployeeId=" + _staffEmployeeId + "&employeeId=" + obj.employeeId + "&organizationId=" + obj.organizationId + "&firstName=" + obj.firstName + "&lastName=" + obj.lastName + "&email=" + obj.email + "&businessPhoneCode=" + obj.businessPhoneCode + "&businessPhone=" + obj.businessPhone + "&state=" + obj.state + "&area=" + obj.area + "&city=" + obj.city + "&addressLine1=" + obj.addressLine1 + "&salary=" + obj.salary + "&userName="******"&role=" + obj.empRoleArray; webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageEmployee/updateEmployee")), "POST", data); //Assign Event Handler webClient.UploadStringCompleted += wc_UploadSycnedOfflineCompleted; } } catch (Exception ex) { MessageBox.Show("Something wrong happened."); } } } CustomerDataProvider _CustomerDataProvider = new CustomerDataProvider(); var resultCustomer = _CustomerDataProvider.GetsyncedCustomerOfflineList("False"); if (resultCustomer != null) { if (resultCustomer.Count > 0) { try { foreach (var itm in resultCustomer) { CustomerRequest obj = new CustomerRequest(); obj.employeeId = _employeeId; obj.organizationId = _organizationId; obj.customerId = Convert.ToInt32(itm.customerId); //_customerId = Convert.ToInt32(itm.customerId); obj.addressLine1 = itm.addressLine1; obj.street = itm.address_Line2; obj.firstName = itm.firstName; obj.lastName = itm.lastName; obj.city = Convert.ToInt32(itm.city); obj.state = Convert.ToInt32(itm.state); obj.area = Convert.ToInt32(itm.area); obj.email = itm.email; obj.phone = itm.phone; obj.notes = string.Empty; 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 = "customerId=" + obj.customerId + "&employeeId=" + obj.employeeId + "&organizationId=" + obj.organizationId + "&firstName=" + obj.firstName + "&lastName=" + obj.lastName + "&phone=" + obj.phone + "&state=" + obj.state + "&area=" + obj.area + "&city=" + obj.city + "&addressLine1=" + obj.addressLine1 + "&street=" + obj.street + "¬es=" + obj.notes + "&email=" + obj.email; webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageCustomer/updateCustomer")), "POST", data); //Assign Event Handler webClient.UploadStringCompleted += wc_UploadSycnedCustomerOfflineCompleted; } } catch (Exception ex) { MessageBox.Show("Something wrong happened."); } } } } } } } } else { NavigationService.Navigate(new Uri("/Views/Login/LoginPage.xaml", UriKind.RelativeOrAbsolute)); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { // ---------------------------------------------------------------------- // Parameters EmployeeRequest obj = new EmployeeRequest(); obj.employeeId = _employeeId; // Logged In User's id obj.organizationId = _organizationId; // Logged In organizationId obj.staffEmployeeId = _staffEmployeeId; // Logged In User's id obj.firstName = txtFirstName.Text.Trim(); obj.lastName = txtLastName.Text.Trim(); obj.email = txtEmail.Text.Trim(); obj.businessPhoneCode = _businessPhoneCode; // hardcoded now obj.businessPhone = txtPhone.Text.Trim(); obj.addressLine1 = txtStreet.Text.Trim(); obj.salary = txtSalary.Text.Trim(); obj.userName = txtUsername.Text.Trim(); obj.designation = txtRoleTitle.Text.Trim(); ////obj.empRoleArray = "[" + _Roleccollections + "]"; string[] dataarry = new string[] { _Roleccollections }; // Serialise the data we are sending in to JSON string serialisedDataempRoleArray = JsonConvert.SerializeObject(dataarry); if (Utilities.CheckInternetConnection()) { // ---------------------------------------------------------------------- // "Network Status: Connected." ListPickerItem selectedItemState = this.listPickerState.ItemContainerGenerator.ContainerFromItem(this.listPickerState.SelectedItem) as ListPickerItem; data_State SelecteddataState = selectedItemState.DataContext as data_State; obj.state = Convert.ToInt32(SelecteddataState.stateId); ListPickerItem selectedItemArea = this.listPickerArea.ItemContainerGenerator.ContainerFromItem(this.listPickerArea.SelectedItem) as ListPickerItem; data_Area SelecteddataArea = selectedItemArea.DataContext as data_Area; obj.area = Convert.ToInt32(SelecteddataArea.areaId); ListPickerItem selectedItemCity = this.listPickerCity.ItemContainerGenerator.ContainerFromItem(this.listPickerCity.SelectedItem) as ListPickerItem; data_City SelecteddatCity = selectedItemCity.DataContext as data_City; obj.city = Convert.ToInt32(SelecteddatCity.zipId); // here zipId is cityID String data = string.Empty; if (Validation() == true) { // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; //==================================================================================================================== // Submit Details //==================================================================================================================== //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 = "designation=" + obj.designation + "&employeeId=" + obj.employeeId + "&organizationId=" + obj.organizationId + "&firstName=" + obj.firstName + "&lastName=" + obj.lastName + "&email=" + obj.email + "&businessPhoneCode=" + obj.businessPhoneCode + "&businessPhone=" + obj.businessPhone + "&state=" + obj.state + "&area=" + obj.area + "&city=" + obj.city + "&addressLine1=" + obj.addressLine1 + "&salary=" + obj.salary + "&userName="******"&role=" + serialisedDataempRoleArray; webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageEmployee/addEmployee")), "POST", data); } if (_mode == "Edit") { data = "designation=" + obj.designation + "&staffEmployeeId=" + obj.staffEmployeeId + "&employeeId=" + obj.employeeId + "&organizationId=" + obj.organizationId + "&firstName=" + obj.firstName + "&lastName=" + obj.lastName + "&email=" + obj.email + "&businessPhoneCode=" + obj.businessPhoneCode + "&businessPhone=" + obj.businessPhone + "&state=" + obj.state + "&area=" + obj.area + "&city=" + obj.city + "&addressLine1=" + obj.addressLine1 + "&salary=" + obj.salary + "&userName="******"&role=" + serialisedDataempRoleArray; webClient.UploadStringAsync(new Uri(Utilities.GetURL("manageEmployee/updateEmployee")), "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 employee in offline mode."); } if (_mode == "Edit") { EmployeeDataProvider _EmployeeDataProvider = new Provider.EmployeeDataProvider(); var result = _EmployeeDataProvider.UpdateEmployeeOffline(obj, "False"); if (result == true) { MessageBox.Show("successfully Updated."); } } } } catch (Exception ex) { MessageBox.Show("Something wrong happened."); } } } }
public bool UpdateEmployeeOffline(EmployeeRequest newEmployeeOffline, string _synced) { bool result = false; try { using (var db = new SQLite.SQLiteConnection(_dbPath)) { var objEmpOffline = db.Query<PointePayApp.Model.EmployeeOffline>("select * from EmployeeOffline where staffEmployeeId=" + newEmployeeOffline.staffEmployeeId).FirstOrDefault(); if (objEmpOffline != null) { ////objEmpOffline.employeeId = Convert.ToString(newEmployeeOffline.employeeId); ////objEmpOffline.organizationId = Convert.ToString(newEmployeeOffline.organizationId); objEmpOffline.firstName = newEmployeeOffline.firstName; objEmpOffline.lastName = newEmployeeOffline.lastName; objEmpOffline.email = newEmployeeOffline.email; objEmpOffline.businessPhoneCode = newEmployeeOffline.businessPhoneCode; objEmpOffline.businessPhone = newEmployeeOffline.businessPhone; objEmpOffline.designation = ""; ////objEmpOffline.state = Convert.ToString(newEmployeeOffline.state); ////objEmpOffline.city = Convert.ToString(newEmployeeOffline.city); ////objEmpOffline.area = Convert.ToString(newEmployeeOffline.area); objEmpOffline.addressLine1 = newEmployeeOffline.addressLine1; objEmpOffline.salary = newEmployeeOffline.salary; objEmpOffline.userName = newEmployeeOffline.userName; ////objEmpOffline.role = newEmployeeOffline.empRoleArray; ////objEmpOffline.active = newEmployeeOffline.active; objEmpOffline.synced = _synced; // i.e. Need to synced when online and Update the synced status = "True" db.RunInTransaction(() => { db.Update(objEmpOffline); }); } } result = true; }//try catch (Exception ex) { }//catch return result; }