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 UpdateEmployee(Class_Employee ce)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (var db = new MySQLBase.MySQL_Model())
                    {
                        var original = db.employees.Find(ce.empID);
                        if (original != null)
                        {
                            original.counterNo = ce.counterNo;
                            original.empID = ce.empID;
                            original.empName = ce.empName;
                        }
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(ce);
                    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.DBemployees.Find(ce.empID);
                        if (original != null)
                        {
                            original.counterNo = ce.counterNo;
                            original.empID = ce.empID;
                            original.empName = ce.empName;
                        }
                        db.SaveChanges();
                    }
                }
            }
            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 UpdateMySQL()
        {
            try
            {

                using (MySQLBase.MySQL_Model db = new MySQLBase.MySQL_Model())
                {
                    string sFilePath = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    System.IO.StreamReader or = new System.IO.StreamReader(sFilePath);
                    do
                    {
                        qtype = or.ReadLine();
                        if (qtype == "Insert")
                        {
                            var p1 = new MySQLBase.patient
                            {
                                patientNo = Convert.ToInt32(or.ReadLine()),
                                PatientName = or.ReadLine(),
                                age = Convert.ToInt32(or.ReadLine()),
                                sex = or.ReadLine(),
                                address = or.ReadLine(),
                                regDate = Convert.ToDateTime(or.ReadLine()).Date,
                                disDate = Convert.ToDateTime(or.ReadLine()).Date,
                                remarks = or.ReadLine(),
                                empID = Convert.ToInt32(or.ReadLine())
                            };
                            db.patients.Add(p1);
                            db.SaveChanges();
                        }
                        else if (qtype == "Update")
                        {
                            var original = db.patients.Find(Convert.ToInt32(or.ReadLine()));
                            if (original != null)
                            {
                                original.patientNo = Convert.ToInt32(or.ReadLine());
                                original.PatientName = or.ReadLine();
                                original.age = Convert.ToInt32(or.ReadLine());
                                original.address = or.ReadLine();
                                original.sex = or.ReadLine();
                                original.regDate = Convert.ToDateTime(or.ReadLine()).Date;
                                original.disDate = Convert.ToDateTime(or.ReadLine()).Date;
                                original.remarks = or.ReadLine();
                            }
                            db.SaveChanges();
                        }
                    } while (qtype != null);
                    or.Close();
                }
                return "done";

            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                return "notdone    " + ex.Message;
            }
        }
        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 InsertNewTest(Class_Test ct)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (MySQLBase.MySQL_Model db = new MySQLBase.MySQL_Model())
                    {
                        var t = new MySQLBase.test
                        {
                            patientNo = ct.patientNo,
                            testdate = ct.testdate,
                            testhead = ct.testhead,
                            amount = ct.amount,
                            remarks = ct.remarks
                        };
                        db.tests.Add(t);
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(ct);
                    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 t = new SQL2008.DBtest
                        {
                            patientNo = ct.patientNo,
                            testdate = ct.testdate,
                            testhead = ct.testhead,
                            amount = ct.amount,
                            remarks = ct.remarks
                        };
                        db.DBtests.Add(t);
                        db.SaveChanges();
                    }
                    return "done";
                }
            }

            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";
        }
        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";
        }
        public string InsertNewDoctor(Class_Doctor da)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (MySQLBase.MySQL_Model db = new MySQLBase.MySQL_Model())
                    {
                        var d = new MySQLBase.doctor
                        {
                            docID = da.docID,
                            docName = da.docName,
                            address = da.address,
                            contact = da.contact,
                            faculty = da.faculty
                        };
                        db.doctors.Add(d);
                        db.SaveChanges();
                    }
                }
                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(da);
                    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 d = new SQL2008.DBdoctor
                        {
                            docID = da.docID,
                            docName = da.docName,
                            address = da.address,
                            contact = da.contact,
                            faculty = da.faculty
                        };
                        db.DBdoctors.Add(d);
                        db.SaveChanges();
                    }
                }
            }
            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";
        }
        public string InsertNewChecking(Class_Checking cc)
        {
            checkDB();
            try
            {
                if (mysql == true)
                {
                    using (MySQLBase.MySQL_Model db = new MySQLBase.MySQL_Model())
                    {
                        var c = new MySQLBase.checking
                        {
                            docID = cc.docID,
                            patientNo = cc.patientNo,
                            checkDate = cc.checkdate,
                            fee = cc.fee,
                            remarks = cc.remarks
                        };
                        db.checkings.Add(c);
                        db.SaveChanges();
                    }
                }

                else
                {
                    string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt";
                    string sDateTime = GetLogFor(cc);
                    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 c = new SQL2008.DBchecking
                        {
                            docID = cc.docID,
                            patientNo = cc.patientNo,
                            checkDate = cc.checkdate,
                            fee = cc.fee,
                            remarks = cc.remarks
                        };
                        db.DBcheckings.Add(c);
                        db.SaveChanges();
                    }
                }
            }

            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";
        }