private void DelExecute(object parameter)
        {
            if (Selected_Patient.Id == "")
            {
                Error = "Select Item to be deleted.";
            }
            else
            {
                glob_id = Selected_Patient.Id;
                Console.WriteLine("hehehe");
                //var itemToRemove = display_data.Single(r => r.Id == Selected_Patient.Id);
                //display_data.Remove(itemToRemove);
                Flag = 1;
                display_data.Remove(Selected_Patient);
                Console.WriteLine("fefef");
                var itemToRemove2 = main_data.Single(r => r.Id == glob_id);
                main_data.Remove(itemToRemove2);
                overwrite();
                ErrorPos = "67,0,0,480";
                Error    = "Deletion Successful";

                Add_Update       = "Add";
                Selected_Patient = new Patient {
                    Mobile = "", Id = "", Fname = ""
                };
                PatientRecord_data = new Patient_Record {
                    Email = "", Lname = "", Mobile = "", DOB = "", Id = ""
                };
            }

            //Thread.Sleep(1000);
        }
        private void AddExecute(object parameter)
        {
            //Person obj = new Person();
            var passwordBox = parameter as PasswordBox;
            var password    = passwordBox.Password;

            Console.WriteLine(password);
            if (checkDuplicate(PatientRecord_data.Fname, PatientRecord_data.Lname, PatientRecord_data.Email, PatientRecord_data.Mobile))
            {
                PatientRecord_data.Id = DateTime.Now.ToString("ddMMyyyyHHmmss");
                main_data.Add(PatientRecord_data);
                Patient temp_p = new Patient();
                temp_p.Fname  = PatientRecord_data.Fname;
                temp_p.Mobile = PatientRecord_data.Mobile;
                temp_p.Id     = PatientRecord_data.Id;
                display_data.Add(temp_p);
                if (Add_Update == "Add")
                {
                    string str = PatientRecord_data.Id + "#" + PatientRecord_data.Fname + "#" + PatientRecord_data.Lname + "#" + PatientRecord_data.Email + "#" + PatientRecord_data.Mobile + "#" + PatientRecord_data.DOB;
                    File.AppendAllText(@"D:\file.txt", str + Environment.NewLine);
                    ErrorPos = "67,0,0,480";
                    Error    = "Registered Successfully!";
                }
                else
                {
                    glob_id = Selected_Patient.Id;
                    Console.WriteLine("hehehe2");
                    //var itemToRemove = display_data.Single(r => r.Id == Selected_Patient.Id);
                    //display_data.Remove(itemToRemove);
                    Flag = 1;
                    display_data.Remove(Selected_Patient);
                    Console.WriteLine("fefef2");
                    var itemToRemove2 = main_data.Single(r => r.Id == glob_id);
                    main_data.Remove(itemToRemove2);
                    overwrite();
                    ErrorPos = "67,0,0,480";
                    Error    = "Record Updated.";

                    Add_Update       = "Add";
                    Selected_Patient = new Patient {
                        Mobile = "", Id = "", Fname = ""
                    };
                    PatientRecord_data = new Patient_Record {
                        Email = "", Lname = "", Mobile = "", DOB = "", Id = ""
                    };
                }
                PatientRecord_data = new Patient_Record();
            }
            else
            {
                return;
            }
            //Thread.Sleep(1000);
        }
 private void RegExecute(object parameter)
 {
     Selected_Patient = new Patient {
         Mobile = "", Id = "", Fname = ""
     };
     PatientRecord_data = new Patient_Record {
         Email = "", Lname = "", Mobile = "", DOB = "", Id = ""
     };
     Error      = "";
     ErrorPos   = "67,0,0,480";
     Add_Update = "Add";
     //Thread.Sleep(1000);
 }
 public PersonViewModel()
 {
     ErrorPos = "67,0,0,480";
     Flag     = 0;
     //SQLiteConnection conn = new SQLiteConnection("Data Source=Patients.db");
     Selected_Patient = new Patient {
         Fname = "", Id = "", Mobile = ""
     };
     Error              = "";
     Add_Update         = "Add";
     PatientRecord_data = new Patient_Record {
         Email = "", DOB = "", Fname = "", Id = "", Lname = "", Mobile = ""
     };
     display_data = new ObservableCollection <Patient>();
     main_data    = new List <Patient_Record>();
     ReadFile();
 }
        void ReadFile()
        {
            string text2 = System.IO.File.ReadAllText(@"D:\file.txt");
            // string ln = "";
            var temp_da = text2.Split('\n');

            for (int i = 0; i < temp_da.Length - 1; i++)
            {
                var     spdata = temp_da[i].Split('#');
                Patient temp_p = new Patient();
                temp_p.Fname = spdata[1]; temp_p.Id = spdata[0]; temp_p.Mobile = spdata[4];
                //System.Console.WriteLine(temp_p.Fname + " " + temp_p.Id + " " + temp_p.Mobile);
                display_data.Add(temp_p);
                Patient_Record temp_pt = new Patient_Record();
                temp_pt.Fname = spdata[1]; temp_pt.Id = spdata[0]; temp_pt.Mobile = spdata[4];
                temp_pt.Lname = spdata[2]; temp_pt.DOB = spdata[5]; temp_pt.Email = spdata[3];
                main_data.Add(temp_pt);
            }
        }