//Method to Activate LabIncharge Account public string ActivateLabIncharge_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } LabIncharge LabIncharge1 = objHmsDataContext.LabIncharges.SingleOrDefault(id => (id.LabIncharge_ID == inchargeBO.pid || id.Email_ID == inchargeBO.emailID)); LabIncharge1.IsActive = true; objHmsDataContext.SubmitChanges(); LabIncharge LabIncharge2 = objHmsDataContext.LabIncharges.SingleOrDefault(id => id.LabIncharge_ID == inchargeBO.pid); return(" Account Activated"); } } catch (Exception e) { return("Unable To Activate Account Try again later"); } }
//Method to deactivate LabIncharge account, with string return type public string DeactivateLabIncharge_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } LabIncharge LabIncharge = objHmsDataContext.LabIncharges.SingleOrDefault(id => (id.LabIncharge_ID == inchargeBO.pid || id.Email_ID == inchargeBO.emailID)); LabIncharge.IsActive = false; objHmsDataContext.SubmitChanges(); return("Account Deactivated Successfully"); } } catch (Exception e) { return("Unable to deactive please try again"); } }
public IEnumerable <LabInchargeBO> UpdateLabIncharge_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } LabIncharge labIncharge = objHmsDataContext.LabIncharges.SingleOrDefault(pat => (pat.LabIncharge_ID == inchargeBO.pid || pat.Email_ID == inchargeBO.emailID)); LabIncharge updaterLabIncharge = ConvertBOToLabIncharge(labIncharge, inchargeBO); objHmsDataContext.SubmitChanges(); return(GetAllLabInchargeDetials_DAL()); } } catch (Exception e) { return(GetAllLabInchargeDetials_DAL()); } }
//Method to insert labincharge details into labincharge table, with return type lab incharge public LabInchargeBO InsertInchargeDetails_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } { LabIncharge labIncharge = new LabIncharge(); inchargeBO.isActive = true; LabIncharge obj_incharge = ConvertBOToLabIncharge(labIncharge, inchargeBO); objHmsDataContext.LabIncharges.InsertOnSubmit(obj_incharge); objHmsDataContext.SubmitChanges(); LabInchargeBO labInchargeBO = GetLabInchargeDetials_DAL(inchargeBO); return(labInchargeBO); } } } catch (Exception e) { LabInchargeBO labInc_BO = new LabInchargeBO(); return(labInc_BO); } }
//Method to update LabIncharge details SecurityQuestion, with string return type public string UpdateLabInchargeDetails_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } LabIncharge labIncharge = objHmsDataContext.LabIncharges.SingleOrDefault(pat => (pat.LabIncharge_ID == inchargeBO.pid || pat.Email_ID == inchargeBO.emailID)); LabIncharge updaterLabIncharge = ConvertBOToLabIncharge(labIncharge, inchargeBO); objHmsDataContext.SubmitChanges(); return("Successfullly Updated"); } } catch (Exception e) { return("Unable to update Please try once again"); } }
//Convert LabIncharge to BO public LabInchargeBO ConvertLabInchargeToBO(LabIncharge LabIncharge) { try { LabInchargeBO inchargeBO = new LabInchargeBO(LabIncharge.LabIncharge_ID, LabIncharge.First_Name, LabIncharge.Last_Name, LabIncharge.Email_ID, LabIncharge.Password, LabIncharge.DateOfBirth, LabIncharge.Security_Question, LabIncharge.Security_Answer, LabIncharge.Phone, LabIncharge.Address, LabIncharge.Gender, LabIncharge.IsActive); if (!string.IsNullOrEmpty(inchargeBO.securityQn)) { LabIncharge.Security_Question = inchargeBO.securityQn; } return(inchargeBO); } catch (Exception e) { LabInchargeBO incharge_BO = new LabInchargeBO(); return(incharge_BO); } }
//Method to get LabIncharge details public LabInchargeBO GetLabInchargeDetials_DAL(LabInchargeBO inchargeBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } LabIncharge LabInchargeInfo = objHmsDataContext.LabIncharges.SingleOrDefault(incharge => ((incharge.LabIncharge_ID == inchargeBO.pid || incharge.Email_ID == inchargeBO.emailID) && (incharge.Password == inchargeBO.pwd))); LabInchargeBO incharge_BO = ConvertLabInchargeToBO(LabInchargeInfo); return(incharge_BO); } } catch (Exception e) { return(null); } }
//Convert BO to LabIncharge public LabIncharge ConvertBOToLabIncharge(LabIncharge labIncharge, LabInchargeBO inchargeBO) { if (inchargeBO.pid != 0) { labIncharge.LabIncharge_ID = inchargeBO.pid; } if (!string.IsNullOrEmpty(inchargeBO.firstName)) { labIncharge.First_Name = inchargeBO.firstName; } if (!string.IsNullOrEmpty(inchargeBO.lastName)) { labIncharge.Last_Name = inchargeBO.lastName; } if (!string.IsNullOrEmpty(inchargeBO.emailID)) { labIncharge.Email_ID = inchargeBO.emailID; } if (!string.IsNullOrEmpty(inchargeBO.pwd)) { labIncharge.Password = inchargeBO.pwd; } if (inchargeBO.dateOfBirth != DateTime.MinValue) { labIncharge.DateOfBirth = inchargeBO.dateOfBirth; } if (!string.IsNullOrEmpty(inchargeBO.phone)) { labIncharge.Phone = inchargeBO.phone; } if (!string.IsNullOrEmpty(inchargeBO.address)) { labIncharge.Address = inchargeBO.address; } if (!string.IsNullOrEmpty(inchargeBO.securityQn)) { labIncharge.Security_Question = inchargeBO.securityQn; } if (!string.IsNullOrEmpty(inchargeBO.securityAns)) { labIncharge.Security_Answer = inchargeBO.securityAns; } if (!string.IsNullOrEmpty(inchargeBO.gender)) { labIncharge.Gender = inchargeBO.gender; } { labIncharge.IsActive = inchargeBO.isActive; } return(labIncharge); }