public string UpdateDoctor(Class_Doctor doc) { checkDB(); try { if (mysql == true) { using (var db = new MySQLBase.MySQL_Model()) { var original = db.doctors.Find(doc.docID); if (original != null) { original.docID = doc.docID; original.address = doc.address; original.docName = doc.docName; original.contact = doc.contact; original.faculty = doc.faculty; } db.SaveChanges(); } } else { string sFilePath1 = @"C:\Users\Pratik\Desktop\MySQL.txt"; string sDateTime = GetLogFor(doc); 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.DBdoctors.Find(doc.docID); if (original != null) { original.docID = doc.docID; original.address = doc.address; original.docName = doc.docName; original.contact = doc.contact; original.faculty = doc.faculty; } 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 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"; }