public void EditDoctor()
        {
            try
            {
                ClinicUser clinicUser = new ClinicUser();
                clinicUser.ClinicUserId = selectedDoctor.ClinicUserId;
                clinicUser.FullName     = selectedDoctor.FullName;
                clinicUser.DateOfBirth  = selectedDoctor.DateOfBirth;
                clinicUser.IDNumber     = selectedDoctor.IDNumber;
                clinicUser.GenderId     = selectedDoctor.GenderId;
                clinicUser.Citizenship  = selectedDoctor.Citizenship;
                clinicUser.Username     = selectedDoctor.Username;
                clinicUser.Password     = selectedDoctor.Password;

                ClinicDoctor clinicDoctor = new ClinicDoctor();
                clinicDoctor.ClinicDoctorId      = selectedDoctor.ClinicDoctorId;
                clinicDoctor.ClinicUserId        = selectedDoctor.ClinicUserId;
                clinicDoctor.UniqueNumber        = selectedDoctor.UniqueNumber;
                clinicDoctor.BancAccount         = selectedDoctor.BancAccount;
                clinicDoctor.DepartmentId        = selectedDoctor.DepartmentId;
                clinicDoctor.WorkShiftId         = selectedDoctor.WorkShiftId;
                clinicDoctor.InChargeOfAdmission = selectedDoctor.InChargeOfAdmission;
                clinicDoctor.ClinicManagerId     = selectedDoctor.ClinicManagerId;

                AddDoctorView addDoctorView = new AddDoctorView(User, clinicUser, clinicDoctor, true);
                addDoctorView.Show();
                doctorView.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public void WhenAddDoctor_ThenAddsDoctorToClinic()
        {
            var doctor = new ClinicDoctor("adoctorid", "afirstname", "alastname");
            var entity = new ClinicEntity(this.logger.Object, this.idFactory.Object);

            entity.RegisterDoctor(doctor);

            this.personService.Setup(ps => ps.Create(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Person
            {
                Id = "apersonid", Name = new PersonName {
                    FirstName = "afirstname", LastName = "alastname"
                }
            });
            this.storage.Setup(s => s.Load(It.Is <Identifier>(i => i == "aclinicid")))
            .Returns(entity);
            this.storage.Setup(s => s.Save(It.Is <ClinicEntity>(e => e.Unavailabilities.Count == 1)))
            .Returns(entity);

            var result =
                this.clinicsApplication.RegisterDoctor(this.caller.Object, "aclinicid", "afirstname", "alastname");

            result.Should().NotBeNull();
            this.personService.Verify(ps => ps.Create("afirstname", "alastname"));
        }
Exemple #3
0
        public void WhenAddDoctor_ThenDoctorAdded()
        {
            var doctor = new ClinicDoctor("adoctorid", "afirstname", "alastname");

            this.entity.RegisterDoctor(doctor);

            this.entity.Doctors.Doctors.Single().Should().Be("adoctorid".ToIdentifier());
            this.entity.Events[1].Should().BeOfType <Events.Clinic.DoctorRegisteredToClinic>();
        }
        public static Doctor ToDoctor(this ClinicDoctor doctor)
        {
            var dto = doctor.ConvertTo <Doctor>();

            dto.Name = new PersonName
            {
                FirstName = doctor.FirstName,
                LastName  = doctor.LastName
            };

            return(dto);
        }
 public AddDoctorViewModel(ClinicUser userAdmin, ClinicUser user, ClinicDoctor clinicDoctor, AddDoctorView addDoctorViewOpen, bool isForEdit)
 {
     this.userAdmin     = userAdmin;
     this.userDoctor    = clinicDoctor;
     this.user          = user;
     this.isForEdit     = isForEdit;
     addDoctorView      = addDoctorViewOpen;
     GenderList         = new ObservableCollection <Gender>(service.GetAllGender());
     SelectedGender     = GenderList.FirstOrDefault(p => p.GenderId == user.GenderId);
     DepartmentList     = new ObservableCollection <Department>(service.GetAllDepartment());
     SelectedDepartment = DepartmentList.FirstOrDefault(p => p.DepartmentId == userDoctor.DepartmentId);
     WorkShiftList      = new ObservableCollection <Workshift>(service.GetAllWorkshift());
     SelectedWorkShift  = WorkShiftList.FirstOrDefault(p => p.WorkShiftId == userDoctor.WorkShiftId);
     ManagerList        = new ObservableCollection <vwManager>(service.GetAllManager());
     SelectedManager    = ManagerList.FirstOrDefault(p => p.ClinicManagerId == userDoctor.ClinicManagerId);
 }
Exemple #6
0
        public int AddNewDoctor(ClinicDoctor user)
        {
            try
            {
                using (MedicaClinicEntities2 context = new MedicaClinicEntities2())
                {
                    if (user.ClinicDoctorId == 0)
                    {
                        ClinicDoctor newClinicUser = new ClinicDoctor();
                        newClinicUser.ClinicUserId        = user.ClinicUserId;
                        newClinicUser.UniqueNumber        = user.UniqueNumber;
                        newClinicUser.BancAccount         = user.BancAccount;
                        newClinicUser.DepartmentId        = user.DepartmentId;
                        newClinicUser.WorkShiftId         = user.WorkShiftId;
                        newClinicUser.InChargeOfAdmission = user.InChargeOfAdmission;
                        newClinicUser.ClinicManagerId     = user.ClinicManagerId;

                        context.ClinicDoctors.Add(newClinicUser);
                        context.SaveChanges();
                        user.ClinicDoctorId = newClinicUser.ClinicDoctorId;
                        return(user.ClinicDoctorId);
                    }
                    else
                    {
                        ClinicDoctor editClinicUser = (from p in context.ClinicDoctors where p.ClinicDoctorId == user.ClinicDoctorId select p).First();
                        editClinicUser.ClinicUserId        = user.ClinicUserId;
                        editClinicUser.UniqueNumber        = user.UniqueNumber;
                        editClinicUser.BancAccount         = user.BancAccount;
                        editClinicUser.DepartmentId        = user.DepartmentId;
                        editClinicUser.WorkShiftId         = user.WorkShiftId;
                        editClinicUser.InChargeOfAdmission = user.InChargeOfAdmission;
                        editClinicUser.ClinicManagerId     = user.ClinicManagerId;
                        editClinicUser.ClinicDoctorId      = user.ClinicDoctorId;
                        context.SaveChanges();
                        Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull edited doctor");
                        return(user.ClinicDoctorId);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                Logging.LoggAction("AddDoctorViweModel", "Error", ex.ToString());
                return(0);
            }
        }
Exemple #7
0
        public bool CheckBancAccount(long bancAccount)
        {
            try
            {
                using (MedicaClinicEntities2 context = new MedicaClinicEntities2())
                {
                    ClinicDoctor clinicUser = (from d in context.ClinicDoctors where d.BancAccount == bancAccount select d).FirstOrDefault();

                    if (clinicUser != null)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(false);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DoctorRosterItem"/> class.
        /// </summary>
		public DoctorRosterItem(ClinicDoctor.Entities.DoctorRoster entity)
			: base()
		{
			_entity = entity;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:CustomerItem"/> class.
        /// </summary>
		public CustomerItem(ClinicDoctor.Entities.Customer entity)
			: base()
		{
			_entity = entity;
		}
Exemple #10
0
 /// <summary>
 /// 初始化所有的属性,包括引用类型的属性自己的属性
 /// </summary>
 public override void ReInitializeAllProperties()
 {
     try
     {
         if (AdmitInfo != null)
         {
             AdmitInfo.ReInitializeAllProperties();
         }
         if (DischargeInfo != null)
         {
             DischargeInfo.ReInitializeAllProperties();
         }
         if (AdmissionKind != null)
         {
             AdmissionKind.ReInitializeAllProperties();
         }
         if (AdmitStatus != null)
         {
             AdmitStatus.ReInitializeAllProperties();
         }
         if (DischargeStatus != null)
         {
             DischargeStatus.ReInitializeAllProperties();
         }
         if (DiagnosisOfClinic != null)
         {
             DiagnosisOfClinic.ReInitializeAllProperties();
         }
         if (ClinicDoctor != null)
         {
             ClinicDoctor.ReInitializeAllProperties();
         }
         if (ChineseDiagnosisOfClinic != null)
         {
             ChineseDiagnosisOfClinic.ReInitializeAllProperties();
         }
         if (ChineseDiagnosisOfClinic2 != null)
         {
             ChineseDiagnosisOfClinic2.ReInitializeAllProperties();
         }
         if (Resident != null)
         {
             Resident.ReInitializeAllProperties();
         }
         if (AttendingPhysician != null)
         {
             AttendingPhysician.ReInitializeAllProperties();
         }
         if (Director != null)
         {
             Director.ReInitializeAllProperties();
         }
         if (CareLevel != null)
         {
             CareLevel.ReInitializeAllProperties();
         }
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DoctorFuncItem"/> class.
        /// </summary>
		public DoctorFuncItem(ClinicDoctor.Entities.DoctorFunc entity)
			: base()
		{
			_entity = entity;
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Staff object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.Staff object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.Staff entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Staff_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@OriginalId", DbType.Int64, entity.OriginalId);
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@ShortName", DbType.String, entity.ShortName );
			database.AddInParameter(commandWrapper, "@UserName", DbType.String, entity.UserName );
			database.AddInParameter(commandWrapper, "@Email", DbType.String, entity.Email );
			database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
			database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
			database.AddInParameter(commandWrapper, "@WorkPhone", DbType.String, entity.WorkPhone );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Birthdate", DbType.DateTime, (entity.Birthdate.HasValue ? (object) entity.Birthdate : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@Roles", DbType.String, entity.Roles );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ContentItem"/> class.
        /// </summary>
		public ContentItem(ClinicDoctor.Entities.Content entity)
			: base()
		{
			_entity = entity;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:GroupItem"/> class.
        /// </summary>
		public GroupItem(ClinicDoctor.Entities.Group entity)
			: base()
		{
			_entity = entity;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:RoomItem"/> class.
        /// </summary>
		public RoomItem(ClinicDoctor.Entities.Room entity)
			: base()
		{
			_entity = entity;
		}
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.RosterType object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.RosterType object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.RosterType object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.RosterType entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.RosterType_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@Id", DbType.Int64, 8);
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, entity.IsBooked );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _id = database.GetParameterValue(commandWrapper, "@Id");
			entity.Id = (System.Int64)_id;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.DoctorRoster object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.DoctorRoster object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.DoctorRoster object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.DoctorRoster entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.DoctorRoster_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@DoctorUserName", DbType.String, entity.DoctorUserName );
			database.AddInParameter(commandWrapper, "@DoctorShortName", DbType.String, entity.DoctorShortName );
			database.AddInParameter(commandWrapper, "@DoctorEmail", DbType.String, entity.DoctorEmail );
			database.AddInParameter(commandWrapper, "@RosterTypeId", DbType.Int64, entity.RosterTypeId );
			database.AddInParameter(commandWrapper, "@RosterTypeTitle", DbType.String, entity.RosterTypeTitle );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, (entity.IsBooked.HasValue ? (object) entity.IsBooked  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@StartTime", DbType.DateTime, entity.StartTime );
			database.AddInParameter(commandWrapper, "@EndTime", DbType.DateTime, entity.EndTime );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsComplete", DbType.Boolean, entity.IsComplete );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AppointmentItem"/> class.
        /// </summary>
		public AppointmentItem(ClinicDoctor.Entities.Appointment entity)
			: base()
		{
			_entity = entity;
		}
 public AddDoctorView(ClinicUser adminUser, ClinicUser user, ClinicDoctor doctor, bool isForEdit)
 {
     InitializeComponent();
     this.DataContext = new AddDoctorViewModel(adminUser, user, doctor, this, isForEdit);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:StaffItem"/> class.
        /// </summary>
		public StaffItem(ClinicDoctor.Entities.Staff entity)
			: base()
		{
			_entity = entity;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:RosterTypeItem"/> class.
        /// </summary>
		public RosterTypeItem(ClinicDoctor.Entities.RosterType entity)
			: base()
		{
			_entity = entity;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FloorItem"/> class.
        /// </summary>
		public FloorItem(ClinicDoctor.Entities.Floor entity)
			: base()
		{
			_entity = entity;
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Appointment object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.Appointment object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.Appointment entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Appointment_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@OriginalId", DbType.String, entity.OriginalId);
			database.AddInParameter(commandWrapper, "@CustomerId", DbType.String, entity.CustomerId );
			database.AddInParameter(commandWrapper, "@CustomerName", DbType.String, entity.CustomerName );
			database.AddInParameter(commandWrapper, "@ContentId", DbType.Int64, (entity.ContentId.HasValue ? (object) entity.ContentId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@ContentTitle", DbType.String, entity.ContentTitle );
			database.AddInParameter(commandWrapper, "@DoctorUsername", DbType.String, entity.DoctorUsername );
			database.AddInParameter(commandWrapper, "@DoctorShortName", DbType.String, entity.DoctorShortName );
			database.AddInParameter(commandWrapper, "@DoctorEmail", DbType.String, entity.DoctorEmail );
			database.AddInParameter(commandWrapper, "@RoomId", DbType.Int64, (entity.RoomId.HasValue ? (object) entity.RoomId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@RoomTitle", DbType.String, entity.RoomTitle );
			database.AddInParameter(commandWrapper, "@NurseUsername", DbType.String, entity.NurseUsername );
			database.AddInParameter(commandWrapper, "@NurseShortName", DbType.String, entity.NurseShortName );
			database.AddInParameter(commandWrapper, "@StatusId", DbType.Int64, (entity.StatusId.HasValue ? (object) entity.StatusId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@StatusTitle", DbType.String, entity.StatusTitle );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@StartTime", DbType.DateTime, (entity.StartTime.HasValue ? (object) entity.StartTime : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@EndTime", DbType.DateTime, (entity.EndTime.HasValue ? (object) entity.EndTime : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@IsComplete", DbType.Boolean, entity.IsComplete );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FunctionalityItem"/> class.
        /// </summary>
		public FunctionalityItem(ClinicDoctor.Entities.Functionality entity)
			: base()
		{
			_entity = entity;
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.RosterType object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.RosterType object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.RosterType entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.RosterType_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, entity.IsBooked );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.Customer object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Customer object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.Customer object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.Customer entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Customer_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
			database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
			database.AddInParameter(commandWrapper, "@WorkPhone", DbType.String, entity.WorkPhone );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Birthdate", DbType.DateTime, (entity.Birthdate.HasValue ? (object) entity.Birthdate  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}