Ejemplo n.º 1
0
        public void SaveData(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(userName.Text))
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please fill in the Costumers Name");
                return;
            }
            if (patientID == "" || thisIDIsSaved)
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "This Patient is already saved, please generate a new Patient ID");
                return;
            }
            string URI        = "http://jubeeapps.000webhostapp.com/workNew/savelist2.php";
            string Parameters = "name=" + Uri.EscapeDataString(userName.Text) + "&numID=" + patientID;

            using (WebClient wc = new WebClient())
            {
                try
                {
                    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                    string HtmlResult = wc.UploadString(URI, Parameters);
                }
                catch (WebException)
                {
                    MessageBoxEx1.Show(new MainWindow().Wind(), "CONNECTION ERROR: Check your internet connection");
                    return;
                }
            }
            info1.Text    = "This User's ID is " + patientID;
            patientID     = "";
            thisIDIsSaved = true;
            Settings.Default.IDIsSaved = true;
            Settings.Default.Save();
            MessageBoxEx1.Show(new MainWindow().Wind(), "Patient details has been saved!");
        }
Ejemplo n.º 2
0
        private void GenerateID(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(userName.Text))
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please fill in the Costumers Name");
                return;
            }
            if (patientID != "" && !thisIDIsSaved)
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please save this Patient ID");
                return;
            }
            string resultNum  = "";
            string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            Random rnd        = new Random();

            for (int i = 0; i < 9; i++)
            {
                resultNum = resultNum + characters[rnd.Next(62)];
            }
            info1.Text    = "Generated ID is " + resultNum;
            patientID     = resultNum;
            info2.Text    = resultNum;
            thisIDIsSaved = false;
            Settings.Default.IDIsSaved = false;
            Settings.Default.IDSetting = resultNum;
            Settings.Default.Save();
            MessageBoxEx1.Show(new MainWindow().Wind(), "Patient ID has been generated");
        }
Ejemplo n.º 3
0
 public void CopyToClipBoard(object sender, RoutedEventArgs e)
 {
     if (info2.Text != "")
     {
         System.Windows.Clipboard.SetText(patientID);
         MessageBoxEx1.Show(new MainWindow().Wind(), "Patient ID copied to clipboard");
         return;
     }
     MessageBoxEx1.Show(new MainWindow().Wind(), "Nothing to copy!");
 }
Ejemplo n.º 4
0
        public void ShowPreviousBalance(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ID.Text))
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please fill in the Patient's ID");
                return;
            }

            DisplayPatientDetails(GetPatientDetails(), false);
        }
Ejemplo n.º 5
0
        public void AddAmountToDB(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ID.Text))
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please fill in the Patient's ID");
                return;
            }
            if (string.IsNullOrWhiteSpace(Amount.Text))
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "Please fill in the amount to add");
                return;
            }

            DisplayPatientDetails(GetPatientDetails(), true);
        }
Ejemplo n.º 6
0
        public JArray GetPatientDetails()
        {
            string URI        = "http://jubeeapps.000webhostapp.com/workNew/checkID2.php";
            string Parameters = "ID=" + Uri.EscapeDataString(ID.Text);
            string HtmlResult = "";

            using (WebClient wc = new WebClient())
            {
                wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                try
                {
                    HtmlResult = wc.UploadString(URI, Parameters);
                }
                catch (WebException)
                {
                    MessageBoxEx1.Show(new MainWindow().Wind(), "CONNECTION ERROR: Check your internet connection");
                    string[] connectionE     = new string[1]; connectionE[0] = "NULL";
                    string   connectionError = JsonConvert.SerializeObject(connectionE);
                    return(JArray.Parse(connectionError));
                }
            }
            return(JArray.Parse(HtmlResult));
        }
Ejemplo n.º 7
0
        public void DisplayPatientDetails(JArray patientDetailsTmp, Boolean checkTotal)
        {
            if (patientDetailsTmp[0].ToString() == "Nothing")
            {
                MessageBoxEx1.Show(new MainWindow().Wind(), "This ID does not exist in our system!");
                return;
            }
            else if (patientDetailsTmp[0].ToString() == "NULL")
            {
                return;
            }
            var patientDetails = patientDetailsTmp[1];

            PatientName.Text        = "NAME :  " + patientDetails[0][0];
            PatientID.Text          = "ID :  " + patientDetails[0][1];
            Balance.Text            = "LAST BALANCE :  ₦" + patientDetails[0][2];
            PatientTotal.Visibility = Visibility.Collapsed;
            AmtNow.Visibility       = Visibility.Collapsed;
            if (checkTotal)
            {
                PatientTotal.Visibility = Visibility.Visible;
                AmtNow.Visibility       = Visibility.Visible;
                AmtNow.Text             = "TODAYS PURCHASE :  Data error";
                PatientTotal.Text       = "TOTAL :  Data error";
                if (!string.IsNullOrWhiteSpace(Amount.Text))
                {
                    for (int i = 0; i < Amount.Text.Length; i++)
                    {
                        if (!Char.IsDigit(Amount.Text[i]))
                        {
                            MessageBoxEx1.Show(new MainWindow().Wind(), "Only numbers are required to fill a purchase!");
                            return;
                        }
                    }
                    AmtNow.Text = "TODAYS PURCHASE :  ₦" + Amount.Text;
                    int totalAmount = Convert.ToInt32(Amount.Text) + Convert.ToInt32(patientDetails[0][2]);
                    PatientTotal.Text = "TOTAL :  ₦" + totalAmount.ToString();

                    string URI;
                    string Parameters;
                    string HtmlResult;
                    URI        = "http://jubeeapps.000webhostapp.com/workNew/savepurchase.php";
                    Parameters = "ID=" + Uri.EscapeDataString(ID.Text) + "&Amt=" + Amount.Text;
                    using (WebClient wc = new WebClient())
                    {
                        try
                        {
                            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                            HtmlResult = wc.UploadString(URI, Parameters);
                        }
                        catch (WebException)
                        {
                            MessageBoxEx1.Show(new MainWindow().Wind(), "Purchase was not saved. CONNECTION ERROR: " +
                                               "Check your internet connection");
                            AmtNow.Text       = "TODAYS PURCHASE :  Error";
                            PatientTotal.Text = "TOTAL :  Error";
                            return;
                        }
                    }
                }
                MessageBoxEx1.Show(new MainWindow().Wind(), "Patient purchase successfully updated!");
                return;
            }
            MessageBoxEx1.Show(new MainWindow().Wind(), "Patient purchase statement loaded");
        }