Esempio n. 1
0
        private void info_but_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new MyDialog("User details", connect.details);

            dialog.Show();
            dialog.Closing += (sender1, e1) =>
            {
                var d = sender1 as MyDialog;
                if (!d.Canceled)
                {
                }
            };
        }
        private void DELETE_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dynamic list   = customer_grid.SelectedItems[0];
                string  ms     = "Do you want to delete \n customer: " + list.customer_name;
                var     dialog = new MyDialog("DELETE CUSTOMER", ms);
                dialog.Show();
                dialog.Closing += async(sender1, e1) =>
                {
                    var d = sender1 as MyDialog;
                    if (!d.Canceled)
                    {
                        try
                        {
                            var response = await connect.client.DeleteAsync(connect.customer_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))
                                {
                                    MessageBox.Show("CUSTOMER DELETED");
                                }
                                else
                                {
                                    MessageBox.Show("CUSTOMER NOT DELETED\nMESSAGE:" + obj["data"].ToString());
                                }
                                customer_grid.ItemsSource = null;
                                get_cust();
                                clear();
                            }
                            else
                            {
                                MessageBox.Show("NO RESPONSE");
                            }
                        }
                        catch (Exception m)
                        {
                            MessageBox.Show(m.Message);
                        }
                    }
                };
            }
            catch (Exception m)
            {
                MessageBox.Show(m.Message);
            }
        }
Esempio n. 3
0
        private void DELETE_Click(object sender, RoutedEventArgs e)
        {
            bool success = connect.CheckForInternetConnection();

            if (success)
            {
                dynamic list   = adatagrid.SelectedItems[0];
                string  ms     = "Do you want to delete \nandroid user name: " + list.name;
                var     dialog = new MyDialog("DELETE ANDROID USER", ms);
                dialog.Show();
                dialog.Closing += async(sender1, e1) =>
                {
                    var d = sender1 as MyDialog;
                    if (!d.Canceled)
                    {
                        try
                        {
                            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))
                                {
                                    MessageBox.Show("ANDROID USER DELETED");
                                }
                                else
                                {
                                    MessageBox.Show("ANDROID USER NOT DELETED" + responseString);
                                }
                                adatagrid.ItemsSource = null;
                                android_no_get();
                                clear();
                            }
                            else
                            {
                                MessageBox.Show("NO RESPONSE");
                            }
                        }
                        catch (Exception m)
                        {
                            MessageBox.Show(m.Message);
                        }
                    }
                };
            }
        }
Esempio n. 4
0
        public void msg(string f, string t)
        {
            string ms     = "DATE:\n from: " + f + "\n to: " + t;
            var    dialog = new MyDialog("REPORT GENERATION", ms);

            dialog.Show();
            dialog.Closing += (sender, e) =>
            {
                var d = sender as MyDialog;
                if (!d.Canceled)
                {
                    bool suc = software_get(f, t);
                    if (suc)
                    {
                        MessageBox.Show("Report generated");
                    }
                    else
                    {
                        MessageBox.Show("Report not generated");
                    }
                }
            };
        }
        private void editpro_but_Click(object sender, RoutedEventArgs e)
        {
            if (connect.CheckForInternetConnection())
            {
                editpro_but.IsEnabled = false;
                try
                {
                    if ((cus_tphone.Text == "Phone number"))
                    {
                        MessageBox.Show("PLEASE ENTER THE PHONE NUMBER");
                    }
                    else
                    {
                        if (head_box.Text == "EDIT CUSTOMER")
                        {
                            string ms     = "Do you want to EDIT \n customer ph no: " + ph;
                            var    dialog = new MyDialog("EDIT CUSTOMER", ms);
                            dialog.Show();
                            dialog.Closing += async(sender1, e1) =>
                            {
                                var d = sender1 as MyDialog;
                                if (!d.Canceled)
                                {
                                    if (cus_name.Text == "Customer name")
                                    {
                                        cus_name.Text = "nil";
                                    }
                                    if (cus_shop.Text == "Shop name")
                                    {
                                        cus_shop.Text = "nil";
                                    }
                                    if (cus_reg.Text == "GST number")
                                    {
                                        cus_reg.Text = "nil";
                                    }
                                    if (cus_address.Text == "Full address")
                                    {
                                        cus_address.Text = "nil";
                                    }
                                    if (cus_email.Text == "E-mail")
                                    {
                                        cus_email.Text        = "";
                                        email_st.Text         = "";
                                        cus_email.BorderBrush = new SolidColorBrush(Colors.White);
                                    }
                                    if (cus_fax.Text == "Fax")
                                    {
                                        cus_fax.Text = "nil";
                                    }
                                    var final_val = new Dictionary <string, Dictionary <string, string> >
                                    {
                                        { "customer", new Dictionary <string, string> {
                                              { "name", cus_name.Text },
                                              { "shop_name", cus_shop.Text },
                                              { "gst_no", cus_reg.Text },
                                              { "address", cus_address.Text },
                                              { "phone", cus_tphone.Text },
                                              { "fax", cus_fax.Text },
                                              { "email", cus_email.Text }
                                          } }
                                    };

                                    string json     = JsonConvert.SerializeObject(final_val);
                                    var    response = await connect.client.PutAsync(connect.customer_url + "/" + ph, new StringContent(json, Encoding.UTF8, "application/json"));

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

                                    if (connect.IsValidJson(responseString))
                                    {
                                        var obj = JObject.Parse(responseString);
                                        if (string.Equals(obj["status"].ToString(), "true", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            MessageBox.Show("CUSTOMER EDITED");
                                        }
                                        else
                                        {
                                            MessageBox.Show("CUSTOMER NOT EDITED\nMESSAGE:" + obj["data"].ToString());
                                        }
                                        customer_grid.ItemsSource = null;
                                        get_cust();
                                        clear();
                                    }
                                    else
                                    {
                                        MessageBox.Show("NO RESPONSE");
                                    }
                                }
                            };
                        }
                    }
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message);
                }
                editpro_but.IsEnabled = true;
            }
        }
