protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdRegistration.FooterRow.FindControl("lblId"); RegisterStaff registerStaff = RegisterStaffDB.GetByID(Convert.ToInt32(lblId.Text)); if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID) > 0) { SetErrorMessage("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists a booking for this provider there."); return; } try { RegisterStaffDB.UpdateInactive(Convert.ToInt32(lblId.Text), false); } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { HideTableAndSetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); }
public static void UpdateActive(int register_staff_id, bool checkFKConstraint = true) { if (checkFKConstraint) { RegisterStaff registerStaff = RegisterStaffDB.GetByID(register_staff_id); if (IsStaffWorkingInOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID, false)) { throw new CustomMessageException("Can not undelete registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because a new active regsitration exists already."); } } string sql = "UPDATE RegisterStaff SET is_deleted = 0 WHERE register_staff_id = " + register_staff_id.ToString(); DBBase.ExecuteNonResult(sql); }
public static void UpdateInactive(int register_staff_id, bool checkFKConstraint = true) { if (checkFKConstraint) { RegisterStaff registerStaff = RegisterStaffDB.GetByID(register_staff_id); if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID, "0") > 0) { throw new CustomMessageException("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists incomplete bookings for this provider there."); } } string sql = "UPDATE RegisterStaff SET is_deleted = 1 WHERE register_staff_id = " + register_staff_id.ToString(); DBBase.ExecuteNonResult(sql); }