public Class_Patient Find(int id)
        {
            Class_Patient p = new Class_Patient();
            if (isMySqlOnline())
            {
                using (var db = new MySQLBase.MySQL_Model())
                {
                    try
                    {

                        var query = from p1 in db.patients
                                    where p1.patientNo.Equals(id)
                                    select p1;

                        foreach (var item in query)
                        {
                            p.patientNo = item.patientNo;
                            p.patientName = item.PatientName;
                            p.Paddress = item.address;
                            p.Psex = item.sex;
                            p.PregDate = item.regDate;
                            p.PdisDate = item.disDate;
                            p.PempID = item.empID;
                            p.Page = Convert.ToInt32(item.age);
                        }

                    }
                    catch (Exception)
                    {
                        //MessageBox.Show("NO DATA FOUND");
                    }
                }
            }
              else if (isSql2008Online())
                    {
                        using (var db = new SQL2008.hospitalEntities())
                        {
                            try
                            {
                                var query = from p1 in db.DBpatients
                                            where p1.patientNo.Equals(id)
                                            select p1;
                                foreach (var item in query)
                                {
                                    p.patientNo = item.patientNo;
                                    p.patientName = item.PatientName;
                                    p.Paddress = item.address;
                                    p.Psex = item.sex;
                                    p.PregDate = item.regDate;
                                    p.PdisDate = item.disDate;
                                    p.PempID = item.empID;
                                    p.Page = Convert.ToInt32(item.age);
                                }
                            }
                            catch (Exception)
                            {
                                //MessageBox.Show("NO DATA FOUND");
                            }
                        }
                    }
            else
            {

            }

            return p;
        }
        public string UpdatePatient(Class_Patient pa)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (var db = new MySQLBase.MySQL_Model())
                    {
                        var original = db.patients.Find(pa.patientNo);
                        if (original != null)
                        {
                            original.PatientName = pa.patientName;
                            original.remarks = pa.Premarks;
                            original.regDate = pa.PregDate;
                            original.age = pa.Page;
                            original.disDate = pa.PdisDate;
                            original.empID = pa.PempID;
                            original.sex = pa.Psex;
                            original.address = pa.Paddress;
                        }

                        db.SaveChanges();
                    }
                }

                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(pa);
                    sDateTime.Remove((sDateTime.Length - 2), 1);
                    System.IO.StreamWriter oFileWriter = new System.IO.StreamWriter(sFilePath1, true);
                    oFileWriter.WriteLine("Insert");
                    oFileWriter.WriteLine(sDateTime);
                    oFileWriter.Close();
                }

                if (sql2008 == true)
                {

                    using (var db = new SQL2008.hospitalEntities())
                    {
                        var original = db.DBpatients.Find(pa.patientNo);
                        if (original != null)
                        {
                            original.PatientName = pa.patientName;
                            original.remarks = pa.Premarks;
                            original.regDate = pa.PregDate;
                            original.age = pa.Page;
                            original.disDate = pa.PdisDate;
                            original.empID = pa.PempID;
                            original.sex = pa.Psex;
                            original.address = pa.Paddress;
                        }
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\SQL2008.txt";
                    string sDateTime = GetLogFor(pa);
                    sDateTime.Remove((sDateTime.Length - 2), 1);
                    System.IO.StreamWriter oFileWriter = new System.IO.StreamWriter(sFilePath1, true);
                    oFileWriter.WriteLine("Insert");
                    oFileWriter.WriteLine(sDateTime);
                    oFileWriter.Close();
                }
            }

            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        return "Property: " + validationError.PropertyName + "Error: " + validationError.ErrorMessage;
                    }
                }
            }
            catch (Exception e)
            {
                return "not done" + e.Message;
            }
            return "hell";
        }
        public string InsertNewPatients(Class_Patient pa)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (MySQLBase.MySQL_Model db = new MySQLBase.MySQL_Model())
                    {
                        var p = new MySQLBase.patient
                        {
                            patientNo = pa.patientNo,
                            PatientName = pa.patientName,
                            age = pa.Page,
                            sex = pa.Psex,
                            address = pa.Paddress,
                            regDate = pa.PregDate.Date,
                            disDate = pa.PdisDate.Date,
                            remarks = pa.Premarks,
                            empID = pa.PempID,
                        };
                        db.patients.Add(p);
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(pa);
                    sDateTime.Remove((sDateTime.Length - 2), 1);
                    System.IO.StreamWriter oFileWriter = new System.IO.StreamWriter(sFilePath1, true);
                    oFileWriter.WriteLine("Insert");
                    oFileWriter.WriteLine(sDateTime);
                    oFileWriter.Close();
                }

                if (sql2008 == true)
                {
                    using (SQL2008.hospitalEntities db = new SQL2008.hospitalEntities())
                    {
                        var p = new SQL2008.DBpatient
                        {
                            patientNo = pa.patientNo,
                            PatientName = pa.patientName,
                            age = pa.Page,
                            sex = pa.Psex,
                            address = pa.Paddress,
                            regDate = pa.PregDate,
                            disDate = pa.PdisDate,
                            remarks = pa.Premarks,
                            empID = pa.PempID,
                        };
                        db.DBpatients.Add(p);
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\SQL2008.txt";
                    string sDateTime = GetLogFor(pa);
                    sDateTime.Remove((sDateTime.Length - 2), 1);
                    System.IO.StreamWriter oFileWriter = new System.IO.StreamWriter(sFilePath1, true);
                    oFileWriter.WriteLine("Insert");
                    oFileWriter.WriteLine(sDateTime);
                    oFileWriter.Close();
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        return "Property: " + validationError.PropertyName + "Error: " + validationError.ErrorMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                return "not done" + ex.Message;
            }

            return "hell";
        }