public MainWindow() { InitializeComponent(); loginFrame = new LoginFrame(); UtilProvider.initMainFrame(mainFrame); mainFrame.Navigate(loginFrame); }
public async void editData(TextBox id_transaksi, TextBox alamat_pembeli, TextBox namaPembeli, TextBox totalHarga) { ApiClient client = UtilProvider.getSession().getClient(); var request = new ApiRequestBuilder(); MessageBox.Show(id.ToString()); String URL = "transaction/" + id; var req = request .buildHttpRequest() .setEndpoint(URL) .addParameters("price", totalHarga.Text) .addParameters("amount", transaction.getAmount().ToString()) .setRequestMethod(HttpMethod.Put); client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken()); var response = await client.sendRequest(request.getApiRequestBundle()); Console.WriteLine(response.getHttpResponseMessage().ToString()); if (response.getHttpResponseMessage().ReasonPhrase.Equals("Created")) { MessageBox.Show("Edited"); UserCredential userCredential = response.getParsedObject <UserCredential>(); } else { MessageBox.Show(response.getHttpResponseMessage().ReasonPhrase); } }
private void logout_btn_Click(object sender, RoutedEventArgs e) { UtilProvider.getMainFrame().Navigate(new LoginFrame()); getController().callMethod("OnLogout"); UtilProvider.getSession().logout(); UtilProvider.destroySession(); }
public async void setData(int id, TextBox id_transaksi, TextBox alamat_pembeli, TextBox namaPembeli, TextBox totalHarga) { this.id = id; transaction = UtilProvider.getDataTransaction().getData()[id]; this.id = transaction.getId(); id_transaksi.Text = transaction.getPoNumber(); alamat_pembeli.Text = transaction.getAddress(); namaPembeli.Text = transaction.getCustomerId().ToString(); totalHarga.Text = transaction.price.ToString(); }
public async void OnLogout() { ApiClient client = UtilProvider.getSession().getClient(); var request = new ApiRequestBuilder(); var req = request .buildHttpRequest() .setEndpoint("logout") .setRequestMethod(HttpMethod.Get); client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken()); var response = await client.sendRequest(request.getApiRequestBundle()); }
public async void generateData(DataGrid data_grid_transaction) { if (UtilProvider.getDataTransaction() != null) { List <DataTransaction> data = UtilProvider.getDataTransaction().getData(); List <HistoryData> dataHistory = new List <HistoryData>(); for (int i = 0; i < data.Count(); i++) { String po_number = data.ElementAt(i).getPoNumber(); DateTime date = data.ElementAt(i).getCreatedAt(); Double amount = data.ElementAt(i).getAmount().GetValueOrDefault(); ApiClient client = UtilProvider.getSession().getClient(); var request = new ApiRequestBuilder(); String URL = "user/id/" + data.ElementAt(i).getCustomerId().ToString(); var req = request .buildHttpRequest() .setEndpoint(URL) .setRequestMethod(HttpMethod.Get); client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken()); var response = await client.sendRequest(request.getApiRequestBundle()); String name; String phone; if (response.getHttpResponseMessage().ReasonPhrase.Equals("OK")) { UserCredential userCredential = response.getParsedObject <UserCredential>(); name = userCredential.getData().getFullName(); phone = userCredential.getData().getPhone(); } else { //MessageBox.Show(response.getHttpResponseMessage().ReasonPhrase); phone = name = "unknown"; } dataHistory.Add(new HistoryData(po_number, date, name, phone, amount)); } data_grid_transaction.ItemsSource = dataHistory; } else { MessageBox.Show("Your Outlet never Have any Transaction History"); } }
public void generateChart() { MyList <double> income = new MyList <double>(); for (int i = 0; i < UtilProvider.getDataTransaction().getData().Count; i++) { income.Add(UtilProvider.getDataTransaction().getData().ElementAt(i).getAmount().GetValueOrDefault()); } myLineChart = builderChart.activate(this, "monthly_chart") .addSeries("Income", income) .changeSeriesFillColor("Income", "#80bfff"); generateEarnings(income); }
private void cleanData(Transaction transaction) { for (int i = 0; i < transaction.getData().Count; i++) { if (transaction.getData().ElementAt(i).getStatus() == null) { transaction.getData().ElementAt(i).setStatus("Calculating"); } Double?amount = transaction.getData().ElementAt(i).getAmount(); Double?price = transaction.getData().ElementAt(i).getPrice(); if (amount == null) { transaction.getData().ElementAt(i).setAmount(0); } if (price == null) { transaction.getData().ElementAt(i).setPrice(0.0); } } UtilProvider.initDataTransaction(transaction); UtilProvider.initDataTransaction(transaction); getView().callMethod("generateChart"); }
public async void generateTransactionData() { ApiClient client = UtilProvider.getSession().getClient(); var request = new ApiRequestBuilder(); String URL = "transaction/owner/" + UtilProvider.getSession().getUser().getData().getId(); var req = request .buildHttpRequest() .setEndpoint(URL) .setRequestMethod(HttpMethod.Get); client.setAuthorizationToken(UtilProvider.getSession().getUser().getData().getToken()); var response = await client.sendRequest(request.getApiRequestBundle()); if (response.getHttpResponseMessage().ReasonPhrase.Equals("OK")) { Transaction transaction = response.getParsedObject <Transaction>(); cleanData(transaction); } else { MessageBox.Show("Your Outlet never Have any Transaction"); } }
private void dashboard_btn_Click(object sender, RoutedEventArgs e) { UtilProvider.getMainFrame().Navigate(new DashboardFrame()); }
private void history_btn_Click(object sender, RoutedEventArgs e) { UtilProvider.getMainFrame().Navigate(new HistoryFrame()); }
private void Row_DoubleClick(object sender, MouseButtonEventArgs s) { int currentIndex = data_grid_transaction.Items.IndexOf(data_grid_transaction.CurrentItem); UtilProvider.getMainFrame().Navigate(new HistoryDetailFrame(currentIndex)); }
public void redirectToDashboard() { UtilProvider.getMainFrame().Navigate(new DashboardFrame()); }
public async void OnLogin(string username, string password) { ApiClient client = new ApiClient("https://api.cuci-in.me/api/auth/"); var request = new ApiRequestBuilder(); var req = request .buildHttpRequest() .addParameters("username", username) .addParameters("password", password) .setEndpoint("login") .setRequestMethod(HttpMethod.Post); var response = await client.sendRequest(request.getApiRequestBundle()); if (response.getHttpResponseMessage().ReasonPhrase != null) { if (response.getHttpResponseMessage().ReasonPhrase.Equals("OK")) { //assigning json object to User Model User user = response.getParsedObject <User>(); //Set Endpoint String ownerEndPoint = "owner/user_id/" + user.getData().getId().ToString(); //Request for owner id var reqOwner = request .buildHttpRequest() .setEndpoint(ownerEndPoint) .setRequestMethod(HttpMethod.Get); client.setAuthorizationToken(user.getData().getToken()); var responseOnOwner = await client.sendRequest(request.getApiRequestBundle()); if (responseOnOwner.getHttpResponseMessage().ReasonPhrase.Equals("OK")) { //assigning owner object to owner model Owner owner = responseOnOwner.getParsedObject <Owner>(); UtilProvider.initSession(user, owner, client); getView().callMethod("redirectToDashboard"); } else if (responseOnOwner.getHttpResponseMessage().ReasonPhrase.Equals("Not Found")) { MessageBox.Show("Your Account has Not Registered as Owner"); } else { MessageBox.Show(responseOnOwner.getHttpResponseMessage().ReasonPhrase); } } else if (response.getHttpResponseMessage().ReasonPhrase.Equals("Unauthorized")) { MessageBox.Show(FAILED_MESSAGE); } else { MessageBox.Show(response.getHttpResponseMessage().ReasonPhrase); } } else { MessageBox.Show("Check Your Internect Connection"); } }