//update a doctor public Boolean UpdateDoctor(Doctor doctor) { var result = false; var l = new LoginRequest(); DOCTORS updateDOC = new DOCTORS(); updateDOC.id = doctor.id; updateDOC.native_name = doctor.nativeName; if (LinqToSQL.updateDoc(doctor.id, updateDOC)) result = true; //listd.ForEach(c => //{ // if (c.userName == doctor.userName) // { // listd.Insert(listd.IndexOf(c),doctor); // result = true; // } //}); login.ForEach(c => { if (c.userName == doctor.userName) { l.userName = c.userName; l.password = c.password; login.Insert(login.IndexOf(c), l); } }); return result; }
public static void insert2doctors(DOCTORS newDOCTORS) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); /* * //Create new Doctor * DOCTORS newDOCTORS = new DOCTORS(); * newDOCTORS.id = "001"; * newDOCTORS.user_name = "John"; * newDOCTORS.native_name = "Doc.John"; * newDOCTORS.password = "******"; * newDOCTORS.gender = "M"; * newDOCTORS.age = 23; * newDOCTORS.start_year_of_work = 2014; */ //Add new DOCTORS to database db.DOCTORS.InsertOnSubmit(newDOCTORS); //Save changes to Database. db.SubmitChanges(); //Get new Inserted Employee //DOCTORS insertedEmployee = db.DOCTORS.FirstOrDefault(e => e.user_name.Equals("Michael")); }
public static bool deleteDoc(string str_username) { bool result = false; string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); try { //Get DOCTORS to Delete DOCTORS deleteDoctor = db.DOCTORS.FirstOrDefault(e => e.user_name.Equals(str_username)); //Delete DOCTORS db.DOCTORS.DeleteOnSubmit(deleteDoctor); //Save changes to Database. db.SubmitChanges(); result = true; } catch () { result = false } return(result); }
/// <summary> /// DOCTORS /// </summary> /// public static DOCTORS selectDocByID(string str_id) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); //Get selected user DOCTORS selectDoc = db.DOCTORS.FirstOrDefault(e => e.id.Equals(id)); return(selectDoc); }
//get a doctor by id public Doctor getDoctor(string id) { Doctor p = new Doctor(); DOCTORS selectDoc = LinqToSQL.selectDocByID(id); p.nativeName = selectDoc.native_name; p.userName = selectDoc.user_name; //listd.ForEach(c => { // if (c.id == id) // { // p = c; // return; // } //}); return p; }
//create a doctor public Boolean CreatDoctor(Doctor doctor) { var result = true; if (login.Exists(t => t.userName == doctor.userName)) { result = false; } else { //listd.Add(doctor); DOCTORS newDOC = new DOCTORS(); newDOC.id = doctor.id; newDOC.native_name = doctor.nativeName; LinqToSQL.insert2doctors(newDOC); login.Add(new LoginRequest { userName = doctor.userName, password = doctor.password }); } return result; }
public static bool updateDoc(string str_id, DOCTORS newDOCTORS) { bool result = true; string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); try { //Get DOCTORS for update DOCTORS oldDOCTORS = db.DOCTORS.FirstOrDefault(e => e.id.Equals(str_id)); oldDOCTORS = newDOCTORS; //Save changes to Database. db.SubmitChanges(); } catch { result = false; } return(result); }