Esempio n. 6
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");
                }
            }
        }
Esempio n. 7
0
        private void editpro_but_Click(object sender, RoutedEventArgs e)
        {
            bool success = connect.CheckForInternetConnection();


            if (success)
            {
                editpro_but.IsEnabled = false;
                if (aname_text.Text == "Name" || aphone_text.Text == "Phone number" || aemail_text.Text == "E-mail id" || (adest_text.Text == "Destination" && adesign_text.Text == "Designation") || connect.valid_email(aemail_text.Text) != true)
                {
                    MessageBox.Show("Invalid fields");
                }
                else
                {
                    ph = aphone_text.Text;
                    string val = adesign_text.Text;

                    string head = "dashboard", head_json = "admin";
                    if (head_box.Text == "EDIT APP USER")
                    {
                        head = "android"; head_json = "user";
                        val  = adest_text.Text;
                    }
                    string ms     = "Do you want to edit \n " + head + " user\n phone number: " + ph;
                    var    dialog = new MyDialog("EDIT " + head.ToUpper() + " USER", ms);
                    dialog.Show();
                    dialog.Closing += async(sender1, e1) =>
                    {
                        var d = sender1 as MyDialog;
                        if (!d.Canceled)
                        {
                            try
                            {
                                var final_val = new Dictionary <string, Dictionary <string, string> >
                                {
                                    { "user", new Dictionary <string, string> {
                                          { "first_name", aname_text.Text },
                                          { "email", aemail_text.Text },
                                          { "location", val },
                                          { "role", head_json }
                                      } }
                                };


                                string json     = JsonConvert.SerializeObject(final_val);
                                var    response = await connect.client.PutAsync(connect.as_add_url + "/" + ph, new StringContent(json, Encoding.UTF8, "application/json"));

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

                                if (connect.IsValidJson(responseString))
                                {
                                    var obj = JObject.Parse(responseString);
                                    if (string.Equals(obj["status"].ToString(), "true", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        MessageBox.Show(head.ToUpper() + " USER EDITED");
                                    }
                                    else
                                    {
                                        MessageBox.Show(head.ToUpper() + " USER NOT EDITED" + responseString);
                                    }
                                    switch (head)
                                    {
                                    case "android":
                                        adatagrid.ItemsSource = null;
                                        android_no_get();
                                        break;

                                    case "dashboard":
                                        sdatagrid.ItemsSource = null;
                                        software_get();
                                        break;
                                    }

                                    clear();
                                }
                                else
                                {
                                    MessageBox.Show("NO RESPONSE");
                                }
                            }catch (Exception m)
                            {
                                MessageBox.Show(m.Message);
                            }
                        }
                    };
                }
                editpro_but.IsEnabled = true;
            }
        }
Esempio n. 8
0
        private void submit_but_Click(object sender, RoutedEventArgs e)
        {
            bool success = connect.CheckForInternetConnection();

            if (success)
            {
                submit_but.IsEnabled = false;
                if (head_box.Text == "ADD APP USER")
                {
                    if (aname_text.Text == "Name" || aphone_text.Text == "Phone number" || aemail_text.Text == "E-mail id" || adest_text.Text == "Destination" || new_pass_box.Password == "" || retype_pass_box.Password == "" || retype_pass_st.Text != "password matched" || connect.valid_email(aemail_text.Text) != true)
                    {
                        MessageBox.Show("Invalid fields");
                    }
                    else
                    {
                        string ms     = "Do you want to add android user \n name: " + aname_text.Text;
                        var    dialog = new MyDialog("ADD ANDROID USER", ms);
                        dialog.Show();
                        dialog.Closing += async(sender1, e1) =>
                        {
                            try
                            {
                                var d = sender1 as MyDialog;
                                if (!d.Canceled)
                                {
                                    if (auser_name.Text == "User name")
                                    {
                                        auser_name.Text = "";
                                    }
                                    var final_val = new Dictionary <string, Dictionary <string, string> >
                                    {
                                        { "user", new Dictionary <string, string> {
                                              { "first_name", aname_text.Text },
                                              { "user_name", auser_name.Text },
                                              { "phone", aphone_text.Text },
                                              { "email", aemail_text.Text },
                                              { "location", adest_text.Text },
                                              { "password", new_pass_box.Password },
                                              { "role", "user" }
                                          } }
                                    };
                                    string json     = JsonConvert.SerializeObject(final_val);
                                    var    response = await connect.client.PostAsync(connect.as_add_url, new StringContent(json, Encoding.UTF8, "application/json"));

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

                                    var obj = JObject.Parse(responseString);
                                    if (string.Equals(obj["status"].ToString(), "true", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        MessageBox.Show("ANDROID USER ADDED");
                                    }
                                    else
                                    {
                                        MessageBox.Show("ANDROID USER NOT ADDED" + responseString);
                                    }

                                    adatagrid.ItemsSource = null;
                                    android_no_get();
                                    clear();
                                }
                            }
                            catch (Exception m)
                            {
                                MessageBox.Show(m.Message);
                            }
                        };
                    }
                }
                else if (head_box.Text == "ADD DASHBOARD USER")
                {
                    if (aname_text.Text == "Name" || aphone_text.Text == "Phone number" || aemail_text.Text == "E-mail id" || auser_name.Text == "User name" || adesign_text.Text == "Designation" || new_pass_box.Password == "" || retype_pass_box.Password == "" || retype_pass_st.Text != "password matched" || connect.valid_email(aemail_text.Text) != true)
                    {
                        MessageBox.Show("Invalid fields");
                    }
                    else
                    {
                        string ms     = "Do you want to add dashboard user \n name: " + aname_text.Text;
                        var    dialog = new MyDialog("ADD DASHBOARD USER", ms);
                        dialog.Show();
                        dialog.Closing += async(sender1, e1) =>
                        {
                            var d = sender1 as MyDialog;
                            if (!d.Canceled)
                            {
                                try
                                {
                                    var final_val = new Dictionary <string, Dictionary <string, string> >
                                    {
                                        { "user", new Dictionary <string, string> {
                                              { "first_name", aname_text.Text },
                                              { "user_name", auser_name.Text },
                                              { "phone", aphone_text.Text },
                                              { "email", aemail_text.Text },
                                              { "location", adesign_text.Text },
                                              { "password", new_pass_box.Password },
                                              { "role", "admin" }
                                          } }
                                    };
                                    string json     = JsonConvert.SerializeObject(final_val);
                                    var    response = await connect.client.PostAsync(connect.as_add_url, new StringContent(json, Encoding.UTF8, "application/json"));

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

                                    if (connect.IsValidJson(responseString))
                                    {
                                        var obj = JObject.Parse(responseString);
                                        if (string.Equals(obj["status"].ToString(), "true", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            MessageBox.Show("DASHBOARD USER ADDED");
                                        }
                                        else
                                        {
                                            MessageBox.Show("DASHBOARD USER NOT ADDED" + responseString);
                                        }
                                        sdatagrid.ItemsSource = null;
                                        software_get();
                                        clear();
                                    }
                                    else
                                    {
                                        MessageBox.Show("NO RESPONSE");
                                    }
                                }catch (Exception m)
                                {
                                    MessageBox.Show(m.Message);
                                }
                            }
                        };
                    }
                }
                submit_but.IsEnabled = true;
            }
        }