コード例 #1
0
        private void sign_out_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            startupscreen s1 = new startupscreen();

            s1.Show();
            this.Close();
        }
コード例 #2
0
        private void SDELETE_Click(object sender, RoutedEventArgs e)
        {
            bool success = connect.CheckForInternetConnection();

            if (success)
            {
                if (sdatagrid.Items.Count > 1)
                {
                    dynamic  list   = sdatagrid.SelectedItems[0];
                    string[] detail = connect.details.Split('\n');
                    string[] phone1 = detail[1].Split(':');
                    string   ms     = "Do you want to delete \ndashboard user name: " + list.name;
                    var      dialog = new MyDialog("DELETE DASHBOARD USER", ms);
                    dialog.Show();
                    dialog.Closing += async(sender1, e1) =>
                    {
                        var d = sender1 as MyDialog;
                        if (!d.Canceled)
                        {
                            try
                            {
                                if (phone1[1] == list.phone_no)
                                {
                                    MainWindow.t.Stop();
                                }
                                var response = await connect.client.DeleteAsync(connect.as_delete_url + "/" + list.phone_no);

                                var responseString = await response.Content.ReadAsStringAsync();

                                if (connect.IsValidJson(responseString))
                                {
                                    var obj = JObject.Parse(responseString);
                                    if (string.Equals(obj["status"].ToString(), "true", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        Mouse.OverrideCursor = Cursors.Arrow;
                                        if (phone1[1] == list.phone_no)
                                        {
                                            var w = Application.Current.Windows[0];
                                            w.Hide();

                                            startupscreen s1 = new startupscreen();
                                            s1.Show();
                                            w.Close();
                                        }
                                        else
                                        {
                                            MainWindow.t.Start();
                                            MessageBox.Show("DASHBOARD USER DELETED");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("NO RESPONSE");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("DASHBOARD USER NOT DELETED" + responseString);
                                }
                                sdatagrid.ItemsSource = null;
                                software_get();
                                clear();
                            }
                            catch (Exception m)
                            {
                                MessageBox.Show(m.Message);
                            }
                        }
                    };
                }
                else
                {
                    MessageBox.Show("User count cannot be less than one");
                }
            }
        }